version
stringclasses
1 value
style
stringclasses
2 values
subset
stringclasses
12 values
question_id
stringlengths
9
23
question
stringlengths
27
8.13k
solution
stringlengths
99
5.97k
test
stringlengths
105
4.45k
test_info
listlengths
0
13
gpt_pass_sequence
listlengths
1
10
gpt_pass_trial_num
int64
1
10
gpt_difficulty
stringclasses
3 values
gpt_pass_percentage
float64
0.1
1
trials
dict
chosen_trial
stringclasses
10 values
metadata
dict
benchmark_similarity
float64
0.16
0.93
benchmark_instruction
stringclasses
1 value
benchmark_task_id
stringclasses
1 value
filter_reason
stringclasses
1 value
base_id
stringlengths
7
21
variant
stringclasses
2 values
top_function_names
listlengths
2
13
n_top_functions
int64
2
13
helper_call_edges
listlengths
1
16
n_helper_call_edges
int64
1
16
harness_functions
listlengths
0
3
structural_wrapper
bool
1 class
class_names
listlengths
0
5
has_class
bool
2 classes
test_kind
stringclasses
1 value
test_has_solution_import
bool
2 classes
third_party_imports
listlengths
0
5
stdlib_only
bool
2 classes
question_norm_sha1
stringlengths
40
40
solution_ast_sha1
stringlengths
40
40
v1.0
instruct
Taco
Taco_48057_I
Tim and Jane are participating in a collaborative coding competition. They have to solve a problem that involves working with a matrix of integers. Given an $M \times N$ matrix, they need to find the largest sum of any submatrix within the given matrix. A submatrix is defined as any contiguous block of the original mat...
def largest_sum_submatrix(matrix): """ Returns the largest sum of any submatrix within the given matrix. """ import numpy as np M = len(matrix) N = len(matrix[0]) max_sum = -float('inf') for left in range(N): row_sum = [0] * M for right in range(left, N): ...
from solution import largest_sum_submatrix def test_largest_sum_submatrix(): matrix = [ [1, -2, 3], [-4, 5, -6], [7, 8, 9] ] assert largest_sum_submatrix(matrix) == 24 def test_largest_sum_submatrix_all_negative(): matrix = [ [-1, -2], [-3, -4] ] assert ...
[ { "docstring": "Returns the largest sum of any submatrix within the given matrix.", "function_declaration": "def largest_sum_submatrix(matrix):", "function_name": "largest_sum_submatrix", "parameter_list": "(matrix)" }, { "docstring": "Helper function to find the maximum sum subarray using K...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_submatrix_sum(matrix):\n def get_kadane(arr):\n max_current = max_global = arr[0]\n for x in arr[1:]:\n max_current = max(x, ma...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00048057", "row_id": 48057, "seed_ids": "[23476]" }
0.618097
Taco_48057
I
[ "largest_sum_submatrix", "max_subarray_sum" ]
2
[ [ "largest_sum_submatrix", "max_subarray_sum" ] ]
1
[]
false
[]
false
pytest
true
[ "numpy" ]
false
771bee0b1f1fa39e255c2985ddc71ac9c9cce5ce
d5f396f16ea4d93bb643453999ac7739d3ddee75
v1.0
instruct
Taco
Taco_48143_I
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 be treated as separate groups....
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": "", "prompt_id": "00048143", "row_id": 48143, "seed_ids": "[8539]" }
0.559157
Taco_48143
I
[ "group_urls", "print_grouped_urls", "handle_urls" ]
3
[ [ "handle_urls", "group_urls" ], [ "handle_urls", "print_grouped_urls" ] ]
2
[]
false
[]
false
pytest
true
[]
true
5228c0d1dc7e698e61a50b7e753d69fa1e885f67
5d6c659afcb23837970d7865b3ea9ee01d60c5b1
v1.0
instruct
Taco
Taco_48241_I
Problem description: This problem focuses on using Binary Search and Divide and Conquer techniques. You 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. You need to solve this problem using two approaches: Brute Forc...
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": "", "prompt_id": "00048241", "row_id": 48241, "seed_ids": "[8305]" }
0.684576
Taco_48241
I
[ "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
cff64b0275a6bc2592e11409fbc7b2cdc5b1815c
5cfe899fa175b537dd7ee0786321dd63d0ede3fb
v1.0
instruct
Taco
Taco_48247_I
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. Input First line contains integer T (number of test cases). Next T test cases contain first integer N (size of the matrix) followed by N*N integers representing the matrix elements in ...
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": "", "prompt_id": "00048247", "row_id": 48247, "seed_ids": "[24731]" }
0.590042
Taco_48247
I
[ "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
9d5802be905997ab81fea1c96921fdcb6f9f54e2
4c5370caa0dbe5ef0709400d1670d4d0c999cf04
v1.0
instruct
Taco
Taco_48252_I
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. Given the costs of painting eac...
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": "", "prompt_id": "00048252", "row_id": 48252, "seed_ids": "[13099]" }
0.768996
Taco_48252
I
[ "max_paint_cost", "process_input", "solve" ]
3
[ [ "solve", "max_paint_cost" ], [ "solve", "process_input" ] ]
2
[ "process_input" ]
false
[]
false
pytest
false
[]
true
b01d28bed8d24a76e6aa78257113d28e054b1622
a7e3202f6aa7903fcfa9934bf72bd0359ae5695b
v1.0
instruct
Taco
Taco_48254_I
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: 1. P(t) = P(t-1) + 2*t, P(1) = 4 2. Q(t) = Q(t-2) + P(t), Q(1) = 2, Q(2) = 5 Your task is to help Clara calculate the Timelor...
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": "", "prompt_id": "00048254", "row_id": 48254, "seed_ids": "[3276]" }
0.583863
Taco_48254
I
[ "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
9fc0699cef7e7dbcd715a3345ae438760bbf0fb3
ebbeb715326067da14a7e37daa65363609c847fc
v1.0
instruct
Taco
Taco_48287_I
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. Given the information about the dependencies of each server, you need to dete...
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": "", "prompt_id": "00048287", "row_id": 48287, "seed_ids": "[23340]" }
0.578982
Taco_48287
I
[ "find_start_order", "servers_start_order" ]
2
[ [ "servers_start_order", "find_start_order" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ca2fccb006e2c65de4fa4af0f89a338ef1984345
f72a1bc807f49b82e35e86ae6b9188d7b04695a1
v1.0
instruct
Taco
Taco_48294_I
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 move through these cells. Des...
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": "", "prompt_id": "00048294", "row_id": 48294, "seed_ids": "[16085]" }
0.792931
Taco_48294
I
[ "distinct_paths", "read_input_and_execute" ]
2
[ [ "read_input_and_execute", "distinct_paths" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d2541543bd297ca17353e85540e5a2b0b21cefda
0d9a9738c49f6bd9024dd8709afcad63abfe57ce
v1.0
instruct
Taco
Taco_48317_I
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. Input The first input line contains one number T — number of test cases (1 ≤ T ≤ 100). Each of the following T lines contains an integ...
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": "", "prompt_id": "00048317", "row_id": 48317, "seed_ids": "[141]" }
0.787668
Taco_48317
I
[ "largest_distance", "solve", "parse_input", "main" ]
4
[ [ "solve", "largest_distance" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
638dda897895f3872b1223cbc4ea8aeea76ded47
dd0a2553aa0d98fd4593d6d96ca5be6e0d4c7aaf
v1.0
instruct
Taco
Taco_48318_I
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. Write a function to achieve this. If a...
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": "", "prompt_id": "00048318", "row_id": 48318, "seed_ids": "[13140]" }
0.760915
Taco_48318
I
[ "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
3646b9e7b3c833e808dee4bb9000f60259ce5c06
8fc0c4f696ac7a4c93f5f7219cc94530f6eab050
v1.0
instruct
Taco
Taco_48342_I
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 defined as the sum of the el...
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": "", "prompt_id": "00048342", "row_id": 48342, "seed_ids": "[18336]" }
0.560796
Taco_48342
I
[ "multiply_matrices", "trace_of_matrix", "matrix_trace" ]
3
[ [ "matrix_trace", "multiply_matrices" ], [ "matrix_trace", "trace_of_matrix" ] ]
2
[]
false
[]
false
pytest
false
[]
true
1a84dba0016c9b4093b558617d2938c2ef7b8c6a
b70ff49a32731ee43af512bafaa432c171e20a49
v1.0
instruct
Taco
Taco_48344_I
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. If a server is unreachable f...
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": "", "prompt_id": "00048344", "row_id": 48344, "seed_ids": "[14312]" }
0.67117
Taco_48344
I
[ "dijkstra", "min_latency_to_all_servers" ]
2
[ [ "min_latency_to_all_servers", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2f856b5b73ff18c30ab35be60b83dbe59d4f1d9f
7ca2979e392220bb84f167f259bfa2f2274d34a9
v1.0
instruct
Taco
Taco_48396_I
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. Your task is to write a program that calculates the number of valid queen arrang...
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": "", "prompt_id": "00048396", "row_id": 48396, "seed_ids": "[23132]" }
0.568861
Taco_48396
I
[ "is_safe", "solve_n_queens", "n_queens" ]
3
[ [ "n_queens", "solve_n_queens" ], [ "solve_n_queens", "is_safe" ] ]
2
[]
false
[]
false
pytest
true
[]
true
f32933da97c9071736c3c7db1fd7a0ea3d844a23
8fdd42aac24982b4d2b16da3dfe9dee13835d8db
v1.0
instruct
Taco
Taco_48550_I
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 (cell (N,M)) that only traverses...
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": "", "prompt_id": "00048550", "row_id": 48550, "seed_ids": "[17587]" }
0.727266
Taco_48550
I
[ "is_path_exist", "solve_maze" ]
2
[ [ "solve_maze", "is_path_exist" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e14bac4c5a14c36049ce7a3ebc7c10cdf852d099
be6a34aab85bf4cc3550907c44f63c2432804ba4
v1.0
instruct
Taco
Taco_48598_I
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. Given a positive integer n (1 ≤ n ≤ 10^6), de...
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": "", "prompt_id": "00048598", "row_id": 48598, "seed_ids": "[2850]" }
0.819503
Taco_48598
I
[ "is_palindrome", "closest_palindromes" ]
2
[ [ "closest_palindromes", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
029db6324d984fece4f3a3529e2a474903d0edd1
86d4b6eb7cc72c2550db0d90167f76f47062dd9d
v1.0
instruct
Taco
Taco_48607_I
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 descending order (the largest e...
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": "", "prompt_id": "00048607", "row_id": 48607, "seed_ids": "[2865]" }
0.745537
Taco_48607
I
[ "partition", "quickselect", "findKthLargest" ]
3
[ [ "findKthLargest", "quickselect" ], [ "quickselect", "partition" ] ]
2
[]
false
[]
false
pytest
false
[]
true
6ab462589d26677bd626cd6a2065d5e6d15acf90
ee190281e7da8e63ebd30fd9c2852cbabe8b12a8
v1.0
instruct
Taco
Taco_48633_I
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. Example 1: Input: N = 13 Output: YES Explanation: 13 is a prime number and its reverse, 31, is also a prime number. Therefore, 13 ...
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": "", "prompt_id": "00048633", "row_id": 48633, "seed_ids": "[9707]" }
0.625153
Taco_48633
I
[ "is_prime", "isEmirp" ]
2
[ [ "isEmirp", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fb0ef692aa6dbfed9d46b389e6a8244a3679eed5
f8e1ba77e14f4937ecaceac7db129c0280eab1ad
v1.0
instruct
Taco
Taco_48697_I
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 exact center. Each friend has a st...
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": "", "prompt_id": "00048697", "row_id": 48697, "seed_ids": "[1378]" }
0.666128
Taco_48697
I
[ "closest_friend_index", "find_closest_friend" ]
2
[ [ "find_closest_friend", "closest_friend_index" ] ]
1
[]
false
[]
false
pytest
true
[]
true
14ce009fdf5e403550dee030501a2b96f5043f6d
895d53bff7b4a2183efb3ce56b3de05f0725aea8
v1.0
instruct
Taco
Taco_48706_I
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 courses should be taken to finish ...
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": "", "prompt_id": "00048706", "row_id": 48706, "seed_ids": "[790]" }
0.587557
Taco_48706
I
[ "find_course_order", "solve" ]
2
[ [ "solve", "find_course_order" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cd5365e8a2283ab946916468d8e3c768b5263cd4
64ec74834f74676d6f3bce682c3b32376f141605
v1.0
instruct
Taco
Taco_48796_I
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. The matrix is represented as a list of lists. Each element of the matrix can be either 0 or 1. For example, in the matrix: \[ \begin{matrix} 1 & 0 & 1 & 0 ...
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": "", "prompt_id": "00048796", "row_id": 48796, "seed_ids": "[18448]" }
0.752213
Taco_48796
I
[ "maximal_rectangle", "largest_rectangle_area" ]
2
[ [ "maximal_rectangle", "largest_rectangle_area" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d1d42c2689fd8a5a238594d6fcc6588c3c4ddd8d
95068d8d147e52f2317d3996254fe9e93708bf5d
v1.0
instruct
Taco
Taco_48859_I
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: - A string 'a' can defeat string 'b' in a round if and only if 'a' is a subsequence of 'b'. - The game consists of multiple rounds, with players submitting their strings ...
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": "", "prompt_id": "00048859", "row_id": 48859, "seed_ids": "[16136]" }
0.772666
Taco_48859
I
[ "is_subsequence", "max_wins_in_game" ]
2
[ [ "max_wins_in_game", "is_subsequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
502e939a75720eb96808ce5bf699840bf6e52333
9817870e18366e40296cea1ce3e1761dae629a17
v1.0
instruct
Taco
Taco_48901_I
Bob is exploring the concept of prime factorization and he stumbled upon an interesting problem. He has a natural number N and he wants to break it down into its constituent prime factors, but not just that, he is interested in using these prime factors to answer Q queries. Each query consists of a type identifier T a...
import math from collections import Counter def prime_factors(n): """Return a dictionary with prime factors as keys and their powers as values.""" i = 2 factors = {} while i * i <= n: while (n % i) == 0: if i in factors: factors[i] += 1 else: ...
def test_prime_factors(): assert prime_factors(1000) == {2: 3, 5: 3} assert prime_factors(50) == {2: 1, 5: 2} assert prime_factors(13) == {13: 1} assert prime_factors(1) == {} def test_get_smallest_prime_greater_equal(): assert get_smallest_prime_greater_equal(1000, 3) == 5 assert get_smallest_...
[ { "docstring": "Return a dictionary with prime factors as keys and their powers as values.", "function_declaration": "def prime_factors(n):", "function_name": "prime_factors", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def get_smallest_prime_greater_equal(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 prime_factors(n):\n \"\"\"Helper function to find the prime factors of a number n along with their highest power in n.\"\"\"\n factors = {}\n d = 2\n ...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00048901", "row_id": 48901, "seed_ids": "[18219]" }
0.643589
Taco_48901
I
[ "prime_factors", "get_smallest_prime_greater_equal", "handle_queries" ]
3
[ [ "handle_queries", "get_smallest_prime_greater_equal" ], [ "handle_queries", "prime_factors" ] ]
2
[ "handle_queries" ]
false
[]
false
pytest
true
[]
true
081a3300103fd0257518fdef4e3b4c0bc8b2f906
03046f878da90c5e666401672e41e0eddc17022e
v1.0
instruct
Taco
Taco_48973_I
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? Input The first line contains one integer n (1 ≤ n ≤ 200000) — t...
def merge_and_count(arr, temp_arr, left, mid, right): i = left # Starting index for left subarray j = mid + 1 # Starting index for right subarray k = left # Starting index to be sorted inv_count = 0 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": "", "prompt_id": "00048973", "row_id": 48973, "seed_ids": "[6878]" }
0.703385
Taco_48973
I
[ "merge_and_count", "merge_sort_and_count", "minimum_swaps_to_sort" ]
3
[ [ "merge_sort_and_count", "merge_and_count" ], [ "minimum_swaps_to_sort", "merge_sort_and_count" ] ]
2
[]
false
[]
false
pytest
false
[]
true
982e84a8f54966666f9f9652ce8d2fe0c6d56b23
f06f2766f981ff2a098b2b3e8fbc2a1669e8aea8
v1.0
instruct
Taco
Taco_48975_I
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 display them on shelves. Howev...
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": "", "prompt_id": "00048975", "row_id": 48975, "seed_ids": "[2014]" }
0.67382
Taco_48975
I
[ "digit_sum", "organize_books_by_digit_sum" ]
2
[ [ "organize_books_by_digit_sum", "digit_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5c5b7c482d8e53ba21e9b9a45766424291fea694
6e4b38a2889be5fcee60f39b657cdd6a66e42731
v1.0
instruct
Taco
Taco_49001_I
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. Limak starts with an initial card. Each move consists of either increasing the card value by a number \( k \) (where \( k \) is in the range of [1, 10]...
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": "", "prompt_id": "00049001", "row_id": 49001, "seed_ids": "[11236]" }
0.589907
Taco_49001
I
[ "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
85df3a270fd5c49cca75a7c223e129fed8b07f04
97bda78988dd988376ad8a7e25b2eb60fc736625
v1.0
instruct
Taco
Taco_49102_I
Alice is conducting a survey and has a notebook with N pages, where each page contains a list of unique survey responses represented by integers. She wants to combine all the responses into a single final list, but while combining, she needs to ensure that the combined list maintains non-decreasing order. Each page's r...
import heapq def merge_sorted_responses(pages): """ Merges a list of sorted lists into a single sorted list. :param pages: List of sorted lists :return: A single sorted list with all elements from all input lists """ min_heap = [] result = [] # Initialize the min_heap with the...
from solution import merge_pages_input def test_merge_pages_input_single_page(): assert merge_pages_input(1, ["3 1 2 3"]) == [1, 2, 3] def test_merge_pages_input_multiple_pages(): assert merge_pages_input(3, ["3 10 20 30", "4 5 7 25 29", "2 1 100"]) == [1, 5, 7, 10, 20, 25, 29, 30, 100] def test_merge_pages_...
[ { "docstring": "Merges a list of sorted lists into a single sorted list.\n\n:param pages: List of sorted lists\n:return: A single sorted list with all elements from all input lists", "function_declaration": "def merge_sorted_responses(pages):", "function_name": "merge_sorted_responses", "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\n\ndef merge_responses(N, pages):\n \"\"\"\n Merges multiple sorted lists into a single sorted list.\n \n Args:\n N : int : the number ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00049102", "row_id": 49102, "seed_ids": "[208]" }
0.612808
Taco_49102
I
[ "merge_sorted_responses", "merge_pages_input" ]
2
[ [ "merge_pages_input", "merge_sorted_responses" ] ]
1
[]
false
[]
false
pytest
true
[]
true
82b721b6f9e9d07fc861f0336cb58db24f9f19e0
5922968901b98c83524ae31b3a76e9f9b234f40e
v1.0
instruct
Taco
Taco_49104_I
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 distance between any two sky...
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": "", "prompt_id": "00049104", "row_id": 49104, "seed_ids": "[13982]" }
0.701876
Taco_49104
I
[ "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
000569ee7468ff3f1636ff3d6b804bf8480ec73e
f648d9077c817122e138fc6dba2f93d87decd7d5
v1.0
instruct
Taco
Taco_49145_I
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 movements are: 1. Translation, d...
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": "", "prompt_id": "00049145", "row_id": 49145, "seed_ids": "[5118]" }
0.676053
Taco_49145
I
[ "apply_movement_seq", "island_treasures" ]
2
[ [ "island_treasures", "apply_movement_seq" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a242f93df6e8071871ac625768af0e20904a64bf
6b2f51fbc7d2d803e65ce8f10988844c11ae12fd
v1.0
instruct
Taco
Taco_49180_I
Problem Statement Anay 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: Given a sequence A, consider all the non-empty subsequences ...
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": "", "prompt_id": "00049180", "row_id": 49180, "seed_ids": "[1170]" }
0.772254
Taco_49180
I
[ "greatest_sum_of_subsequences", "solve", "execute_problem_statements" ]
3
[ [ "execute_problem_statements", "solve" ], [ "solve", "greatest_sum_of_subsequences" ] ]
2
[]
false
[]
false
pytest
true
[]
true
91859c6a49a6c2ce72afc9bccb53ab1e1e18a7da
0686624e6bd4fe58a207cc45b0683e0855cadc4a
v1.0
instruct
Taco
Taco_49185_I
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. To achieve this, they propose to build additional roads to ensure the village forms ...
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": "", "prompt_id": "00049185", "row_id": 49185, "seed_ids": "[17450]" }
0.72878
Taco_49185
I
[ "find", "union", "min_additional_roads" ]
3
[ [ "min_additional_roads", "find" ], [ "min_additional_roads", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
e6c69a43a6911e8b0f71a4c66ccd6694380609c0
eeb8fc0e276b0739887143cdc5a7296656d9ef07
v1.0
instruct
Taco
Taco_49254_I
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. The king loves prime numbers and wants to kno...
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": "", "prompt_id": "00049254", "row_id": 49254, "seed_ids": "[1497]" }
0.606299
Taco_49254
I
[ "sieve_of_eratosthenes", "prime_performances" ]
2
[ [ "prime_performances", "sieve_of_eratosthenes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bf94bec9c9042e8dd8616af89b8d7bcffb21b714
828c8538d9212fca52678d5ca6e3ffb7abdadf6e
v1.0
instruct
Taco
Taco_49304_I
# Least Common Multiple of Array Calculate 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` with **`LCM(a, b)`**. ___ # ...
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": "", "prompt_id": "00049304", "row_id": 49304, "seed_ids": "[9938]" }
0.697268
Taco_49304
I
[ "lcm", "lcm_of_array" ]
2
[ [ "lcm_of_array", "lcm" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8bf791125db93b9a24a62841c209abbb0a44aa07
486a1bfcb9f4dd3d1b0d1d595238c583502d592f
v1.0
instruct
Taco
Taco_49414_I
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 elements of A. An increasing subseq...
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": "", "prompt_id": "00049414", "row_id": 49414, "seed_ids": "[22713]" }
0.839409
Taco_49414
I
[ "longest_increasing_subsequence_length", "solve", "parse_input" ]
3
[ [ "solve", "longest_increasing_subsequence_length" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
20507ef61c6b1d7675d605a8bba3a2f874aeff43
e52e1433d88f4683db579fc344d8661ce30a1a65
v1.0
instruct
Taco
Taco_49447_I
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. Input: 1st line contains an integer n, denoting the number of elements in the array. 2nd line contains n space-separated int...
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": "", "prompt_id": "00049447", "row_id": 49447, "seed_ids": "[21332]" }
0.773179
Taco_49447
I
[ "subarray_sum", "count_subarrays_with_sum" ]
2
[ [ "count_subarrays_with_sum", "subarray_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5315b76d92d737b9650be2ab5a110444d086d577
4942007a4ffa4afc6ddd526bff13b2ab3fa4ff9e
v1.0
instruct
Taco
Taco_49454_I
You are given an array of n positive integers. You need to process q queries, where each query gives two numbers: l and r. For each query, you need to return the sum of the divisors of all the numbers in the segment of the array from index l to r (both inclusive). -----Input----- The first line contains two integers ...
import math def sum_of_divisors(n): total = 0 for i in range(1, int(math.sqrt(n)) + 1): if n % i == 0: total += i if i != n // i: total += n // i return total def preprocess(array): """ Preprocess the array to calculate the sum of divisors for each e...
def test_sum_of_divisors(): assert sum_of_divisors(1) == 1 assert sum_of_divisors(2) == 3 assert sum_of_divisors(3) == 4 assert sum_of_divisors(4) == 7 assert sum_of_divisors(5) == 6 def test_preprocess(): array = [1, 2, 3, 4, 5] assert preprocess(array) == [1, 3, 4, 7, 6] def test_prefix_...
[ { "docstring": null, "function_declaration": "def sum_of_divisors(n):", "function_name": "sum_of_divisors", "parameter_list": "(n)" }, { "docstring": "Preprocess the array to calculate the sum of divisors for each element.", "function_declaration": "def preprocess(array):", "function...
[ 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 sum_of_divisors_of_number(n):\n \"\"\"\n Returns the sum of all divisors of a given number.\n \"\"\"\n divisors_sum = 0\n for i in range(1, int(...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00049454", "row_id": 49454, "seed_ids": "[9425]" }
0.677876
Taco_49454
I
[ "sum_of_divisors", "preprocess", "prefix_sums", "query", "solve" ]
5
[ [ "preprocess", "sum_of_divisors" ], [ "solve", "prefix_sums" ], [ "solve", "preprocess" ], [ "solve", "query" ] ]
4
[]
false
[]
false
pytest
false
[]
true
85b50f65644ab82ecf1b08e6f1191f1377a9b261
fde4578a40cd54708ae0716b02ca94f43efe83e9
v1.0
instruct
Taco
Taco_49487_I
Implement a function to filter an array of integers, only keeping the prime numbers. The function should meet these requirements: + Accepts an array of positive integers as its parameter (example: `[4, 6, 7, 9, 10, 13]`) + Returns a new array containing only the prime numbers from the input array. **Note:** + A pri...
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": "", "prompt_id": "00049487", "row_id": 49487, "seed_ids": "[19512]" }
0.624537
Taco_49487
I
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
06d7e45be5e09327852176ab9d0983b5c295c2a8
742b98b0276d7962f33ed34b36e39b27dfb2060e
v1.0
instruct
Taco
Taco_49512_I
A group of friends has planned a movie marathon for the weekend. They want to watch multiple movies back-to-back without taking long breaks between them. Given the duration of each movie in minutes, you need to calculate the total time in hours and minutes they will spend watching the movies. ------ Input Format -----...
def movie_marathon_durations(test_cases): results = [] for case in test_cases: n, durations = case total_minutes = sum(durations) hours = total_minutes // 60 minutes = total_minutes % 60 results.append(f"{hours} hours and {minutes} minutes") return results def parse_...
def test_movie_marathon_durations(): # Sample input 1 input_string = "2\n3\n120\n150\n90\n2\n180\n135" expected_output = ["6 hours and 0 minutes", "5 hours and 15 minutes"] assert solve_movie_marathon(input_string) == expected_output def test_single_movie(): # Single movie of 120 minutes (2 hours) ...
[ { "docstring": null, "function_declaration": "def movie_marathon_durations(test_cases):", "function_name": "movie_marathon_durations", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_string):", "function_name": "parse_input", ...
[ 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 movie_marathon_durations(test_cases):\n results = []\n for case in test_cases:\n n, durations = case\n total_minutes = sum(durations)\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00049512", "row_id": 49512, "seed_ids": "[2901]" }
0.654244
Taco_49512
I
[ "movie_marathon_durations", "parse_input", "solve_movie_marathon" ]
3
[ [ "solve_movie_marathon", "movie_marathon_durations" ], [ "solve_movie_marathon", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
7ad15562a15099c7f71d58deaa658d7146904e59
b1a89d069a83300dea1a91782ba0b9f3a43d77f8
v1.0
instruct
Taco
Taco_49521_I
You are given a grid of size $N \times M$, filled with numbers. Your task is to find the largest rectangle containing only $1$s in the grid and return its area. ------ Input ------ The first line contains two integers, $N$ and $M$, denoting the number of rows and columns of the grid. Each of the next $N$ lines contai...
def maximalRectangle(matrix): if not matrix: return 0 n, m = len(matrix), len(matrix[0]) max_area = 0 heights = [0] * (m + 1) for row in range(n): for col in range(m): if matrix[row][col] == 1: heights[col] += 1 else: ...
from solution import find_largest_rectangle_area def test_sample_input_1(): input_list = [4, 4, [1, 1, 0, 1], [1, 1, 1, 1], [1, 1, 1, 0], [0, 1, 0, 0]] expected_output = 6 assert find_largest_rectangle_area(input_list) == expected_...
[ { "docstring": null, "function_declaration": "def maximalRectangle(matrix):", "function_name": "maximalRectangle", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def find_largest_rectangle_area(input_list):", "function_name": "find_largest_rectangle_are...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def maximalRectangle(matrix):\n if not matrix:\n return 0\n \n n, m = len(matrix), len(matrix[0])\n max_area = 0\n heights = [0] * (m + 1...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00049521", "row_id": 49521, "seed_ids": "[1443]" }
0.776313
Taco_49521
I
[ "maximalRectangle", "find_largest_rectangle_area" ]
2
[ [ "find_largest_rectangle_area", "maximalRectangle" ] ]
1
[]
false
[]
false
pytest
true
[]
true
defbf107a9ac874bd5a91bc97224feba8fcf5866
0be8be20fe99b5372ef36eb094d0db4295dd1652
v1.0
instruct
Taco
Taco_49562_I
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 format: Input Format: The first ...
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": "", "prompt_id": "00049562", "row_id": 49562, "seed_ids": "[89]" }
0.703267
Taco_49562
I
[ "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
06f35ea924413947fc8f8d3c1f7b2acf7e8def13
8bf73f893a8826c34b3fd9734f9265d1e5634738
v1.0
instruct
Taco
Taco_49639_I
Develop a program to identify the common prime factors of two given numbers. INPUT: The first line contains the number of test cases t. For each test case, there are two space-separated integers, a and b. OUTPUT: For each test case, output the common prime factors of the two numbers as a space-separated string. If ...
def gcd(a, b): while b != 0: a, b = b, a % b return a def prime_factors(n): i = 2 factors = set() while i * i <= n: if n % i: i += 1 else: n //= i factors.add(i) if n > 1: factors.add(n) return factors def common_prime_fac...
def test_gcd(): assert gcd(28, 35) == 7 assert gcd(15, 25) == 5 assert gcd(100, 10) == 10 assert gcd(17, 19) == 1 def test_prime_factors(): assert prime_factors(28) == {2, 7} assert prime_factors(35) == {5, 7} assert prime_factors(15) == {3, 5} assert prime_factors(25) == {5} def test_...
[ { "docstring": null, "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": null, "function_declaration": "def prime_factors(n):", "function_name": "prime_factors", "parameter_list": "(n)" }, { "docstring": null, ...
[ 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 common_prime_factors(a, b):\n def prime_factors(n):\n i = 2\n factors = set()\n while i * i <= n:\n if n % i:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00049639", "row_id": 49639, "seed_ids": "[977]" }
0.611315
Taco_49639
I
[ "gcd", "prime_factors", "common_prime_factors", "main" ]
4
[ [ "common_prime_factors", "gcd" ], [ "common_prime_factors", "prime_factors" ] ]
2
[]
false
[]
false
pytest
false
[]
true
998d99446d4dc554bef6490dc6d1a3ddc1a4bd8e
5d43d78367af094f51e3cbcd367ca908f7869919
v1.0
instruct
Taco
Taco_49678_I
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. ### Input - The first line ...
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": "", "prompt_id": "00049678", "row_id": 49678, "seed_ids": "[8843]" }
0.738111
Taco_49678
I
[ "is_palindrome", "find_path", "solve", "parse_input", "main" ]
5
[ [ "find_path", "is_palindrome" ], [ "solve", "find_path" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
62e65fac3aecf3747c41e3515d48a0418a56b0dd
22e155d136123016e07a563323744442b769d65f
v1.0
instruct
Taco
Taco_49693_I
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 square tile must be a factor of...
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": "", "prompt_id": "00049693", "row_id": 49693, "seed_ids": "[1448]" }
0.679334
Taco_49693
I
[ "gcd", "maxSquareTiles" ]
2
[ [ "maxSquareTiles", "gcd" ] ]
1
[]
false
[]
false
pytest
true
[]
true
adbcb603c538c47be67108ac4d6613e21f8cd2d1
b3bf8a4535098eaf37739003157f94971bf14ca4
v1.0
instruct
Taco
Taco_49710_I
Determine if a Binary Tree is Balanced Given 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. ### Input The input is a list of space-separated integers representing the nodes of a binary tree in lev...
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": "", "prompt_id": "00049710", "row_id": 49710, "seed_ids": "[21725]" }
0.812523
Taco_49710
I
[ "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
7053a7991b6b9bc0d5e85faa8b2f71ae7c0442f0
32b0587edd8e01d425ae74aacf689023ef336f6b
v1.0
instruct
Taco
Taco_49717_I
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 minimum time required to connect a...
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": "", "prompt_id": "00049717", "row_id": 49717, "seed_ids": "[9013]" }
0.712589
Taco_49717
I
[ "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
b00dc7ee0c4daec8604a8161256f09e4beec4a37
3c90384ae706d630d0635673ab124615df18be1e
v1.0
instruct
Taco
Taco_49722_I
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 can only move right or down fro...
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": "", "prompt_id": "00049722", "row_id": 49722, "seed_ids": "[22978]" }
0.700902
Taco_49722
I
[ "can_reach_end", "can_crowley_escape", "parse_input", "main" ]
4
[ [ "can_crowley_escape", "can_reach_end" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
294a83b6e10478a5a9dd80b2533720ad638bca66
35e8660bbdf921caac6a209624da8dea52352c9e
v1.0
instruct
Taco
Taco_49754_I
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 to lowercase, the original cas...
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": "", "prompt_id": "00049754", "row_id": 49754, "seed_ids": "[5427]" }
0.608222
Taco_49754
I
[ "sort_books", "organize_library" ]
2
[ [ "organize_library", "sort_books" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c0326a5f889036cf1b0fcd07330ad504547a7558
520f2888f0c8758eb6e6512a2d85c4fa6a09d164
v1.0
instruct
Taco
Taco_49766_I
Given a positive integer N, write a program to determine whether the sum of the digits of N is a prime number. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Example 1: Input: N = 47 Output: True Explanation: The sum of the digits 4 + 7 = 11, and 11 is a prime...
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": "", "prompt_id": "00049766", "row_id": 49766, "seed_ids": "[12650]" }
0.675167
Taco_49766
I
[ "is_prime", "isSumPrime" ]
2
[ [ "isSumPrime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
94987a08b9ae866cd6c7ace31610f1f18fb5a778
1957d9209f3284518b25ba231238588cf35f044a
v1.0
instruct
Taco
Taco_49978_I
Create a 2048 game solver in Python. ## The Game 2048 is a single-player sliding block puzzle game. The objective is to slide numbered tiles on a grid to combine them and create a tile with the number 2048. The game is played on a 4×4 grid, with tiles numbered in powers of 2 that merge when they touch a tile with th...
import random from typing import List def evaluate_grid(grid): eval_score = 0 for row in grid: eval_score += sum(row) return eval_score def slide_left(grid): out_grid = [] for row in grid: new_row = [num for num in row if num != 0] new_row += [0] * (len(row) - len(new_row))...
from solution import best_move def test_scenario1(): grid = [ [2, 4, 2, 0], [2, 0, 4, 2], [8, 16, 32, 0], [1024, 1024, 64, 0] ] assert best_move(grid) in ['up', 'down', 'left', 'right'] def test_scenario2(): grid = [ [0, 0, 2, 2], [2, 2, 2, 2], [...
[ { "docstring": null, "function_declaration": "def evaluate_grid(grid):", "function_name": "evaluate_grid", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def slide_left(grid):", "function_name": "slide_left", "parameter_list": "(grid)" }, { "d...
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from typing import List\nimport copy\nimport random\n\ndef best_move(grid: List[List[int]]) -> str:\n def merge_left(board):\n new_board = []\n fo...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00049978", "row_id": 49978, "seed_ids": "[4243]" }
0.637053
Taco_49978
I
[ "evaluate_grid", "slide_left", "merge_left", "move_left", "move_right", "move_up", "move_down", "generate_successors", "best_move" ]
9
[ [ "best_move", "evaluate_grid" ], [ "best_move", "generate_successors" ], [ "generate_successors", "move_down" ], [ "generate_successors", "move_left" ], [ "generate_successors", "move_right" ], [ "generate_successors", "move_up" ], [ "move...
11
[]
false
[]
false
pytest
true
[]
true
24e31424738666f6f765fdb86866f68ccd063038
5d946028fc1c4aad3c546b5fca015ad0cfeea9bb
v1.0
instruct
Taco
Taco_50045_I
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 where the teacher had written...
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": "", "prompt_id": "00050045", "row_id": 50045, "seed_ids": "[3909]" }
0.736686
Taco_50045
I
[ "count_valid_ap", "is_arithmetic_progression" ]
2
[ [ "count_valid_ap", "is_arithmetic_progression" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c4058d395524d49fca5b65d6cad3689a5bd28a81
d09e6568fe2a617abc12734e111ff177e0af6740
v1.0
instruct
Taco
Taco_50145_I
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 at depth `d` in the tree. Th...
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": "", "prompt_id": "00050145", "row_id": 50145, "seed_ids": "[5075]" }
0.571336
Taco_50145
I
[ "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
8e100682709b8466f2cb2b60b3cc094944285727
cd6b406b7f5ca028df96771495cd038f6531c9ec
v1.0
instruct
Taco
Taco_50167_I
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: - The `matrix` is a 2D list consisting of 0s and 1s. - 0 represents a walkable path, and 1 represents a...
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": "", "prompt_id": "00050167", "row_id": 50167, "seed_ids": "[19329]" }
0.730986
Taco_50167
I
[ "is_valid_move", "find_path" ]
2
[ [ "find_path", "is_valid_move" ] ]
1
[]
false
[]
false
pytest
true
[]
true
19a5c8ad750672035e5741879124bedf35078239
2eed3b586fcf8224636df8bfe1dbb94239364901
v1.0
instruct
Taco
Taco_50199_I
You are given a string consisting of digits from '0' to '9' and characters 'a' to 'f'. Each digit can be interpreted as is, and each character from 'a' to 'f' corresponds to a hexadecimal digit (10, 11, 12, 13, 14, 15). Your task is to convert the string into an integer and determine whether the resultant integer is a ...
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 hex_string_prime(s): num = int(s, 16) ...
def test_hex_string_prime_prime(): assert hex_string_prime("11") == "Prime" assert hex_string_prime("2b") == "Prime" assert hex_string_prime("7") == "Prime" def test_hex_string_prime_not_prime(): assert hex_string_prime("2a") == "Not Prime" assert hex_string_prime("10") == "Not Prime" assert he...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def hex_string_prime(s):", "function_name": "hex_string_prime", "parameter_list": "(s)" } ]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00050199", "row_id": 50199, "seed_ids": "[4503]" }
0.755067
Taco_50199
I
[ "is_prime", "hex_string_prime" ]
2
[ [ "hex_string_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
false
[]
true
0b803abd9fed7bd1c9f8aba559258f801ac6a855
684a6902b56ae3a5a7397d888ae5b21770522ccb
v1.0
instruct
Taco
Taco_50247_I
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. Function Signature: ```python def sum_of_primes(numbers: List[int]) -> int: pass ``` Input: - A list of...
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": "", "prompt_id": "00050247", "row_id": 50247, "seed_ids": "[23653]" }
0.664786
Taco_50247
I
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ba8ba6b873a4239b80492a015721d6bc122feccc
bb1f02048756cec53f4e7f1aa4755ce0af19b8d6
v1.0
instruct
Taco
Taco_50264_I
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' for mountains. Anastasia wan...
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": "", "prompt_id": "00050264", "row_id": 50264, "seed_ids": "[20362]" }
0.644993
Taco_50264
I
[ "maxForestArea", "largestRectangleArea" ]
2
[ [ "maxForestArea", "largestRectangleArea" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cac565a644db65fa70c85c41a976513b2c78b787
1a424cd93b3623e37a5f055636a0575fe139aa19
v1.0
instruct
Taco
Taco_50279_I
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. A string is called a palindromic string if it reads the s...
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": "", "prompt_id": "00050279", "row_id": 50279, "seed_ids": "[11158]" }
0.696129
Taco_50279
I
[ "is_promotable", "segment_book_titles" ]
2
[ [ "segment_book_titles", "is_promotable" ] ]
1
[]
false
[]
false
pytest
false
[]
true
b210d87c88724db565b76b807f89df6e5b383acf
c13511f37d4fd65e1ff35b40a5e3805a44b52cc6
v1.0
instruct
Taco
Taco_50308_I
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 characters. To ensure the message...
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": "", "prompt_id": "00050308", "row_id": 50308, "seed_ids": "[5543]" }
0.6896
Taco_50308
I
[ "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
053228cbbbb9b00b5cb0caed6a6c0e01209ab919
9cfaee0ab02fb3a64fb2319f233343d6b6c4744a
v1.0
instruct
Taco
Taco_50313_I
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 the edge are in the same set. ...
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": "", "prompt_id": "00050313", "row_id": 50313, "seed_ids": "[9633]" }
0.657268
Taco_50313
I
[ "is_bipartite", "partition_graph" ]
2
[ [ "partition_graph", "is_bipartite" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c21ddf1467596fa4dd75b57f59e0bc13335f624e
119a52fa7e04f18b7a38d3f926ae3252e772ab3c
v1.0
instruct
Taco
Taco_50503_I
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, output the sum of the specified...
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": "", "prompt_id": "00050503", "row_id": 50503, "seed_ids": "[4062]" }
0.655371
Taco_50503
I
[ "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
2ac04898ef1460e7b502db9133b22dbfded8a780
37f1a7c4fcc11ff6afb5a64bc90bf995c8d17ffd
v1.0
instruct
Taco
Taco_50525_I
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 elements between two given indices....
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": "", "prompt_id": "00050525", "row_id": 50525, "seed_ids": "[24726]" }
0.635447
Taco_50525
I
[ "preprocess_array", "range_sum", "process_queries" ]
3
[ [ "process_queries", "preprocess_array" ], [ "process_queries", "range_sum" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
false
[]
true
4f1604f9d0db6158d1a6d563f2b5593337f5ad9d
93750738ec6379bddee5546273a794e7d8d0cca2
v1.0
instruct
Taco
Taco_50556_I
-----Task----- Write 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: 1. Every opening parenthesis '(', bracket '[', or brace '{' has a corresponding closing parenthesis...
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": "", "prompt_id": "00050556", "row_id": 50556, "seed_ids": "[6545]" }
0.745536
Taco_50556
I
[ "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
0d8f74b72847710d45b95d25657b4e38fed17345
116ba29b29be26181bc51497375c500beef4f782
v1.0
instruct
Taco
Taco_50558_I
You are given a linked list containing unique integers. Your task is to determine if this linked list is a circular linked list. A circular linked list is one where the last node points back to any previous node in the list. Input: - The first line contains an integer T, the number of test cases. - For each test case,...
class ListNode: def __init__(self, val=0): self.val = val self.next = None def is_circular_linked_list(head): """ Function to check if the linked list is circular. """ if not head or not head.next: return False slow, fast = head, head.next while fast and fast.ne...
from solution import build_linked_list, is_circular_linked_list def test_non_circular_list(): head = build_linked_list([1, 2, 3]) assert not is_circular_linked_list(head), "Test case failed for non-circular list [1, 2, 3]" def test_circular_list(): head = build_linked_list([10, 20, 30, 40], circular_index...
[]
[ 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 ListNode:\n def __init__(self, value):\n self.value = value\n self.next = None\n\ndef is_circular(head):\n if not head or not head.next:\...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00050558", "row_id": 50558, "seed_ids": "[2868]" }
0.546299
Taco_50558
I
[ "is_circular_linked_list", "parse_input", "build_linked_list", "process_input" ]
4
[ [ "parse_input", "is_circular_linked_list" ], [ "process_input", "build_linked_list" ], [ "process_input", "parse_input" ] ]
3
[ "parse_input", "process_input" ]
false
[ "ListNode" ]
true
pytest
true
[]
true
9d1a804c5eb6f59710e68fbaceda32e19544d60b
e7bb84c94d7f20109546460a72e4db02b40a7166
v1.0
instruct
Taco
Taco_50586_I
A number is called Palprime if it is both a palindrome and a prime number. Given a number N, check whether it is a Palprime or not. Example 1: Input: N = 131 Output: 1 Explanation: 131 is a prime number and also a palindrome. Thus 131 is a Palprime and so, the answer is 1. Example 2: Input: N = 37 Output: 0 Explanation...
def is_palindrome(n): """ Helper function to check if a number is a palindrome. """ return str(n) == str(n)[::-1] def is_prime(n): """ Helper function to check if a number is a prime number. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % ...
from solution import is_palindrome, is_prime, isPalprime def test_is_palindrome(): assert is_palindrome(131) == True assert is_palindrome(123) == False assert is_palindrome(1) == True assert is_palindrome(22) == True assert is_palindrome(10) == False def test_is_prime(): assert is_prime(2) == ...
[ { "docstring": "Helper function to check if a number is a palindrome.", "function_declaration": "def is_palindrome(n):", "function_name": "is_palindrome", "parameter_list": "(n)" }, { "docstring": "Helper function to check if a number is a prime number.", "function_declaration": "def is_...
[ 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_palindrome(n):\n \"\"\"\n Helper function to check if a number is a palindrome.\n \"\"\"\n return str(n) == str(n)[::-1]\n\ndef is_prime(n):\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00050586", "row_id": 50586, "seed_ids": "[2544]" }
0.635336
Taco_50586
I
[ "is_palindrome", "is_prime", "isPalprime" ]
3
[ [ "isPalprime", "is_palindrome" ], [ "isPalprime", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
1d3a582821e7fa3f1cee6941aa1fd7915cd15b37
450e749fbbd23547e14cbc217d15642033ac93e3
v1.0
instruct
Taco
Taco_50629_I
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 same. Input The first line...
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": "", "prompt_id": "00050629", "row_id": 50629, "seed_ids": "[8219]" }
0.644744
Taco_50629
I
[ "is_magic_square", "check_magic_square_in_array" ]
2
[ [ "check_magic_square_in_array", "is_magic_square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2ef684462ec8357c9d49e294677a0dfa32eb92b1
656a256a5464863939ec4dc1ff80e9a2a08a7cdb
v1.0
instruct
Taco
Taco_50688_I
Given a binary tree, return all root-to-leaf paths as a list of strings. A leaf is a node with no children. The binary tree is represented as follows: - Each node has a unique integer value. - The tree structure is given as a list of tuples, where each tuple contains two integer values representing a node and its chil...
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": "", "prompt_id": "00050688", "row_id": 50688, "seed_ids": "[3879]" }
0.543128
Taco_50688
I
[ "build_tree", "binaryTreePaths" ]
2
[ [ "binaryTreePaths", "build_tree" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
be42a0601fd9818f2bc97d74b11fbbf1e479ba5f
678d9fc138982b1e80408e8090eac2d1df9a7c05
v1.0
instruct
Taco
Taco_50706_I
Given a number n, check if it can be expressed as the sum of two prime numbers. -----Input:----- - N — the number to check for the prime sum representation. -----Output:----- - Print "YES" if the number can be expressed as the sum of two prime numbers. - Otherwise, print "NO". -----Constraints----- - $4 \leq N \leq...
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": "", "prompt_id": "00050706", "row_id": 50706, "seed_ids": "[476]" }
0.632649
Taco_50706
I
[ "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
bdc3c2318fd66a327076d1c9b984995a5aa28fd2
a7ca2d7c83c910b2ffe546e23639a2bc8351c114
v1.0
instruct
Taco
Taco_50715_I
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. Each train route incurs a maintenance cost per kilometer, which...
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": "", "prompt_id": "00050715", "row_id": 50715, "seed_ids": "[15999]" }
0.7646
Taco_50715
I
[ "find", "union", "min_maintenance_cost" ]
3
[ [ "min_maintenance_cost", "find" ], [ "min_maintenance_cost", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
fdba64b8d5376c119412414a9e6b261aa53c0b9d
935375368a286904497ba3e38af546ab5f24d099
v1.0
instruct
Taco
Taco_50750_I
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. Ex: Input: [10, 15, 3, 7, 18, 19] --> Output: [3, 7, 19] Ex: Input: [4, 6, 8, 9] --> O...
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": "", "prompt_id": "00050750", "row_id": 50750, "seed_ids": "[5908]" }
0.680735
Taco_50750
I
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4c0ec4e09b82fc861eb4764c6b178bf71b37fef9
2ffe65392858d7597a0362326d6afd5570b5da89
v1.0
instruct
Taco
Taco_50774_I
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. Input First line contains T (number of test cases). Next ...
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": "", "prompt_id": "00050774", "row_id": 50774, "seed_ids": "[12500]" }
0.771644
Taco_50774
I
[ "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
5ae0d1a5c0409a463b1c078945582fad908e6ba1
653731c65c21441d1bd49fe1e9d6802cd1f6008a
v1.0
instruct
Taco
Taco_50808_I
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 employee. An employee can only...
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": "", "prompt_id": "00050808", "row_id": 50808, "seed_ids": "[4303]" }
0.68904
Taco_50808
I
[ "is_feasible", "find_minimum_max_pages" ]
2
[ [ "find_minimum_max_pages", "is_feasible" ] ]
1
[]
false
[]
false
pytest
true
[]
true
69eeb156692fb08302f1d89135e00ae5c432089b
50a26e4417e681f92b1da06af86cf1a0d0d9ee9a
v1.0
instruct
Taco
Taco_50812_I
Alice has a collection of different colored marbles, and she loves to arrange them in patterns. She plans to create a spiral pattern on the floor, starting from the center and moving outwards in a clockwise direction. Each marble has a unique identifier (a positive integer). Given the sequence of identifiers of the mar...
def generate_spiral_pattern(n, marbles): grid = [[0]*n for _ in range(n)] top, bottom, left, right = 0, n-1, 0, n-1 direction = 0 # 0-right, 1-down, 2-left, 3-up index = 0 while top <= bottom and left <= right: if direction == 0: # Move right for i in range(left, right + 1...
from solution import generate_spiral_pattern, process_input_and_generate_output, format_output def test_generate_spiral_pattern_3x3(): marbles = [1, 2, 3, 4, 5, 6, 7, 8, 9] grid = generate_spiral_pattern(3, marbles) assert grid == [ [1, 2, 3], [8, 9, 4], [7, 6, 5] ] def test_ge...
[ { "docstring": null, "function_declaration": "def generate_spiral_pattern(n, marbles):", "function_name": "generate_spiral_pattern", "parameter_list": "(n, marbles)" }, { "docstring": null, "function_declaration": "def process_input_and_generate_output(test_cases):", "function_name":...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def generate_spiral_pattern(N, marbles):\n spiral = [[0] * N for _ in range(N)]\n directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] # right, down, left, up\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050812", "row_id": 50812, "seed_ids": "[16955]" }
0.619685
Taco_50812
I
[ "generate_spiral_pattern", "process_input_and_generate_output", "format_output" ]
3
[ [ "process_input_and_generate_output", "generate_spiral_pattern" ] ]
1
[ "format_output" ]
false
[]
false
pytest
true
[]
true
797badf188a4f925176995320c34af27de4eccbf
2c5e3f62055a8098cc242439d27daa539df66331
v1.0
instruct
Taco
Taco_50911_I
Uttu is fascinated by palindromes and often challenges Shil with different palindrome-related puzzles. Recently, Uttu introduced Shil to a new game involving strings and palindromes. Given a string, Shil needs to determine if it's possible to make the string a palindrome by removing at most one character. INPUT The f...
def is_palindrome(s, i, j): """ Helper function to check if the substring s[i:j+1] is a palindrome. """ while i < j: if s[i] != s[j]: return False i += 1 j -= 1 return True def can_be_made_palindrome(s): """ Function to check if the string s can be made a...
from solution import process_inputs def test_sample_inputs(): assert process_inputs(2, ['abca', 'abc']) == ["YES", "NO"] def test_single_character(): assert process_inputs(1, ['a']) == ["YES"] def test_two_character_palindrome(): assert process_inputs(1, ['aa']) == ["YES"] def test_two_character_non_pal...
[ { "docstring": "Helper function to check if the substring s[i:j+1] is a palindrome.", "function_declaration": "def is_palindrome(s, i, j):", "function_name": "is_palindrome", "parameter_list": "(s, i, j)" }, { "docstring": "Function to check if the string s can be made a palindrome by removi...
[ 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_almost_palindrome(s):\n \"\"\"\n Checks if the string s can be made a palindrome by removing at most one character.\n \"\"\"\n def is_palindrome...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00050911", "row_id": 50911, "seed_ids": "[8940]" }
0.811832
Taco_50911
I
[ "is_palindrome", "can_be_made_palindrome", "process_inputs" ]
3
[ [ "can_be_made_palindrome", "is_palindrome" ], [ "process_inputs", "can_be_made_palindrome" ] ]
2
[ "process_inputs" ]
false
[]
false
pytest
true
[]
true
5571ac320ac3d197b6467aeb7352e6885db063b6
39f06ec9e699a890e6c659bb024b963008cdcfbf
v1.0
instruct
Taco
Taco_50921_I
You are given a list of numbers. Your task is to identify all the prime numbers in the list and print them in ascending order. Input Format The first line will contain a single integer $\mathbf{N}$ which represents the number of elements in the list. The second line of input will contain space-separated integers. O...
def is_prime(n): """ Determines if a number is prime. """ if n <= 1: return False if n == 2: return True # 2 is the only even prime number if n % 2 == 0: return False # all other even numbers are not primes sqrt_n = int(n**0.5) + 1 for i in range(3, sqrt_n, 2):...
from solution import is_prime, find_primes_in_list, main def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(13) == True assert is_prime(15) == False assert is_prime(1) == False assert is_prime(29) == True def test_find_pri...
[ { "docstring": "Determines 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 found in the input list, sorted in ascending order.", "function_declaration": "def find_p...
[ 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 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...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00050921", "row_id": 50921, "seed_ids": "[6843]" }
0.634659
Taco_50921
I
[ "is_prime", "find_primes_in_list", "main" ]
3
[ [ "find_primes_in_list", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7c2c6377de4a974745279901172d39a85becbf85
ea7222c4da6692eacbe478ed592fd043a3dec1ef
v1.0
instruct
Taco
Taco_50980_I
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. Chef 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.). Chef has given his students...
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": "", "prompt_id": "00050980", "row_id": 50980, "seed_ids": "[15109]" }
0.621749
Taco_50980
I
[ "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
7d302ed89b31057d89d6d4998c3eae5f69c89af1
977692d8772c67eeef343ab0bb7069a6878c00f8
v1.0
instruct
Taco
Taco_51040_I
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 they are balanced. Help Alice ...
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": "", "prompt_id": "00051040", "row_id": 51040, "seed_ids": "[3473]" }
0.811254
Taco_51040
I
[ "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
57447c39f5f07ddf27d1018b4731a33197771635
f8acae2355f62ab007e96f8dd977d67bd47eca63
v1.0
instruct
Taco
Taco_51053_I
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.
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": "", "prompt_id": "00051053", "row_id": 51053, "seed_ids": "[4920]" }
0.662826
Taco_51053
I
[ "is_prime", "get_prime_numbers" ]
2
[ [ "get_prime_numbers", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2d9169c0a953080f5a6ece1c0e9a1e956e3142f7
88f5b132de32d00c12d075c79c30a815301a9f5a
v1.0
instruct
Taco
Taco_51083_I
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 cryptographic hash of the labels ...
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": "", "prompt_id": "00051083", "row_id": 51083, "seed_ids": "[14624]" }
0.620525
Taco_51083
I
[ "hash_func", "merkle_tree" ]
2
[ [ "merkle_tree", "hash_func" ] ]
1
[]
false
[]
false
pytest
true
[]
true
598afa3d2ee2fd162948f30c75abe39954eed86d
711ffa7f7a9a9404e4eb73bd0145233857948ab0
v1.0
instruct
Taco
Taco_51102_I
Given the following problem statement, generate the required output as specified. **Problem Statement:** There 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 network as a graph with junctions as no...
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": "", "prompt_id": "00051102", "row_id": 51102, "seed_ids": "[19842]" }
0.769548
Taco_51102
I
[ "dijkstra", "upgraded_min_travel_time" ]
2
[ [ "upgraded_min_travel_time", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f0ce9597d9fb520cf3ae9ecff54e0c2f7a038c57
a17a45a6898db89ec5897fb0f84c8c2ee1837454
v1.0
instruct
Taco
Taco_51111_I
A robot is placed on a 2D grid at position (0, 0). The grid has n rows and m columns (1 ≤ n, m ≤ 1000). The robot can move to any of four directions: up, down, left, and right. However, some cells in the grid are considered dangerous and the robot cannot step on them. Determine the number of distinct paths the robot ...
def number_of_paths(n, m, k, dangerous_cells): MOD = 1000000007 dp = [[0] * m for _ in range(n)] if (0, 0) in dangerous_cells: return 0 dp[0][0] = 1 for i in range(n): for j in range(m): if (i, j) in dangerous_cells: dp[i][j] = 0 else: ...
def test_number_of_paths_case1(): assert number_of_paths(3, 3, 1, {(1, 1)}) == 2 def test_number_of_paths_case2(): assert number_of_paths(4, 4, 2, {(1, 1), (2, 2)}) == 4 def test_number_of_paths_case3(): assert number_of_paths(2, 2, 0, set()) == 2 def test_number_of_paths_no_path(): assert number...
[ { "docstring": null, "function_declaration": "def number_of_paths(n, m, k, dangerous_cells):", "function_name": "number_of_paths", "parameter_list": "(n, m, k, dangerous_cells)" }, { "docstring": null, "function_declaration": "def solve():", "function_name": "solve", "parameter_l...
[ 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": "MOD = 1000000007\n\ndef num_paths(n, m, k, dangers):\n # Initialize DP table with 0s\n dp = [[0] * m for _ in range(n)]\n\n # Mark dangerous cells in the ...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00051111", "row_id": 51111, "seed_ids": "[22866]" }
0.793601
Taco_51111
I
[ "number_of_paths", "solve" ]
2
[ [ "solve", "number_of_paths" ] ]
1
[]
false
[]
false
pytest
false
[]
true
14831af33000d8792ab74ee51f3eec01c041834d
f2d556e24e3147d10ff91ed94dd4f02221650d77
v1.0
instruct
Taco
Taco_51137_I
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 minimized. The villages' chief decid...
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": "", "prompt_id": "00051137", "row_id": 51137, "seed_ids": "[12672]" }
0.753632
Taco_51137
I
[ "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
c8492c5d17d946660a984b208557409bd57bf1ec
9f76cedd3cfc9bb9dafec6c8e91c4b7e45f3f8ef
v1.0
instruct
Taco
Taco_51170_I
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). Write a program that handles multiple test cases efficiently. -----Input----- The first line contains a single ...
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": "", "prompt_id": "00051170", "row_id": 51170, "seed_ids": "[6196]" }
0.696494
Taco_51170
I
[ "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
e23612ac930ac84f7fbd5ba68959435ad08eaa4e
84b0067df614a41257d169e8d77023bff90846da
v1.0
instruct
Taco
Taco_51207_I
Given a string `s` which represents a sequence of lowercase English letters, you need to perform the following operation exactly once: You 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 performing this swap operation, you need...
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": "", "prompt_id": "00051207", "row_id": 51207, "seed_ids": "[7326]" }
0.778767
Taco_51207
I
[ "count_distinct_substrings", "max_distinct_substrings_after_swap" ]
2
[ [ "max_distinct_substrings_after_swap", "count_distinct_substrings" ] ]
1
[]
false
[]
false
pytest
true
[]
true
853bd643d69f46cc64aaab52985cd7596c54a09b
8999b0ffe55554da8e572b5918eb299282336c69
v1.0
instruct
Taco
Taco_51219_I
Frank is a video game developer, and he is working on a level where the player needs to collect coins positioned around a maze. To make the game more challenging, he wants to calculate the optimal timer setting for players to gather all coins within a specific time frame. Each coin is positioned at a specific location...
from itertools import permutations def calculate_distance(p1, p2): """Calculate Manhattan distance between two points""" return abs(p1[0] - p2[0]) + abs(p1[1] - p2[1]) def minimum_time_to_collect_all_coins_and_return(r, c, k, coins): start = (0, 0) min_time = float('inf') # Generate all permutati...
import pytest from solution import calculate_distance, minimum_time_to_collect_all_coins_and_return, optimal_timer_settings def test_calculate_distance(): assert calculate_distance((0, 0), (0, 1)) == 1 assert calculate_distance((0, 0), (1, 1)) == 2 assert calculate_distance((2, 3), (5, 7)) == 7 assert ...
[ { "docstring": "Calculate Manhattan distance between two points", "function_declaration": "def calculate_distance(p1, p2):", "function_name": "calculate_distance", "parameter_list": "(p1, p2)" }, { "docstring": null, "function_declaration": "def minimum_time_to_collect_all_coins_and_retu...
[ 0, 0, 0, 1 ]
1
hard
0.25
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import permutations\n\ndef minimum_collection_time(r, c, k, coins):\n def manhattan_distance(p1, p2):\n return abs(p1[0] - p2[0]) + abs(p1...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00051219", "row_id": 51219, "seed_ids": "[12102]" }
0.693725
Taco_51219
I
[ "calculate_distance", "minimum_time_to_collect_all_coins_and_return", "optimal_timer_settings" ]
3
[ [ "minimum_time_to_collect_all_coins_and_return", "calculate_distance" ], [ "optimal_timer_settings", "minimum_time_to_collect_all_coins_and_return" ] ]
2
[]
false
[]
false
pytest
true
[]
true
dff754cead97d3f07902613d4f718c36d9aa729d
de4de1cf2c99f7c899f3593e7a3e382fe26117cf
v1.0
instruct
Taco
Taco_51270_I
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 connecting these locations w...
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": "", "prompt_id": "00051270", "row_id": 51270, "seed_ids": "[19208]" }
0.69841
Taco_51270
I
[ "dijkstra", "shortest_route", "logistic_routes", "parse_input", "main" ]
5
[ [ "logistic_routes", "shortest_route" ], [ "shortest_route", "dijkstra" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
a8f71806b92e71278cf1e7faf97a986cea2a9d65
6a801c50a078ad9aa2d06bfae2f90814c1a614cb
v1.0
instruct
Taco
Taco_51280_I
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 of available components. *R...
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": "", "prompt_id": "00051280", "row_id": 51280, "seed_ids": "[2033]" }
0.679886
Taco_51280
I
[ "can_construct_product", "process_input_and_check_construction" ]
2
[ [ "process_input_and_check_construction", "can_construct_product" ] ]
1
[]
false
[]
false
pytest
false
[]
true
8223779bbd3906923a1f73ed325a9038658a86aa
53c03c5bb4dfe8ad7a35a361db202af4fd9a8db3
v1.0
instruct
Taco
Taco_51346_I
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. Input The input will consist of the first line containing the number of test cases 't' f...
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": "", "prompt_id": "00051346", "row_id": 51346, "seed_ids": "[307]" }
0.633005
Taco_51346
I
[ "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
3d1317862b38c938d0fe86865f586078e67ace47
c7f174b3c315dc354a5ceeba993a94fa7da136da
v1.0
instruct
Taco
Taco_51361_I
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 process simultaneously. Ana ai...
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": "", "prompt_id": "00051361", "row_id": 51361, "seed_ids": "[17336]" }
0.653816
Taco_51361
I
[ "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
2501f334c157adc76a5f66badae83a2cde2f2c8f
7713f8da61698f3c17204a06c77afe4e5c4e5392
v1.0
instruct
Taco
Taco_51370_I
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. You are given the coordinates of N points on a plane. Your...
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": "", "prompt_id": "00051370", "row_id": 51370, "seed_ids": "[13057]" }
0.620868
Taco_51370
I
[ "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
afbf4dbad9a8f22440b8e3ce0e08c389ea1d56fb
30591427a5a3b15a268e463b884f054ea24d1735
v1.0
instruct
Taco
Taco_51389_I
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, finds the resulting single-digi...
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": "", "prompt_id": "00051389", "row_id": 51389, "seed_ids": "[12059]" }
0.651196
Taco_51389
I
[ "multiply_non_zero_digits", "single_digit_result" ]
2
[ [ "single_digit_result", "multiply_non_zero_digits" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fc22a771d37ab33cc842940ef709ed530512a1dd
c619341102548a50a9544d5cf495a52b8e109f8b
v1.0
instruct
Taco
Taco_51406_I
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. The mall's layout is represented as a 2D grid of size $m \times n$, where each cell can either be empty ...
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": "", "prompt_id": "00051406", "row_id": 51406, "seed_ids": "[23613]" }
0.639989
Taco_51406
I
[ "maximal_rectangle", "largest_rectangle_area" ]
2
[ [ "maximal_rectangle", "largest_rectangle_area" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4a2cb5d0a4483ba26fcf61372976f9741d56b0a1
6c071216aee9b29031d6df9e62ae553ca793c0c6
v1.0
instruct
Taco
Taco_51427_I
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. Example 1: Input: arr = [7, 10, 4, 3, 20, 15] k = 3 Output: 7 Explanation: The 3rd smallest element in the array is 7. Example 2: Input: arr ...
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": "", "prompt_id": "00051427", "row_id": 51427, "seed_ids": "[10353]" }
0.601038
Taco_51427
I
[ "partition", "quickselect", "find_kth_smallest" ]
3
[ [ "find_kth_smallest", "quickselect" ], [ "quickselect", "partition" ] ]
2
[]
false
[]
false
pytest
true
[]
true
78e9cee85ff6182748bbcbac486d99ecf0768602
413587a500f172269d2005edcb7952ccfda58f8d
v1.0
instruct
Taco
Taco_51550_I
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. -----Input----- The first line of input contains two integers $n$ and $k$ ($1 \le...
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": "", "prompt_id": "00051550", "row_id": 51550, "seed_ids": "[15827]" }
0.621972
Taco_51550
I
[ "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
9d58d467a06f37bf2a13b327785fd2789712414f
659369975f48d59ca92bdd233aa5a23f0533a795
v1.0
instruct
Taco
Taco_51595_I
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 the bottom-right corner (cell (...
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": "", "prompt_id": "00051595", "row_id": 51595, "seed_ids": "[6443]" }
0.762383
Taco_51595
I
[ "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
553b039afa88517308d61561bdd90b5827ec18ba
57a447bb8e450f0a6c553653a576d7f00e40ffcb
v1.0
instruct
Taco
Taco_51639_I
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 to the road. The road can be...
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": "", "prompt_id": "00051639", "row_id": 51639, "seed_ids": "[23850]" }
0.682578
Taco_51639
I
[ "minimize_total_distance", "process_input_and_call_function" ]
2
[ [ "process_input_and_call_function", "minimize_total_distance" ] ]
1
[]
false
[]
false
pytest
true
[ "numpy" ]
false
1de15212374eaf00eb2ef8b5dbe78c36e51420db
b347b7be8c83fb7f10bf66e78b0de51cdfa4a448
v1.0
instruct
Taco
Taco_51644_I
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 minimum cost required to cons...
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": "", "prompt_id": "00051644", "row_id": 51644, "seed_ids": "[10990]" }
0.784132
Taco_51644
I
[ "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
8b7e4354ed53a3d2e34af54d499d6f722c791f68
4b459a67b29cbce512e1ed3c928e01406a89d8c4
v1.0
instruct
Taco
Taco_51727_I
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 path may or may not pass throu...
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": "", "prompt_id": "00051727", "row_id": 51727, "seed_ids": "[20783]" }
0.643814
Taco_51727
I
[ "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
a8ba8591565d89b19d31d868a5c7c7861bbfe3b4
1f6411b8274decc96700fd0faa0338a409d24fe1
v1.0
instruct
Taco
Taco_51747_I
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. Unfortunately, due to frequent natural disasters, the roads are failing unpredictably. To ...
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": "", "prompt_id": "00051747", "row_id": 51747, "seed_ids": "[23457]" }
0.718699
Taco_51747
I
[ "find_bridges", "minimum_roads_to_reinforce" ]
2
[ [ "minimum_roads_to_reinforce", "find_bridges" ] ]
1
[]
false
[]
false
pytest
true
[]
true
35b4621bca8cfb77414410c1b95cfe18f311ed90
d46e0c66825a0d031c2e4e48efafefbda28b4db4
v1.0
instruct
Taco
Taco_51785_I
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 utilized as possible without excee...
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": "", "prompt_id": "00051785", "row_id": 51785, "seed_ids": "[23045]" }
0.659901
Taco_51785
I
[ "max_storage_utilization", "process_warehouses", "parse_input", "main" ]
4
[ [ "process_warehouses", "max_storage_utilization" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
b7e3ab0c3535b36df4eafab569cf8ddb9bef41c3
133455aecdc7a41be211907e79499f90ef617f41
v1.0
instruct
Taco
Taco_51794_I
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 goal is to determine the minimu...
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": "", "prompt_id": "00051794", "row_id": 51794, "seed_ids": "[16529]" }
0.664997
Taco_51794
I
[ "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
33d3d9666dcfeb3ef4df7223229367a02bdef27d
5e91f0c81dfaeebe6c0d3d8903299f69e942740a
v1.0
instruct
Taco
Taco_51809_I
Captain Flint decided to further test the skills of potential crew members by giving them another challenge involving prime numbers. Let'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$ ($3^2$), and $25$ ($5^2$) are ...
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": "", "prompt_id": "00051809", "row_id": 51809, "seed_ids": "[19406]" }
0.490612
Taco_51809
I
[ "is_prime", "count_prime_squares" ]
2
[ [ "count_prime_squares", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2fc253c846a4bc6378b595dde0463f17a3540c27
d5b1d16d5c29da9315e10222a1d20709ef58359d
v1.0
instruct
Taco
Taco_52046_I
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". A subsequence is a sequence that can be derived from another sequence by deleting some ...
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": "", "prompt_id": "00052046", "row_id": 52046, "seed_ids": "[5433]" }
0.682768
Taco_52046
I
[ "is_perfect_square", "subsequence_has_perfect_square_product", "solve" ]
3
[ [ "solve", "subsequence_has_perfect_square_product" ] ]
1
[]
false
[]
false
pytest
true
[]
true
efa3c7179642186dc4255170aecb223481b513d9
b3f4b73ea1714448236e8a5a92750d1824159b27