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_48318_C
def highest_average_score_main(input_data: str) -> str: """ Find the highest average score of any subject excluding the highest and lowest scores in that subject. If a subject has fewer than three students, return -1 for that subject. Process multiple test cases provided as input. >>> highest_avera...
def highest_average_score(test_cases): results = [] for test_case in test_cases: max_avg = float('-inf') for subject_scores in test_case: if len(subject_scores) < 3: results.append(-1) continue sorted_scores = sorted(subject_scores) ...
def test_highest_average_score(): input_data = "2\n2\n5\n50 60 70 80 90\n3\n80 90 100\n1\n2\n70 75" expected_output = "70.00\n90.00\n-1" assert highest_average_score_main(input_data) == expected_output def test_single_subject_single_test_case(): input_data = "1\n1\n5\n10 20 30 40 50" expected_outpu...
[ { "docstring": null, "function_declaration": "def highest_average_score(test_cases):", "function_name": "highest_average_score", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def process_input(input_data):", "function_name": "process_input", "p...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def highest_average_score(T, test_cases):\n results = []\n\n for i in range(T):\n S = test_cases[i][0]\n subjects = test_cases[i][1]\n h...
trial_gpt4o_3
{ "original_instruction": "In a university, students are enrolled in various subjects. Each subject has a list of students with their respective scores. The university wants to find the highest average score of any subject. However, this average should exclude the highest and lowest scores in that subject.\n\nWrite a...
0.599651
Taco_48318
C
[ "highest_average_score", "process_input", "highest_average_score_main" ]
3
[ [ "highest_average_score_main", "process_input" ], [ "process_input", "highest_average_score" ] ]
2
[ "process_input" ]
false
[]
false
pytest
false
[]
true
36e9d28b4829c118e9ec57f5f09a7bc38cbfb0b3
8fc0c4f696ac7a4c93f5f7219cc94530f6eab050
v1.0
complete
Taco
Taco_48048_C
def unique_departments(test_cases: List[List[Tuple[str, str]]]) -> List[int]: """ Determine the number of unique departments for each test case. >>> unique_departments([[("E001", "HR"), ("E002", "Finance"), ("E003", "HR")]]) [2] >>> unique_departments([[("E004", "IT"), ("E005", "IT"), ("E006", "Marketin...
def unique_departments(test_cases): results = [] for employees in test_cases: departments = set() for emp_id, dept in employees: departments.add(dept) results.append(len(departments)) return results def parse_input(input_str): lines = input_str.strip().split('\n') ...
import pytest from solution import unique_departments, parse_input, solve def test_unique_departments(): test_cases = [ [("E001", "HR"), ("E002", "Finance"), ("E003", "HR")], [("E004", "IT"), ("E005", "IT"), ("E006", "Marketing"), ("E007", "Finance")] ] assert unique_departments(test_cases...
[ { "docstring": null, "function_declaration": "def unique_departments(test_cases):", "function_name": "unique_departments", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_str):", "function_name": "parse_input", "parameter_li...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_unique_departments(test_cases):\n result = []\n for case in test_cases:\n unique_departments = set()\n for emp_id, dept in case:\n ...
trial_gpt4o_2
{ "original_instruction": "A company needs to manage its employee information effectively. Each employee has a unique ID and belongs to a specific department. The goal is to determine the number of unique departments in the company based on given employee records. Can you help with this task?\n\nWrite a program that ...
0.699866
Taco_48048
C
[ "unique_departments", "parse_input", "solve" ]
3
[ [ "solve", "parse_input" ], [ "solve", "unique_departments" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
3818f913d4ea3d6ff980ce0f78d37a62bb939a0c
e44e1f84af5414dc0d454893edda58d17b8b13ef
v1.0
complete
Taco
Taco_48396_C
def n_queens(N: int) -> int: """ Calculate the number of distinct ways to arrange N queens on an N x N chessboard such that no two queens attack each other. >>> n_queens(1) 1 >>> n_queens(2) 0 >>> n_queens(3) 0 >>> n_queens(4) 2 >>> n_queens(5) 10 >>> n_queens(6) 4 >>> n_queens(7) 40 ...
def is_safe(board, row, col): # Check this row on left side for i in range(col): if board[row][i] == 1: return False # Check upper diagonal on left side for i, j in zip(range(row, -1, -1), range(col, -1, -1)): if board[i][j] == 1: return False # Check lower ...
from solution import n_queens def test_n_queens_1(): assert n_queens(1) == 1 def test_n_queens_2(): assert n_queens(2) == 0 def test_n_queens_3(): assert n_queens(3) == 0 def test_n_queens_4(): assert n_queens(4) == 2 def test_n_queens_5(): assert n_queens(5) == 10 def test_n_queens_6(): a...
[ { "docstring": null, "function_declaration": "def is_safe(board, row, col):", "function_name": "is_safe", "parameter_list": "(board, row, col)" }, { "docstring": null, "function_declaration": "def solve_n_queens(board, col, count):", "function_name": "solve_n_queens", "parameter_...
[ 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 solveNQueens(N):\n \"\"\"\n Returns the number of distinct arrangements to place N queens on an N x N chessboard\n such that no two queens can attack ...
trial_gpt4o_2
{ "original_instruction": "Jane is an avid chess player who is participating in an international chess competition. She noticed a pattern in the number of distinct ways to arrange a set of N queens on an N x N chessboard so that no two queens can attack each other.\n\nYour task is to write a program that calculates t...
0.541961
Taco_48396
C
[ "is_safe", "solve_n_queens", "n_queens" ]
3
[ [ "n_queens", "solve_n_queens" ], [ "solve_n_queens", "is_safe" ] ]
2
[]
false
[]
false
pytest
true
[]
true
cc6f80575a20d4dd62076aa60dbf5f869df64e05
8fdd42aac24982b4d2b16da3dfe9dee13835d8db
v1.0
complete
Taco
Taco_48247_C
def rotate_matrix_clockwise(matrix): """ Rotates the given square matrix 90 degrees clockwise. Args: matrix (list of list of int): The N x N matrix to rotate. Returns: list of list of int: The rotated matrix. """ def process_test_cases(test_cases): """ Processes multiple t...
def rotate_matrix_clockwise(matrix): """ Rotates the given square matrix 90 degrees clockwise. Args: matrix (list of list of int): The N x N matrix to rotate. Returns: list of list of int: The rotated matrix. """ N = len(matrix) rotated_matrix = [[0] * N for _ in range(N)] ...
from solution import rotate_matrix_clockwise, process_test_cases, read_input, matrices_to_string def test_rotate_matrix_clockwise(): matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] rotated = rotate_matrix_clockwise(matrix) expected = [ [7, 4, 1], [8, 5, 2], ...
[ { "docstring": "Rotates the given square matrix 90 degrees clockwise.\n\nArgs:\nmatrix (list of list of int): The N x N matrix to rotate.\n\nReturns:\nlist of list of int: The rotated matrix.", "function_declaration": "def rotate_matrix_clockwise(matrix):", "function_name": "rotate_matrix_clockwise", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def rotate_matrix(matrix):\n \"\"\"\n Rotates a given NxN matrix 90 degrees clockwise.\n \"\"\"\n N = len(matrix)\n rotated_matrix = [[0] * N for _ ...
trial_gpt4o_2
{ "original_instruction": "Write a function to perform matrix rotation. Given a square matrix of size N x N, you need to rotate the matrix 90 degrees clockwise. \n\nInput\nFirst line contains integer T (number of test cases).\nNext T test cases contain first integer N (size of the matrix) followed by N*N integers rep...
0.521932
Taco_48247
C
[ "rotate_matrix_clockwise", "process_test_cases", "read_input", "matrices_to_string" ]
4
[ [ "process_test_cases", "rotate_matrix_clockwise" ] ]
1
[ "process_test_cases", "read_input" ]
false
[]
false
pytest
true
[]
true
053aecd54a00621474c8f5302379834dea5cccb2
4c5370caa0dbe5ef0709400d1670d4d0c999cf04
v1.0
complete
Taco
Taco_48239_C
from flask import Flask, request, jsonify app = Flask(__name__) # Dictionary to store previously computed Fibonacci numbers memo = {0: 0, 1: 1} def fib(n): """ Compute the nth Fibonacci number using memoization. Args: n (int): The position in the Fibonacci sequence to compute. Returns: ...
from flask import Flask, request, jsonify app = Flask(__name__) # Dictionary to store previously computed Fibonacci numbers memo = {0: 0, 1: 1} def fib(n): if n not in memo: memo[n] = fib(n-1) + fib(n-2) return memo[n] @app.route('/fibonacci', methods=['GET']) def get_fibonacci(): try: n...
import pytest from flask import Flask, request, jsonify from flask.testing import FlaskClient # Define the Flask app app = Flask(__name__) # Dictionary to store previously computed Fibonacci numbers memo = {0: 0, 1: 1} def fib(n): if n not in memo: memo[n] = fib(n-1) + fib(n-2) return memo[n] @app.r...
[ { "docstring": null, "function_declaration": "def fib(n):", "function_name": "fib", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def get_fibonacci():", "function_name": "get_fibonacci", "parameter_list": "()" } ]
[ 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": "from flask import Flask, request, jsonify\nfrom functools import lru_cache\n\napp = Flask(__name__)\n\n# Using lru_cache for memoization\n@lru_cache(None)\ndef fib...
trial_gpt4o_8
{ "original_instruction": "Write a Microservice to Efficiently Calculate Fibonacci Numbers\nCreate a microservice that efficiently calculates the nth Fibonacci number using memoization to optimize performance. Your microservice should expose an endpoint that accepts an integer n and returns the nth Fibonacci number. ...
0.654437
Taco_48239
C
[ "fib", "get_fibonacci" ]
2
[ [ "get_fibonacci", "fib" ] ]
1
[]
false
[]
false
pytest
false
[ "flask" ]
false
f7d2268146bfba76418e43ad0c99b5820727fe53
e9a1572e450581b8a595755ca6828c7c9a28b4f1
v1.0
complete
Taco
Taco_48294_C
def distinct_paths(grid: List[List[int]]) -> int: """ Determines the number of distinct paths from the top-left to the bottom-right corner of a grid while only moving right or down and avoiding blocked cells. :param grid: List[List[int]] representing the grid (0 for open, 1 for blocked). :return: i...
def distinct_paths(grid): """ Determines the number of distinct paths from the top-left to the bottom-right corner of a grid while only moving right or down and avoiding blocked cells. :param grid: List[List[int]] representing the grid (0 for open, 1 for blocked). :return: int Number of distinct pa...
from solution import distinct_paths def test_distinct_paths_example1(): grid = [ [0, 0, 0], [0, 1, 0], [0, 0, 0], ] assert distinct_paths(grid) == 2 def test_distinct_paths_example2(): grid = [ [0, 1], [0, 0], ] assert distinct_paths(grid) == 1 def test...
[ { "docstring": "Determines the number of distinct paths from the top-left to the bottom-right\ncorner of a grid while only moving right or down and avoiding blocked cells.\n\n:param grid: List[List[int]] representing the grid (0 for open, 1 for blocked).\n:return: int Number of distinct paths modulo 1000000007"...
[ 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 = 1000000007\n\ndef num_paths(grid, N, M):\n dp = [[0] * M for _ in range(N)]\n \n # Initialization\n dp[0][0] = 1\n \n # Fill the dp table\n...
trial_gpt4o_8
{ "original_instruction": "A robot is initially located at the top-left corner (1,1) of an NxM grid. The goal of the robot is to move to the bottom-right corner (N,M). The robot can only move either one step to the right or one step down at a time. However, certain cells in the grid are blocked and the robot cannot m...
0.692551
Taco_48294
C
[ "distinct_paths", "read_input_and_execute" ]
2
[ [ "read_input_and_execute", "distinct_paths" ] ]
1
[]
false
[]
false
pytest
true
[]
true
34f6cb741c47b54edc56499ff223c66b6ab473b6
0d9a9738c49f6bd9024dd8709afcad63abfe57ce
v1.0
complete
Taco
Taco_48254_C
MOD = 10**9 + 7 def calculate_pt(t: int) -> int: """ Calculate the P(t) value for the given time t. >>> calculate_pt(1) 4 >>> calculate_pt(2) 8 >>> calculate_pt(3) 14 """ pass def calculate_qt(t: int) -> int: """ Calculate the Q(t) value for the given time t. >>> ca...
MOD = 10**9 + 7 def calculate_pt(t): if t == 1: return 4 return (4 + 2 * sum(range(2, t + 1))) % MOD def calculate_qt(t): if t == 1: return 2 if t == 2: return 5 q1 = 2 q2 = 5 p_values = {1: 4} for i in range(2, t + 1): if i not in p_values: ...
import pytest from solution import calculate_pt, calculate_qt, timelord_numbers def test_calculate_pt(): assert calculate_pt(1) == 4 assert calculate_pt(2) == 8 assert calculate_pt(3) == 14 def test_calculate_qt(): assert calculate_qt(1) == 2 assert calculate_qt(2) == 5 assert calculate_qt(3) ...
[ { "docstring": null, "function_declaration": "def calculate_pt(t):", "function_name": "calculate_pt", "parameter_list": "(t)" }, { "docstring": null, "function_declaration": "def calculate_qt(t):", "function_name": "calculate_qt", "parameter_list": "(t)" }, { "docstring":...
[ 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": "MOD = 10**9 + 7\n\ndef P(t):\n \"\"\"\n Returns the value of P(t) modulo (10^9 + 7)\n \"\"\"\n if t == 1:\n return 4\n return (P(t-1) + 2*t) ...
trial_gpt4o_3
{ "original_instruction": "Clara Oswald is a time traveler. She loves playing around with sequences and decided to invent a new sequence pattern called Timelord numbers. A Timelord number sequence is defined as follows:\n\n1. P(t) = P(t-1) + 2*t, P(1) = 4\n2. Q(t) = Q(t-2) + P(t), Q(1) = 2, Q(2) = 5\n\nYour task is t...
0.584877
Taco_48254
C
[ "calculate_pt", "calculate_qt", "timelord_numbers", "main" ]
4
[ [ "calculate_qt", "calculate_pt" ], [ "timelord_numbers", "calculate_pt" ], [ "timelord_numbers", "calculate_qt" ] ]
3
[]
false
[]
false
pytest
true
[]
true
e4faa2d0d8a4b85365f4264cf2356652790593a3
ebbeb715326067da14a7e37daa65363609c847fc
v1.0
complete
Taco
Taco_48143_C
from typing import List, Dict from collections import defaultdict from urllib.parse import urlparse def group_urls(urls: List[str]) -> Dict[str, Dict[str, List[str]]]: """Groups the URLs by their domains and subdomains. >>> group_urls([ ... "https://mail.google.com", ... "http://www.google.com", ...
from collections import defaultdict from urllib.parse import urlparse def group_urls(urls): """ Groups the URLs by their domains and subdomains. """ root_domain_dict = defaultdict(lambda: defaultdict(list)) for url in urls: # Parse the URL parsed_url = urlparse(url) hos...
import pytest from solution import group_urls, print_grouped_urls, handle_urls def test_group_urls_basic(): urls = [ "https://mail.google.com", "http://www.google.com", "https://docs.google.com" ] expected_output = { 'google.com': { 'mail.google.com': ['https://m...
[ { "docstring": "Groups the URLs by their domains and subdomains.", "function_declaration": "def group_urls(urls):", "function_name": "group_urls", "parameter_list": "(urls)" }, { "docstring": null, "function_declaration": "def print_grouped_urls(grouped_urls):", "function_name": "pri...
[ 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\nfrom urllib.parse import urlparse\n\ndef group_urls(urls):\n \"\"\"\n Groups the URLs by their domains and subdomains.\n...
trial_gpt4o_0
{ "original_instruction": "Given a list of strings, each representing a website URL, design an algorithm to group the URLs by their domains and subdomains. The URLs should be considered the same if they have the same root domain, regardless of their subdomains or the protocol used (http or https). Subdomains should b...
0.704137
Taco_48143
C
[ "group_urls", "print_grouped_urls", "handle_urls" ]
3
[ [ "handle_urls", "group_urls" ], [ "handle_urls", "print_grouped_urls" ] ]
2
[]
false
[]
false
pytest
true
[]
true
3a7e0fb870f7a6f8e53a9e4b381097e3497f6a6c
5d6c659afcb23837970d7865b3ea9ee01d60c5b1
v1.0
complete
Taco
Taco_47846_C
import heapq import sys from typing import List def find_shortest_paths(input_data: List[str]) -> List[int]: """ Parse input data and apply Dijkstra's algorithm to find the shortest path between attractions. Args: input_data (List[str]): Input data containing number of attractions, paths, and queries....
import heapq import sys def dijkstra(graph, start, end): """ Use Dijkstra's algorithm to find the shortest path from start to end. """ n = len(graph) distances = [sys.maxsize] * n distances[start] = 0 priority_queue = [(0, start)] while priority_queue: current_distance...
def test_sample_case(): input_data = [ "5 6", "1 2 2", "1 3 4", "2 3 1", "2 4 7", "3 5 3", "4 5 1", "1 5", "0 0" ] expected_output = [6] assert find_shortest_paths(input_data) == expected_output def test_no_path(): input_data =...
[ { "docstring": "Use Dijkstra's algorithm to find the shortest path from start to end.", "function_declaration": "def dijkstra(graph, start, end):", "function_name": "dijkstra", "parameter_list": "(graph, start, end)" }, { "docstring": null, "function_declaration": "def shortest_path(num_...
[ 0, 0, 0, 0, 1, 0, 0, 1, 0 ]
2
hard
0.222
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\nimport sys\n\ndef dijkstra(n, graph, start, end):\n \"\"\"\n Find the shortest path between start and end in a graph with n nodes.\n \"\"\"\...
trial_gpt4o_5
{ "original_instruction": "You are working on a navigation system for a new amusement park. The park consists of a network of attractions connected by bidirectional paths. Each path has a certain length. Visitors often like to start from one attraction and explore different attractions while minimizing the distance t...
0.738089
Taco_47846
C
[ "dijkstra", "shortest_path", "parse_input", "find_shortest_paths" ]
4
[ [ "find_shortest_paths", "parse_input" ], [ "parse_input", "shortest_path" ], [ "shortest_path", "dijkstra" ] ]
3
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
4a7e8a30df943da21feabf8ca3a847a32b335f22
ccdc1bd4dffb446acb7266b3cb81cd70d68e31d0
v1.0
complete
Taco
Taco_48598_C
def closest_palindromes(n: int) -> (int, int): """ Determine the largest palindromic number smaller than n and the smallest palindromic number larger than n. >>> closest_palindromes(12321) (12221, 12421) >>> closest_palindromes(100) (99, 101) >>> closest_palindromes(1) (0, 2) >>> closest...
def is_palindrome(num): num_str = str(num) return num_str == num_str[::-1] def closest_palindromes(n): # Find the largest palindromic number smaller than n smaller_palindrome = n - 1 while not is_palindrome(smaller_palindrome): smaller_palindrome -= 1 # Find the smallest palindromi...
from solution import closest_palindromes def test_closest_palindromes_case_1(): assert closest_palindromes(12321) == (12221, 12421) def test_closest_palindromes_case_2(): assert closest_palindromes(100) == (99, 101) def test_closest_palindromes_case_3(): assert closest_palindromes(1) == (0, 2) def test_...
[ { "docstring": null, "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def closest_palindromes(n):", "function_name": "closest_palindromes", "parameter_list": "(n)" } ]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(number):\n \"\"\"\n Check if a number is a palindrome.\n \"\"\"\n return str(number) == str(number)[::-1]\n\ndef closest_palindromic(...
trial_gpt4o_1
{ "original_instruction": "Alex loves palindromic numbers and likes to play with them. A palindromic number is a number that remains the same when its digits are reversed. Today, he found a very large positive integer and decided to calculate the closest smaller and larger palindromic numbers to it.\n\nGiven a positi...
0.730936
Taco_48598
C
[ "is_palindrome", "closest_palindromes" ]
2
[ [ "closest_palindromes", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d1d90c58112192e2165d14c8dac4f24658b08810
86d4b6eb7cc72c2550db0d90167f76f47062dd9d
v1.0
complete
Taco
Taco_48697_C
from typing import List import math def closest_friend_index(n: int, strengths: List[int]) -> int: """ Help the friends find out the name of the friend who pulls the object closest to the center. Args: n (int): The number of friends. strengths (List[int]): The strength of each friend. Ret...
import math def closest_friend_index(n, strengths): x_sum = 0 y_sum = 0 for i in range(n): x_sum += strengths[i] * math.cos(2 * math.pi * i / n) y_sum += strengths[i] * math.sin(2 * math.pi * i / n) theta = math.atan2(y_sum, x_sum) if theta < 0: theta += 2 * m...
import math from solution import find_closest_friend, closest_friend_index def test_example_case(): assert find_closest_friend(4, [10, 20, 30, 40]) == 3 def test_additional_case_1(): assert find_closest_friend(3, [1, 5, 2]) == 1 def test_additional_case_2(): assert find_closest_friend(5, [1, 1, 1, 1, 1])...
[ { "docstring": null, "function_declaration": "def closest_friend_index(n, strengths):", "function_name": "closest_friend_index", "parameter_list": "(n, strengths)" }, { "docstring": null, "function_declaration": "def find_closest_friend(n, strengths):", "function_name": "find_closest...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef closest_to_center(n, strengths):\n # Calculate the positions based on the strengths\n x_sum = sum(strengths[i] * math.cos(2 * math.pi * i ...
trial_gpt4o_3
{ "original_instruction": "A group of friends decided to play a game called \"Rope Tugging\". They stand evenly spaced around a large circle, and each of them is holding a rope tied to an object in the center of the circle. The goal of the game is to find the name of the friend who pulls the object closest to the exa...
0.554437
Taco_48697
C
[ "closest_friend_index", "find_closest_friend" ]
2
[ [ "find_closest_friend", "closest_friend_index" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a9e915b90076bfde2190fe550229dfa353e7f24e
895d53bff7b4a2183efb3ce56b3de05f0725aea8
v1.0
complete
Taco
Taco_48550_C
def solve_maze(N: int, M: int, grid: List[str]) -> str: """ Determine if there exists a path from the top-left corner to the bottom-right corner of the maze. Args: N (int): Number of rows in the maze. M (int): Number of columns in the maze. grid (List[str]): The maze represented as a list of st...
def is_path_exist(maze): from collections import deque N, M = len(maze), len(maze[0]) directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] queue = deque([(0, 0)]) visited = set((0, 0)) while queue: x, y = queue.popleft() if (x, y) == (N-1, M-1): return "YES"...
from solution import solve_maze def test_sample_input_1(): N = 4 M = 4 grid = [ "....", "...#", "#...", "...." ] assert solve_maze(N, M, grid) == "YES" def test_sample_input_2(): N = 3 M = 3 grid = [ ".#.", "###", ".#." ] ...
[ { "docstring": null, "function_declaration": "def is_path_exist(maze):", "function_name": "is_path_exist", "parameter_list": "(maze)" }, { "docstring": null, "function_declaration": "def solve_maze(N, M, grid):", "function_name": "solve_maze", "parameter_list": "(N, M, grid)" }...
[ 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_path(maze):\n \"\"\"\n Determines if there exists a path from the top-left corner to the bottom-right corner that only traverses empty cells.\n\n ...
trial_gpt4o_2
{ "original_instruction": "You are given a maze represented by a grid of size N x M, where each cell of the grid can be either empty (represented by '.') or blocked (represented by '#'). Your task is to determine if there exists any path from the top-left corner of the maze (cell (1,1)) to the bottom-right corner (ce...
0.627488
Taco_48550
C
[ "is_path_exist", "solve_maze" ]
2
[ [ "solve_maze", "is_path_exist" ] ]
1
[]
false
[]
false
pytest
true
[]
true
42c750de6d13cf7e6990cb6608ac034273968ec5
be6a34aab85bf4cc3550907c44f63c2432804ba4
v1.0
complete
Taco
Taco_48344_C
def min_latency_to_all_servers(N: int, M: int, source: int, links: List[str]) -> List[int]: """ Determine the minimum latency required to transfer data from a specified source server to all other servers in the network. If a server is unreachable from the source server, return -1 for that server. >>>...
import heapq def dijkstra(n, m, source, edges): graph = {i: [] for i in range(1, n+1)} for u, v, latency in edges: graph[u].append((latency, v)) # Initialize distances with infinity distances = {i: float('inf') for i in range(1, n+1)} distances[source] = 0 # Priority queue to ...
import pytest from solution import min_latency_to_all_servers def test_case_1(): N = 4 M = 4 source = 1 links = [ "1 2 1", "2 3 1", "3 4 1", "4 2 1" ] expected = [0, 1, 2, 3] assert min_latency_to_all_servers(N, M, source, links) == expected def test_unreach...
[ { "docstring": null, "function_declaration": "def dijkstra(n, m, source, edges):", "function_name": "dijkstra", "parameter_list": "(n, m, source, edges)" }, { "docstring": null, "function_declaration": "def min_latency_to_all_servers(N, M, source, links):", "function_name": "min_late...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\nfrom collections import defaultdict\nimport sys\n\ndef minimum_latency(N, M, source, edges):\n # Build the graph\n graph = defaultdict(list)\n ...
trial_gpt4o_1
{ "original_instruction": "A network of servers is represented as a graph. There are N servers, connected by M directed links. Each link has a certain latency associated with it. Your task is to determine the minimum latency required to transfer data from a specified source server to all other servers in the network....
0.482972
Taco_48344
C
[ "dijkstra", "min_latency_to_all_servers" ]
2
[ [ "min_latency_to_all_servers", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
64231979f0a848534f86920fe0f7bfbc0d599003
7ca2979e392220bb84f167f259bfa2f2274d34a9
v1.0
complete
Taco
Taco_48607_C
from typing import List def findKthLargest(nums: List[int], k: int) -> int: """ Determine the k-th largest element in the array. Given an integer array of unique elements and an integer k, returns the k-th largest element in the array. >>> findKthLargest([3, 2, 1, 5, 6, 4], 2) 5 >>> ...
from typing import List import random def partition(nums: List[int], low: int, high: int) -> int: pivot = nums[high] i = low for j in range(low, high): if nums[j] > pivot: nums[i], nums[j] = nums[j], nums[i] i += 1 nums[i], nums[high] = nums[high], nums[i] return i ...
def test_findKthLargest_case1(): nums = [3, 2, 1, 5, 6, 4] k = 2 assert findKthLargest(nums, k) == 5 def test_findKthLargest_case2(): nums = [7, 10, 4, 3] k = 1 assert findKthLargest(nums, k) == 10 def test_findKthLargest_case3(): nums = [9, 3, 2, 5, 7] k = 3 assert findKthLargest(...
[ { "docstring": null, "function_declaration": "def partition(nums, low, high):", "function_name": "partition", "parameter_list": "(nums, low, high)" }, { "docstring": null, "function_declaration": "def quickselect(nums, low, high, k):", "function_name": "quickselect", "parameter_l...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\nfrom typing import List\n\ndef findKthLargest(nums: List[int], k: int) -> int:\n \"\"\"\n Returns the k-th largest element in the array nums.\n...
trial_gpt4o_2
{ "original_instruction": "You are given an integer array nums of unique elements, and an integer k. You need to determine the k-th largest element in the array. Implement a function `findKthLargest(nums: List[int], k: int) -> int` that returns the k-th largest element, considering the sorted order of the array in de...
0.800136
Taco_48607
C
[ "partition", "quickselect", "findKthLargest" ]
3
[ [ "findKthLargest", "quickselect" ], [ "quickselect", "partition" ] ]
2
[]
false
[]
false
pytest
false
[]
true
e5f4f6dfa7348bd457d8fd797153195bef753725
ee190281e7da8e63ebd30fd9c2852cbabe8b12a8
v1.0
complete
Taco
Taco_48706_C
from typing import List, Tuple, Union def solve(c: int, r: int, prerequisites: List[Tuple[int, int]]) -> Union[List[int], str]: """ Determine the order in which courses should be taken to complete all, or state that it's not possible. Args: c: An integer representing the number of courses. r: An integ...
from collections import defaultdict, deque def find_course_order(num_courses, prerequisites): # Create an adjacency list for all courses and a dictionary for in-degree graph = defaultdict(list) in_degree = {i: 0 for i in range(1, num_courses + 1)} # Fill the graph and in-degree based on prerequisi...
from solution import solve def test_sample_input_1(): c = 4 r = 3 prerequisites = [(2, 1), (3, 2), (4, 3)] assert solve(c, r, prerequisites) == [1, 2, 3, 4] def test_sample_input_2(): c = 2 r = 2 prerequisites = [(1, 2), (2, 1)] assert solve(c, r, prerequisites) == "Cannot complete all...
[ { "docstring": null, "function_declaration": "def find_course_order(num_courses, prerequisites):", "function_name": "find_course_order", "parameter_list": "(num_courses, prerequisites)" }, { "docstring": null, "function_declaration": "def solve(c, r, prerequisites):", "function_name"...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict, deque\n\ndef find_course_order(num_courses, prerequisites):\n def has_cycle(v, visited, rec_stack):\n visited[v] = T...
trial_gpt4o_3
{ "original_instruction": "In an online educational platform, users can create their own learning paths by completing courses. Each course is connected to other courses it depends on, i.e., a course can only be started once all its prerequisite courses are completed. You need to determine the order in which the cours...
0.553076
Taco_48706
C
[ "find_course_order", "solve" ]
2
[ [ "solve", "find_course_order" ] ]
1
[]
false
[]
false
pytest
true
[]
true
416d469b61c28d43d5ebd1fbead41dd1f575befe
64ec74834f74676d6f3bce682c3b32376f141605
v1.0
complete
Taco
Taco_48317_C
import math from typing import List, Tuple def largest_distance(points: List[Tuple[int, int]]) -> float: """ Calculate the largest distance between any two points in a list. >>> largest_distance([(0, 0), (0, 1), (1, 0)]) 1.414214 >>> largest_distance([(-1, -1), (1, 1)]) 2.828427 """ pass d...
import math def largest_distance(points): max_dist = 0 for i in range(len(points)): for j in range(i + 1, len(points)): dist = math.sqrt((points[i][0] - points[j][0])**2 + (points[i][1] - points[j][1])**2) max_dist = max(max_dist, dist) return max_dist def solve(test_cases)...
def test_largest_distance(): assert largest_distance([(0, 0), (0, 1), (1, 0)]) == math.sqrt(2) assert largest_distance([(-1, -1), (1, 1)]) == 2 * math.sqrt(2) assert largest_distance([(0, 0), (3, 4)]) == 5.000000 assert largest_distance([(0, 0), (0, 0)]) == 0.0 def test_solve(): test_cases = [ ...
[ { "docstring": null, "function_declaration": "def largest_distance(points):", "function_name": "largest_distance", "parameter_list": "(points)" }, { "docstring": null, "function_declaration": "def solve(test_cases):", "function_name": "solve", "parameter_list": "(test_cases)" }...
[ 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": "import math\n\ndef largest_distance_in_plane(test_cases):\n results = []\n for case in test_cases:\n N = case[0]\n points = [(case[i], case[i +...
trial_gpt4o_4
{ "original_instruction": "You are given a set of points in a two-dimensional plane. Your task is to find the largest distance between any two points from the set and output that distance with 6 decimal places.\n\nInput\n\nThe first input line contains one number T — number of test cases (1 ≤ T ≤ 100). Each of the fo...
0.652307
Taco_48317
C
[ "largest_distance", "solve", "parse_input", "main" ]
4
[ [ "solve", "largest_distance" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
d343327a28ddcb65501a3b88a36b6fc01f9ba0ff
dd0a2553aa0d98fd4593d6d96ca5be6e0d4c7aaf
v1.0
complete
Taco
Taco_48252_C
def max_paint_cost(test_cases): """ Calculate the maximum total cost of painting houses such that no two adjacent houses are painted on the same day. Args: test_cases (List[Tuple[int, List[int]]]): A list of test cases where each test case is a tuple containing: - An integer N representing the ...
def max_paint_cost(test_cases): results = [] for case in test_cases: n, costs = case if n == 0: results.append(0) continue if n == 1: results.append(costs[0]) continue # Dynamic programming list to keep track of the ma...
def test_process_input(): input_str = "2\n5\n3 2 5 10 7\n4\n1 2 9 4\n" expected_output = [(5, [3, 2, 5, 10, 7]), (4, [1, 2, 9, 4])] assert process_input(input_str) == expected_output def test_max_paint_cost(): test_cases = [(5, [3, 2, 5, 10, 7]), (4, [1, 2, 9, 4])] expected_output = [15, 10] as...
[ { "docstring": null, "function_declaration": "def max_paint_cost(test_cases):", "function_name": "max_paint_cost", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def process_input(input_str):", "function_name": "process_input", "parameter_list":...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_paint_cost(test_cases):\n results = []\n \n for case in test_cases:\n n, costs = case\n if n == 0:\n results.append(0)\n ...
trial_gpt4o_0
{ "original_instruction": "A house painter is planning out a schedule to paint several houses lined up in a row. Every house has a certain cost associated with painting it. However, the painter cannot paint two adjacent houses on the same day. He can, however, skip any number of houses between two painted houses.\n\n...
0.656036
Taco_48252
C
[ "max_paint_cost", "process_input", "solve" ]
3
[ [ "solve", "max_paint_cost" ], [ "solve", "process_input" ] ]
2
[ "process_input" ]
false
[]
false
pytest
false
[]
true
8b7dc6b7408b61ac0facfbaf9d1067e92c44836b
a7e3202f6aa7903fcfa9934bf72bd0359ae5695b
v1.0
complete
Taco
Taco_48342_C
def multiply_matrices(A, B): """ Multiplies two square matrices A and B. >>> multiply_matrices([[1, 2], [3, 4]], [[5, 6], [7, 8]]) == [[19, 22], [43, 50]] >>> multiply_matrices([[1]], [[1]]) == [[1]] >>> multiply_matrices([[0, 0], [0, 0]], [[0, 0], [0, 0]]) == [[0, 0], [0, 0]] >>> multiply_matrices(...
def multiply_matrices(A, B): """ Multiplies two square matrices A and B. """ n = len(A) product = [[0] * n for _ in range(n)] for i in range(n): for j in range(n): for k in range(n): product[i][j] += A[i][k] * B[k][j] return product def trace_of...
def test_multiply_matrices(): assert multiply_matrices([[1, 2], [3, 4]], [[5, 6], [7, 8]]) == [[19, 22], [43, 50]] assert multiply_matrices([[1]], [[1]]) == [[1]] assert multiply_matrices([[0, 0], [0, 0]], [[0, 0], [0, 0]]) == [[0, 0], [0, 0]] assert multiply_matrices([[1, 0], [0, 1]], [[1, 0], [0, 1]])...
[ { "docstring": "Multiplies two square matrices A and B.", "function_declaration": "def multiply_matrices(A, B):", "function_name": "multiply_matrices", "parameter_list": "(A, B)" }, { "docstring": "Computes the trace of a square matrix.\nThe trace is the sum of the elements on the main diago...
[ 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 matrix_trace(n, matrix_A, matrix_B):\n \"\"\"\n Returns the trace of the product of two n x n matrices, matrix_A and matrix_B.\n \"\"\"\n # Initial...
trial_gpt4o_1
{ "original_instruction": "Claire is a computer science student, and one day in her algorithms class, the professor introduces the concept of matrix multiplication. As homework, the professor asks the students to implement matrix multiplication and determine the trace of the resulting matrix. The trace of a matrix is...
0.535995
Taco_48342
C
[ "multiply_matrices", "trace_of_matrix", "matrix_trace" ]
3
[ [ "matrix_trace", "multiply_matrices" ], [ "matrix_trace", "trace_of_matrix" ] ]
2
[]
false
[]
false
pytest
false
[]
true
2e593f54cdc620e62c08f43527ee36ac9010834e
b70ff49a32731ee43af512bafaa432c171e20a49
v1.0
complete
Taco
Taco_48633_C
def is_prime(n): """Check if a number is prime.""" if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True def isEm...
def is_prime(n): if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True def isEmirp(N): """ Returns "YES" if N...
from solution import isEmirp def test_emirp_number(): assert isEmirp(13) == "YES" assert isEmirp(17) == "YES" assert isEmirp(31) == "YES" assert isEmirp(37) == "YES" assert isEmirp(71) == "YES" assert isEmirp(73) == "YES" def test_non_emirp_number(): assert isEmirp(10) == "NO" asse...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns \"YES\" if N is an Emirp number, \"NO\" otherwise.", "function_declaration": "def isEmirp(N):", "function_name": "isEmirp", "parameter_...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"Helper function to check if a number is prime.\"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if...
trial_gpt4o_2
{ "original_instruction": "Given a positive integer N, write a program to determine if N is an \"Emirp number\". An Emirp number is a prime number that results in a different prime number when its digits are reversed.\n\nExample 1:\nInput:\nN = 13\nOutput:\nYES\nExplanation:\n13 is a prime number and its reverse, 31,...
0.82631
Taco_48633
C
[ "is_prime", "isEmirp" ]
2
[ [ "isEmirp", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
dc62ae220fe144e5a9dae4c573f7aaa3a2d40e0c
f8e1ba77e14f4937ecaceac7db129c0280eab1ad
v1.0
complete
Taco
Taco_48973_C
from typing import List def minimum_swaps_to_sort(arr: List[int]) -> int: """ Determine the minimum number of swaps needed to sort the array in ascending order. >>> minimum_swaps_to_sort([4, 3, 2, 1, 5]) 6 >>> minimum_swaps_to_sort([1, 3, 2]) 1 >>> minimum_swaps_to_sort([1]) 0 >>> minim...
def merge_and_count(arr, temp_arr, left, mid, right): i = left # Starting index for left subarray j = mid + 1 # Starting index for right subarray k = left # Starting index to be sorted inv_count = 0 while i <= mid and j <= right: if arr[i] <= arr[j]: temp_arr[k] = arr[i]...
def test_example_1(): assert minimum_swaps_to_sort([4, 3, 2, 1, 5]) == 6 def test_example_2(): assert minimum_swaps_to_sort([1, 3, 2]) == 1 def test_single_element(): assert minimum_swaps_to_sort([1]) == 0 def test_already_sorted(): assert minimum_swaps_to_sort([1, 2, 3, 4, 5]) == 0 def test_reverse...
[ { "docstring": null, "function_declaration": "def merge_and_count(arr, temp_arr, left, mid, right):", "function_name": "merge_and_count", "parameter_list": "(arr, temp_arr, left, mid, right)" }, { "docstring": null, "function_declaration": "def merge_sort_and_count(arr, temp_arr, left, r...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def merge_and_count(arr, temp_arr, left, mid, right):\n i = left # Starting index for left subarray\n j = mid + 1 # Starting index for right subarray\n ...
trial_gpt4o_0
{ "original_instruction": "You are given an array of integers and you need to sort it using the minimum number of moves. In one move, you can select any two adjacent elements and swap them. Can you determine the minimum number of swaps needed to sort the array in ascending order?\n\nInput\n\nThe first line contains o...
0.650846
Taco_48973
C
[ "merge_and_count", "merge_sort_and_count", "minimum_swaps_to_sort" ]
3
[ [ "merge_sort_and_count", "merge_and_count" ], [ "minimum_swaps_to_sort", "merge_sort_and_count" ] ]
2
[]
false
[]
false
pytest
false
[]
true
3497a5b67feac9162b12f1d4f3c424d0d0ff4a3d
f06f2766f981ff2a098b2b3e8fbc2a1669e8aea8
v1.0
complete
Taco
Taco_48241_C
from typing import List, Tuple def brute_force_search(arr: List[int], key: int) -> Tuple[int, int]: """ Brute force search to find the index of the key in the array and the number of comparisons made. If the key is not found, return -1 and the number of comparisons. """ # Your implementation here ...
def brute_force_search(arr, key): comparisons = 0 for index, value in enumerate(arr): comparisons += 1 if value == key: return index, comparisons return -1, comparisons def binary_search(arr, key, low, high, comparisons = 0): if low > high: return -1, comparisons ...
from solution import process_input def test_single_case_key_present(): t = 1 cases = [(10, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 6)] expected_output = [(5, 6, 3)] assert process_input(t, cases) == expected_output def test_single_case_key_absent(): t = 1 cases = [(10, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]...
[ { "docstring": null, "function_declaration": "def brute_force_search(arr, key):", "function_name": "brute_force_search", "parameter_list": "(arr, key)" }, { "docstring": null, "function_declaration": "def binary_search(arr, key, low, high, comparisons=0):", "function_name": "binary_s...
[ 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 brute_force_search(arr, key):\n comparisons = 0\n for i in range(len(arr)):\n comparisons += 1\n if arr[i] == key:\n return i, c...
trial_gpt4o_1
{ "original_instruction": "Problem description:\n\nThis problem focuses on using Binary Search and Divide and Conquer techniques.\n\nYou will be given an array of integers and a key value. Your task is to determine if the key value exists in the array and return its index if it exists.\n\nYou need to solve this probl...
0.582125
Taco_48241
C
[ "brute_force_search", "binary_search", "search_and_compare", "process_test_case", "process_input" ]
5
[ [ "process_input", "process_test_case" ], [ "process_test_case", "search_and_compare" ], [ "search_and_compare", "binary_search" ], [ "search_and_compare", "brute_force_search" ] ]
4
[ "process_test_case", "process_input" ]
false
[]
false
pytest
true
[]
true
f931da472a8886ab9f70569b7c3d9fac65d8a35f
5cfe899fa175b537dd7ee0786321dd63d0ede3fb
v1.0
complete
Taco
Taco_48287_C
def servers_start_order(n: int, dependencies: List[str]) -> str: """Determine the order in which the servers can be started given their dependencies. Args: n (int): The number of servers. dependencies (List[str]): The dependencies of each server in the form of lists ending with -1. Ret...
from collections import deque, defaultdict def find_start_order(n, dependencies): # Initialize graph and in-degree count graph = defaultdict(list) in_degree = [0] * (n + 1) # Parse the dependencies for i in range(n): for dep in dependencies[i]: if dep == -1: ...
import pytest from solution import servers_start_order def test_no_dependencies(): n = 3 deps = ["-1", "-1", "-1"] assert servers_start_order(n, deps) in ["1 2 3", "1 3 2", "2 1 3", "2 3 1", "3 1 2", "3 2 1"] def test_sequential_dependencies(): n = 3 deps = ["-1", "1 -1", "2 -1"] assert server...
[ { "docstring": null, "function_declaration": "def find_start_order(n, dependencies):", "function_name": "find_start_order", "parameter_list": "(n, dependencies)" }, { "docstring": null, "function_declaration": "def servers_start_order(n, dependencies_list):", "function_name": "server...
[ 0, 0, 0, 1 ]
1
hard
0.25
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def find_dependency_order(n, dependencies):\n from collections import defaultdict, deque\n \n # Create the adjacency list for the...
trial_gpt4o_4
{ "original_instruction": "A company has an IT infrastructure with several servers. Each server has a unique identifier (an integer) and a predefined dependency on other servers. If server A depends on server B, then server B must be up before server A can be started.\n\nGiven the information about the dependencies o...
0.471699
Taco_48287
C
[ "find_start_order", "servers_start_order" ]
2
[ [ "servers_start_order", "find_start_order" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e1b6f484545559270c3258ab500716cebc19e165
f72a1bc807f49b82e35e86ae6b9188d7b04695a1
v1.0
complete
Taco
Taco_48975_C
def digit_sum(n: int) -> int: """ Returns the sum of the digits of n. >>> digit_sum(340) 7 >>> digit_sum(14) 5 >>> digit_sum(123) 6 >>> digit_sum(59) 14 >>> digit_sum(32767) 25 """ def organize_books_by_digit_sum(n: int, book_ids: List[int]) -> List[int]: """...
def digit_sum(n): """ Returns the sum of the digits of n. """ return sum(int(digit) for digit in str(n)) def organize_books_by_digit_sum(n, book_ids): """ Organizes the list of book IDs based on their digit-sum and in case of a tie, by their actual value in ascending order. Paramet...
from solution import digit_sum, organize_books_by_digit_sum def test_digit_sum(): assert digit_sum(340) == 7 assert digit_sum(14) == 5 assert digit_sum(123) == 6 assert digit_sum(59) == 14 assert digit_sum(32767) == 25 def test_organize_books_by_digit_sum(): assert organize_books_by_digit_sum(...
[ { "docstring": "Returns the sum of the digits of n.", "function_declaration": "def digit_sum(n):", "function_name": "digit_sum", "parameter_list": "(n)" }, { "docstring": "Organizes the list of book IDs based on their digit-sum and in case of a tie,\nby their actual value in ascending order....
[ 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 digit_sum(n):\n \"\"\"\n Returns the sum of the digits of the given number n.\n \"\"\"\n return sum(int(digit) for digit in str(n))\n\ndef arrange_...
trial_gpt4o_4
{ "original_instruction": "In a faraway kingdom, there is an old library with many ancient books. The librarian, Ms. Eleanor, wants to organize these books in a specific way. Each book has a unique ID represented by a positive integer. Ms. Eleanor wants to arrange the books in ascending order based on their IDs and d...
0.637568
Taco_48975
C
[ "digit_sum", "organize_books_by_digit_sum" ]
2
[ [ "organize_books_by_digit_sum", "digit_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
671dba7da11af26393e3ae5331d1c9c661b7bea6
6e4b38a2889be5fcee60f39b657cdd6a66e42731
v1.0
complete
Taco
Taco_48796_C
def maximal_rectangle(matrix: List[List[int]]) -> int: """ Given a binary matrix, find the maximum area of a rectangle formed only by 1's. >>> maximal_rectangle([ >>> [1, 0, 1, 0, 0], >>> [1, 0, 1, 1, 1], >>> [1, 1, 1, 1, 1], >>> [1, 0, 0, 1, 0] >>> ]) 6 >>> maximal_...
def maximal_rectangle(matrix): """ Given a binary matrix, find the maximum area of a rectangle formed only by 1's. """ if not matrix: return 0 n = len(matrix) m = len(matrix[0]) height = [0] * m max_area = 0 for i in range(n): for j in range(m): ...
import pytest from solution import maximal_rectangle def test_maximal_rectangle_example1(): matrix = [ [1, 0, 1, 0, 0], [1, 0, 1, 1, 1], [1, 1, 1, 1, 1], [1, 0, 0, 1, 0] ] assert maximal_rectangle(matrix) == 6 def test_maximal_rectangle_example2(): matrix = [ [1...
[ { "docstring": "Given a binary matrix, find the maximum area of a rectangle formed only by 1's.", "function_declaration": "def maximal_rectangle(matrix):", "function_name": "maximal_rectangle", "parameter_list": "(matrix)" }, { "docstring": "Helper function to find the largest rectangle area...
[ 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 maximalRectangle(matrix):\n if not matrix or not matrix[0]:\n return 0\n \n n = len(matrix)\n m = len(matrix[0])\n max_area = 0\n ...
trial_gpt4o_2
{ "original_instruction": "You are given a matrix of integers with \\(n\\) rows and \\(m\\) columns. Your task is to find the largest rectangle containing only the number 1 and print its area.\n\nThe matrix is represented as a list of lists. Each element of the matrix can be either 0 or 1.\n\nFor example, in the matr...
0.711337
Taco_48796
C
[ "maximal_rectangle", "largest_rectangle_area" ]
2
[ [ "maximal_rectangle", "largest_rectangle_area" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5a5dc75b14a411c2981d65dd62581476a45b631d
95068d8d147e52f2317d3996254fe9e93708bf5d
v1.0
complete
Taco
Taco_49104_C
from typing import List, Tuple def min_max_distance(n: int, bridges: List[Tuple[int, int]]) -> int: """ Determine the minimum possible maximum distance between any two skyscrapers after adding the optimal set of new sky bridges. >>> min_max_distance(5, [(1, 2), (1, 3), (3, 4), (3, 5)]) == 2 >>> min_max_dis...
from collections import deque def tree_diameter(tree, n): def bfs(start): dist = [-1] * n queue = deque([start]) dist[start] = 0 max_dist_node = start max_dist = 0 while queue: node = queue.popleft() for neighbor in tree[node]: ...
from solution import min_max_distance def test_case_1(): n = 5 bridges = [(1, 2), (1, 3), (3, 4), (3, 5)] assert min_max_distance(n, bridges) == 2 def test_case_2(): n = 6 bridges = [(1, 2), (2, 3), (2, 4), (4, 5), (4, 6)] assert min_max_distance(n, bridges) == 2 def test_case_3(): n = 2 ...
[ { "docstring": null, "function_declaration": "def tree_diameter(tree, n):", "function_name": "tree_diameter", "parameter_list": "(tree, n)" }, { "docstring": null, "function_declaration": "def min_max_distance(n, bridges):", "function_name": "min_max_distance", "parameter_list": ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef tree_diameter(tree, n):\n def bfs(start):\n dist = [-1] * n\n queue = deque([start])\n dist[start] = 0...
trial_gpt4o_0
{ "original_instruction": "Julia is the head architect of a futuristic city with skyscrapers connected by sky bridges. The city has $n$ skyscrapers, and certain pairs of skyscrapers are directly connected by a sky bridge. Julia wants to install additional sky bridges based on some rules to minimize the maximum travel...
0.619183
Taco_49104
C
[ "tree_diameter", "min_max_distance", "process_input" ]
3
[ [ "min_max_distance", "tree_diameter" ], [ "process_input", "min_max_distance" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
e6179c36e2ddd4d0bc74552b17c1e2b016c17f42
f648d9077c817122e138fc6dba2f93d87decd7d5
v1.0
complete
Taco
Taco_48859_C
def is_subsequence(a: str, b: str) -> bool: """ Determines if a is a subsequence of b. """ pass def max_wins_in_game(test_cases: List[Tuple[int, List[str]]]) -> List[int]: """ Given a list of test cases, determine the maximum number of rounds a string can win in a game of rock-paper-scissor...
def is_subsequence(a, b): """ Determines if a is a subsequence of b. """ it = iter(b) return all(char in it for char in a) def max_wins_in_game(test_cases): outputs = [] for n, strings in test_cases: max_wins = 1 # the minimum rounds any string can win is itself for i ...
from solution import is_subsequence, max_wins_in_game def test_is_subsequence(): assert is_subsequence("abc", "aebdc") == True assert is_subsequence("abc", "acb") == False assert is_subsequence("a", "a") == True assert is_subsequence("a", "b") == False def test_max_wins_in_game(): # Example test c...
[ { "docstring": "Determines if a is a subsequence of b.", "function_declaration": "def is_subsequence(a, b):", "function_name": "is_subsequence", "parameter_list": "(a, b)" }, { "docstring": null, "function_declaration": "def max_wins_in_game(test_cases):", "function_name": "max_wins_...
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_subsequence(a, b):\n it = iter(b)\n return all(char in it for char in a)\n\ndef max_rounds(strings):\n max_wins = 0\n for i in range(len(strings...
trial_gpt4o_7
{ "original_instruction": "In a distant land, there is a kingdom where the most popular game is a version of rock-paper-scissors played with strings. The rules are as follows:\n\n- A string 'a' can defeat string 'b' in a round if and only if 'a' is a subsequence of 'b'.\n- The game consists of multiple rounds, with p...
0.699115
Taco_48859
C
[ "is_subsequence", "max_wins_in_game" ]
2
[ [ "max_wins_in_game", "is_subsequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0dfa569ed914a229b3a859d65fcddfd04ff5df37
9817870e18366e40296cea1ce3e1761dae629a17
v1.0
complete
Taco
Taco_49180_C
from typing import List, Tuple def greatest_sum_of_subsequences(s: List[int]) -> int: """ Given a sequence of integers, find the greatest sum of all non-empty subsequences. >>> greatest_sum_of_subsequences([1, -2, 3, 4, -1]) 8 >>> greatest_sum_of_subsequences([-1, -2, -3]) -1 """ pass def ...
def greatest_sum_of_subsequences(s): return max(0, sum(x for x in s if x > 0)) or max(s) def solve(t, test_cases): results = [] for i in range(t): n, s = test_cases[i] result = greatest_sum_of_subsequences(s) results.append(result) return results # Function to parse the input a...
from solution import greatest_sum_of_subsequences, execute_problem_statements def test_greatest_sum_of_subsequences(): assert greatest_sum_of_subsequences([1, -2, 3, 4, -1]) == 8 assert greatest_sum_of_subsequences([-1, -2, -3]) == -1 assert greatest_sum_of_subsequences([0, 0, 0]) == 0 assert greatest_...
[ { "docstring": null, "function_declaration": "def greatest_sum_of_subsequences(s):", "function_name": "greatest_sum_of_subsequences", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def solve(t, test_cases):", "function_name": "solve", "parameter_list": "...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def greatest_sum_of_subsequences(s):\n return max(0, sum(x for x in s if x > 0)) or max(s)\n\ndef solve(t, test_cases):\n results = []\n for i in range(t)...
trial_gpt4o_0
{ "original_instruction": "Problem Statement\n\nAnay loves working with numbers and often engages in various mathematical puzzles. Today, he has a sequence of `n` integers and he is interested in finding the \"Greatest Sum of Subsequences\" (GSS). GSS of a sequence is defined as follows: \n\nGiven a sequence A, consi...
0.659118
Taco_49180
C
[ "greatest_sum_of_subsequences", "solve", "execute_problem_statements" ]
3
[ [ "execute_problem_statements", "solve" ], [ "solve", "greatest_sum_of_subsequences" ] ]
2
[]
false
[]
false
pytest
true
[]
true
f4a431775440a7dbf7f7090d3c6e95e363303830
0686624e6bd4fe58a207cc45b0683e0855cadc4a
v1.0
complete
Taco
Taco_49001_C
def process_queries(t: int, queries: List[int]) -> List[str]: """ Determines if within 50 moves, Limak can hold any card with a prime number. Args: t: An integer representing the number of test cases. queries: A list of integers representing the initial values of cards for each test case. Retu...
def is_prime(n): """ 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 += 6 ...
from solution import process_queries def test_single_test_case(): assert process_queries(1, [10]) == ["yes"] def test_multiple_test_cases(): assert process_queries(3, [10, 15, 4]) == ["yes", "yes", "yes"] def test_prime_initial_card(): assert process_queries(1, [17]) == ["yes"] def test_non_prime_no_pat...
[ { "docstring": "Function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Function to determine if a prime number can be held within 50 moves.", "function_declaration": "def can_hold_prime...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Function to check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n ...
trial_gpt4o_0
{ "original_instruction": "Bear Limak is playing a game with a set of cards numbered from 1 to 100. He wants to know if a sequence of moves will lead to him holding any card with a prime number.\n\nLimak starts with an initial card. Each move consists of either increasing the card value by a number \\( k \\) (where \...
0.546189
Taco_49001
C
[ "is_prime", "can_hold_prime", "process_queries" ]
3
[ [ "can_hold_prime", "is_prime" ], [ "process_queries", "can_hold_prime" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
true
[]
true
bad63274d95843d64d851e8e16076d9ad2407879
97bda78988dd988376ad8a7e25b2eb60fc736625
v1.0
complete
Taco
Taco_49766_C
def isSumPrime(N: int) -> bool: """ Determine whether the sum of the digits of N is a prime number. >>> isSumPrime(47) True >>> isSumPrime(123) False """
def is_prime(num): """ Helper function to check if a number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return F...
from solution import isSumPrime def test_isSumPrime_example1(): assert isSumPrime(47) == True # 4 + 7 = 11, 11 is a prime number def test_isSumPrime_example2(): assert isSumPrime(123) == False # 1 + 2 + 3 = 6, 6 is not a prime number def test_isSumPrime_single_digit_prime(): assert isSumPrime(2) == Tr...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Function to determine whether the sum of the digits of N is a prime number.", "function_declaration": "...
[ 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(num):\n \"\"\"\n Helper function to check if a number is a prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n ...
trial_gpt4o_8
{ "original_instruction": "Given a positive integer N, write a program to determine whether the sum of the digits of N is a prime number. \nA prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.\n\nExample 1:\nInput: N = 47\nOutput: True\nExplanation: The sum of the d...
0.758281
Taco_49766
C
[ "is_prime", "isSumPrime" ]
2
[ [ "isSumPrime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c5d4f065ec82891087eddc0d78dba56770c55977
1957d9209f3284518b25ba231238588cf35f044a
v1.0
complete
Taco
Taco_49693_C
def maxSquareTiles(H: int, W: int) -> int: """ Find the maximum number of equal-sized square tiles that can completely cover the given rectangle of height H and width W. The size of the square tile must be a factor of both the height and the width of the rectangle. >>> maxSquareTiles(6,...
def gcd(a, b): """ Helper function to compute the greatest common divisor (GCD) using the Euclidean algorithm. """ while b != 0: a, b = b, a % b return a def maxSquareTiles(H, W): """ Function to find the maximum number of equal-sized square tiles that can completely cover the g...
from solution import maxSquareTiles def test_maxSquareTiles_example1(): assert maxSquareTiles(6, 9) == 6 def test_maxSquareTiles_example2(): assert maxSquareTiles(8, 12) == 6 def test_maxSquareTiles_prime_numbers(): assert maxSquareTiles(7, 11) == 77 def test_maxSquareTiles_large_common_factor(): as...
[ { "docstring": "Helper function to compute the greatest common divisor (GCD) using the Euclidean algorithm.", "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": "Function to find the maximum number of equal-sized square tiles\nthat ...
[ 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\n\ndef maxSquareTiles(H, W):\n \"\"\"\n Returns the maximum number of equal-sized square tiles that can completely cover the given rectangle.\n ...
trial_gpt4o_2
{ "original_instruction": "A rectangle is denoted by its height H and width W. The rectangle can be divided into smaller equal-sized square tiles. Write a function `maxSquareTiles` to find the maximum number of equal-sized square tiles that can completely cover the given rectangle without any gaps. The size of the sq...
0.662961
Taco_49693
C
[ "gcd", "maxSquareTiles" ]
2
[ [ "maxSquareTiles", "gcd" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5487d64ad245ca8a1b900e93c599710096721ebe
b3bf8a4535098eaf37739003157f94971bf14ca4
v1.0
complete
Taco
Taco_49487_C
def is_prime(n: int) -> bool: """ Determines if a number is prime. >>> is_prime(2) True >>> is_prime(4) False """ def filter_primes(arr: List[int]) -> List[int]: """ Returns a new list containing only the prime numbers from the input list. :param arr: List[int] :return: List[in...
def is_prime(n): """ Determines if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False limit = int(n**0.5) + 1 for i in range(3, limit, 2): if n % i == 0: return False return True def filter_pr...
from solution import filter_primes def test_filter_primes_all_primes(): assert filter_primes([2, 3, 5, 7, 11, 13, 17, 19, 23]) == [2, 3, 5, 7, 11, 13, 17, 19, 23] def test_filter_primes_mixed_numbers(): assert filter_primes([4, 6, 7, 9, 10, 13]) == [7, 13] assert filter_primes([15, 25, 31, 37, 41]) == [31...
[ { "docstring": "Determines if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a new list containing only the prime numbers from the input list.\n\n:param arr: List[int]\n:return: List[int]", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n ...
trial_gpt4o_2
{ "original_instruction": "Implement a function to filter an array of integers, only keeping the prime numbers. The function should meet these requirements:\n\n+ Accepts an array of positive integers as its parameter (example: `[4, 6, 7, 9, 10, 13]`)\n+ Returns a new array containing only the prime numbers from the i...
0.756423
Taco_49487
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
87d1efdf0f4c3351d7a4c293853404cba41b01ce
742b98b0276d7962f33ed34b36e39b27dfb2060e
v1.0
complete
Taco
Taco_49185_C
from typing import List, Tuple def min_additional_roads(N: int, M: int, roads: List[Tuple[int, int]]) -> int: """ Determine the minimum number of additional roads needed to make the network of houses connected. >>> min_additional_roads(6, 5, [(1, 2), (2, 3), (3, 4), (4, 5), (5, 6)]) 0 >>> min_additiona...
def find(root, parent): if parent[root] != root: parent[root] = find(parent[root], parent) return parent[root] def union(node1, node2, parent, rank): root1 = find(node1, parent) root2 = find(node2, parent) if root1 != root2: if rank[root1] > rank[root2]: parent[root...
from solution import min_additional_roads def test_case_1(): N = 6 M = 5 roads = [(1, 2), (2, 3), (3, 4), (4, 5), (5, 6)] assert min_additional_roads(N, M, roads) == 0 def test_case_2(): N = 6 M = 3 roads = [(1, 2), (2, 3), (4, 5)] assert min_additional_roads(N, M, roads) == 2 def tes...
[ { "docstring": null, "function_declaration": "def find(root, parent):", "function_name": "find", "parameter_list": "(root, parent)" }, { "docstring": null, "function_declaration": "def union(node1, node2, parent, rank):", "function_name": "union", "parameter_list": "(node1, node2...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, x):\n if parent[x] != x:\n parent[x] = find(parent, parent[x])\n return parent[x]\n\ndef union(parent, rank, x, y):\n rootX = find...
trial_gpt4o_2
{ "original_instruction": "In a remote village, there are N houses connected by M roads. Each road connects two different houses bidirectionally. The people of the village want to ensure that every house is reachable from every other house by using those roads.\n\nTo achieve this, they propose to build additional roa...
0.638479
Taco_49185
C
[ "find", "union", "min_additional_roads" ]
3
[ [ "min_additional_roads", "find" ], [ "min_additional_roads", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
ad8925086ce794037792d790c41aa977c8bc830b
eeb8fc0e276b0739887143cdc5a7296656d9ef07
v1.0
complete
Taco
Taco_49447_C
from typing import List def subarray_sum(nums: List[int], k: int) -> int: """ Returns the number of subarrays whose sum is exactly equal to k. >>> subarray_sum([1, 2, 3, 4, 5], 5) == 2 >>> subarray_sum([1, 1, 1, 1], 2) == 3 """
def subarray_sum(nums, k): """ Returns the number of subarrays whose sum is exactly equal to k. """ count = 0 cumulative_sum = 0 sum_dict = {0: 1} for num in nums: cumulative_sum += num if (cumulative_sum - k) in sum_dict: count += sum_dict[cumulative_sum - k] ...
from solution import count_subarrays_with_sum def test_sample_input(): assert count_subarrays_with_sum(5, [1, 2, 3, 4, 5], 5) == 2 def test_all_elements_same(): assert count_subarrays_with_sum(4, [1, 1, 1, 1], 2) == 3 def test_no_subarray_with_sum(): assert count_subarrays_with_sum(5, [1, 2, 3, 4, 5], 20...
[ { "docstring": "Returns the number of subarrays whose sum is exactly equal to k.", "function_declaration": "def subarray_sum(nums, k):", "function_name": "subarray_sum", "parameter_list": "(nums, k)" }, { "docstring": "Wrapper function to process input and call subarray_sum function.", "...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_subarrays_with_sum_k(n, array, k):\n \"\"\"\n This function returns the number of subarrays whose sum is exactly equal to k.\n \n :param n: N...
trial_gpt4o_2
{ "original_instruction": "You are given an array of n integers and a target integer k. You need to find the number of subarrays whose sum is exactly equal to k. A subarray is defined as a contiguous segment of the array.\n\nInput:\n1st line contains an integer n, denoting the number of elements in the array.\n2nd li...
0.673644
Taco_49447
C
[ "subarray_sum", "count_subarrays_with_sum" ]
2
[ [ "count_subarrays_with_sum", "subarray_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9bbbd8249756a084e8a0bf2fb58cedba87fef187
4942007a4ffa4afc6ddd526bff13b2ab3fa4ff9e
v1.0
complete
Taco
Taco_49254_C
def sieve_of_eratosthenes(max_num): """ Uses the Sieve of Eratosthenes to find all prime numbers up to max_num and returns a list of counts of primes up to each index. """ is_prime = [True] * (max_num + 1) p = 2 while (p * p <= max_num): if (is_prime[p] == True): for i in...
def sieve_of_eratosthenes(max_num): """ Uses the Sieve of Eratosthenes to find all prime numbers up to max_num and returns a list of counts of primes up to each index. """ is_prime = [True] * (max_num + 1) p = 2 while (p * p <= max_num): if (is_prime[p] == True): for i in...
from solution import prime_performances def test_prime_performances(): assert prime_performances(3, [10, 20, 30]) == [4, 8, 10] assert prime_performances(1, [1]) == [0] assert prime_performances(2, [11, 50]) == [5, 15] assert prime_performances(1, [1000000]) == [78498] def test_edge_cases(): asser...
[ { "docstring": "Uses the Sieve of Eratosthenes to find all prime numbers up to max_num\nand returns a list of counts of primes up to each index.", "function_declaration": "def sieve_of_eratosthenes(max_num):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(max_num)" }, { "docs...
[ 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_n):\n is_prime = [True] * (max_n + 1)\n is_prime[0] = is_prime[1] = False\n \n p = 2\n while (p * p <= max_n):\n ...
trial_gpt4o_2
{ "original_instruction": "In a faraway kingdom, there is a tradition of organizing a grand parade where people line up to watch an impressive sequence of lancer performances. Each lancer in the parade exhibits stunning displays of skill in a series of performances numbered sequentially from 1 to N.\n\nThe king loves...
0.685724
Taco_49254
C
[ "sieve_of_eratosthenes", "prime_performances" ]
2
[ [ "prime_performances", "sieve_of_eratosthenes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
26ca4af464c1ce6658e4af3f0b1377ff49e97335
828c8538d9212fca52678d5ca6e3ffb7abdadf6e
v1.0
complete
Taco
Taco_49145_C
def island_treasures(P: int, test_cases: List[Dict]) -> List[str]: """ Compute which treasures Bob can collect after moving on the island. Args: P: The number of test cases. test_cases: A list of dictionaries, where each dictionary represents a test case. Each dictionary contains: - ini...
def apply_movement_seq(position, movement_seq): x, y = position for move in movement_seq: if move[0] == 'T': x += move[1] y += move[2] elif move[0] == 'VS': y *= move[1] elif move[0] == 'HS': x *= move[1] elif move[0] == 'FX': ...
from solution import island_treasures def test_island_treasures_1(): P = 1 test_cases = [ { 'initial_conditions': (2, 1, 0, 0), 'treasures': [(2, 3), (-4, 5)], 'movement_seq': [('T', 1, -1), ('VS', 2), ('HS', -1)] } ] result = island_treasures(P, test...
[ { "docstring": null, "function_declaration": "def apply_movement_seq(position, movement_seq):", "function_name": "apply_movement_seq", "parameter_list": "(position, movement_seq)" }, { "docstring": null, "function_declaration": "def island_treasures(P, test_cases):", "function_name":...
[ 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 treasure_finder(P, test_cases):\n results = []\n for case in test_cases:\n n, M, x_0, y_0, treasures, L, movements = case\n\n current_pos =...
trial_gpt4o_2
{ "original_instruction": "Bob is exploring a mysterious 2D island, with an initial location at $(x_0, y_0)$. On this island, Bob can collect treasures located at certain points $(a_i, b_i)$ (for $i = 1$ to $n$). However, to reach these treasures, Bob needs to use a sequence of limited movements. The permissible move...
0.622107
Taco_49145
C
[ "apply_movement_seq", "island_treasures" ]
2
[ [ "island_treasures", "apply_movement_seq" ] ]
1
[]
false
[]
false
pytest
true
[]
true
10d937697643afbe93a7b3f1bed9c820468a693b
6b2f51fbc7d2d803e65ce8f10988844c11ae12fd
v1.0
complete
Taco
Taco_49414_C
from bisect import bisect_left from typing import List def longest_increasing_subsequence_length(A: List[int]) -> int: """ Returns the length of the longest increasing subsequence in the array A. >>> longest_increasing_subsequence_length([5, 2, 8, 6, 3, 6]) == 3 >>> longest_increasing_subsequence_leng...
from bisect import bisect_left def longest_increasing_subsequence_length(A): """ Returns the length of the longest increasing subsequence in the array A. """ if not A: return 0 lis = [] for num in A: pos = bisect_left(lis, num) if pos == len(lis): ...
from solution import longest_increasing_subsequence_length, solve, parse_input def test_longest_increasing_subsequence_length(): assert longest_increasing_subsequence_length([5, 2, 8, 6, 3, 6]) == 3 assert longest_increasing_subsequence_length([1, 2, 3, 4, 5]) == 5 assert longest_increasing_subsequence_len...
[ { "docstring": "Returns the length of the longest increasing subsequence in the array A.", "function_declaration": "def longest_increasing_subsequence_length(A):", "function_name": "longest_increasing_subsequence_length", "parameter_list": "(A)" }, { "docstring": null, "function_declarat...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import bisect\n\ndef length_of_lis(arr):\n \"\"\"\n Returns the length of the longest increasing subsequence in the array.\n \"\"\"\n if not arr:\n ...
trial_gpt4o_2
{ "original_instruction": "A subsequence of an array is a sequence that can be derived from the array by deleting some or no elements without changing the order of the remaining elements. You are given an array A of size N. Determine the length of the longest increasing subsequence that can be formed from the element...
0.642624
Taco_49414
C
[ "longest_increasing_subsequence_length", "solve", "parse_input" ]
3
[ [ "solve", "longest_increasing_subsequence_length" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
777ef4e3c3158894d8fc5672b00b8304769920bf
e52e1433d88f4683db579fc344d8661ce30a1a65
v1.0
complete
Taco
Taco_49710_C
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def build_tree(nodes): """ Build a tree from a list of nodes. """ if not nodes: return None n = len(nodes) if n == 0 or nodes[0] is None: return None root = TreeNod...
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def build_tree(nodes): if not nodes: return None n = len(nodes) if n == 0 or nodes[0] is None: return None root = TreeNode(nodes[0]) queue = [root] i = 1 while ...
from solution import determine_if_balanced def test_balanced_tree1(): assert determine_if_balanced("3 9 20 null null 15 7") == "BALANCED" def test_not_balanced_tree1(): assert determine_if_balanced("1 2 2 3 3 null null 4 4") == "NOT BALANCED" def test_balanced_tree2(): assert determine_if_balanced("1 2 3...
[]
[ 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, x):\n self.val = x\n self.left = None\n self.right = None\n\ndef is_balanced(root):\n def check_bal...
trial_gpt4o_1
{ "original_instruction": "Determine if a Binary Tree is Balanced\n\nGiven a binary tree, determine if it is balanced. A balanced tree is defined as a tree in which the left and right subtrees of every node differ in height by no more than 1.\n\n### Input\n\nThe input is a list of space-separated integers representin...
0.750045
Taco_49710
C
[ "build_tree", "is_balanced", "determine_if_balanced" ]
3
[ [ "determine_if_balanced", "build_tree" ], [ "determine_if_balanced", "is_balanced" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
3e3fa252aa7c25a647f1d017b14c76baa79948a2
32b0587edd8e01d425ae74aacf689023ef336f6b
v1.0
complete
Taco
Taco_49722_C
def can_crowley_escape(N: int, M: int, grid: List[str]) -> str: """ Determine whether Crowley can reach the bottom-right cell in the labyrinth from the top-left cell. Args: N (int): The number of rows in the grid. M (int): The number of columns in the grid. grid (List[str]): The labyrin...
def can_reach_end(grid): N = len(grid) M = len(grid[0]) if grid[0][0] == '#' or grid[N-1][M-1] == '#': return "NO" # Use a queue for BFS queue = [(0, 0)] visited = set() directions = [(1, 0), (0, 1)] # down, right while queue: x, y = queue.pop(0) if (x, y) == (...
from solution import main def test_case_1(): input_string = """4 4 . . . # . # . . . . # . . . . .""" assert main(input_string) == "YES" def test_case_2(): input_string = """4 4 . # . # . # . . . . # . . # . .""" assert main(input_string) == "NO" def test_case_3(): ...
[ { "docstring": null, "function_declaration": "def can_reach_end(grid):", "function_name": "can_reach_end", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def can_crowley_escape(N, M, grid):", "function_name": "can_crowley_escape", "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": "def can_reach_artifact(n, m, grid):\n \"\"\"\n Determines whether Crowley can reach the bottom-right cell in the labyrinth.\n \n Args:\n n : int : n...
trial_gpt4o_1
{ "original_instruction": "Crowley is tasked with finding an ancient artifact hidden in a vast labyrinth. The labyrinth is represented as a grid of cells, where each cell is either open ('.') or contains an obstacle ('#'). Crowley starts at the top-left cell (1,1) and wants to reach the bottom-right cell (N,M). He ca...
0.617405
Taco_49722
C
[ "can_reach_end", "can_crowley_escape", "parse_input", "main" ]
4
[ [ "can_crowley_escape", "can_reach_end" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
51f157f455cb52b3521de88dd5f92cac1b515ef2
35e8660bbdf921caac6a209624da8dea52352c9e
v1.0
complete
Taco
Taco_50167_C
from typing import List, Tuple def find_path(matrix: List[List[int]], start: Tuple[int, int], end: Tuple[int, int]) -> bool: """ Determine if there is a path from the start position to the end position in a given 2D grid matrix. Parameters: matrix (List[List[int]]): A 2D list of integers where 0 repre...
from collections import deque def is_valid_move(matrix, x, y): return 0 <= x < len(matrix) and 0 <= y < len(matrix[0]) and matrix[x][y] == 0 def find_path(matrix, start, end): if start == end: return True rows, cols = len(matrix), len(matrix[0]) visited = [[False for _ in range(cols)] for _ i...
from solution import find_path def test_path_exists(): matrix = [ [0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 1], [0, 1, 0, 0] ] start = (0, 0) end = (3, 3) assert find_path(matrix, start, end) == True def test_path_not_exists(): matrix = [ [0, 1, 1, 0], ...
[ { "docstring": null, "function_declaration": "def is_valid_move(matrix, x, y):", "function_name": "is_valid_move", "parameter_list": "(matrix, x, y)" }, { "docstring": null, "function_declaration": "def find_path(matrix, start, end):", "function_name": "find_path", "parameter_lis...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef is_valid_move(matrix, x, y):\n return 0 <= x < len(matrix) and 0 <= y < len(matrix[0]) and matrix[x][y] == 0\n\ndef find_pa...
trial_gpt4o_0
{ "original_instruction": "Implement a function `find_path(matrix, start, end)` that determines if there is a path from the `start` position to the `end` position in a given 2D grid `matrix`. The function should adhere to the following rules:\n\n- The `matrix` is a 2D list consisting of 0s and 1s.\n- 0 represents a w...
0.660201
Taco_50167
C
[ "is_valid_move", "find_path" ]
2
[ [ "find_path", "is_valid_move" ] ]
1
[]
false
[]
false
pytest
true
[]
true
90e83dc78a00808f85b2c023a908e7ebb1308ce9
2eed3b586fcf8224636df8bfe1dbb94239364901
v1.0
complete
Taco
Taco_49754_C
def organize_library(n: int, titles: List[str]) -> List[str]: """ Organize John's library by sorting book titles in a case-insensitive manner, with lowercase titles coming before uppercase titles when the titles are the same. Args: n : int : number of book titles titles : list of str : list...
def sort_books(titles): """ Sorts a list of book titles in a case-insensitive manner, with lowercase titles appearing before uppercase when the lowercased titles are the same. """ return sorted(titles, key=lambda title: (title.lower(), title)) def organize_library(n, titles): """ Organize J...
from solution import organize_library def test_organize_library_case_insensitive(): titles = [ "The Hobbit", "harry potter", "Moby Dick", "harry potter and the Chamber of Secrets", "THE GREAT GATSBY" ] sorted_titles = organize_library(5, titles) expected = [ ...
[ { "docstring": "Sorts a list of book titles in a case-insensitive manner,\nwith lowercase titles appearing before uppercase when the lowercased titles are the same.", "function_declaration": "def sort_books(titles):", "function_name": "sort_books", "parameter_list": "(titles)" }, { "docstrin...
[ 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 sort_books(n, titles):\n \"\"\"\n Sorts book titles in a case-insensitive manner with lowercase titles coming before uppercase \n if titles are the sa...
trial_gpt4o_3
{ "original_instruction": "John is trying to organize his library of books. He wants to arrange the books in alphabetical order by their titles. However, some of the titles are in lowercase and others are in uppercase. He wants to sort them in a case-insensitive manner, but if the titles are the same when converted t...
0.540819
Taco_49754
C
[ "sort_books", "organize_library" ]
2
[ [ "organize_library", "sort_books" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b5ef79e8a960d32000e6115a78959b1c642e22a9
520f2888f0c8758eb6e6512a2d85c4fa6a09d164
v1.0
complete
Taco
Taco_50264_C
def maxForestArea(r: int, c: int, grid: List[str]) -> int: """ Given a grid with r rows and c columns, this function returns the area of the largest rectangle composed entirely of forest tiles ('F'). >>> maxForestArea(3, 3, ["WFW", "FWF", "FFF"]) 3 >>> maxForestArea(4, 5, ["MFMFM", "FFMFF", "FM...
def maxForestArea(r, c, grid): """ Given a grid with r rows and c columns, this function returns the area of the largest rectangle composed entirely of forest tiles ('F'). """ # Histogram heights for each column, initialized to 0 heights = [0] * c max_area = 0 for row in grid: f...
from solution import maxForestArea def test_example1(): r, c = 3, 3 grid = ['WFW', 'FWF', 'FFF'] assert maxForestArea(r, c, grid) == 3 def test_example2(): r, c = 4, 5 grid = ['MFMFM', 'FFMFF', 'FMFFF', 'FFFFF'] assert maxForestArea(r, c, grid) == 6 def test_no_forest(): r, c = 2, 2 g...
[ { "docstring": "Given a grid with r rows and c columns, this function returns the area of the\nlargest rectangle composed entirely of forest tiles ('F').", "function_declaration": "def maxForestArea(r, c, grid):", "function_name": "maxForestArea", "parameter_list": "(r, c, grid)" }, { "docst...
[ 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 maximalRectangleArea(grid):\n if not grid:\n return 0\n \n r = len(grid)\n c = len(grid[0])\n \n # Convert grid into height matrix\n ...
trial_gpt4o_2
{ "original_instruction": "Anastasia is a map enthusiast and likes to create maps for different terrains. She uses a grid with r rows and c columns to represent different terrains such as water, forest, and mountains. Each cell in the grid can be represented by three characters: 'W' for water, 'F' for forest, and 'M'...
0.621383
Taco_50264
C
[ "maxForestArea", "largestRectangleArea" ]
2
[ [ "maxForestArea", "largestRectangleArea" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5c8e7a49fa6d347b1a6706aeb98abe40a88e7e10
1a424cd93b3623e37a5f055636a0575fe139aa19
v1.0
complete
Taco
Taco_50045_C
from typing import List def count_valid_ap(n: int, sequence: List[int]) -> int: """ Counts the number of valid ways to restore the arithmetic progression by replacing the -1 with an integer between 1 and n. >>> count_valid_ap(5, [1, -1, 3, 4, 5]) 1 >>> count_valid_ap(4, [4, -1, 2, 1]) 1 >>> count_valid...
def count_valid_ap(n, sequence): possible_values = set(range(1, n + 1)) - set(sequence) valid_ways = 0 for value in possible_values: new_sequence = [value if x == -1 else x for x in sequence] if is_arithmetic_progression(new_sequence): valid_ways += 1 return valid_ways def...
from solution import count_valid_ap def test_example_case(): assert count_valid_ap(5, [1, -1, 3, 4, 5]) == 1 def test_no_immediate_gap(): assert count_valid_ap(4, [4, -1, 2, 1]) == 1 def test_multiple_missing_values(): assert count_valid_ap(5, [1, 2, -1, 4, 5]) == 1 assert count_valid_ap(5, [1, 3, -1...
[ { "docstring": null, "function_declaration": "def count_valid_ap(n, sequence):", "function_name": "count_valid_ap", "parameter_list": "(n, sequence)" }, { "docstring": null, "function_declaration": "def is_arithmetic_progression(sequence):", "function_name": "is_arithmetic_progressio...
[ 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_valid_aps(n, sequence):\n \"\"\"\n Returns the number of ways to replace the -1 in the sequence to form a valid arithmetic progression.\n \"\"\"...
trial_gpt4o_2
{ "original_instruction": "Dora is studying different sequences in mathematics class, and she gets particularly interested in arithmetic progressions (AP). An arithmetic progression is a sequence of numbers in which the difference of any two successive members is a constant. She decides to sabotage her math notebook ...
0.650509
Taco_50045
C
[ "count_valid_ap", "is_arithmetic_progression" ]
2
[ [ "count_valid_ap", "is_arithmetic_progression" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9ddcf968689cbcc2311bb1a974ea4107d8b231bb
d09e6568fe2a617abc12734e111ff177e0af6740
v1.0
complete
Taco
Taco_49562_C
def unique_sequence(N: int) -> int: """ Returns the N-th number in the unique sequence, where each number is the product of all previous numbers plus one. >>> unique_sequence(1) == 1 >>> unique_sequence(2) == 2 >>> unique_sequence(4) == 7 """ def find_nth_number(seq: callable, test_cases: List[int]...
def unique_sequence(N): """ Returns the N-th number in the unique sequence. """ if N == 1: return 1 sequence = [1] # Start the sequence with the first number for i in range(1, N): # Each new number is the product of all previous numbers plus one product = 1 for ...
import pytest from solution import unique_sequence, find_nth_number, process_input def test_unique_sequence(): assert unique_sequence(1) == 1 assert unique_sequence(2) == 2 assert unique_sequence(3) == 3 assert unique_sequence(4) == 7 assert unique_sequence(5) == 43 def test_find_nth_number(): ...
[ { "docstring": "Returns the N-th number in the unique sequence.", "function_declaration": "def unique_sequence(N):", "function_name": "unique_sequence", "parameter_list": "(N)" }, { "docstring": "Given a list of test cases, compute the N-th number in the sequence for each test case.", "f...
[ 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 unique_sequence(N):\n \"\"\"\n Returns the N-th number in the unique sequence.\n \"\"\"\n if N == 1:\n return 1\n sequence = [1] # Start...
trial_gpt4o_0
{ "original_instruction": "A scientist discovered a unique sequence of integers where each number is the product of all previous numbers plus one. Starting from 1, the sequence begins as 1, 2, 3, 7, 43, and so on. Given the integer N, write a function to find the N-th number in this sequence using the following forma...
0.656172
Taco_49562
C
[ "unique_sequence", "find_nth_number", "process_input" ]
3
[ [ "find_nth_number", "unique_sequence" ], [ "process_input", "find_nth_number" ], [ "process_input", "unique_sequence" ] ]
3
[ "process_input" ]
false
[]
false
pytest
true
[]
true
05993ff9cc0fbb936454113a6608c96fb83e320a
8bf73f893a8826c34b3fd9734f9265d1e5634738
v1.0
complete
Taco
Taco_49717_C
def minimum_time_to_connect_all_grids(N: int, M: int, edges: List[Tuple[int, int, int]]) -> int: """ Determine the minimum time required to connect all grids so they form a Single Connected Network. Args: N : int : the number of nodes (grids) M : int : the number of edges (connections) edges : List[...
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 minimum_time_to_connect_all_grids def test_minimum_time_example_1(): assert minimum_time_to_connect_all_grids(4, 5, [ (1, 2, 1), (2, 3, 4), (3, 4, 2), (1, 4, 3), (1, 3, 5) ]) == 6 def test_minimum_time_example_2(): assert minimum_time_to_connect...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n root_x = find(parent, x)\...
trial_gpt4o_0
{ "original_instruction": "MegaGrid Inc. is working on optimizing their network of interconnected grids. Each grid can be represented as a node, and each connection between grids can be represented as a bidirectional edge with a particular weight (time to establish the connection). Your task is to determine the minim...
0.577518
Taco_49717
C
[ "find", "union", "minimum_time_to_connect_all_grids" ]
3
[ [ "minimum_time_to_connect_all_grids", "find" ], [ "minimum_time_to_connect_all_grids", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
e79275e3ce03ec3717dbfb259f0e6ecb5fb831d3
3c90384ae706d630d0635673ab124615df18be1e
v1.0
complete
Taco
Taco_50279_C
from typing import List def is_promotable(title: str) -> str: """ Determines if a book title is promotable. A title is promotable if it contains a palindromic substring of length ≥ 3. Parameters: title (str): The book title. Returns: str: "YES" if promotable, "NO" if not. >>> is_p...
def is_promotable(title): """ Determines if a book title is promotable. A title is promotable if it contains a palindromic substring of length ≥ 3. Parameters: title (str): The book title. Returns: str: "YES" if promotable, "NO" if not. """ n = len(title) def is_pa...
def test_is_promotable(): assert is_promotable("racecar") == "YES" assert is_promotable("book") == "NO" assert is_promotable("hello") == "NO" assert is_promotable("aabaa") == "YES" assert is_promotable("abcde") == "NO" assert is_promotable("aaa") == "YES" assert is_promotable("abacdcaba") ==...
[ { "docstring": "Determines if a book title is promotable.\nA title is promotable if it contains a palindromic substring of length ≥ 3.\n\nParameters:\ntitle (str): The book title.\n\nReturns:\nstr: \"YES\" if promotable, \"NO\" if not.", "function_declaration": "def is_promotable(title):", "function_nam...
[ 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_promotable(title):\n \"\"\"\n Check if a title contains any palindromic substring of length >= 3\n \"\"\"\n n = len(title)\n for length in ra...
trial_gpt4o_1
{ "original_instruction": "A bookstore owner wants to segment their list of book titles for a promotion campaign. They have a special criterion: a book title is considered \"promotable\" if and only if it contains at least one palindromic substring with a length greater than or equal to 3.\n\nA string is called a pal...
0.552384
Taco_50279
C
[ "is_promotable", "segment_book_titles" ]
2
[ [ "segment_book_titles", "is_promotable" ] ]
1
[]
false
[]
false
pytest
false
[]
true
b2231fa3723b7d580c3f0b01d7a2bb829cb273fe
c13511f37d4fd65e1ff35b40a5e3805a44b52cc6
v1.0
complete
Taco
Taco_50556_C
def is_valid_parentheses(s: str) -> str: """ Determines if the given string of parentheses is valid. >>> is_valid_parentheses("()") "Valid" >>> is_valid_parentheses("([{}])") "Valid" >>> is_valid_parentheses("([)]") "Invalid" """ pass def validate_parentheses_cases(test_cases: l...
def is_valid_parentheses(s): """ Determines if the given string of parentheses is valid. Args: s (str): The input string containing '()', '[]', '{}'. Returns: str: "Valid" if the string is valid, otherwise "Invalid". """ stack = [] matching_bracket = {')': '(', ']': '[', '}...
import pytest from solution import is_valid_parentheses, validate_parentheses_cases, process_input def test_is_valid_parentheses(): assert is_valid_parentheses("()") == "Valid" assert is_valid_parentheses("([{}])") == "Valid" assert is_valid_parentheses("([)]") == "Invalid" assert is_valid_parentheses(...
[ { "docstring": "Determines if the given string of parentheses is valid.\n\nArgs:\ns (str): The input string containing '()', '[]', '{}'.\n\nReturns:\nstr: \"Valid\" if the string is valid, otherwise \"Invalid\".", "function_declaration": "def is_valid_parentheses(s):", "function_name": "is_valid_parenth...
[ 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_valid(s):\n \"\"\"\n Determines if a string consisting of parentheses, brackets, and curly braces is valid.\n \"\"\"\n stack = []\n mapping =...
trial_gpt4o_2
{ "original_instruction": "-----Task-----\nWrite a program that determines whether a given string consisting of opening and closing parentheses, brackets, and curly braces is valid. A string is considered valid if the following conditions are met:\n\n1. Every opening parenthesis '(', bracket '[', or brace '{' has a c...
0.795162
Taco_50556
C
[ "is_valid_parentheses", "validate_parentheses_cases", "process_input" ]
3
[ [ "process_input", "validate_parentheses_cases" ], [ "validate_parentheses_cases", "is_valid_parentheses" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
246113018d147f036c47acdfe8f930eecca24006
116ba29b29be26181bc51497375c500beef4f782
v1.0
complete
Taco
Taco_50247_C
from typing import List def sum_of_primes(numbers: List[int]) -> int: """ Given a list of non-negative integers, returns the sum of all prime numbers in the list. >>> sum_of_primes([3, 11, 4, 6, 8]) 14 >>> sum_of_primes([0, 1, 4, 6, 8]) 0 >>> sum_of_primes([7, 7, 11, 13, 17]) 55 """ ...
from typing import List def is_prime(num: int) -> bool: """ Check if a number is prime. """ if num < 2: return False for i in range(2, int(num ** 0.5) + 1): if num % i == 0: return False return True def sum_of_primes(numbers: List[int]) -> int: """ Returns t...
from solution import sum_of_primes def test_example_cases(): assert sum_of_primes([3, 11, 4, 6, 8]) == 14 assert sum_of_primes([0, 1, 4, 6, 8]) == 0 assert sum_of_primes([7, 7, 11, 13, 17]) == 55 def test_empty_list(): assert sum_of_primes([]) == 0 def test_no_primes(): assert sum_of_primes([4, 6...
[ { "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 all prime numbers in the given list.", "function_declaration": "def sum_of_primes(numbers):", "func...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from typing import List\n\ndef is_prime(n: int) -> bool:\n \"\"\"\n Returns True if n is a prime number, False otherwise.\n \"\"\"\n if n <= 1:\n ...
trial_gpt4o_2
{ "original_instruction": "Given a list of non-negative integers, write a function that returns the sum of all prime numbers in the given list. If the list is empty or there are no prime numbers in the list, the function should return 0.\n\nFunction Signature:\n```python\ndef sum_of_primes(numbers: List[int]) -> int:...
0.778875
Taco_50247
C
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
53a5a1e4156203cc21352eb18eb4425aaac0592b
bb1f02048756cec53f4e7f1aa4755ce0af19b8d6
v1.0
complete
Taco
Taco_50750_C
from typing import List def filter_primes(nums: List[int]) -> List[int]: """ Write a function that takes a list of integers as input and returns a new list containing only the prime numbers from the input list. If the input list is empty or contains no prime numbers, the function should return an empty list. ...
from math import isqrt def is_prime(n): if n <= 1: return False for i in range(2, isqrt(n) + 1): if n % i == 0: return False return True def filter_primes(nums): return [num for num in nums if is_prime(num)]
from solution import filter_primes def test_with_mixed_numbers(): assert filter_primes([10, 15, 3, 7, 18, 19]) == [3, 7, 19] def test_with_no_primes(): assert filter_primes([4, 6, 8, 9]) == [] def test_with_all_primes(): assert filter_primes([2, 5, 11, 13]) == [2, 5, 11, 13] def test_with_empty_list...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def filter_primes(nums):", "function_name": "filter_primes", "parameter_list": "(nums)" } ]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return ...
trial_gpt4o_1
{ "original_instruction": "Write a function that takes a list of integers as input and returns a new list containing only the prime numbers from the input list. If the input list is empty or contains no prime numbers, the function should return an empty list.\n\nEx: Input: [10, 15, 3, 7, 18, 19] --> Output: [3, 7, 19...
0.676742
Taco_50750
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4d1ca2cd1bdd8fb0fec155fc010352898c6962ab
2ffe65392858d7597a0362326d6afd5570b5da89
v1.0
complete
Taco
Taco_50629_C
def is_magic_square(square): """ Checks if a given 2D list represents a magic square. """ pass # Implement the logic to check if 2D list is a magic square def check_magic_square_in_array(nums): """ Determines if any subarray of nums forms a magic square. >>> check_magic_square_in_array([2, 7, 6, 9]) "...
def is_magic_square(square): """ Checks if a given 2D list represents a magic square. """ # Check if all rows have the same sum target_sum = sum(square[0]) for row in square: if sum(row) != target_sum: return False # Check if all columns have the same sum for col...
from solution import check_magic_square_in_array def test_example1(): nums = [2, 7, 6, 9] assert check_magic_square_in_array(nums) == "NO" def test_example2(): nums = [4, 9, 2, 3, 5, 7, 8, 1, 6] assert check_magic_square_in_array(nums) == "YES" def test_large_input_no_magic_square(): nums = list(...
[ { "docstring": "Checks if a given 2D list represents a magic square.", "function_declaration": "def is_magic_square(square):", "function_name": "is_magic_square", "parameter_list": "(square)" }, { "docstring": "Determines if any subarray of nums forms a magic square.", "function_declarat...
[ 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_magic_square(nums):\n \"\"\"\n Determines if any 3x3 subarray of nums forms a magic square.\n \"\"\"\n n = len(nums)\n if n < 9:\n ret...
trial_gpt4o_1
{ "original_instruction": "Given an integer array nums of size n, determine if any of its subarrays form a magic square. A subarray is defined as a contiguous portion of the array. A magic square in this context refers to a square where the sums of the numbers in each row, each column, and both main diagonals are the...
0.705747
Taco_50629
C
[ "is_magic_square", "check_magic_square_in_array" ]
2
[ [ "check_magic_square_in_array", "is_magic_square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9ee7b018af6c15a2749fc2efce3537e0aae4a977
656a256a5464863939ec4dc1ff80e9a2a08a7cdb
v1.0
complete
Taco
Taco_49304_C
from typing import List import math from functools import reduce def lcm_of_array(arr: List[int]) -> int: """ Calculate the least common multiple (LCM) of an array of integers. >>> lcm_of_array([4, 6, 8]) == 24 >>> lcm_of_array([3, 7]) == 21 >>> lcm_of_array([10, 20, 30]) == 60 >>> lcm_of_array([5]...
import math from functools import reduce def lcm(a, b): """ Returns the least common multiple of a and b. """ return abs(a * b) // math.gcd(a, b) def lcm_of_array(arr): """ Given an array of integers, return the least common multiple (LCM) of the array. """ return reduce(lcm, arr)
from solution import lcm_of_array def test_lcm_of_array_example1(): assert lcm_of_array([4, 6, 8]) == 24 def test_lcm_of_array_example2(): assert lcm_of_array([3, 7]) == 21 def test_lcm_of_array_example3(): assert lcm_of_array([10, 20, 30]) == 60 def test_lcm_of_array_single_element(): asser...
[ { "docstring": "Returns the least common multiple of a and b.", "function_declaration": "def lcm(a, b):", "function_name": "lcm", "parameter_list": "(a, b)" }, { "docstring": "Given an array of integers, return the least common multiple (LCM) of the array.", "function_declaration": "def ...
[ 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 \"\"\"\n Returns the least common multiple of a and b.\n \"\"\"\n return a * b // math.gc...
trial_gpt4o_2
{ "original_instruction": "# Least Common Multiple of Array\n\nCalculate the **least common multiple (LCM)** of an array of integers. The **LCM** of a set of integers is the smallest positive integer that is evenly divisible by all the integers in the set. Let's denote the least common multiple of numbers `a` and `b`...
0.62979
Taco_49304
C
[ "lcm", "lcm_of_array" ]
2
[ [ "lcm_of_array", "lcm" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b2782596e180500821c0caffe77505d70bd7d677
486a1bfcb9f4dd3d1b0d1d595238c583502d592f
v1.0
complete
Taco
Taco_50313_C
def partition_graph(n: int, m: int, edges: List[Tuple[int, int]]) -> str: """ Partition the vertices of an undirected, unweighted graph into two sets such that no edge has both ends in the same set. If possible, return the partition, otherwise return "IMPOSSIBLE". >>> partition_graph(4, 4, [(1, 2), (1...
def is_bipartite(n, edges): from collections import deque, defaultdict # Build the graph graph = defaultdict(list) for u, v in edges: graph[u].append(v) graph[v].append(u) # Initialize color array, -1 means unvisited/undefined color = [-1] * (n + 1) # Implement...
from solution import partition_graph def test_partition_graph_possible(): n = 4 m = 4 edges = [(1, 2), (1, 3), (2, 4), (3, 4)] expected = "POSSIBLE\n1 2 2 1" assert partition_graph(n, m, edges) == expected def test_partition_graph_impossible(): n = 3 m = 3 edges = [(1, 2), (1, 3), (2, ...
[ { "docstring": null, "function_declaration": "def is_bipartite(n, edges):", "function_name": "is_bipartite", "parameter_list": "(n, edges)" }, { "docstring": null, "function_declaration": "def partition_graph(n, m, edges):", "function_name": "partition_graph", "parameter_list": "...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def partition_graph(n, m, edges):\n from collections import deque, defaultdict\n\n adj = defaultdict(list)\n for u, v in edges:\n adj[u].append(v)\...
trial_gpt4o_2
{ "original_instruction": "You are given an undirected, unweighted graph with n vertices and m edges. Each vertex is assigned a unique number from 1 to n, and each edge has a unique number from 1 to m. Your task is to partition the vertices into two sets, such that there are no edges in the graph where both ends of t...
0.577044
Taco_50313
C
[ "is_bipartite", "partition_graph" ]
2
[ [ "partition_graph", "is_bipartite" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7ae1dfe777807d7aef306eaa5065d3b53a54497e
119a52fa7e04f18b7a38d3f926ae3252e772ab3c
v1.0
complete
Taco
Taco_50808_C
def find_minimum_max_pages(books: List[int], n: int, k: int) -> int: """ Find the minimum possible value for the maximum number of pages assigned to any employee. Parameters: books (List[int]): List of integers representing the page counts of the books. n (int): Number of books. k (int): Nu...
def is_feasible(books, n, k, max_pages): """ Check if it is possible to allocate books to k employees such that the maximum number of pages assigned to any employee is less than or equal to max_pages. """ required_employees = 1 current_sum = 0 for i in range(n): if current_sum + boo...
from solution import find_minimum_max_pages def test_example_1(): assert find_minimum_max_pages([12, 34, 67, 90], 4, 2) == 113 def test_example_2(): assert find_minimum_max_pages([10, 20, 30, 40, 50], 5, 3) == 60 def test_single_book_for_each(): assert find_minimum_max_pages([10, 20, 30], 3, 3) == 30 de...
[ { "docstring": "Check if it is possible to allocate books to k employees such that the\nmaximum number of pages assigned to any employee is less than or equal to max_pages.", "function_declaration": "def is_feasible(books, n, k, max_pages):", "function_name": "is_feasible", "parameter_list": "(books...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_feasible(books, n, k, max_pages):\n \"\"\"\n Check if it is possible to allocate books to k employees such that the\n maximum number of pages assig...
trial_gpt4o_0
{ "original_instruction": "You are given an array of integers representing book page counts. A colleague wants to divide these books among k employees in such a way that the maximum number of pages assigned to any employee is minimized. Each employee must get at least one book, and every book must be assigned to an e...
0.649023
Taco_50808
C
[ "is_feasible", "find_minimum_max_pages" ]
2
[ [ "find_minimum_max_pages", "is_feasible" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f11508965eb2cb0906e8643c72f5a6b96d4c4506
50a26e4417e681f92b1da06af86cf1a0d0d9ee9a
v1.0
complete
Taco
Taco_50706_C
def is_prime(num): """ Check if a number is a prime number. """ 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 ...
def is_prime(num): """ Check if a number is a prime number. """ 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 ...
from solution import can_be_expressed_as_sum_of_two_primes def test_example_case(): assert can_be_expressed_as_sum_of_two_primes(34) == "YES" def test_smallest_case(): assert can_be_expressed_as_sum_of_two_primes(4) == "YES" def test_prime_sum_not_possible(): assert can_be_expressed_as_sum_of_two_primes(...
[ { "docstring": "Check if a number is a prime number.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Check if the number n can be expressed as the sum of two prime numbers.", "function_declaration": "def can_be_exp...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Check if a number is a prime number.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True...
trial_gpt4o_0
{ "original_instruction": "Given a number n, check if it can be expressed as the sum of two prime numbers. \n\n-----Input:-----\n- N — the number to check for the prime sum representation.\n\n-----Output:-----\n- Print \"YES\" if the number can be expressed as the sum of two prime numbers.\n- Otherwise, print \"NO\"....
0.786283
Taco_50706
C
[ "is_prime", "can_be_expressed_as_sum_of_two_primes" ]
2
[ [ "can_be_expressed_as_sum_of_two_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d95d1dd086d067e2007b72f1a7ad953e559dcbfd
a7ca2d7c83c910b2ffe546e23639a2bc8351c114
v1.0
complete
Taco
Taco_50525_C
def preprocess_array(arr): """ Preprocess the given array to create a prefix sum array. Parameters: arr (list of int): Input array of integers. Returns: list of int: Prefix sum array. """ pass # Implement the function def range_sum(prefix_sum, l, r): """ Compute the s...
def preprocess_array(arr): """ Preprocess the given array to create a prefix sum array. Parameters: arr (list of int): Input array of integers. Returns: list of int: Prefix sum array. """ n = len(arr) prefix_sum = [0] * (n + 1) for i in range(n): prefix_sum[i + ...
def test_preprocess_array(): assert preprocess_array([1, 2, 3, 4, 5]) == [0, 1, 3, 6, 10, 15] assert preprocess_array([7, 1, 2]) == [0, 7, 8, 10] def test_range_sum(): prefix_sum = preprocess_array([1, 2, 3, 4, 5]) assert range_sum(prefix_sum, 0, 2) == 6 assert range_sum(prefix_sum, 1, 3) == 9 ...
[ { "docstring": "Preprocess the given array to create a prefix sum array.\n\nParameters:\narr (list of int): Input array of integers.\n\nReturns:\nlist of int: Prefix sum array.", "function_declaration": "def preprocess_array(arr):", "function_name": "preprocess_array", "parameter_list": "(arr)" },...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def create_prefix_sum_array(arr):\n \"\"\"\n Function to create prefix sum array for the given array.\n \"\"\"\n prefix_sum = [0] * len(arr)\n prefi...
trial_gpt4o_2
{ "original_instruction": "You are given an array of integers, and you need to find the sum of elements between two given indices, inclusive. To make it more efficient, you firstly preprocess the array to create a prefix sum array. After preprocessing, you then answer multiple queries, which ask for the sum of elemen...
0.634643
Taco_50525
C
[ "preprocess_array", "range_sum", "process_queries" ]
3
[ [ "process_queries", "preprocess_array" ], [ "process_queries", "range_sum" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
false
[]
true
1a53b27bedb703d6730f64eec324ccea641649fd
93750738ec6379bddee5546273a794e7d8d0cca2
v1.0
complete
Taco
Taco_50774_C
def is_prime(n: int) -> bool: """ Determines whether a given number n is a prime number. """ # Implement the function to check if 'n' is a prime number. def find_prime_pair(N: int) -> int: """ Determines if N can be expressed as a sum of two prime numbers and returns the pair of prime numbe...
def is_prime(n): """ Determines whether a given number n is a prime number. """ 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 find_prime_pair, process_test_cases def test_find_prime_pair(): assert find_prime_pair(10) == (3, 7) assert find_prime_pair(16) == (3, 13) assert find_prime_pair(27) == -1 assert find_prime_pair(34) == (3, 31) assert find_prime_pair(4) == (2, 2) def test_process_test_case...
[ { "docstring": "Determines whether a given number n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Determines if N can be expressed as a sum of two prime numbers\nand returns the pair of prime numbers i...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Determines whether a given number n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n ...
trial_gpt4o_0
{ "original_instruction": "Given an integer N, determine if N can be expressed as a sum of two prime numbers. If it can, find the two prime numbers that sum up to N. In case there are multiple pairs, return the pair with the smallest prime number. If there are no such pairs, return -1. \n\nInput\nFirst line contains ...
0.712629
Taco_50774
C
[ "is_prime", "find_prime_pair", "process_test_cases" ]
3
[ [ "find_prime_pair", "is_prime" ], [ "process_test_cases", "find_prime_pair" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
91617e81f816324d52eed3049d26d4acc6a8a5b0
653731c65c21441d1bd49fe1e9d6802cd1f6008a
v1.0
complete
Taco
Taco_49678_C
def is_palindrome(s): """ Check if the given string is a palindrome. >>> is_palindrome("abba") True >>> is_palindrome("abcd") False """ pass def find_path(grid, n, m, i, j, path, memo): """ Find if there's a path in the grid that forms a palindrome. >>> find_path([["a", "b", "a"], [...
def is_palindrome(s): return s == s[::-1] def find_path(grid, n, m, i, j, path, memo): if i >= n or j >= m: return False path += grid[i][j] if (i, j) in memo: return memo[(i, j)] if i == n-1 and j == m-1: memo[(i, j)] = is_palindrome(path) return memo[(i, j)] dow...
def test_main(): input_str = "2\n3 3\naba\nbcb\naba\n2 4\nabcd\ndcba" expected_output = "YES\nNO" assert main(input_str) == expected_output def test_single_cell_yes(): input_str = "1\n1 1\na" expected_output = "YES" assert main(input_str) == expected_output def test_single_cell_no(): input...
[ { "docstring": null, "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def find_path(grid, n, m, i, j, path, memo):", "function_name": "find_path", "parameter_list": "(grid, ...
[ 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_palindromic_path_exists(grid, n, m):\n def is_palindrome(s):\n return s == s[::-1]\n\n def dfs(x, y, path):\n if x == n - 1 and y == m -...
trial_gpt4o_1
{ "original_instruction": "Given a grid of size n x m filled with characters, your task is to determine if there exists a path from the top-left corner to the bottom-right corner such that the concatenation of the characters along the path forms a palindrome. The path can only move right or down at any point in time....
0.711652
Taco_49678
C
[ "is_palindrome", "find_path", "solve", "parse_input", "main" ]
5
[ [ "find_path", "is_palindrome" ], [ "solve", "find_path" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
1ca65820f5724aa58c40f688fefd2aa972e804bc
22e155d136123016e07a563323744442b769d65f
v1.0
complete
Taco
Taco_51083_C
from typing import List def hash_func(data: str) -> str: """ Computes and returns the hash of the given data block. """ import hashlib return hashlib.sha256(data.encode('utf-8')).hexdigest() def merkle_tree(data_blocks: List[str]) -> str: """ Constructs a balanced Merkle Tree given a list ...
import hashlib from typing import List def hash_func(data: str) -> str: return hashlib.sha256(data.encode('utf-8')).hexdigest() def merkle_tree(data_blocks: List[str]) -> str: def compute_merkle_root(leaves): while len(leaves) > 1: if len(leaves) % 2 == 1: leaves.append(lea...
from solution import merkle_tree, hash_func def test_merkle_tree_power_of_two(): data_blocks = ["data1", "data2", "data3", "data4"] root_hash = merkle_tree(data_blocks) # manually computing expected result leaf_hashes = [hash_func(data) for data in data_blocks] level1_hashes = [hash_func(leaf_hashe...
[ { "docstring": null, "function_declaration": "def hash_func(data):", "function_name": "hash_func", "parameter_list": "(data)" }, { "docstring": null, "function_declaration": "def merkle_tree(data_blocks):", "function_name": "merkle_tree", "parameter_list": "(data_blocks)" }, ...
[ 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 hashlib\nfrom typing import List\n\ndef hash_func(data: str) -> str:\n return hashlib.sha256(data.encode('utf-8')).hexdigest()\n\ndef merkle_tree(data_bl...
trial_gpt4o_0
{ "original_instruction": "Alex is a blockchain enthusiast and he loves organizing data structures. Recently, he's been working with a specific data structure called a \"Merkle Tree\". A Merkle Tree is a binary tree in which every leaf node is labelled with a data block and every non-leaf node is labelled with the cr...
0.510454
Taco_51083
C
[ "hash_func", "merkle_tree" ]
2
[ [ "merkle_tree", "hash_func" ] ]
1
[]
false
[]
false
pytest
true
[]
true
643981749b8e98e7c36ba4768e8aa842f4c25d0e
711ffa7f7a9a9404e4eb73bd0145233857948ab0
v1.0
complete
Taco
Taco_51137_C
def minimum_road_length(test_cases): """ Determine the total length of the selected paths to maintain connectivity while minimizing the total road length. >>> minimum_road_length([ (4, 5, [(0, 1, 3), (0, 2, 2), (0, 3, 4), (1, 2, 5), (2, 3, 4)]), (5, 7, [(0, 1, 1), (0, 2, 4), (0, 3, 3), (1, ...
def find(parent, i): # Function to find the root of the subset including 'i' using path compression if parent[i] == i: return i else: parent[i] = find(parent, parent[i]) return parent[i] def union(parent, rank, x, y): # Function to unite two subsets x and y using union by rank ...
def test_minimum_road_length(): input_data = [ (4, 5, [(0, 1, 3), (0, 2, 2), (0, 3, 4), (1, 2, 5), (2, 3, 4)]), (5, 7, [(0, 1, 1), (0, 2, 4), (0, 3, 3), (1, 2, 2), (1, 4, 6), (2, 3, 5), (3, 4, 7)]) ] expected_output = [9, 12] assert minimum_road_length(input_data) == expected_output def...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 1, 0, 1 ]
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 # Function to find the root of the subset including 'i' using path compression\n if parent[i] == i:\n return i\n else:\n ...
trial_gpt4o_0
{ "original_instruction": "In a faraway land, there are n villages and m bidirectional paths connecting pairs of villages. Each path has a certain length. The villages' chief wants to construct a road network so that any village can be reached from any other village, and the total length of the roads used is minimize...
0.680817
Taco_51137
C
[ "find", "union", "kruskal_mst", "minimum_road_length" ]
4
[ [ "kruskal_mst", "find" ], [ "kruskal_mst", "union" ], [ "minimum_road_length", "kruskal_mst" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
false
[]
true
411dab6b5fcfbeee357f7b452cea8717942fd7b1
9f76cedd3cfc9bb9dafec6c8e91c4b7e45f3f8ef
v1.0
complete
Taco
Taco_51053_C
from typing import List def get_prime_numbers(arr: List[int]) -> List[int]: """ Returns a list of prime numbers from the given array. Note that 1 is not considered a prime number. >>> get_prime_numbers([1, 4, 6, 8, 10]) [] >>> get_prime_numbers([2, 3, 5, 7, 11]) [2, 3, 5, 7, 11] >>> g...
def is_prime(n): """ Check if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True...
from solution import get_prime_numbers def test_no_primes(): assert get_prime_numbers([1, 4, 6, 8, 10]) == [] def test_all_primes(): assert get_prime_numbers([2, 3, 5, 7, 11]) == [2, 3, 5, 7, 11] def test_mixed_array(): assert get_prime_numbers([4, 6, 7, 9, 11]) == [7, 11] def test_negative_numbers(): ...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers from the given array.", "function_declaration": "def get_prime_numbers(arr):", "function_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 is_prime(n):\n \"\"\"\n Helper function to determine if a number n is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n r...
trial_gpt4o_2
{ "original_instruction": "Write a function that takes an integer array as input and returns a new array containing only the elements from the original array that are prime numbers. If there are no prime numbers, the function should return an empty array. Note that 1 is not considered a prime number.", "prompt_id":...
0.723963
Taco_51053
C
[ "is_prime", "get_prime_numbers" ]
2
[ [ "get_prime_numbers", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a312ca5cda5c66d8f2423ba17f8d4825b4f8d730
88f5b132de32d00c12d075c79c30a815301a9f5a
v1.0
complete
Taco
Taco_50688_C
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def build_tree(nodes): from collections import defaultdict tree = {} children = set() for parent, child in nodes: if parent not in tree: tree[parent] = TreeNode(pa...
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def build_tree(nodes): from collections import defaultdict tree = {} children = set() for parent, child in nodes: if parent not in tree: tree[parent] = TreeNode(pa...
from solution import binaryTreePaths def test_example_1(): nodes = [(1, 2), (1, 3), (2, 4), (3, 5), (3, 6)] assert binaryTreePaths(nodes) == ["1->2->4", "1->3->5", "1->3->6"] def test_example_2(): nodes = [(7, 2), (7, 3), (2, 5), (3, 1)] assert binaryTreePaths(nodes) == ["7->2->5", "7->3->1"] def tes...
[]
[ 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": "# Define the TreeNode class to represent nodes in the binary tree\nclass TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n...
trial_gpt4o_1
{ "original_instruction": "Given a binary tree, return all root-to-leaf paths as a list of strings. A leaf is a node with no children. \nThe binary tree is represented as follows:\n- Each node has a unique integer value.\n- The tree structure is given as a list of tuples, where each tuple contains two integer values ...
0.591514
Taco_50688
C
[ "build_tree", "binaryTreePaths" ]
2
[ [ "binaryTreePaths", "build_tree" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
08466855187cf086f7bfce4fa06b7bfc81b88eca
678d9fc138982b1e80408e8090eac2d1df9a7c05
v1.0
complete
Taco
Taco_50503_C
def compute_prefix_sum(matrix): """ Compute the prefix sum matrix for the given matrix. """ pass def sum_submatrix(prefix_sum, r1, c1, r2, c2): """ Calculate the sum of elements in the submatrix defined by top-left corner (r1, c1) and bottom-right corner (r2, c2). """ pass def find_sub...
def compute_prefix_sum(matrix): rows = len(matrix) cols = len(matrix[0]) prefix_sum = [[0] * (cols + 1) for _ in range(rows + 1)] for r in range(1, rows + 1): for c in range(1, cols + 1): prefix_sum[r][c] = matrix[r-1][c-1] + prefix_sum[r-1][c] + prefix_sum[r][c-1] - prefix_sum[...
def test_compute_prefix_sum(): matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] prefix_sum = compute_prefix_sum(matrix) assert prefix_sum == [ [0, 0, 0, 0], [0, 1, 3, 6], [0, 5, 12, 21], [0, 12, 27, 45] ] def test_sum_submatrix(): prefix_...
[ { "docstring": null, "function_declaration": "def compute_prefix_sum(matrix):", "function_name": "compute_prefix_sum", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def sum_submatrix(prefix_sum, r1, c1, r2, c2):", "function_name": "sum_submatrix", ...
[ 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 compute_prefix_sums(matrix):\n N = len(matrix)\n M = len(matrix[0])\n prefix_sums = [[0] * (M + 1) for _ in range(N + 1)]\n \n for i in range(1,...
trial_gpt4o_1
{ "original_instruction": "You are given a rectangular matrix with $N$ rows and $M$ columns, filled with non-negative integers. You need to find the sum of elements in the submatrix defined by the top-left corner $(r1, c1)$ and the bottom-right corner $(r2, c2)$. You will be given multiple queries; for each query, ou...
0.528015
Taco_50503
C
[ "compute_prefix_sum", "sum_submatrix", "find_submatrix_sums" ]
3
[ [ "find_submatrix_sums", "compute_prefix_sum" ], [ "find_submatrix_sums", "sum_submatrix" ] ]
2
[]
false
[]
false
pytest
false
[]
true
25039abc6e76f5bb1ecce690ddcb050591db7e4e
37f1a7c4fcc11ff6afb5a64bc90bf995c8d17ffd
v1.0
complete
Taco
Taco_50308_C
def char_frequency(s: str) -> dict: """ Calculate the frequency of each character in the string. :param s: A string :return: A dictionary with characters as keys and their frequencies as values """ pass def sort_strings(strings: List[str]) -> List[str]: """ Sort a list of strings based...
def char_frequency(s): freq = {} for char in s: if char in freq: freq[char] += 1 else: freq[char] = 1 return freq def sort_strings(strings): def custom_sort(s): freq = char_frequency(s) freq_sorted = sorted(freq.values()) return (freq_sort...
from solution import process_test_cases def test_process_test_cases(): t = 2 test_cases = [ [3, "banana", "apple", "pear"], [4, "a", "ab", "aa", "b"] ] expected_output = [ ["pear", "apple", "banana"], ["a", "b", "ab", "aa"] ] assert process_test_cases(t, test_cas...
[ { "docstring": null, "function_declaration": "def char_frequency(s):", "function_name": "char_frequency", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def sort_strings(strings):", "function_name": "sort_strings", "parameter_list": "(strings)" }, { ...
[ 0, 0, 0, 0, 0, 1, 1, 1, 0, 1 ]
4
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sort_galactic_codes(t, test_cases):\n from collections import Counter\n \n def frequency_key(s):\n freq_cnt = Counter(s) # count frequency of ...
trial_gpt4o_9
{ "original_instruction": "In a distant galaxy, there is a unique form of digital communication that revolves around sequences of strings called \"galactic codes\". These codes are used to send messages between planets. Each message consists of a list of strings, and each string is made up of lowercase alphabetic cha...
0.720091
Taco_50308
C
[ "char_frequency", "sort_strings", "process_test_cases" ]
3
[ [ "process_test_cases", "sort_strings" ], [ "sort_strings", "char_frequency" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
d398df40256dacf9728ffb76af55580417d727bb
9cfaee0ab02fb3a64fb2319f233343d6b6c4744a
v1.0
complete
Taco
Taco_50715_C
def min_maintenance_cost(N: int, M: int, edges: List[Tuple[int, int, int]]) -> Union[int, str]: """ Compute the minimum total maintenance cost to ensure every city is reachable from any other city. If it is not possible to connect all cities, return "Impossible". >>> min_maintenance_cost(4, 5, [(1...
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]: paren...
import pytest from solution import min_maintenance_cost def test_example_1(): N = 4 M = 5 edges = [ (1, 2, 3), (2, 3, 4), (3, 4, 5), (1, 3, 8), (2, 4, 2) ] assert min_maintenance_cost(N, M, edges) == 9 def test_example_2(): N = 4 M = 2 edges = [ ...
[ { "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": "class UnionFind:\n def __init__(self, size):\n self.parent = list(range(size))\n self.rank = [1] * size\n\n def find(self, p):\n if self...
trial_gpt4o_1
{ "original_instruction": "The kingdom of Arithmoria consists of $N$ cities, which are identified by consecutive integers from $1$ to $N$. As the newly appointed Minister of Transportation, your task is to optimize the construction of train routes between specified pairs of cities.\n\nEach train route incurs a mainte...
0.604428
Taco_50715
C
[ "find", "union", "min_maintenance_cost" ]
3
[ [ "min_maintenance_cost", "find" ], [ "min_maintenance_cost", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
1fd863241aa61b12a25e90962a989ad98f0a7fd4
935375368a286904497ba3e38af546ab5f24d099
v1.0
complete
Taco
Taco_50980_C
from typing import List, Tuple def is_prime(num: int) -> bool: """ Check if a number is a prime number. >>> is_prime(2) True >>> is_prime(4) False """ # Implementation here def max_distinct_primes_after_change(arr: List[int]) -> int: """ Calculate the maximum number of distinct...
def is_prime(num): if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6 return True def max_distinct_primes_after_...
from solution import is_prime, max_distinct_primes_after_change, process_test_cases 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(20) == False def test_max_distinct_primes_after_change(): asser...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def max_distinct_primes_after_change(arr):", "function_name": "max_distinct_primes_after_change", "parameter_...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sieve(n):\n \"\"\"\n Performs the Sieve of Eratosthenes up to n and returns a list of primes up to n.\n \"\"\"\n is_prime = [True] * (n + 1)\n p...
trial_gpt4o_1
{ "original_instruction": "Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.\n\nChef is teaching his students about properties of integers. Today he is teaching them about prime numbers. Prime numbers are those numbers which are divisible only by 1 and themselves (e.g. 2, 3, 5, 7, 11, etc....
0.630961
Taco_50980
C
[ "is_prime", "max_distinct_primes_after_change", "process_test_cases", "main" ]
4
[ [ "max_distinct_primes_after_change", "is_prime" ], [ "process_test_cases", "max_distinct_primes_after_change" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
a20b8ff1d3dd7d4c90411ba044518ef9ab4f7f6b
977692d8772c67eeef343ab0bb7069a6878c00f8
v1.0
complete
Taco
Taco_50145_C
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def create_tree(node_list): """Creates a binary tree from a list of nodes. Args: node_list: List of tuples where each tuple contains (val, left, right) Re...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def create_tree(node_list): nodes = {} for idx, node in enumerate(node_list): val, left, right = node if idx + 1 not in nodes: nodes[idx ...
from solution import find_sums_of_depths def test_single_test_case_1(): test_cases = [ (2, 5, [ (1, 2, 3), (2, 4, 5), (3, 0, 0), (4, 0, 0), (5, 0, 0) ]) ] assert find_sums_of_depths(test_cases) == [9] # Depth 2 nodes are [4, 5] ...
[]
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\n\ndef creat...
trial_gpt4o_0
{ "original_instruction": "Zephyr loves working with binary trees, and he recently came across a challenge that involves finding the sum of all nodes at a particular depth in a binary tree. Specifically, you are given a binary tree and a depth value `d`. Your task is to compute the sum of all the node values located ...
0.599231
Taco_50145
C
[ "create_tree", "sum_at_depth", "find_sums_of_depths" ]
3
[ [ "find_sums_of_depths", "create_tree" ], [ "find_sums_of_depths", "sum_at_depth" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
3a79fb490751a7c1eeb2225cb89aa9697a7b374b
cd6b406b7f5ca028df96771495cd038f6531c9ec
v1.0
complete
Taco
Taco_51406_C
def maximal_rectangle(grid): """Determine the area of the largest rectangular block that can be formed completely by store cells. Args: grid (List[str]): The mall's layout represented as a list of strings, where '.' represents an empty cell and '*' represents a store. Returns: int: The area...
def maximal_rectangle(grid): if not grid or not grid[0]: return 0 m, n = len(grid), len(grid[0]) heights = [0] * n max_area = 0 for i in range(m): for j in range(n): if grid[i][j] == '*': heights[j] += 1 else: heights[j] = 0 ...
from solution import maximal_rectangle def test_maximal_rectangle_case1(): grid = [ ".....", ".***.", ".***.", "....." ] assert maximal_rectangle(grid) == 6 def test_maximal_rectangle_case2(): grid = [ "***", "*.*", "***" ] assert maximal...
[ { "docstring": null, "function_declaration": "def maximal_rectangle(grid):", "function_name": "maximal_rectangle", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def largest_rectangle_area(heights):", "function_name": "largest_rectangle_area", "parame...
[ 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 maximalRectangle(matrix):\n \"\"\"\n Find the area of the largest rectangular block of store ('*') cells.\n \"\"\"\n if not matrix:\n return...
trial_gpt4o_2
{ "original_instruction": "In the bustling city of Codeopolis, the newly built mega-mall houses numerous technology stores. The mall administrators want to efficiently manage store space, and they decided to implement a unique layout format.\n\nThe mall's layout is represented as a 2D grid of size $m \\times n$, wher...
0.693253
Taco_51406
C
[ "maximal_rectangle", "largest_rectangle_area" ]
2
[ [ "maximal_rectangle", "largest_rectangle_area" ] ]
1
[]
false
[]
false
pytest
true
[]
true
851497f9d9bb396cfb98b8538c7c910bb6f621f3
6c071216aee9b29031d6df9e62ae553ca793c0c6
v1.0
complete
Taco
Taco_51389_C
from functools import reduce def multiply_non_zero_digits(n): """ Multiply the non-zero digits of n. >>> multiply_non_zero_digits(39) 27 >>> multiply_non_zero_digits(123) 6 """ pass def single_digit_result(N): """ Given an integer N, finds the resulting single-digit integer by repeated...
from functools import reduce def multiply_non_zero_digits(n): result = 1 for digit in str(n): if digit != '0': result *= int(digit) return result def single_digit_result(N): while N >= 10: N = multiply_non_zero_digits(N) return N
from solution import single_digit_result def test_single_digit_result(): assert single_digit_result(39) == 4 assert single_digit_result(123) == 6 assert single_digit_result(99) == 8 assert single_digit_result(100) == 1 assert single_digit_result(987654321) == 8 assert single_digit_result(1) == ...
[ { "docstring": null, "function_declaration": "def multiply_non_zero_digits(n):", "function_name": "multiply_non_zero_digits", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def single_digit_result(N):", "function_name": "single_digit_result", "parameter_...
[ 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 single_digit_from_product(N):\n \"\"\"\n Given an integer N, repeatedly multiply all its non-zero digits until a single-digit integer is obtained.\n \...
trial_gpt4o_8
{ "original_instruction": "Lily loves playing games with numbers. She has created a new game in which she takes an integer N and forms a new integer by multiplying all of its non-zero digits. She continues this process until she gets a single-digit integer. Your task is to write a program that, given an integer N, fi...
0.755564
Taco_51389
C
[ "multiply_non_zero_digits", "single_digit_result" ]
2
[ [ "single_digit_result", "multiply_non_zero_digits" ] ]
1
[]
false
[]
false
pytest
true
[]
true
daa8bd9995d9b7df815a7a8f0ac44959738c5243
c619341102548a50a9544d5cf495a52b8e109f8b
v1.0
complete
Taco
Taco_51370_C
from typing import List, Tuple def process_input(input_str: str) -> List[str]: """ Determines if given points form a convex polygon for multiple test cases. Args: input_str (str): Input string containing number of test cases, followed by each test case containing number of points and their coordinates. ...
def is_convex_polygon(points): def cross_product(o, a, b): return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]) n = len(points) if n < 3: return False direction = 0 for i in range(n): a, b, c = points[i], points[(i + 1) % n], points[(i + 2)...
from solution import process_input def test_basic_cases(): input_str = """2 4 0 0 0 1 1 1 1 0 5 0 0 1 1 2 0 3 1 4 0""" assert process_input(input_str) == ["YES", "NO"] def test_single_case_convex(): input_str = """1 4 0 0 0 2 2 2 2 0""" assert process_input(input_str) == ["YES"] def test_single_case_...
[ { "docstring": null, "function_declaration": "def is_convex_polygon(points):", "function_name": "is_convex_polygon", "parameter_list": "(points)" }, { "docstring": null, "function_declaration": "def check_convex_polygon(test_cases):", "function_name": "check_convex_polygon", "par...
[ 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 is_convex_polygon(points):\n def cross(o, a, b):\n return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0])\n\n n = len(points)\n i...
trial_gpt4o_3
{ "original_instruction": "Your friend is a fan of geometric shapes and recently learned about polygons. A polygon can be termed as a convex polygon if every internal angle is strictly less than 180 degrees. He wants to find out if a given set of points can form a convex polygon or not.\n\nYou are given the coordinat...
0.51822
Taco_51370
C
[ "is_convex_polygon", "check_convex_polygon", "process_input" ]
3
[ [ "check_convex_polygon", "is_convex_polygon" ], [ "process_input", "check_convex_polygon" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
a398658f5f3180bfe4ce2f03284af4bb4a84f232
30591427a5a3b15a268e463b884f054ea24d1735
v1.0
complete
Taco
Taco_51207_C
def count_distinct_substrings(s: str) -> int: """Count the number of distinct substrings of a given string. >>> count_distinct_substrings("abcde") 15 >>> count_distinct_substrings("aaa") 3 """ pass def max_distinct_substrings_after_swap(n: int, s: str) -> int: """Determine the maximum n...
def count_distinct_substrings(s): substrings = set() for i in range(len(s)): for j in range(i + 1, len(s) + 1): substrings.add(s[i:j]) return len(substrings) def max_distinct_substrings_after_swap(n, s): # Calculate distinct substrings in original string original_count = count_d...
from solution import count_distinct_substrings, max_distinct_substrings_after_swap def test_count_distinct_substrings(): assert count_distinct_substrings("abcde") == 15 assert count_distinct_substrings("aaa") == 3 assert count_distinct_substrings("abcd") == 10 assert count_distinct_substrings("a") == 1...
[ { "docstring": null, "function_declaration": "def count_distinct_substrings(s):", "function_name": "count_distinct_substrings", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def max_distinct_substrings_after_swap(n, s):", "function_name": "max_distinct_subs...
[ 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 count_distinct_substrings(s):\n \"\"\"\n Returns the count of distinct substrings in the given string s.\n \"\"\"\n n = len(s)\n substrings = se...
trial_gpt4o_2
{ "original_instruction": "Given a string `s` which represents a sequence of lowercase English letters, you need to perform the following operation exactly once:\n\nYou can choose two indices, `i` and `j` (1 ≤ i < j ≤ n, where `n` is the length of the string), and swap the characters at these indices. After performin...
0.740827
Taco_51207
C
[ "count_distinct_substrings", "max_distinct_substrings_after_swap" ]
2
[ [ "max_distinct_substrings_after_swap", "count_distinct_substrings" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6f9f2b24844491a6de10819d0af675727533ce57
8999b0ffe55554da8e572b5918eb299282336c69
v1.0
complete
Taco
Taco_51550_C
def partition_to_prime_subsets(n: int, k: int, array: List[int]) -> None: """Determine if you can partition the array into exactly k non-empty subsets such that the sum of the elements in each subset is a prime number. Print "YES" if possible, otherwise "NO". >>> partition_to_prime_subsets(5, 2, [3, ...
from itertools import combinations import math def is_prime(x): """Returns True if x is a prime number, otherwise False.""" if x <= 1: return False for i in range(2, int(math.sqrt(x)) + 1): if x % i == 0: return False return True def can_partition_prime_sum(n, k, array): ...
from solution import partition_to_prime_subsets def test_example_1(): import sys from io import StringIO captured_output = StringIO() sys.stdout = captured_output partition_to_prime_subsets(5, 2, [3, 8, 12, 5, 13]) sys.stdout = sys.__stdout__ output = captured_output.getvalue().strip(...
[ { "docstring": "Returns True if x is a prime number, otherwise False.", "function_declaration": "def is_prime(x):", "function_name": "is_prime", "parameter_list": "(x)" }, { "docstring": "Determine if the array can be partitioned into exactly k non-empty subsets \nsuch that the sum of the el...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import combinations\nfrom functools import lru_cache\n\ndef is_prime(num):\n \"\"\"Helper function to determine if a number is prime.\"\"\"\n ...
trial_gpt4o_5
{ "original_instruction": "You are given an array of $n$ integers $A = [a_1, a_2, \\dots, a_n]$ and another integer $k$. Determine if you can partition the array into exactly $k$ non-empty subsets such that the sum of the elements in each subset is a prime number.\n\n-----Input-----\n\nThe first line of input contain...
0.600278
Taco_51550
C
[ "is_prime", "can_partition_prime_sum", "partition_to_prime_subsets" ]
3
[ [ "can_partition_prime_sum", "is_prime" ], [ "partition_to_prime_subsets", "can_partition_prime_sum" ] ]
2
[]
false
[]
false
pytest
true
[]
true
56670ad2cba930b71c62b9bfab25aa9fd9dab22d
659369975f48d59ca92bdd233aa5a23f0533a795
v1.0
complete
Taco
Taco_51102_C
import heapq from typing import List, Tuple def dijkstra(N: int, graph: List[List[Tuple[int, int]]], start: int, end: int) -> int: """ Implementation of Dijkstra's algorithm to find the shortest path distance from start to end in the given graph. """ distances = [float('inf')] * (N + 1) distanc...
import heapq def dijkstra(N, graph, start, end): """ Implementation of Dijkstra's algorithm to find the shortest path distance from start to end in the given graph. """ distances = [float('inf')] * (N + 1) distances[start] = 0 priority_queue = [(0, start)] while priority_queue: ...
from solution import upgraded_min_travel_time def test_case_1(): N, M, K = 5, 5, 1 streets = [ (1, 2, 10), (2, 3, 10), (3, 4, 10), (4, 5, 10), (1, 5, 50) ] upgrades = [(1, 5, 5)] A, B = 1, 5 assert upgraded_min_travel_time(N, M, K, streets, upgrades, A, B...
[ { "docstring": "Implementation of Dijkstra's algorithm to find the shortest path distance\nfrom start to end in the given graph.", "function_declaration": "def dijkstra(N, graph, start, end):", "function_name": "dijkstra", "parameter_list": "(N, graph, start, end)" }, { "docstring": "Finds t...
[ 0, 0, 0, 0, 0, 0, 0, 1, 1, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(n, graph, start):\n dist = [float('inf')] * (n + 1)\n dist[start] = 0\n priority_queue = [(0, start)]\n \n while priori...
trial_gpt4o_7
{ "original_instruction": "Given the following problem statement, generate the required output as specified.\n\n**Problem Statement:**\n\nThere exists a city with \\(N\\) junctions and \\(M\\) streets connecting these junctions. Each street is bidirectional and has a certain travel time. Let us represent this road ne...
0.698899
Taco_51102
C
[ "dijkstra", "upgraded_min_travel_time" ]
2
[ [ "upgraded_min_travel_time", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cf3c0db1948784babaecc36e806bf6356d3fdb05
a17a45a6898db89ec5897fb0f84c8c2ee1837454
v1.0
complete
Taco
Taco_51170_C
def precalculate_prefix_sums(array): """ Precalculates prefix sums for the given array. Returns a list of prefix sums. """ # Your code here def query_sum(prefix_sums, l, r): """ Returns the sum of the subarray from index l to r using prefix sums. """ # Your code here def process_qu...
def precalculate_prefix_sums(array): """ Precalculates prefix sums for the given array. Returns a list of prefix sums. """ prefix_sums = [0] * (len(array) + 1) # Initializing prefix sum array for i in range(1, len(array) + 1): prefix_sums[i] = prefix_sums[i-1] + array[i-1] return pr...
def test_precalculate_prefix_sums(): assert precalculate_prefix_sums([1, 2, 3, 4, 5]) == [0, 1, 3, 6, 10, 15] assert precalculate_prefix_sums([10, -10, 10, -10, 10]) == [0, 10, 0, 10, 0, 10] def test_query_sum(): prefix_sums = [0, 1, 3, 6, 10, 15] assert query_sum(prefix_sums, 1, 3) == 6 assert que...
[ { "docstring": "Precalculates prefix sums for the given array.\nReturns a list of prefix sums.", "function_declaration": "def precalculate_prefix_sums(array):", "function_name": "precalculate_prefix_sums", "parameter_list": "(array)" }, { "docstring": "Returns the sum of the subarray from in...
[ 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 precalculate_prefix_sums(array):\n \"\"\"\n Precalculates prefix sums for the given array.\n Returns a list of prefix sums.\n \"\"\"\n prefix_su...
trial_gpt4o_0
{ "original_instruction": "You are given an integer array $A$ of length $n$. You need to answer $q$ queries. Each query consists of two integers $l$ and $r$ and your task is to find the sum of the subarray $A[l:r]$ (both inclusive).\n\nWrite a program that handles multiple test cases efficiently.\n\n-----Input-----\n...
0.521381
Taco_51170
C
[ "precalculate_prefix_sums", "query_sum", "process_queries" ]
3
[ [ "process_queries", "precalculate_prefix_sums" ], [ "process_queries", "query_sum" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
false
[]
true
fbe6b6ef77e1912e02771e693f5140978a0f78bd
84b0067df614a41257d169e8d77023bff90846da
v1.0
complete
Taco
Taco_51427_C
def find_kth_smallest(arr: List[int], k: int) -> int: """ Find the k-th smallest element in the array using a modified version of the Quickselect algorithm. >>> find_kth_smallest([7, 10, 4, 3, 20, 15], 3) 7 >>> find_kth_smallest([7, 10, 4, 3, 20, 15], 4) 10 """ def partition(arr, low, high): ...
def partition(arr, low, high): """ This function takes the last element as pivot, places the pivot element at its correct position in sorted array, and places all smaller (smaller than pivot) to left of pivot and all greater elements to right of pivot. """ pivot = arr[high] i = low - 1 # in...
from solution import find_kth_smallest def test_find_kth_smallest(): assert find_kth_smallest([7, 10, 4, 3, 20, 15], 3) == 7 assert find_kth_smallest([7, 10, 4, 3, 20, 15], 4) == 10 assert find_kth_smallest([1, 2, 3, 4, 5, 6], 1) == 1 assert find_kth_smallest([1, 2, 3, 4, 5, 6], 6) == 6 assert find...
[ { "docstring": "This function takes the last element as pivot, places the pivot element at its correct\nposition in sorted array, and places all smaller (smaller than pivot) to left of pivot\nand all greater elements to right of pivot.", "function_declaration": "def partition(arr, low, high):", "functio...
[ 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 partition(arr, low, high):\n pivot = arr[high]\n i = low\n for j in range(low, high):\n if arr[j] <= pivot:\n arr[i], arr[j] = arr[j...
trial_gpt4o_2
{ "original_instruction": "You are given an array of integers `arr` and an integer `k`. Your task is to find the k-th smallest element in the array using a modified version of the Quickselect algorithm.\n\nExample 1:\nInput: \narr = [7, 10, 4, 3, 20, 15]\nk = 3\nOutput: 7\nExplanation: The 3rd smallest element in the...
0.624181
Taco_51427
C
[ "partition", "quickselect", "find_kth_smallest" ]
3
[ [ "find_kth_smallest", "quickselect" ], [ "quickselect", "partition" ] ]
2
[]
false
[]
false
pytest
true
[]
true
ca874ee050a499e9e9fd49d6cc652d7467ad6d07
413587a500f172269d2005edcb7952ccfda58f8d
v1.0
complete
Taco
Taco_51346_C
def is_prime(num: int) -> bool: """Helper function to check if a number is prime. >>> is_prime(1) # False >>> is_prime(2) # True >>> is_prime(11) # True >>> is_prime(4) # False """ def digit_sum(n: int) -> int: """Helper function to calculate the sum of digits of a number. >>> digit_sum...
def is_prime(num): """Helper function to check if a number is prime.""" if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num**0.5) + 1, 2): if num % i == 0: return False return True def digit_sum(n...
from solution import count_prime_friend_numbers def test_single_test_case(): assert count_prime_friend_numbers([[29, 31, 42, 57]]) == [1] def test_multiple_test_cases(): assert count_prime_friend_numbers([[29, 31, 42, 57], [11, 15, 13, 23, 25], [100, 101, 102, 103]]) == [1, 3, 2] def test_empty_input(): ...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Helper function to calculate the sum of digits of a number.", "function_declaration": "def digit_sum(n)...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, else False.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n retur...
trial_gpt4o_4
{ "original_instruction": "In a distant land called Primenation, the residents love prime numbers. They consider a number to be \"prime-friend\" if the sum of its digits is a prime number. Given a list of integers, determine how many of them are prime-friend.\n\nInput\nThe input will consist of the first line contain...
0.691413
Taco_51346
C
[ "is_prime", "digit_sum", "prime_friend_count", "count_prime_friend_numbers" ]
4
[ [ "count_prime_friend_numbers", "prime_friend_count" ], [ "prime_friend_count", "digit_sum" ], [ "prime_friend_count", "is_prime" ] ]
3
[]
false
[]
false
pytest
true
[]
true
076bb9d202e33e1155abd39ffdd1f73112e493da
c7f174b3c315dc354a5ceeba993a94fa7da136da
v1.0
complete
Taco
Taco_51040_C
class TreeNode: def __init__(self, value=0, left=None, right=None): self.value = value self.left = left self.right = right def build_tree(node_list): """ Builds a binary tree from a list of nodes. Parameters: node_list (List[Tuple[int, int, int]]): A list of tuples wher...
class TreeNode: def __init__(self, value=0, left=None, right=None): self.value = value self.left = left self.right = right def build_tree(node_list): if not node_list: return None node_dict = {val: TreeNode(val) for val, left, right in node_list} root = node_dict[node_l...
def test_case_1(): n = 5 nodes = [ (1, 2, 3), (2, -1, -1), (3, 4, 5), (4, -1, -1), (5, -1, -1) ] assert is_tree_balanced(n, nodes) == "YES" def test_case_2(): n = 3 nodes = [ (3, 9, 20), (9, -1, -1), (20, 15, 7), (15, -1, -...
[]
[ 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, val=0):\n self.val = val\n self.left = None\n self.right = None\n\ndef build_tree(node_list):\n nod...
trial_gpt4o_1
{ "original_instruction": "Alice loves trees, but she is particularly fond of balanced binary trees. A balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by more than 1. Alice has found a large number of trees in her garden and she wants to find out if t...
0.796068
Taco_51040
C
[ "build_tree", "is_balanced", "is_tree_balanced" ]
3
[ [ "is_tree_balanced", "build_tree" ], [ "is_tree_balanced", "is_balanced" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
false
[]
true
08080c0f681a100478c84b431f04e343f9a73d15
f8acae2355f62ab007e96f8dd977d67bd47eca63
v1.0
complete
Taco
Taco_51639_C
def minimize_total_distance(N: int, points: List[Tuple[int, int]]) -> float: """ Determine the minimum possible total distance from all houses to the optimal road. >>> minimize_total_distance(1, [(1, 2)]) 0.0 >>> minimize_total_distance(3, [(1, 2), (2, 4), (3, 6)]) 0.0 >>> minimize_total_distanc...
import numpy as np def minimize_total_distance(N, points): def distance_sum(m, b): return sum( abs(y - (m * x + b)) / np.sqrt(1 + m**2) for x, y in points ) if N == 1: return 0.0 x_coords, y_coords = zip(*points) x_mean = np.mean(x_coords) ...
def test_single_point(): from solution import minimize_total_distance result = minimize_total_distance(1, [(1, 2)]) assert result == 0.0 def test_multiple_points_line(): from solution import minimize_total_distance result = minimize_total_distance(3, [(1, 2), (2, 4), (3, 6)]) assert result == 0...
[ { "docstring": null, "function_declaration": "def minimize_total_distance(N, points):", "function_name": "minimize_total_distance", "parameter_list": "(N, points)" }, { "docstring": null, "function_declaration": "def process_input_and_call_function():", "function_name": "process_inpu...
[ 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.143
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import numpy as np\n\ndef minimal_distance_to_road(points):\n \"\"\"\n Calculates the minimal possible total distance from all houses to the optimal road.\n ...
trial_gpt4o_7
{ "original_instruction": "In the kingdom of Farland, there is a village with N unique houses, each of which is located on a different point in a 2D plane. The king wants to build a single road to collect taxes more efficiently. The road should be constructed such that it minimizes the total distance from each house ...
0.640962
Taco_51639
C
[ "minimize_total_distance", "process_input_and_call_function" ]
2
[ [ "process_input_and_call_function", "minimize_total_distance" ] ]
1
[]
false
[]
false
pytest
true
[ "numpy" ]
false
d14aca898ffffc46c26f5a56e15182fca8f324db
b347b7be8c83fb7f10bf66e78b0de51cdfa4a448
v1.0
complete
Taco
Taco_51595_C
from typing import List def labyrinth_solver(data: List[str]) -> List[int]: """ Determine the minimum number of moves needed to navigate through the labyrinth. >>> labyrinth_solver([ ... "2", ... "3 3", ... "...", ... ".#.", ... "...", ... "4 4", ... "....", ... "#.##", ... ...
from collections import deque def min_moves_to_reach_end(labyrinths): def bfs(grid, n, m): visited = [[False] * m for _ in range(n)] queue = deque([(0, 0, 0)]) # (row, col, distance) directions = [(1, 0), (-1, 0), (0, 1), (0, -1)] while queue: r, c, dist = queu...
from solution import labyrinth_solver def test_labyrinth_solver(): data = [ "2", "3 3", "...", ".#.", "...", "4 4", "....", "#.##", "....", "...#" ] assert labyrinth_solver(data) == [4, -1] def test_single_case(): data = [...
[ { "docstring": null, "function_declaration": "def min_moves_to_reach_end(labyrinths):", "function_name": "min_moves_to_reach_end", "parameter_list": "(labyrinths)" }, { "docstring": null, "function_declaration": "def parse_input(T, data):", "function_name": "parse_input", "parame...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef min_moves_to_reach_end(labyrinths):\n def bfs(grid, n, m):\n visited = [[False] * m for _ in range(n)]\n queu...
trial_gpt4o_0
{ "original_instruction": "You are tasked with helping a character navigate through a labyrinth. The labyrinth is represented as an $n \\times m$ grid of cells, where each cell can either be an open space ('.') or a wall ('#'). The character starts at the top-left corner of the grid (cell (1,1)) and wishes to reach t...
0.580971
Taco_51595
C
[ "min_moves_to_reach_end", "parse_input", "labyrinth_solver" ]
3
[ [ "labyrinth_solver", "min_moves_to_reach_end" ], [ "labyrinth_solver", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
ee987f19b0ad36029a416ed8f7910a3b1d3192b2
57a447bb8e450f0a6c553653a576d7f00e40ffcb
v1.0
complete
Taco
Taco_51747_C
def minimum_roads_to_reinforce(N: int, M: int, roads: List[Tuple[int, int]]) -> int: """ Determine the minimum number of roads that need reinforcement to ensure the kingdom remains connected even after the failure of any one road. Args: N : int : Number of cities in the kingdom M : int : Number of road...
def find_bridges(N, edges): from collections import defaultdict def dfs(node, parent, discovery_times, low_times, visited, adj, bridges, time): visited[node] = True discovery_times[node] = low_times[node] = time[0] time[0] += 1 for neighbor in adj[node]: if not ...
from solution import minimum_roads_to_reinforce def test_example_case_1(): N, M = 4, 4 roads = [(1, 2), (2, 3), (3, 4), (4, 2)] assert minimum_roads_to_reinforce(N, M, roads) == 1 def test_example_case_2(): N, M = 5, 6 roads = [(1, 2), (2, 3), (3, 4), (4, 1), (1, 3), (2, 4)] assert minimum_roa...
[ { "docstring": null, "function_declaration": "def find_bridges(N, edges):", "function_name": "find_bridges", "parameter_list": "(N, edges)" }, { "docstring": null, "function_declaration": "def minimum_roads_to_reinforce(N, M, roads):", "function_name": "minimum_roads_to_reinforce", ...
[ 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_bridges(N, edges):\n from collections import defaultdict\n \n def dfs(node, parent, discovery_times, low_times, visited, adj, bridges, time):\n ...
trial_gpt4o_0
{ "original_instruction": "In a distant kingdom, there are N cities and M bidirectional roads connecting some of these cities. The kingdom's ruler wants to ensure that every city is accessible from every other city directly or indirectly via other cities.\n\nUnfortunately, due to frequent natural disasters, the roads...
0.671275
Taco_51747
C
[ "find_bridges", "minimum_roads_to_reinforce" ]
2
[ [ "minimum_roads_to_reinforce", "find_bridges" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d8eb7ee80b2b082af707d2ad0cec2659cedf0df0
d46e0c66825a0d031c2e4e48efafefbda28b4db4
v1.0
complete
Taco
Taco_51361_C
def minimum_total_time_all_cases(test_cases): """ Calculate the minimum total time required to complete the maintenance of all servers including their recovery times. >>> minimum_total_time_all_cases([[(0, 3, 2), (5, 4, 1)]]) == [10] >>> minimum_total_time_all_cases([[(2, 6, 3), (1, 5, 2), (4, 2, 3)]]) == [...
def minimum_total_time_all_cases(test_cases): results = [] for servers in test_cases: servers.sort(key=lambda x: x[0]) current_time = 0 max_recovery_time = 0 for start, maintenance, recovery in servers: current_time = max(current_time, start) # Ensure we account for ...
def test_parse_input(): input_text = "2\n2\n0 3 2\n5 4 1\n3\n2 6 3\n1 5 2\n4 2 3\n" expected_output = [ [(0, 3, 2), (5, 4, 1)], [(2, 6, 3), (1, 5, 2), (4, 2, 3)] ] assert parse_input(input_text) == expected_output def test_minimum_total_time_all_cases(): test_cases = [ [(0, ...
[ { "docstring": null, "function_declaration": "def minimum_total_time_all_cases(test_cases):", "function_name": "minimum_total_time_all_cases", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_text):", "function_name": "parse_inpu...
[ 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 minimum_total_time_all_cases(test_cases):\n results = []\n for servers in test_cases:\n servers.sort(key=lambda x: x[0])\n current_time = 0...
trial_gpt4o_0
{ "original_instruction": "Ana is organizing a multi-stage server maintenance process for her company. Each server has its own starting time, maintenance time, and recovery time. The maintenance process must be scheduled such that no two servers are on maintenance at the same time, but they can start their recovery p...
0.613235
Taco_51361
C
[ "minimum_total_time_all_cases", "parse_input", "solve" ]
3
[ [ "solve", "minimum_total_time_all_cases" ], [ "solve", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
c4d07e0329aac713b7879e5a6fde9cbed17684aa
7713f8da61698f3c17204a06c77afe4e5c4e5392
v1.0
complete
Taco
Taco_51785_C
from typing import List, Tuple def max_storage_utilization(n: int, c: int, s: List[int]) -> int: """ Given the number of product types `n`, the total storage capacity `c`, and a list of product spaces `s`, return the maximum storage space that can be utilized without exceeding the total storage capaci...
def max_storage_utilization(n, c, s): """ Given the number of product types `n`, the total storage capacity `c`, and a list of product spaces `s`, return the maximum storage space that can be utilized without exceeding the total storage capacity, using a dynamic programming approach. """ dp...
from solution import max_storage_utilization, process_warehouses, parse_input, main def test_max_storage_utilization(): assert max_storage_utilization(3, 50, [10, 20, 30]) == 50 assert max_storage_utilization(2, 10000, [500, 700]) == 10000 assert max_storage_utilization(5, 1234, [10, 20, 30, 40, 50]) == 12...
[ { "docstring": "Given the number of product types `n`, the total storage capacity `c`,\nand a list of product spaces `s`, return the maximum storage space that can be \nutilized without exceeding the total storage capacity, using a dynamic\nprogramming approach.", "function_declaration": "def max_storage_ut...
[ 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(n, c, sizes):\n dp = [0] * (c + 1)\n for size in sizes:\n for i in range(c, size - 1, -1):\n dp[i] = max(dp[i], dp[i - size] +...
trial_gpt4o_4
{ "original_instruction": "You are in charge of managing a small warehouse that stores different types of products. Each type of product occupies a specified amount of space, and you have a limited total storage capacity. Your task is to optimize the way products are stored such that as much storage capacity is utili...
0.609992
Taco_51785
C
[ "max_storage_utilization", "process_warehouses", "parse_input", "main" ]
4
[ [ "process_warehouses", "max_storage_utilization" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
624487c347b9cad19912363c9541437561ee4648
133455aecdc7a41be211907e79499f90ef617f41
v1.0
complete
Taco
Taco_51809_C
import math from typing import List def is_prime(n: int) -> bool: """ Helper function to check if a number n is prime. """ def count_prime_squares(k: int, numbers: List[int]) -> int: """ Returns the count of prime squares in the list of numbers. Parameters: k (int): The number of integers...
import math def is_prime(n): """ Helper function to check if a number n is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(math.sqrt(n)) + 1, 2): if n % i == 0: return False return Tr...
from solution import count_prime_squares def test_count_prime_squares_example(): assert count_prime_squares(5, [4, 10, 25, 16, 9]) == 3 def test_count_prime_squares_no_prime_squares(): assert count_prime_squares(4, [8, 10, 20, 30]) == 0 def test_count_prime_squares_all_prime_squares(): assert count_prime...
[ { "docstring": "Helper function to check if a number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the count of prime squares in the list of numbers.", "function_declaration": "def count_prime_squ...
[ 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": "import math\n\ndef is_prime(n):\n \"\"\"\n Checks if a number n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n ...
trial_gpt4o_2
{ "original_instruction": "Captain Flint decided to further test the skills of potential crew members by giving them another challenge involving prime numbers.\n\nLet's define a positive integer $m$ as a prime square if it can be represented as $p^2$, where $p$ is a prime number. For example, numbers $4$ ($2^2$), $9$...
0.706301
Taco_51809
C
[ "is_prime", "count_prime_squares" ]
2
[ [ "count_prime_squares", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
11ef145c94c668ef8a14f599f312cf1f831f82f4
d5b1d16d5c29da9315e10222a1d20709ef58359d
v1.0
complete
Taco
Taco_51280_C
def can_construct_product(required_components, available_inventory): """ Determine if it is possible to construct a product with the specified components given the inventory of available components. Args: required_components (dict): A dictionary where keys are component names and values are required quanti...
def can_construct_product(required_components, available_inventory): for component, required_quantity in required_components.items(): if available_inventory.get(component, 0) < required_quantity: return "No" return "Yes" def process_input_and_check_construction(inputs): n = int(inputs[0...
def test_case_1(): inputs = [ "3", "steel 4", "screws 10", "wood 3", "4", "steel 5", "screws 10", "wood 2", "paint 5" ] assert process_input_and_check_construction(inputs) == "No" def test_case_2(): inputs = [ "2", ...
[ { "docstring": null, "function_declaration": "def can_construct_product(required_components, available_inventory):", "function_name": "can_construct_product", "parameter_list": "(required_components, available_inventory)" }, { "docstring": null, "function_declaration": "def process_input...
[ 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_construct_product(required_components, inventory_components):\n \"\"\"\n Determines if the product can be constructed from the inventory.\n \n ...
trial_gpt4o_1
{ "original_instruction": "A new company, Woven Widgets, is experimenting with a new type of machine capable of producing different products. Each product requires a list of components to be assembled. Your task is to determine if it is possible to construct a product with the specified components given the inventory...
0.576264
Taco_51280
C
[ "can_construct_product", "process_input_and_check_construction" ]
2
[ [ "process_input_and_check_construction", "can_construct_product" ] ]
1
[]
false
[]
false
pytest
false
[]
true
2e7aa5b6cd5d28ea04e2ea7f750be1542a99c4ef
53c03c5bb4dfe8ad7a35a361db202af4fd9a8db3
v1.0
complete
Taco
Taco_51644_C
def minimum_cost_to_connect_cities(n: int, m: int, roads: List[Tuple[int, int, int]]) -> int: """Calculate the minimum cost required to construct additional roads such that all cities are directly connected. Args: n (int): Number of cities. m (int): Number of existing roads. roads (...
def find(parent, i): if parent[i] == i: return i return find(parent, parent[i]) def union(parent, rank, x, y): xroot = find(parent, x) yroot = find(parent, y) if rank[xroot] < rank[yroot]: parent[xroot] = yroot elif rank[xroot] > rank[yroot]: parent[yroot] = xroot e...
import pytest from solution import minimum_cost_to_connect_cities def test_case_1(): assert minimum_cost_to_connect_cities(4, 3, [(1, 2, 1), (2, 3, 4), (3, 4, 5)]) == 10 def test_case_2(): assert minimum_cost_to_connect_cities(5, 1, [(1, 2, 3)]) == -1 def test_case_3(): assert minimum_cost_to_connect_cit...
[ { "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": "There are n cities in a country, and each city is connected to other cities via bi-directional roads with given lengths. You are a city planner tasked with ensuring that there is a direct road connection between every pair of cities. However, due to budget constraints, you need to find the ...
0.674344
Taco_51644
C
[ "find", "union", "minimum_cost_to_connect_cities" ]
3
[ [ "minimum_cost_to_connect_cities", "find" ], [ "minimum_cost_to_connect_cities", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
5ec402d28932b4253249606753be64a53f48d3e5
4b459a67b29cbce512e1ed3c928e01406a89d8c4
v1.0
complete
Taco
Taco_51727_C
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def build_tree(edges): nodes = {} for v, l, r in edges: if v not in nodes: nodes[v] = TreeNode(val=v) if l != 0: nodes[l] = Tr...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def build_tree(edges): nodes = {} for v, l, r in edges: if v not in nodes: nodes[v] = TreeNode(val=v) if l != 0: nodes[l] = Tr...
import pytest from solution import find_diameter def test_example1(): n = 5 edges = [ (1, 2, 3), (2, 4, 5), (3, 0, 0), (4, 0, 0), (5, 0, 0) ] assert find_diameter(n, edges) == 3 def test_example2(): n = 3 edges = [ (1, 2, 0), (2, 3, 0), ...
[]
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef build_t...
trial_gpt4o_2
{ "original_instruction": "Pari and Arya are learning about binary trees and came across the concept of tree traversal. They want to find the longest path in a binary tree, which is called the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This p...
0.613247
Taco_51727
C
[ "build_tree", "diameter_of_binary_tree", "find_diameter" ]
3
[ [ "find_diameter", "build_tree" ], [ "find_diameter", "diameter_of_binary_tree" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
589307c8458164983f8d41ec2ab7d6e6d9fd7f81
1f6411b8274decc96700fd0faa0338a409d24fe1
v1.0
complete
Taco
Taco_51794_C
from itertools import combinations from typing import List, Tuple def min_queries_to_retrieve_items(k: int, test_cases: List[Tuple[int, int, List[str], List[List[str]]]]) -> List[int]: """ Determine the minimum number of queries required to retrieve a target list of items by combining the results of any subset of ...
from itertools import combinations def min_queries_to_retrieve_items(k, test_cases): result = [] for case in test_cases: n, m, target_items, queries = case target_set = set(target_items) min_queries = float('inf') found = False for i in range(1, n+...
import pytest from solution import run, parse_input def test_case_1(): input_string = """ 2 3 5 item1 item2 item3 item4 item5 3 item1 item3 item5 2 item2 item4 1 item3 2 3 item1 item2 item3 2 item1 item2 2 item2 item3 """ expected_output = [2, 2] assert run(input...
[ { "docstring": null, "function_declaration": "def min_queries_to_retrieve_items(k, test_cases):", "function_name": "min_queries_to_retrieve_items", "parameter_list": "(k, test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_string):", "function_name": "...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "from itertools import combinations\n\ndef min_queries_to_retrieve_items(k, test_cases):\n result = []\n \n for case in test_cases...
trial_gpt4o_1
{ "original_instruction": "A startup is developing a new database system optimized for handling multiple search queries efficiently. The final stage of development involves checking the database operation by means of a series of search queries. Each search query returns a list of items from a large collection. The go...
0.632726
Taco_51794
C
[ "min_queries_to_retrieve_items", "parse_input", "run" ]
3
[ [ "run", "min_queries_to_retrieve_items" ], [ "run", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
cf056d60e5be7461c4c77b8b1e7db591c94be3f1
5e91f0c81dfaeebe6c0d3d8903299f69e942740a
v1.0
complete
Taco
Taco_52066_C
def is_prime(num): """ Helper function to determine if a number is prime. >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(0) == False >>> is_prime(-7) == False """ def sort_primes(sequence): """ Rearranges prime numbers in the sequence in ascending order while keeping n...
def is_prime(num): """ Helper function to determine if a number is prime. """ if num <= 1: return False if num == 2: return True # 2 is the only even prime number if num % 2 == 0: return False for i in range(3, int(num**0.5) + 1, 2): if num % i == 0: ...
from solution import sort_primes, is_prime # is_prime function tests def test_is_prime_positive_cases(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(5) == True assert is_prime(29) == True def test_is_prime_negative_cases(): assert is_prime(0) == False assert is_prime(...
[ { "docstring": "Helper function to determine if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Rearranges prime numbers in the sequence in ascending order while keeping non-prime numbers in their or...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Determines if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n...
trial_gpt4o_2
{ "original_instruction": "Julia loves to solve puzzles, and she recently encountered a sequence puzzle involving prime numbers. She has a sequence of integers and needs to identify the prime numbers in this sequence. She then intends to rearrange these prime numbers in ascending order while keeping the non-prime num...
0.734056
Taco_52066
C
[ "is_prime", "sort_primes" ]
2
[ [ "sort_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1ec55376e66cd42e7adbf18ce20835865b6087b6
618de2e81d348fb763d355ee1d752c060b4de6e6
v1.0
complete
Taco
Taco_52119_C
from typing import List def search_pattern(pattern: str, txt: str) -> List[int]: """ Given a string pattern of length M and a text txt of length N, identify if pattern exists in txt. Return the starting index of each occurrence of pattern in txt. If pattern does not exist in txt, return an empty list. Exa...
from typing import List def compute_lps(pattern: str) -> List[int]: M = len(pattern) lps = [0] * M length = 0 i = 1 while i < M: if pattern[i] == pattern[length]: length += 1 lps[i] = length i += 1 else: if length != 0: ...
from solution import search_pattern def test_search_pattern_basic(): assert search_pattern("abc", "ababcabc") == [2, 5] def test_search_pattern_no_match(): assert search_pattern("xyz", "ababcabc") == [] def test_search_pattern_pattern_at_start(): assert search_pattern("abc", "abcabcabc") == [0, 3, 6] de...
[ { "docstring": null, "function_declaration": "def compute_lps(pattern):", "function_name": "compute_lps", "parameter_list": "(pattern)" }, { "docstring": null, "function_declaration": "def search_pattern(pattern, txt):", "function_name": "search_pattern", "parameter_list": "(patt...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from typing import List\n\ndef compute_lps(pattern: str) -> List[int]:\n M = len(pattern)\n lps = [0] * M\n length = 0\n i = 1\n \n while i < M:\...
trial_gpt4o_0
{ "original_instruction": "Given a string `pattern` of length `M` and a text `txt` of length `N`, your task is to identify if `pattern` exists in `txt`. If it does, return the starting index of each occurrence of `pattern` in `txt`. If `pattern` does not exist in `txt`, return an empty list. \n\nImplement the functio...
0.65765
Taco_52119
C
[ "compute_lps", "search_pattern" ]
2
[ [ "search_pattern", "compute_lps" ] ]
1
[]
false
[]
false
pytest
true
[]
true
898db22bf5a4d8f2bd7019c8ce578752bd067399
26619bc45711486321c8b5eb2967ec341a76db38
v1.0
complete
Taco
Taco_52046_C
def subsequence_has_perfect_square_product(n: int, arr: List[int]) -> str: """ Determine if a subsequence exists such that the product of the elements in the subsequence is a perfect square. Parameters: n (int): The size of the array arr (List[int]): The elements of the array Returns:...
from collections import defaultdict from math import isqrt def is_perfect_square(n): """ Helper function to check if a number is a perfect square. """ root = isqrt(n) return root * root == n def subsequence_has_perfect_square_product(n, arr): """ Function to determine if a subsequence exis...
import pytest from solution import solve def test_example_cases(): test_cases = [ (4, [2, 3, 4, 6]), (5, [1, 2, 3, 4, 5]), (3, [7, 11, 13]) ] expected_results = ["Yes", "No", "No"] assert solve(test_cases) == expected_results def test_all_ones(): assert solve([(4, [1, 1, 1,...
[ { "docstring": "Helper function to check if a number is a perfect square.", "function_declaration": "def is_perfect_square(n):", "function_name": "is_perfect_square", "parameter_list": "(n)" }, { "docstring": "Function to determine if a subsequence exists such that the product of the element...
[ 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 Counter\nfrom math import isqrt\nfrom functools import reduce\nfrom itertools import combinations\n\ndef is_perfect_square(x):\n \"\"\"\...
trial_gpt4o_4
{ "original_instruction": "Given an integer array $A$ of size $n$, you need to find if there exists a subsequence such that the product of the elements in the subsequence is a perfect square. If such a subsequence exists, output \"Yes\", otherwise output \"No\".\n\nA subsequence is a sequence that can be derived from...
0.560663
Taco_52046
C
[ "is_perfect_square", "subsequence_has_perfect_square_product", "solve" ]
3
[ [ "solve", "subsequence_has_perfect_square_product" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b7c4c818bea5f5ca9e595a2746248558bf7b8803
b3f4b73ea1714448236e8a5a92750d1824159b27
v1.0
complete
Taco
Taco_52077_C
import math def num_divisors(num): """ Helper function to calculate the number of divisors of a given number. """ count = 0 for i in range(1, int(math.sqrt(num)) + 1): if num % i == 0: if i == num // i: count += 1 else: count += 2 ...
import math def num_divisors(num): """ Helper function to calculate the number of divisors of a given number. """ count = 0 for i in range(1, int(math.sqrt(num)) + 1): if num % i == 0: if i == num // i: count += 1 else: count += 2 ...
from solution import next_highly_divisible def test_next_highly_divisible_five_divisors(): assert next_highly_divisible(5) == 12 def test_next_highly_divisible_seven_divisors(): assert next_highly_divisible(7) == 24 def test_next_highly_divisible_one_divisor(): assert next_highly_divisible(1) == 2 def t...
[ { "docstring": "Helper function to calculate the number of divisors of a given number.", "function_declaration": "def num_divisors(num):", "function_name": "num_divisors", "parameter_list": "(num)" }, { "docstring": "Returns the smallest integer which has more than n divisors.", "functio...
[ 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 count_divisors(num):\n \"\"\"\n Counts the number of divisors of the given number `num`.\n \"\"\"\n if num < 1:\n return 0\n \n count ...
trial_gpt4o_3
{ "original_instruction": "#### Task:\n\nYour job is to write a method `next_highly_divisible` in Ruby/Python/JavaScript that finds the smallest number with more than `n` divisors. The method `next_highly_divisible` should take one argument `n` and return the smallest integer which has more than `n` divisors.\n\n1. S...
0.756499
Taco_52077
C
[ "num_divisors", "next_highly_divisible" ]
2
[ [ "next_highly_divisible", "num_divisors" ] ]
1
[]
false
[]
false
pytest
true
[]
true
afa930ffae567e7db880beb40c42598448af9525
54e1a5c4c6956db560f479196a237f191c1545f5
v1.0
complete
Taco
Taco_52184_C
def is_subsequence(s: str, word: str) -> bool: """ Checks if 'word' is a subsequence of 's'. >>> is_subsequence("abcde", "a") True >>> is_subsequence("abcde", "bb") False >>> is_subsequence("abcde", "ace") True >>> is_subsequence("xyz", "xy") True >>> is_subsequence("xyz", "z...
def is_subsequence(s, word): """ Checks if 'word' is a subsequence of 's'. """ it = iter(s) return all(char in it for char in word) def find_subsequences(s, words): """ Takes a string s and a list of words, returns the words that are subsequences of s. """ subsequences = [word for w...
from solution import is_subsequence, find_subsequences def test_is_subsequence(): assert is_subsequence("abcde", "a") == True assert is_subsequence("abcde", "bb") == False assert is_subsequence("abcde", "ace") == True assert is_subsequence("xyz", "xy") == True assert is_subsequence("xyz", "z") == T...
[ { "docstring": "Checks if 'word' is a subsequence of 's'.", "function_declaration": "def is_subsequence(s, word):", "function_name": "is_subsequence", "parameter_list": "(s, word)" }, { "docstring": "Takes a string s and a list of words, returns the words that are subsequences of s.", "f...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_subsequence(s, word):\n \"\"\"\n Check if word is a subsequence of s.\n \"\"\"\n it = iter(s)\n return all(char in it for char in word)\n\nde...
trial_gpt4o_2
{ "original_instruction": "You are given a string s and a list of words. Your task is to determine which words from the list are subsequences of the string s. A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.\n\n...
0.689178
Taco_52184
C
[ "is_subsequence", "find_subsequences" ]
2
[ [ "find_subsequences", "is_subsequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0e3d53a2c6608a65f7799326c715f7e00b01ce4f
499eacc37d2a1001b8f6c34d4a423f0f7f30aecb
v1.0
complete
Taco
Taco_52081_C
class TreeNode: def __init__(self, key): self.left = None self.right = None self.val = key def insert(root, key): """ Insert a key into the BST rooted at root Args: root (TreeNode): The root of the BST key (int): The value to be inserted into the BST Returns: ...
class TreeNode: def __init__(self, key): self.left = None self.right = None self.val = key def insert(root, key): if root is None: return TreeNode(key) else: if root.val < key: root.right = insert(root.right, key) else: root.left = ins...
from solution import calculate_max_depth def test_example(): n = 7 sequence = [4, 2, 6, 1, 3, 5, 7] assert calculate_max_depth(n, sequence) == 3 def test_single_element(): n = 1 sequence = [1] assert calculate_max_depth(n, sequence) == 1 def test_increasing_sequence(): n = 4 sequence ...
[]
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, key):\n self.left = None\n self.right = None\n self.val = key\n\nclass BST:\n def __init__(self):\n...
trial_gpt4o_1
{ "original_instruction": "Alice has recently started learning about binary search trees (BSTs). A binary search tree is a data structure that keeps elements in order, such that for any node:\n- All elements in the left subtree of the node are less than the node.\n- All elements in the right subtree are greater than ...
0.533345
Taco_52081
C
[ "insert", "maxDepth", "calculate_max_depth" ]
3
[ [ "calculate_max_depth", "insert" ], [ "calculate_max_depth", "maxDepth" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
a2b38ff3e2e9f0be2c758ac0fb5e755372b7ff64
75c33e719a87097b4259b0f4f8c325f41f683a43
v1.0
complete
Taco
Taco_52229_C
def is_perfect_number(n: int) -> bool: """ Determine if a number is a perfect number. >>> is_perfect_number(6) True >>> is_perfect_number(28) True >>> is_perfect_number(496) True >>> is_perfect_number(12) False >>> is_perfect_number(27) False """ pass def count_p...
def is_perfect_number(n): if n < 2: return False sum_of_divisors = 1 sqrt_n = int(n**0.5) for i in range(2, sqrt_n + 1): if n % i == 0: sum_of_divisors += i if i != n // i: sum_of_divisors += n // i return sum_of_divisors == n def count_perfec...
from solution import is_perfect_number, count_perfect_numbers_up_to_n, count_perfect_numbers def test_is_perfect_number(): assert is_perfect_number(6) == True assert is_perfect_number(28) == True assert is_perfect_number(496) == True assert is_perfect_number(12) == False assert is_perfect_number(27...
[ { "docstring": null, "function_declaration": "def is_perfect_number(n):", "function_name": "is_perfect_number", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def count_perfect_numbers_up_to_n(N):", "function_name": "count_perfect_numbers_up_to_n", "para...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_perfect_number(n):\n if n < 2:\n return False\n sum_of_divisors = 1\n sqrt_n = int(n**0.5)\n for i in range(2, sqrt_n + 1):\n if n...
trial_gpt4o_0
{ "original_instruction": "Amy has a passion for exploring numerical patterns and number theory. One day, she stumbled upon a series of equations involving a special set of numbers called Perfect Numbers. A Perfect Number is a positive integer that is equal to the sum of its proper divisors, excluding itself. For exa...
0.590557
Taco_52229
C
[ "is_perfect_number", "count_perfect_numbers_up_to_n", "count_perfect_numbers" ]
3
[ [ "count_perfect_numbers", "is_perfect_number" ], [ "count_perfect_numbers_up_to_n", "is_perfect_number" ] ]
2
[]
false
[]
false
pytest
true
[]
true
6824e5c71f0d2542d454ac3094b5e9e29428f9dc
0d74e5ed000528135ce9400982074f9e5dd8a9ca
v1.0
complete
Taco
Taco_51270_C
import heapq from typing import List, Tuple, Dict def dijkstra(graph: Dict[int, Dict[int, int]], start: int, n: int) -> Dict[int, int]: """ Uses Dijkstra's algorithm to find the shortest path from the start node to all other nodes in a weighted graph. """ distances = {node: float('infinity') for node i...
import heapq def dijkstra(graph, start, n): """ Uses Dijkstra's algorithm to find the shortest path from start node to all other nodes in a weighted graph. """ distances = {node: float('infinity') for node in range(1, n+1)} distances[start] = 0 priority_queue = [(0, start)] while priority_...
def test_dijkstra(): graph = { 1: {2: 2, 3: 5, 4: 10}, 2: {3: 2, 5: 10}, 3: {4: 2}, 4: {5: 2}, 5: {} } assert dijkstra(graph, 1, 5) == {1: 0, 2: 2, 3: 4, 4: 6, 5: 8} def test_shortest_route(): assert shortest_route(5, 6, [(1, 2, 2), (2, 3, 2), (3, 4, 2), (4, 5, 2...
[ { "docstring": "Uses Dijkstra's algorithm to find the shortest path from start node to all other nodes in a weighted graph.", "function_declaration": "def dijkstra(graph, start, n):", "function_name": "dijkstra", "parameter_list": "(graph, start, n)" }, { "docstring": "Returns the shortest t...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\nimport sys\n\ndef dijkstra(graph, start, end, num_nodes):\n distances = {node: float('inf') for node in range(1, num_nodes + 1)}\n distances[st...
trial_gpt4o_5
{ "original_instruction": "You are working on a new feature for a logistics software system that tracks delivery routes for a fleet of trucks. Each route is represented as a sequence of nodes (stops) in a directed graph, where nodes represent locations (such as warehouses or delivery points) and edges represent roads...
0.647137
Taco_51270
C
[ "dijkstra", "shortest_route", "logistic_routes", "parse_input", "main" ]
5
[ [ "logistic_routes", "shortest_route" ], [ "shortest_route", "dijkstra" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
a88d6ee3f0cd348bef3ebeb1af9273d268d18670
6a801c50a078ad9aa2d06bfae2f90814c1a614cb
v1.0
complete
Taco
Taco_52393_C
def can_color_graph(vertices: int, edges: List[Tuple[int, int]]) -> str: """ Determines if it's possible to color the graph using three distinct colors such that no two adjacent vertices share the same color. >>> can_color_graph(3, [(1, 2), (2, 3), (3, 1)]) "No" >>> can_color_graph(4, [(1, 2), (2, 3), (...
def is_bipartite(graph, n): """ Helper function to check if a graph is bipartite using BFS """ color = [-1] * n queue = [] for start in range(n): if color[start] == -1: queue.append(start) color[start] = 0 while queue: node = queue.po...
from solution import can_color_graph def test_case_1(): vertices = 3 edges = [(1, 2), (2, 3), (3, 1)] assert can_color_graph(vertices, edges) == "No" def test_case_2(): vertices = 4 edges = [(1, 2), (2, 3), (3, 4), (4, 1)] assert can_color_graph(vertices, edges) == "Yes" def test_case_3(): ...
[ { "docstring": "Helper function to check if a graph is bipartite using BFS", "function_declaration": "def is_bipartite(graph, n):", "function_name": "is_bipartite", "parameter_list": "(graph, n)" }, { "docstring": "Returns \"Yes\" if it is possible to color the graph using three colors such ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_graph_3_colorable(n, edges):\n \"\"\"\n Determines if the given graph with n vertices and edges is 3-colorable such that no\n two adjacent vertices...
trial_gpt4o_1
{ "original_instruction": "You are given an undirected graph with n vertices and m edges. Each vertex has a color represented by an integer. You are asked to determine if it's possible to assign a color from a given set of three distinct colors {0, 1, 2} to each vertex such that no two adjacent vertices share the sam...
0.505619
Taco_52393
C
[ "is_bipartite", "can_color_graph" ]
2
[ [ "can_color_graph", "is_bipartite" ] ]
1
[]
false
[]
false
pytest
true
[]
true
49d2c06c3cd4fa3f86c7e738e91bf9bee2121795
cd0bebc9a8a3ca9a48c27fb697758dd171acc011
v1.0
complete
Taco
Taco_52394_C
def is_subsequence(s: str, t: str) -> bool: """ Check if `t` is a subsequence of `s`. >>> is_subsequence("abcde", "ace") True >>> is_subsequence("abcde", "aec") False """ pass def subsequence_result(s: str, t: str) -> str: """ Determine if `t` is a subsequence of `s` and return "YES" or...
def is_subsequence(s, t): """ Check if `t` is a subsequence of `s`. """ iter_s = iter(s) return all(char in iter_s for char in t) def subsequence_result(s, t): return "YES" if is_subsequence(s, t) else "NO"
from solution import is_subsequence, subsequence_result def test_example_1(): assert subsequence_result("abcde", "ace") == "YES" def test_example_2(): assert subsequence_result("abcde", "aec") == "NO" def test_empty_t(): assert subsequence_result("abcde", "") == "YES" def test_empty_s(): assert subs...
[ { "docstring": "Check if `t` is a subsequence of `s`.", "function_declaration": "def is_subsequence(s, t):", "function_name": "is_subsequence", "parameter_list": "(s, t)" }, { "docstring": null, "function_declaration": "def subsequence_result(s, t):", "function_name": "subsequence_re...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_subsequence(s, t):\n \"\"\"\n Determine if t is a subsequence of s.\n \n Args:\n s (str): The source string.\n t (str): The target string....
trial_gpt4o_2
{ "original_instruction": "### Coding Assessment Question\n\nYou are given two strings `s` and `t` consisting of lowercase English letters. Your task is to determine if you can transform string `s` into string `t` by deleting some (possibly zero) characters from `s` without changing the order of the remaining charact...
0.698275
Taco_52394
C
[ "is_subsequence", "subsequence_result" ]
2
[ [ "subsequence_result", "is_subsequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
978430d5b4210d27fd0e9f60e007bfa7672e0996
6144a73e4f37882fac52cf56019474f3b314e90c
v1.0
complete
Taco
Taco_52224_C
def transportation_scheduling(N: int, C: int, pickup_dropoff_list: List[Tuple[int, int]]) -> int: """ Develop a program that simulates a transportation scheduling system for a shared ride service. Each trip has a fixed capacity of C seats, and there are N passengers wishing to travel, each with a spec...
def min_trips(N, C, passengers): """ Given the number of passengers and seating capacity, this function calculates the minimum number of trips required. """ passengers.sort() trips = 0 i = 0 while i < len(passengers): count = 1 end = passengers[i][1] trips += 1 ...
from solution import transportation_scheduling def test_case_1(): assert transportation_scheduling(4, 3, [(1, 5), (2, 6), (3, 7), (4, 8)]) == 2 def test_case_2(): assert transportation_scheduling(3, 2, [(1, 3), (2, 5), (4, 6)]) == 2 def test_case_3(): assert transportation_scheduling(5, 5, [(1, 10), (2, ...
[ { "docstring": "Given the number of passengers and seating capacity, this function calculates the minimum number of trips required.", "function_declaration": "def min_trips(N, C, passengers):", "function_name": "min_trips", "parameter_list": "(N, C, passengers)" }, { "docstring": null, "...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_trips(N, C, passengers):\n # Sort passengers by pickup location and then by drop-off location\n passengers.sort()\n\n trips = 0\n seats_used = ...
trial_gpt4o_8
{ "original_instruction": "Develop a program that simulates a transportation scheduling system for a shared ride service. Each trip has a fixed capacity of C seats, and there are N passengers wishing to travel, each with a specific pickup location and drop-off location. The goal is to group passengers into the fewest...
0.66978
Taco_52224
C
[ "min_trips", "transportation_scheduling" ]
2
[ [ "transportation_scheduling", "min_trips" ] ]
1
[]
false
[]
false
pytest
true
[]
true
38ca7ed40c8c4eca1458f825bfd35499ddfd4ea8
244d0db03b42c0c8cbe5f86e8b4d46aee9183dde
v1.0
complete
Taco
Taco_52235_C
def preprocess_array(array): """ Preprocess the array to create a prefix sum array. """ pass def range_sum(prefix_sum, l, r): """ Calculate the sum for the range query (l, r) using the prefix sum array. """ pass def answer_queries(n, m, array, queries): """ Answer m queries abo...
def preprocess_array(array): """ Preprocess the array to create a prefix sum array. """ n = len(array) prefix_sum = [0] * (n + 1) for i in range(1, n + 1): prefix_sum[i] = prefix_sum[i - 1] + array[i - 1] return prefix_sum def range_sum(prefix_sum, l, r): """ C...
from solution import answer_queries def test_example_1(): n, m = 5, 3 array = [1, 2, 3, 4, 5] queries = [(1, 3), (2, 5), (1, 5)] expected = [6, 14, 15] assert answer_queries(n, m, array, queries) == expected def test_example_2(): n, m = 5, 2 array = [5, 5, -5, -5, 5] queries = [(1, 5),...
[ { "docstring": "Preprocess the array to create a prefix sum array.", "function_declaration": "def preprocess_array(array):", "function_name": "preprocess_array", "parameter_list": "(array)" }, { "docstring": "Calculate the sum for the range query (l, r) using the prefix sum array.", "fun...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def preprocess(array):\n \"\"\"\n Preprocesses the input array to create a prefix sum array.\n \"\"\"\n prefix_sum = [0] * (len(array) + 1)\n for i ...
trial_gpt4o_2
{ "original_instruction": "Monica is learning data structures and algorithms. She challenges herself by solving a problem related to range queries. She has an array of $n$ integers $a_1, a_2, \\dots, a_n$. She wants to answer $m$ queries. Each query consists of two integers $l$ and $r$ ($1 \\leq l \\leq r \\leq n$) a...
0.640515
Taco_52235
C
[ "preprocess_array", "range_sum", "answer_queries" ]
3
[ [ "answer_queries", "preprocess_array" ], [ "answer_queries", "range_sum" ] ]
2
[]
false
[]
false
pytest
true
[]
true
399980e87bc1a8034ea4ccf3de22afa42c53c3d6
8f99f5fccd7e18e1067ee09c574b7d32c0dced60
v1.0
complete
Taco
Taco_52597_C
def find_primes_in_range(A: int, B: int) -> List[int]: """Generate all prime numbers between two given integers, inclusive. Parameters: A (int): The lower bound of the range. B (int): The upper bound of the range. Returns: List[int]: A list of prime numbers in the range [A, B]. """
def sieve_of_eratosthenes(max_num): primes = [True] * (max_num + 1) primes[0] = primes[1] = False p = 2 while p * p <= max_num: if primes[p]: for i in range(p * p, max_num + 1, p): primes[i] = False p += 1 return primes def find_primes_in_range(A, B): ...
from solution import find_primes_in_range def test_example_case(): assert find_primes_in_range(10, 30) == [11, 13, 17, 19, 23, 29] def test_no_primes_case(): assert find_primes_in_range(14, 16) == ["No primes"] def test_entire_range_prime(): assert find_primes_in_range(2, 2) == [2] def test_range_with_s...
[ { "docstring": null, "function_declaration": "def sieve_of_eratosthenes(max_num):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(max_num)" }, { "docstring": null, "function_declaration": "def find_primes_in_range(A, B):", "function_name": "find_primes_in_range", ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sieve_of_eratosthenes(max_num):\n primes = [True] * (max_num + 1)\n primes[0] = primes[1] = False\n p = 2\n while p * p <= max_num:\n if pri...
trial_gpt4o_0
{ "original_instruction": "Maya is learning about prime numbers and wants to write a program to find all prime numbers within a given range. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.\n\nCan you help Maya by writing a function that generates all prime numb...
0.618915
Taco_52597
C
[ "sieve_of_eratosthenes", "find_primes_in_range" ]
2
[ [ "find_primes_in_range", "sieve_of_eratosthenes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8b3f818fc0751b56f5006513cf238717c2436a65
04f933c766ad14e50378e0f75f8f3b4fcbf11eea
v1.0
complete
Taco
Taco_52373_C
def minimum_cost_to_ensure_connectivity(n: int, m: int, node_types: List[str], edges: List[Tuple[int, int, int]]) -> int: """ Find and return the minimum cost to ensure connectivity between warehouses and customer locations using Minimum Spanning Tree (MST). This ensures that every customer location is reachabl...
def find(parent, i): if parent[i] == i: return i return find(parent, parent[i]) def union(parent, rank, x, y): xroot = find(parent, x) yroot = find(parent, y) if rank[xroot] < rank[yroot]: parent[xroot] = yroot elif rank[xroot] > rank[yroot]: parent[yroot] = xroot ...
def test_minimum_cost_to_ensure_connectivity(): assert minimum_cost_to_ensure_connectivity( 6, 7, ["W", "C", "C", "W", "C", "W"], [(1, 2, 10), (2, 3, 15), (3, 4, 10), (4, 5, 15), (3, 5, 10), (5, 6, 5), (1, 6, 20)] ) == 50 assert minimum_cost_to_ensure_connectivity( 4, ...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n xroot = find(parent, x)\n...
trial_gpt4o_0
{ "original_instruction": "A transportation company is building an automated delivery system. They have a network of delivery points represented as an undirected weighted graph. A delivery point can be a warehouse or a customer location. The company wants to ensure that every customer location is reachable from at le...
0.73714
Taco_52373
C
[ "find", "union", "kruskal", "minimum_cost_to_ensure_connectivity" ]
4
[ [ "kruskal", "find" ], [ "kruskal", "union" ], [ "minimum_cost_to_ensure_connectivity", "kruskal" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
false
[]
true
579e3070085f929b1eb44a1df226533f8581ec0c
d50c976b471d8feef3142c69e7b219073c13d327
v1.0
complete
Taco
Taco_52270_C
class TreeNode: def __init__(self, key=0, left=None, right=None): self.key = key self.left = left self.right = right def build_tree(inorder, postorder): """ Build the binary tree from in-order and post-order traversals. """ pass def preorder_traversal(root): """ Per...
class TreeNode: def __init__(self, key=0, left=None, right=None): self.key = key self.left = left self.right = right def build_tree(inorder, postorder): if not inorder or not postorder: return None root_val = postorder.pop() root = TreeNode(root_val) inorder_ind...
from solution import TreeNode, build_tree, preorder_traversal, reconstruct_and_traverse # Helper to compare two trees def is_same_tree(p, q): if not p and not q: return True if not p or not q: return False return p.key == q.key and is_same_tree(p.left, q.left) and is_same_tree(p.right, q.ri...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef build_t...
trial_gpt4o_2
{ "original_instruction": "Nina loves playing with trees, especially binary trees. She has a special game that involves traversing the binary tree in different orders (pre-order, in-order, and post-order).\n\nAs a challenge, Nina wants you to reconstruct the binary tree given its in-order and post-order traversals. S...
0.540559
Taco_52270
C
[ "build_tree", "preorder_traversal", "reconstruct_and_traverse" ]
3
[ [ "reconstruct_and_traverse", "build_tree" ], [ "reconstruct_and_traverse", "preorder_traversal" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
50765cc621ec3c75d7f0867998c3feb89ca5493a
ddaeb9c7d63452427cd0bfca25bde81daa0ea941