context
listlengths
1
1
gen_kwargs
dict
repeat_idx
int64
0
4
request_idx
int64
0
510
task_name
stringclasses
6 values
metadata
dict
model_outputs
stringlengths
539
136k
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given positive integers low, high, and k.\nA number is beautiful if it meets both of the following conditions:\n\nThe count of even digits in the numbe...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
89
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to create a function that counts the number of beautiful integers between a low and high range. A beautiful integer is one where the count of even digits equals the count of odd digits, and the number is divisible by k. The constraints are that low and high are up to 10^9, and k is up to 20. First, I ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given two 0-indexed strings str1 and str2.\nIn an operation, you select a set of indices in str1, and for each index i in the set, increment str1[i] to...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
90
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to determine if str2 can be made a subsequence of str1 by performing at most one operation where I can increment certain characters in str1 cyclically. Let me break this down. First, let me understand the problem statement again. We have two strings, str1 and str2. We can select a set...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a string moves of length n consisting only of characters 'L', 'R', and '_'. The string represents your movement on a number line starting from th...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
91
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, let's see. The problem is about figuring out the furthest distance from the origin you can get after a series of moves. The moves are given as a string with 'L', 'R', and '_'. Each character represents a move: 'L' is left, 'R' is right, and '_' can be either. The goal is to determine the maximum possible distance...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given two strings s and t of equal length n. You can perform the following operation on the string s:\n\nRemove a suffix of s of length l where 0 < l <...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
92
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to solve this problem where we have two strings s and t of the same length, and we can perform a specific operation k times to transform s into t. The operation is moving a suffix of length l (where 0 < l < n) to the front. The question is asking for the number of ways to do this in ex...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed array nums consisting of non-negative powers of 2, and an integer target.\nIn one operation, you must apply the following changes to ...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
93
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to solve this problem where I have an array of powers of 2, and I need to find the minimum number of operations to make a subsequence that sums up to the target. Each operation allows me to take a number greater than 1, remove it, and add two copies of half of it to the end of the arra...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a 0-indexed 2D integer matrix grid of size n * m, we define a 0-indexed 2D matrix p of size n * m as the product matrix of grid if the following conditio...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
94
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to create a function that takes a 2D matrix (grid) and returns another 2D matrix where each element is the product of all elements except the one at the same position in the original grid, and then take that product modulo 12345. Alright, let's break this down. First, the problem is similar to the clas...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array receiver of length n and an integer k.\nThere are n players having a unique id in the range [0, n - 1] who will play a ...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
95
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to solve this problem where there are n players, each with a unique ID from 0 to n-1. Each player passes the ball to another player (possibly themselves) as given by the receiver array. The task is to choose a starting player such that the sum of the starting player's ID and the IDs of all the players w...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given two 0-indexed binary strings s1 and s2, both of length n, and a positive integer x.\nYou can perform any of the following operations on the strin...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
96
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to solve this problem where we have two binary strings s1 and s2, and we need to make them equal with the minimum cost using two types of operations. Let's break down the problem step by step. First, let's understand the operations: 1. Flip two indices i and j with cost x. 2. Flip tw...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed 2D integer array nums representing the coordinates of the cars parking on a number line. For any index i, nums[i] = [start_i, end_i] ...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
97
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to write a Python function that takes a list of cars' parking coordinates and returns the number of integer points covered by any part of a car. The input is a 2D list where each sub-list has two integers: the start and end points of each car. The example given is [[3,6],[1,5],[4,7]], and the output is ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given an array nums of positive integers and an integer k.\nIn one operation, you can remove the last element of the array and add it to your collectio...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
98
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, let's see. I need to write a Python function that takes an array of positive integers called `nums` and an integer `k`. The goal is to find the minimum number of operations required to collect all elements from 1 to k. An operation consists of removing the last element of the array and adding it to the collection...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed array nums of length n containing distinct positive integers. Return the minimum number of right shifts required to sort nums and -1 ...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
99
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to determine the minimum number of right shifts required to sort an array, or return -1 if it's not possible. Let me start by understanding the problem better. First, a right shift means moving each element to the next position, and the last element wraps around to the first. For exam...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed string num representing a non-negative integer.\nIn one operation, you can pick any digit of num and delete it. Note that if you dele...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
100
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to make a number special by deleting the minimum number of digits. A number is special if it's divisible by 25. Let me think about how numbers divisible by 25 look. They have to end with 00, 25, 50, or 75. So, the last two digits have to be one of those pairs. First, maybe I should c...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 1-indexed array nums of n integers.\nA set of numbers is complete if the product of every pair of its elements is a perfect square.\nFor a subs...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
101
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to solve this problem where given a list of numbers, I have to find the maximum subset sum where every pair of elements in the subset multiplies to a perfect square. Hmm, interesting. Let me try to break this down. First, the problem says a set is complete if the product of every pair of its elements i...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a binary string s that contains at least one '1'.\nYou have to rearrange the bits in such a way that the resulting binary number is the maximum o...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
102
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to create a Python function that takes a binary string and rearranges its bits to form the maximum odd binary number possible. The key points here are that the resulting number has to be odd and as large as possible. Let's break this down step by step. First, I remember that for a binary number to be o...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given an array nums consisting of non-negative integers.\nWe define the score of subarray nums[l..r] such that l <= r as nums[l] AND nums[l + 1] AND .....
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
103
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to split the array into the maximum number of subarrays such that the sum of their scores is minimized. The score of a subarray is the bitwise AND of all its elements. Each element has to be in exactly one subarray. Hmm, let's start by understanding the problem better. First, the scor...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed sorted array of integers nums.\nYou can perform the following operation any number of times:\n\nChoose two indices, i and j, where i ...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
104
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to solve this problem where we have a sorted array, and we can remove pairs of elements where the left one is smaller than the right one. The goal is to find the minimum possible length of the array after doing as many removals as possible. Let me think through this step by step. Firs...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed array nums of non-negative integers, and two integers l and r.\nReturn the count of sub-multisets within nums where the sum of elemen...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
105
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to solve this problem where I have to count the number of sub-multisets in an array nums such that their sum is between l and r inclusive. The answer needs to be modulo 10^9 + 7. Let me try to break this down. First, let me make sure I understand the problem correctly. A sub-multiset is like a subset, ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums and an integer k.\nReturn an integer that denotes the sum of elements in nums whose corresponding indices have exa...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
106
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, let's see. I need to write a Python function that takes a list of integers called `nums` and an integer `k`. The function should return the sum of elements in `nums` whose indices have exactly `k` set bits in their binary representation. First, I need to understand what a set bit is. From the example, it's the ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed array nums consisting of positive integers.\nThere are two types of operations that you can apply on the array any number of times:\n...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
107
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to solve this problem where I have to make an array empty by removing pairs or triplets of the same number, and I need to do this in the minimum number of operations. If it's not possible, return -1. Let's start by understanding the problem better. First, the operations allowed are ei...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums of length n where n is the total number of students in the class. The class teacher tries to select a group of stu...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
108
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, let's see. The problem is about selecting a group of students such that everyone is happy. Each student is happy if either they're selected and the group size is strictly greater than their number, or they're not selected and the group size is strictly less than their number. I need to find how many ways there ar...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed array of integers nums, and an integer target.\nReturn the length of the longest subsequence of nums that sums up to target. If no su...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
109
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to solve this problem where I have to find the length of the longest subsequence in an array that adds up to a target sum. If there's no such subsequence, return -1. Let's start by understanding the problem better. First, a subsequence is a sequence that can be derived from another se...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed array maxHeights of n integers.\nYou are tasked with building n towers in the coordinate line. The i^th tower is built at coordinate ...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
110
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to solve this problem where I have to find the maximum possible sum of heights for a "beautiful" configuration of towers. The towers are built at coordinates from 0 to n-1, and each tower's height has to be between 1 and the given maxHeights at that index. Also, the array of heights has to be a mountain...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed array nums and an integer target.\nA 0-indexed array infinite_nums is generated by infinitely appending the elements of nums to itsel...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
111
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to solve this problem where I have to find the shortest subarray in an infinite array (which is just the original nums array repeated infinitely) that sums up to the target. If there's no such subarray, return -1. Let me think through this step by step. First, the problem is similar to finding a subarr...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a binary string s and a positive integer k.\nA substring of s is beautiful if the number of 1's in it is exactly k.\nLet len be the length of the...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
112
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to write a Python function that takes a binary string `s` and a positive integer `k`. The goal is to find the lexicographically smallest substring of `s` that has exactly `k` ones, and among all such substrings, it should be the shortest possible. If no such substring exists, return an empty string. Le...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You have n processors each having 4 cores and n * 4 tasks that need to be executed such that each core should perform only one task.\nGiven a 0-indexed integer...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
113
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to solve this problem where I have n processors, each with 4 cores. There are 4n tasks that need to be assigned to these cores such that each core does one task. Each processor has a time when it becomes available, given in the array processorTime. The tasks have different execution ti...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums and a positive integer k.\nYou can do the following operation on the array any number of times:\n\nChoose any two ...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
114
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to solve this problem where we can perform operations on an array to maximize the sum of squares of k elements. Let me try to understand the problem step by step. First, the operation allowed is choosing two distinct indices i and j, then updating nums[i] to (nums[i] AND nums[j]) and ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums.\nReturn the maximum value over all triplets of indices (i, j, k) such that i < j < k. If all such triplets have a...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
115
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to write a Python function that takes a list of integers called `nums` and returns the maximum value over all triplets of indices (i, j, k) where i < j < k. If all such triplets have a negative value, the function should return 0. The value of a triplet is calculated as (nums[i] - nums[j]) multiplied by...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums.\nThe distinct count of a subarray of nums is defined as:\n\nLet nums[i..j] be a subarray of nums consisting of al...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
116
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to write a Python function that takes a list of integers called `nums` and returns the sum of the squares of the distinct counts of all its subarrays. Let me try to understand the problem first. A subarray is a contiguous part of the array, right? So for example, if the input is [1,2,1], the subarrays ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a 0-indexed array of strings words where words[i] is either a positive integer represented as a string or the string \"prev\".\nStart iterating from the ...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
117
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, let's try to figure out how to solve this problem. So, the task is to process an array of strings called `words`, where each element is either a positive integer as a string or the string "prev". We need to iterate through the array from the beginning, and whenever we encounter a "prev", we have to find the last ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums of length n.\nWe want to group the indices so for each index i in the range [0, n - 1], it is assigned to exactly ...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
118
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to group the indices of an array such that each group has the same value and the sizes of any two groups differ by at most 1. The goal is to find the minimum number of groups needed. Let me think through this step by step. First, let's understand the problem. We have an array `nums` w...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given two arrays nums1 and nums2 consisting of positive integers.\nYou have to replace all the 0's in both arrays with strictly positive integers such ...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
119
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to write a Python function that takes two arrays, nums1 and nums2, and replaces all the zeros in both arrays with positive integers such that the sums of both arrays become equal. The function should return the minimum possible equal sum or -1 if it's impossible. Let me think through this step by step. ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given positive integers n and m.\nDefine two integers, num1 and num2, as follows:\n\nnum1: The sum of all integers in the range [1, n] that are not div...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
120
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, let's see. I need to write a Python function that takes two positive integers, n and m. The function should compute two numbers: num1, which is the sum of all integers from 1 to n not divisible by m, and num2, which is the sum of all integers from 1 to n that are divisible by m. Then, the function should return t...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed binary string s having an even length.\nA string is beautiful if it's possible to partition it into one or more substrings such that:...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
121
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to make a binary string "beautiful" with the minimum number of changes. The string is even-length, and a beautiful string can be partitioned into substrings of even length, each consisting of only 0s or only 1s. Hmm. Let's break down the problem step by step. First, let's understand t...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed array nums of integers.\nA triplet of indices (i, j, k) is a mountain if:\n\ni < j < k\nnums[i] < nums[j] and nums[k] < nums[j]\n\nRe...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
122
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to write a Python function that finds the minimum sum of a mountain triplet in a given list of integers. A mountain triplet is defined as three indices i, j, k where i < j < k, nums[i] < nums[j], and nums[k] < nums[j]. If no such triplet exists, the function should return -1. First, let me make sure I ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums, and an integer k.\nThe K-or of nums is a non-negative integer that satisfies the following:\n\nThe i^th bit is se...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
123
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to create a Python function that computes the K-or of a given list of integers. Let me try to understand what the K-or is. From the problem statement, the K-or is a number where each bit is set if and only if that bit is set in at least k elements of the input list. Let me break it down. For each bit ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums.\nA subsequence of nums having length k and consisting of indices i_0 < i_1 < ... < i_k-1 is balanced if the follo...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
124
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to solve this problem where given an array of integers, I have to find the maximum sum of a balanced subsequence. A balanced subsequence is defined as one where for each pair of consecutive elements in the subsequence, the difference between their values is at least the difference between their indices....
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.There are n teams numbered from 0 to n - 1 in a tournament.\nGiven a 0-indexed 2D boolean matrix grid of size n * n. For all i, j that 0 <= i, j <= n - 1 and i...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
125
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out which team is the champion in this tournament based on the grid given. Let me try to understand the problem again. We have n teams, numbered from 0 to n-1. The grid is a 2D boolean matrix where grid[i][j] is 1 if team i is stronger than team j, and 0 otherwise. The champion is the team t...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given two 0-indexed integer arrays, nums1 and nums2, both having length n.\nYou are allowed to perform a series of operations (possibly none).\nIn an o...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
126
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to solve this problem where I have two arrays, nums1 and nums2, and I need to make sure that the last elements of both arrays are the maximums in their respective arrays. To do that, I can swap elements between nums1 and nums2 at the same index. The goal is to find the minimum number o...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given three integers a, b, and n, return the maximum value of (a XOR x) * (b XOR x) where 0 <= x < 2^n.\nSince the answer may be too large, return it modulo 10...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
127
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to write a Python function that takes three integers a, b, and n, and returns the maximum value of (a XOR x) * (b XOR x) modulo 10^9 + 7, where x is between 0 and 2^n - 1. Hmm, let's think about how to approach this. First, the problem is about maximizing the product of two numbers after XORing them wi...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums. A pair of integers x and y is called a strong pair if it satisfies the condition:\n\n|x - y| <= min(x, y)\n\nYou ...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
128
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to write a Python function that takes a list of integers called `nums` and returns the maximum XOR value among all strong pairs in the array. A strong pair is defined as two integers x and y where the absolute difference between them is less than or equal to the minimum of the two numbers. First, I ne...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed array of strings words and a character x.\nReturn an array of indices representing the words that contain the character x.\nNote that...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
129
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to write a Python function that takes a list of strings called `words` and a character `x`. The function should return a list of indices corresponding to the words that contain the character `x`. Let me think about how to approach this. First, I need to iterate through each word in the `words` list. Fo...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.There are n balls on a table, each ball has a color black or white.\nYou are given a 0-indexed binary string s of length n, where 1 and 0 represent black and w...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
130
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to solve this problem where I have to group all the black balls (represented by '1's) to the right and all the white balls (represented by '0's) to the left with the minimum number of adjacent swaps. Let me think through this step by step. First, let me understand the problem again. G...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums and an integer k.\nYou can perform the following operation on the array at most k times:\n\nChoose any index i fro...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
131
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to solve this problem where I have an array of integers and I can modify each element by increasing or decreasing it by 1 at most k times. The goal is to make the most frequent element as frequent as possible. Hmm. Let me think. First, the examples given help. In the first example, th...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given two positive integers n and limit.\nReturn the total number of ways to distribute n candies among 3 children such that no child gets more than li...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
132
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to write a Python function that calculates the number of ways to distribute 'n' candies among 3 children, with each child not getting more than 'limit' candies. Let me start by understanding the problem better. First, the problem is about distributing candies, which is a classic combi...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given an integer n.\nA string s is called good if it contains only lowercase English characters and it is possible to rearrange the characters of s suc...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
133
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to count the number of good strings of length n. A good string is one that can be rearranged to contain "leet" as a substring. The examples given help, but I need to come up with a general solution for any n up to 10^5. First, let's understand what makes a string good. The string mus...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed string s having an even length n.\nYou are also given a 0-indexed 2D integer array, queries, where queries[i] = [a_i, b_i, c_i, d_i]....
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
134
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to determine if a string can be made into a palindrome by rearranging two specific substrings. The string is split into two halves, and for each query, I can rearrange characters in one substring from the first half and another from the second half. Each query is independent, so I have...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given two 0-indexed integer arrays nums1 and nums2 of sizes n and m, respectively.\nConsider calculating the following values:\n\nThe number of indices...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
135
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to write a Python function that takes two integer arrays, nums1 and nums2, and returns an array of two integers. The first integer is the count of indices in nums1 where the element at that index appears at least once in nums2. The second integer is the count of indices in nums2 where the element appear...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given three strings s1, s2, and s3. You have to perform the following operation on these three strings as many times as you want.\nIn one operation you...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
136
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to make three strings equal by deleting the rightmost character as few times as possible. If it's not possible, return -1. Let's see. First, the problem says that in each operation, I can choose any of the three strings that has a length of at least 2 and delete the rightmost characte...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are at a fruit market with different types of exotic fruits on display.\nYou are given a 1-indexed array prices, where prices[i] denotes the number of coin...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
137
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to solve this problem where you have to buy fruits with the minimum number of coins, given that buying the i-th fruit allows you to take the next i fruits for free. Hmm, let's break it down. First, the problem is about making the optimal choices at each step to minimize the total cost...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a string s and a positive integer k.\nLet vowels and consonants be the number of vowels and consonants in a string.\nA string is beautiful if:\n\...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
138
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to write a Python function that counts the number of non-empty "beautiful" substrings in a given string `s` with a positive integer `k`. The definition of a beautiful substring is one where the number of vowels equals the number of consonants, and the product of vowels and consonants is divisible by `k`...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums.\nYou can perform any number of operations, where each operation involves selecting a subarray of the array and re...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
139
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to solve this problem where we can replace subarrays with their sums to make the array non-decreasing, and find the maximum possible length of such an array. Let me try to break this down. First, let's understand the problem statement again. We have an array of integers, and we can pe...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed array nums consisting of positive integers.\nA partition of an array into one or more contiguous subarrays is called good if no two s...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
140
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to count the number of good partitions of an array. The problem says a good partition is one where no two subarrays contain the same number. The examples given help, but I need to come up with a general approach. First, let me understand the problem better. A partition divides the arr...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given an integer array nums and a positive integer k.\nReturn the number of subarrays where the maximum element of nums appears at least k times in tha...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
141
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to write a Python function that takes an integer array `nums` and a positive integer `k`, and returns the number of subarrays where the maximum element of `nums` appears at least `k` times. Let me think about how to approach this. First, I should figure out what the maximum element in `nums` is. That w...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed array of positive integers nums and a positive integer limit.\nIn one operation, you can choose any two indices i and j and swap nums...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
142
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to generate the lexicographically smallest array by swapping elements under the given limit. Let's start by understanding the problem better. We have an array of positive integers and a limit. We can swap any two elements if their difference is less than or equal to the limit. The goa...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array batteryPercentages having length n, denoting the battery percentages of n 0-indexed devices.\nYour task is to test each...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
143
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, let's see. I need to write a Python function that takes a list of battery percentages for devices and tests each one in order. The testing process involves checking if the current device's battery percentage is greater than 0. If it is, we increment the count of tested devices and decrease the battery percentage ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed array mountain. Your task is to find all the peaks in the mountain array.\nReturn an array that consists of indices of peaks in the g...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
144
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to write a Python function that finds all the peaks in a given mountain array. Let me start by understanding the problem properly. First, the function should take a 0-indexed array called `mountain` and return the indices of all peaks. A peak is defined as an element that's strictly greater than its n...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a string word and an integer k.\nA substring s of word is complete if:\n\nEach character in s occurs exactly k times.\nThe difference between two...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
145
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to write a Python function that counts the number of complete substrings in a given word. The conditions for a substring to be complete are that each character in it occurs exactly k times, and the difference between adjacent characters is at most 2. The function should take a string 'word' and an integ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given an integer n and a 0-indexed integer array sick which is sorted in increasing order.\nThere are n children standing in a queue with positions 0 t...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
146
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, let's try to figure out how to solve this problem. So, we have n children in a queue, some of them are initially sick. The sick array is sorted, so the positions of the initially sick children are in increasing order. The disease spreads to adjacent children, but each second only one non-infected child can get in...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given an integer array nums and an integer k.\nThe frequency of an element x is the number of times it occurs in an array.\nAn array is called good if ...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
147
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to find the longest subarray where each element's frequency is at most k. Let's start by understanding the problem better. Given an array nums and an integer k, we need to find the longest contiguous subarray where every element in that subarray appears at most k times. The examples ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums of even length and there is also an empty array arr. Alice and Bob decided to play a game where in every round Ali...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
148
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, let's see. So the problem is about Alice and Bob playing a game with an integer array nums. The array has even length, which is good because they take turns removing elements. The goal is to simulate their moves and return the resulting array arr after all elements have been removed. First, let me understand the...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed 2D integer matrix grid of size n * n with values in the range [1, n^2]. Each integer appears exactly once except a which appears twic...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
149
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to write a Python function that takes a square grid (n x n) as input. Each number from 1 to n² should appear exactly once, except one number a which is repeated twice, and another number b which is missing. The function should return a list [a, b] where a is the duplicate and b is the missing number. F...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given two 0-indexed integer arrays nums1 and nums2 of even length n.\nYou must remove n / 2 elements from nums1 and n / 2 elements from nums2. After th...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
150
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to solve this problem where I have two arrays of even length, and I have to remove half of each array's elements. Then, when I combine the remaining elements into a set, I want the set to be as large as possible. Let me try to break this down step by step. First, the problem says that...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums having length n.\nYou are allowed to perform a special move any number of times (including zero) on nums. In one s...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
151
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to make all numbers in an array equal to a palindromic number with the minimum total cost. The cost is calculated by the sum of absolute differences between each number and the target palindrome. Let's break down the problem step by step. First, understanding the problem: We have an a...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed string word.\nIn one operation, you can pick any index i of word and change word[i] to any lowercase English letter.\nReturn the mini...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
152
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to solve this problem where I have to remove all adjacent almost-equal characters from a string with the minimum number of operations. Let me start by understanding the problem better. First, the problem says two characters are almost-equal if they are the same or adjacent in the alph...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array coins, representing the values of the coins available, and an integer target.\nAn integer x is obtainable if there exis...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
153
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to solve this problem where given some coins and a target, I have to determine the minimum number of coins to add so that every number from 1 to the target is achievable by some subsequence sum. Let me try to break this down. First, let me understand the problem again. We have coins, ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed string s and an integer k.\nYou are to perform the following partitioning operations until s is empty:\n\nChoose the longest prefix o...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
154
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to write a Python function that takes a string s and an integer k, and returns the maximum number of partitions possible by changing at most one character in s. The partitions are done by repeatedly cutting the longest prefix with at most k distinct characters until the string is empty. The goal is to m...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed 2D array variables where variables[i] = [a_i, b_i, c_i, m_i], and an integer target.\nAn index i is good if the following formula hol...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
155
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, let's see. I need to write a Python function that takes a 2D array called variables and an integer target. The function should return a list of indices where the given formula holds true. The formula is ((a_i^b_i % 10)^c_i) % m_i == target. First, I need to understand the problem properly. Each variable in the ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given two 0-indexed strings source and target, both of length n and consisting of lowercase English letters. You are also given two 0-indexed character...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
156
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to convert the source string to the target string with the minimum cost using the given operations. Let's start by understanding the problem thoroughly. First, both source and target are strings of the same length, made up of lowercase English letters. The original and changed arrays ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed array of integers nums.\nA prefix nums[0..i] is sequential if, for all 1 <= j <= i, nums[j] = nums[j - 1] + 1. In particular, the pre...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
157
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, let's tackle this problem step by step. So, the task is to find the smallest integer x missing from the array nums such that x is greater than or equal to the sum of the longest sequential prefix. First, I need to understand what a sequential prefix is. The problem states that a prefix nums[0..i] is sequential ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given two positive integers x and y.\nIn one operation, you can do one of the four following operations:\n\nDivide x by 11 if x is a multiple of 11.\nD...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
158
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out the minimum number of operations to make x equal to y. The allowed operations are dividing by 11 or 5 if x is a multiple of those, decrementing by 1, or incrementing by 1. Let me think about how to approach this. First, if x is already equal to y, then no operations are needed. That's the...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given an integer k and an integer x.\nConsider s is the 1-indexed binary representation of an integer num. The price of a number num is the number of i...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
159
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to solve this problem where I have to find the greatest integer num such that the sum of the prices of all numbers from 1 to num is less than or equal to k. The price of a number is determined by the number of set bits (1s) in positions that are multiples of x in its binary representation. The positions...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given an array nums consisting of positive integers.\nReturn the total frequencies of elements in nums such that those elements all have the maximum fr...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
160
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, let's see. I need to write a Python function that takes an array of positive integers and returns the total frequencies of elements that have the maximum frequency. The examples given are: Example 1: Input: [1,2,2,3,1,4] Output: 4 Because elements 1 and 2 each appear twice, which is the maximum frequency, so 2 +...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given three integers start, finish, and limit. You are also given a 0-indexed string s representing a positive integer.\nA positive integer x is called...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
161
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, let's tackle this problem step by step. So, we need to find the number of powerful integers between start and finish inclusive. A powerful integer has two main properties: it ends with the given string s, and each digit in it is at most the given limit. First, let me understand the problem better. The examples ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums containing positive integers.\nYour task is to minimize the length of nums by performing the following operations ...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
162
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to minimize the length of this array by performing operations where I select two distinct indices, compute nums[i] % nums[j], add it to the end, and then remove the original two elements. The goal is to keep doing this until I can't anymore and return the minimum possible length. Let...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed string s, a string a, a string b, and an integer k.\nAn index i is beautiful if:\n\n0 <= i <= s.length - a.length\ns[i..(i + a.length...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
163
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to write a Python function that takes a string s, two substrings a and b, and an integer k. The function should find all "beautiful" indices in s where a occurs, such that there's a occurrence of b within k distance from the a index. Then return those indices sorted. First, I need to understand the pro...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given an array of positive integers nums.\nYou have to check if it is possible to select two or more elements in the array such that the bitwise OR of ...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
164
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to write a Python function that checks if there are two or more numbers in an array such that their bitwise OR has at least one trailing zero in binary. Hmm, let's think about how trailing zeros work. A trailing zero in a binary number means that the number is even, right? Because even numbers in binary...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums and a positive integer k.\nYou can apply the following operation on the array any number of times:\n\nChoose any e...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
165
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to solve this problem where I have an array of integers and a target integer k. The goal is to find the minimum number of bit flips required so that the XOR of all elements in the array equals k. Let's break this down step by step. First, let's recall that XOR is a binary operation th...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 2D 0-indexed integer array dimensions.\nFor all indices i, 0 <= i < dimensions.length, dimensions[i][0] represents the length and dimensions[i]...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
166
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to write a Python function that takes a list of rectangles' dimensions and returns the area of the rectangle with the longest diagonal. If there are multiple rectangles with the same longest diagonal, it should return the maximum area among them. Let me think through this step by step. First, the funct...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed array of positive integers nums.\nA subarray of nums is called incremovable if nums becomes strictly increasing on removing the subar...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
167
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to count the number of incremovable subarrays in a given array. Let me start by understanding the problem again. An incremovable subarray is one where if you remove it, the remaining array is strictly increasing. The examples given help, but I need to come up with a systematic way to d...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums and an integer k.\nIn one operation, you can pick any index i of nums such that 0 <= i < nums.length - 1 and repla...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
168
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to solve this problem where we have an array of integers and we can perform up to k operations. Each operation allows us to replace two consecutive elements with their bitwise AND. The goal is to minimize the bitwise OR of the remaining elements after these operations. First, let me ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given an array of positive integers nums of length n.\nA polygon is a closed plane figure that has at least 3 sides. The longest side of a polygon is s...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
169
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to write a Python function that takes a list of positive integers and returns the largest possible perimeter of a polygon formed by some subset of those numbers. If it's not possible to form any polygon, it should return -1. Let me think through this step by step. First, the problem says that a polygon...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given an array of integers nums of length n.\nThe cost of an array is the value of its first element. For example, the cost of [1,2,3] is 1 while the c...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
170
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to divide an array into three contiguous subarrays such that the sum of their first elements is minimized. Let's break down the problem step by step. First, the cost of each subarray is its first element. So, when we split the array into three parts, each part's cost is determined by ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given an array nums of length n and a positive integer k.\nA subarray of nums is called good if the absolute difference between its first and last elem...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
171
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to write a Python function that takes an array of numbers and a positive integer k. The function should find the maximum sum of a "good" subarray, where a good subarray is defined as one where the absolute difference between its first and last element is exactly k. If there are no such subarrays, the fu...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a string s that consists of lowercase English letters.\nA string is called special if it is made up of only a single character. For example, the ...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
172
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to write a Python function that takes a string s and returns the length of the longest special substring that occurs at least three times. If there's no such substring, it should return -1. Let me think through how to approach this. First, let's clarify what a special substring is. It's a substring com...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums of size n, and a 0-indexed integer array pattern of size m consisting of integers -1, 0, and 1.\nA subarray nums[i...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
173
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, let's see. I need to write a Python function that counts how many subarrays in `nums` match the given `pattern`. The pattern consists of -1, 0, and 1, which indicate whether each subsequent element in the subarray should be less than, equal to, or greater than the previous one. First, I need to understand the p...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Alice and Bob are playing a turn-based game on a circular field surrounded by flowers. The circle represents the field, and there are x flowers in the clockwis...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
174
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, let's try to figure out how to solve this problem. So, Alice and Bob are playing a game on a circular field with flowers. The key points are: - The game is turn-based, starting with Alice. - On each turn, a player picks one flower either clockwise or anti-clockwise. - The player who picks the last flower wins. -...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed array of positive integers nums.\nIn one operation, you can swap any two adjacent elements if they have the same number of set bits. ...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
175
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to determine if an array can be sorted using adjacent swaps between elements with the same number of set bits. Let me break down the problem and think through some examples. First, let's recall that the number of set bits (1s) in a binary representation is called the Hamming weight. F...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given two 1-indexed integer arrays, nums and, changeIndices, having lengths n and m, respectively.\nInitially, all indices in nums are unmarked. Your t...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
176
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to solve this problem where I have to mark all indices in the nums array by the given changeIndices. Let me try to understand the problem first. We have two arrays: nums and changeIndices. nums is 1-indexed, which means the indices go from 1 to n, and each element in nums can be marke...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed string word and an integer k.\nAt every second, you must perform the following operations:\n\nRemove the first k characters of word.\...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
177
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to solve this problem where we have a string `word` and an integer `k`. The goal is to find the minimum time greater than zero required for the word to revert to its initial state by performing the operations of removing the first k characters and adding any k characters to the end eve...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed array nums consisting of positive integers.\nInitially, you can increase the value of any element in the array by at most 1.\nAfter t...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
178
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, let's try to figure out how to solve this problem. So, we have an array of positive integers. Initially, we can increase any element by at most 1. Then, we need to select the longest consecutive sequence of numbers after sorting. The key here is that we can modify each number by +0 or +1 before selecting the cons...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given an array of positive integers nums.\nYou need to select a subset of nums which satisfies the following condition:\n\nYou can place the selected e...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
179
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, let's try to figure out how to solve this problem. So, the task is to find the maximum subset size of an array where the elements can be arranged in a specific symmetric pattern involving powers of x. The pattern is something like [x, x², x⁴, ..., x^k, x^k/2, ..., x², x]. Hmm, that seems a bit complex, but let's ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a string s.\nConsider performing the following operation until s becomes empty:\n\nFor every alphabet character from 'a' to 'z', remove the first...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
180
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to solve this problem where we have to keep removing the first occurrence of each character from a string until it's empty, and then return the string right before the last operation. Let me try to break this down. First, let's understand the example given. The input is "aabcbbca". Th...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed string array words.\nLet's define a boolean function isPrefixAndSuffix that takes two strings, str1 and str2:\n\nisPrefixAndSuffix(st...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
181
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to write a Python function that counts the number of valid index pairs (i, j) where i < j and words[i] is both a prefix and a suffix of words[j]. The function should be named according to the problem, but since the user mentioned "generated from the given prompt," I think the function should be named ba...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.An ant is on a boundary. It sometimes goes left and sometimes right.\nYou are given an array of non-zero integers nums. The ant starts reading nums from the fi...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
182
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, let's see. I need to write a Python function that takes an array of non-zero integers and returns the number of times an ant returns to the boundary. The ant starts at the boundary and moves left or right based on the values in the array. Each time the ant's position brings it back to the boundary after moving, t...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed string s typed by a user. Changing a key is defined as using a key different from the last used key. For example, s = \"ab\" has a ch...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
183
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, let's see. I need to write a Python function that counts the number of times a user had to change the key based on the input string s. The key point here is that changing a key is when the current character is different from the previous one, but ignoring case differences. So, for example, if the user types 'a' f...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed string array words having length n and containing 0-indexed strings.\nYou are allowed to perform the following operation any number o...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
184
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to solve this problem where we have to maximize the number of palindromes in a list of words by swapping any characters between them. Let's try to break it down step by step. First, what's a palindrome? A string that reads the same forwards and backwards. For a string to be a palindro...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given an array of integers called nums, you can perform the following operation while nums contains at least 2 elements:\n\nChoose the first two elements of nu...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
185
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, let's see. I need to write a Python function that takes an array of integers called nums. The goal is to perform as many operations as possible, where each operation deletes the first two elements of the array and the score of each operation must be the same. The function should return the maximum number of such ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given an integer array nums of even length. You have to split the array into two parts nums1 and nums2 such that:\n\nnums1.length == nums2.length == nu...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
186
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to figure out how to split an array into two equal parts where each part has all distinct elements. Let's start by understanding the problem better. Given an even-length array `nums`, we have to split it into two arrays `nums1` and `nums2` each of length `n/2`. Both these arrays must have all distinct ...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given two arrays with positive integers arr1 and arr2.\nA prefix of a positive integer is an integer formed by one or more of its digits, starting from...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
187
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to write a Python function that finds the length of the longest common prefix between any pair of numbers from two given arrays, arr1 and arr2. The common prefix is defined as a sequence of digits starting from the leftmost digit that both numbers share. For example, if one number is 12345 and the other...
[ { "content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums, and an integer k.\nIn one operation, you can remove one occurrence of the smallest element of nums.\nReturn the m...
{ "do_sample": false, "max_new_tokens": 32768, "seed": 1, "temperature": 0.7 }
1
188
LiveCodeBench
{ "expected_answer": "", "problem_id": "", "reference_solution": "" }
Okay, so I need to write a Python function that takes an array of integers called `nums` and an integer `k`. The function should return the minimum number of operations required so that all elements in `nums` are greater than or equal to `k`. An operation is defined as removing one occurrence of the smallest element in...