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 2.43k 136k |
|---|---|---|---|---|---|---|
[
{
"content": "Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.There are three cards with letters $\\texttt{a}$, $\\texttt{b}$, $\\texttt{c}$ placed in a row in some order. You can ... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 0 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to write a Python function that checks if a given permutation of 'a', 'b', 'c' can be transformed into 'abc' with at most one swap. The function should take input from stdin, process each test case, and print "YES" or "NO" accordingly.
First, I need to understand the problem. We have three dist... |
[
{
"content": "Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Slavic is preparing a present for a friend's birthday. He has an array $a$ of $n$ digits and the present will be the p... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 1 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. So, Slavic wants to maximize the product of an array of digits by adding 1 to exactly one of them. The challenge is to figure out which digit to increment to get the highest possible product.
First, I need to understand the problem thoroughly. The input consists of multip... |
[
{
"content": "Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given a strip of paper $s$ that is $n$ cells long. Each cell is either black or white. In an operation you can... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 2 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. So, the goal is to find the minimum number of operations needed to turn all black cells (B) into white cells (W). Each operation allows us to turn any k consecutive cells into white.
First, I need to understand the problem thoroughly. Let's restate it: we have a string of... |
[
{
"content": "Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given a string $s$ of length $n$, consisting of lowercase Latin letters, and an integer $k$.\n\nYou need to ch... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 3 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. So, the task is to determine if we can remove exactly k characters from a given string such that the remaining characters can form a palindrome. The input consists of multiple test cases, each with a string s of length n and an integer k.
First, I need to recall that a pa... |
[
{
"content": "Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given an array of integers $a_1, a_2, \\ldots, a_n$ and a number $k$ ($2 \\leq k \\leq 5$). In one operation, ... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 4 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. So, the goal is to find the minimum number of increments needed so that the product of all numbers in the array is divisible by k. The constraints are that k is between 2 and 5, inclusive.
First, I need to understand what makes a product divisible by k. For each k (2, 3, ... |
[
{
"content": "Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Vanya and Vova are playing a game. Players are given an integer $n$. On their turn, the player can add $1$ to the curr... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 5 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's try to figure out this problem. So, Vanya and Vova are playing a game with an integer n. Vanya goes first, and on each turn, a player can either add 1 or subtract 1 from the current integer. If after Vanya's move the number is divisible by 3, he wins. If after 10 moves (which would be 5 turns each) no one h... |
[
{
"content": "Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Alex is participating in the filming of another video of BrMeast, and BrMeast asked Alex to prepare 250 thousand tons ... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 6 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. So, the goal is to find, for each test case, the maximum possible absolute difference between the total weights of any two trucks when the boxes are divided into groups of size k, for all possible k (from 1 to n). Then, among all these possibilities, we need to find the max... |
[
{
"content": "Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A subarray is a continuous part of array.\n\nYarik recently found an array $a$ of $n$ elements and became very interes... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 7 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. So, Yarik wants the maximum sum of a non-empty subarray where the parities alternate. That means if one element is even, the next has to be odd, and vice versa. Hmm, interesting. Let me think about how to approach this.
First, I remember that for maximum subarray problems,... |
[
{
"content": "Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Yarik is a big fan of many kinds of music. But Yarik loves not only listening to music but also writing it. He likes e... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 8 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. So, Yarik has these notes represented by integers of the form 2^k, where k is a positive integer. Then, combinations of two notes (a, b) are denoted by a^b. The task is to find the number of pairs (i, j) where i < j such that b_i^{b_j} equals b_j^{b_i}.
First, let's under... |
[
{
"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 details. Each element of details provides information about a given passenger compressed into a string of length 15.... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 9 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to write a Python function that takes a list of strings called `details` as input. Each string in the list has a specific format: the first ten characters are the phone number, the next character is the gender, then two characters for the age, and the last two are the seat number. The task is to... |
[
{
"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. Initially, your score is 0. Perform the following operations until the matrix becomes empty:\n\nFrom each row ... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 10 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to write a Python function that takes a 2D integer array called nums. The goal is to perform operations where in each step, I remove the largest number from each row, then add the highest among those removed to my score. Repeat this until the matrix is empty. The function should return the final... |
[
{
"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 and an integer k. In an operation, you can choose an element and multiply it by 2.\nReturn the maximum... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 11 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to figure out how to maximize the bitwise OR of all elements in an array after applying up to k operations, where each operation is multiplying one element by 2. Hmm.
First, let me understand the problem better. The bitwise OR of a set of numbers is a number where each bit is set if at least 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 a 0-indexed integer array nums representing the score of students in an exam. The teacher would like to form one non-empty group of students with... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 12 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. The problem is about finding the maximum strength of a group of students based on their scores. The strength is the product of their scores. We need to form a non-empty group with the highest possible product.
First, I need to think about how to approach this. Since we can choose any subset of the nu... |
[
{
"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 a dictionary of words dictionary. You have to break s into one or more non-overlapping substrings such that each substri... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 13 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. So, we need to find the minimum number of extra characters left after breaking the given string `s` into substrings that are present in the dictionary. The examples make sense: in the first one, "leetscode" is split into "leet" and "code", leaving the 's' at index 4 as extr... |
[
{
"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 prices representing the prices of various chocolates in a store. You are also given a single integer money, which represents you... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 14 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to write a Python function that takes a list of chocolate prices and an amount of money. The goal is to buy exactly two chocolates such that the total cost is as low as possible, but we still have some non-negative leftover money. If we can't afford any two chocolates without going into debt, we... |
[
{
"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 numeric strings num1 and num2 and two integers max_sum and min_sum. We denote an integer x to be good if:\n\nnum1 <= x <= num2\nmin_sum <= di... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 15 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. So, we need to find the number of integers between two given numbers, num1 and num2, such that the sum of their digits is between min_sum and max_sum inclusive. The answer needs to be modulo 10^9 + 7.
First, since num1 and num2 can be up to 10^22, which is a huge range, 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 nums of length n.\nThe distinct difference array of nums is an array diff of length n such that diff[i] is equal to the number ... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 16 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. So, we need to create a function that takes an array `nums` and returns its distinct difference array. The distinct difference array is calculated such that for each index `i`, the value `diff[i]` is the number of distinct elements in the prefix (from start up to `i`) minus... |
[
{
"content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.There is a 0-indexed array nums of length n. Initially, all elements are uncolored (has a value of 0).\nYou are given a 2D integer array queries where queries[... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 17 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to create a Python function that processes a series of coloring queries on an initially uncolored array and returns the count of adjacent colored pairs after each query. The function should be efficient since both the array length and the number of queries can be up to 10^5.
First, I'll start ... |
[
{
"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 representing the strength of some heroes. The power of a group of heroes is defined as follows:\n\nLet i_0, i_1, .... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 18 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. The goal is to compute the sum of the power of all non-empty groups of heroes, where the power of a group is defined as the square of the maximum strength multiplied by the minimum strength in the group. The answer needs to be modulo 10^9 + 7.
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 permutation of n integers nums.\nA permutation is called semi-ordered if the first number equals 1 and the last number equals n. You ... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 19 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to figure out the minimum number of adjacent swaps required to make a permutation semi-ordered. Semi-ordered means the first element is 1 and the last element is n. The given array is a permutation, so each number from 1 to n appears exactly once.
First, I should understand what exactly needs ... |
[
{
"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 that consists of digits from 0 to 9.\nA string t is called a semi-repetitive if there is at most one consecutive pair of the... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 20 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. So, the goal is to find the longest semi-repetitive substring in a given string `s`. A semi-repetitive string is one where there's at most one consecutive pair of the same digits.
First, I need to understand the problem thoroughly. Let me restate it: We have to find the l... |
[
{
"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 friends that are playing a game. The friends are sitting in a circle and are numbered from 1 to n in clockwise order. More formally, moving clockwi... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 21 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to solve this problem where n friends are sitting in a circle and passing a ball according to some rules. The goal is to find out which friends didn't receive the ball at all, and return them in ascending order.
First, let me make sure I understand the problem correctly. The friends are number... |
[
{
"content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A 0-indexed array derived with length n is derived by computing the bitwise XOR (⊕) of adjacent values in a binary array original of length n.\nSpecifically, f... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 22 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to figure out if there's a binary array original such that when I compute the XOR of adjacent elements (with the last one wrapping around to the first), I get the derived array. The problem is asking to determine if such an original array exists.
Hmm, so given derived, can we find original? 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 string s consisting only of uppercase English letters.\nYou can apply some operations to this string where, in one operation, you can remove an... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 23 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to write a Python function that takes a string `s` and returns the minimum possible length after removing all occurrences of "AB" or "CD" as many times as needed. The key here is that after each removal, the string might form new "AB" or "CD" substrings, so we have to keep removing until there a... |
[
{
"content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a positive integer n, return the punishment number of n.\nThe punishment number of n is defined as the sum of the squares of all integers i such that:\n\... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 24 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this punishment number problem. So, the goal is to write a function that, given a positive integer n, returns the sum of the squares of all integers i from 1 to n where the square of i can be partitioned into contiguous substrings that add up to i.
First, let me make sure I understand the problem 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 two 0-indexed integer arrays, cost and time, of size n representing the costs and the time taken to paint n different walls respectively. There a... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 25 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to figure out the minimum cost to paint all the walls using both a paid painter and a free painter. The paid painter takes different amounts of time and costs money for each wall, while the free painter is free but can only paint one wall at a time and takes 1 unit of time. The key here is 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 of size n representing the cost of collecting different chocolates. The cost of collecting the chocolate at the in... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 26 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to figure out the minimum cost to collect all types of chocolates, considering that each operation shifts the chocolate types and costs x each time. Hmm. So, the problem is about rotating the array of costs and figuring out the optimal number of rotations (or operations) to minimize the total co... |
[
{
"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 integers, n and k.\nAn array of distinct positive integers is called a k-avoiding array if there does not exist any pair of distinct elements... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 27 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to create a function that, given two integers n and k, returns the minimum possible sum of a k-avoiding array of length n. The array has to have distinct positive integers, and no two distinct elements can sum up to k.
First, I need to understand the problem better. So, a k-avoiding array is 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 two integers, num and t.\nAn integer x is called achievable if it can become equal to num after applying the following operation no more than t t... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 28 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to figure out the maximum achievable number given num and t. The problem says that we can perform an operation up to t times, where in each operation we can either increase or decrease x by 1 and simultaneously do the opposite to num. So, if I decrease x by 1, num increases by 1, and vice versa.... |
[
{
"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 consisting of lowercase English letters, and you are allowed to perform operations on it. In one operation, you can replace a characte... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 29 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to figure out how to make a given string a palindrome with the minimum number of operations, and if there are multiple possibilities, choose the lexicographically smallest one. Let's start by understanding what the problem is asking for.
First, a palindrome is a string that reads the same forwards 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 binary string s of length n on which you can apply two types of operations:\n\nChoose an index i and invert all characters from index... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 30 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to figure out the minimum cost to make all characters in a binary string equal using the given operations. The operations are inverting from the start up to index i (cost i+1) or from index i to the end (cost n-i). Hmm, so each operation can flip a certain segment of the string, and each has a d... |
[
{
"content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a positive integer num represented as a string, return the integer num without trailing zeros as a string.\n \nExample 1:\n\nInput: num = \"51230100\"\nO... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 31 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to write a Python function that takes a string representing a positive integer and returns the same integer without any trailing zeros. Let me think about how to approach this.
First, the problem says that the input is a string, and we need to process it to remove trailing zeros. Trailing zeros are 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 n that consists of exactly 3 digits.\nWe call the number n fascinating if, after the following modification, the resulting number cont... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 32 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this fascinating number problem. So, the task is to determine if a given three-digit number n is fascinating. The criteria for a fascinating number are that when you concatenate n, 2n, and 3n, the resulting number should contain all digits from 1 to 9 exactly once, with no zeros.
First, I need to p... |
[
{
"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 string s, repeatedly perform the following operation any number of times:\n\nChoose an index i in the string, and let c be the character in p... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 33 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to figure out how to minimize the length of a string by repeatedly deleting the closest left and right occurrences of a chosen character. The goal is to return the length of the minimized string. Hmm. Let me try to understand the problem better with the examples provided.
In the first example, ... |
[
{
"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 you are allowed to traverse between its indices. You can traverse between index i and index j, i != j, if and... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 34 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to determine if all pairs of indices in the given list `nums` can be traversed, meaning there's a path from i to j if gcd(nums[i], nums[j]) > 1. The key here is to check if the graph formed by these connections is connected. If it's connected, then all pairs are reachable, so we return True; oth... |
[
{
"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 consisting of only lowercase English letters. In one operation, you can do the following:\n\nSelect any non-empty substring of s, poss... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 35 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to write a Python function that takes a string `s` and returns the lexicographically smallest string possible by performing exactly one operation. The operation is selecting a non-empty substring and replacing each character with the previous character in the English alphabet (e.g., 'b' becomes ... |
[
{
"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 indices i, j where 0 <= i < j < nums.length is called beautiful if the first digit of nums[i] and the l... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 36 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. So, we need to find the number of beautiful pairs in an array. A pair (i, j) is beautiful if the first digit of nums[i] and the last digit of nums[j] are coprime. Coprime means their greatest common divisor (gcd) is 1.
First, let's understand the requirements. We have to ... |
[
{
"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.\nA subarray is called equal if all of its elements are equal. Note that the empty subarray is an... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 37 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to find the longest equal subarray after deleting at most k elements. Hmm. So, the problem is about finding a subarray where all elements are the same, and we can remove up to k elements to make that happen. The examples given help, but I need to figure out the approach.
First, maybe I should 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 an integer n denoting the total number of servers and a 2D 0-indexed integer array logs, where logs[i] = [server_id, time] denotes that the serve... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 38 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. So, we need to find, for each query, how many servers didn't receive any requests in the interval [query - x, query]. The input is pretty big, with up to 10^5 logs and queries, so we need an efficient solution. Let's think about how to approach this.
First, understanding 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 integer array nums representing the initial positions of some marbles. You are also given two 0-indexed integer arrays moveFrom and m... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 39 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to write a Python function that takes three lists: nums, moveFrom, and moveTo. The goal is to simulate moving marbles from certain positions to others and then return the sorted list of occupied positions after all moves.
First, let me parse the problem again. The initial positions of marbles ... |
[
{
"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 integers num1 and num2.\nIn one operation, you can choose integer i in the range [0, 60] and subtract 2^i + num2 from num1.\nReturn the integ... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 40 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to figure out how to solve this problem where we have two integers, num1 and num2. The goal is to make num1 equal to 0 using the minimum number of operations. Each operation allows me to subtract 2^i + num2 from num1, where i is between 0 and 60. If it's impossible, I should return -1.
Hmm. 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 two 0-indexed integer arrays nums1 and nums2, each of length n, and a 1-indexed 2D array queries where queries[i] = [x_i, y_i].\nFor the i^th que... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 41 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. So, we have two arrays, nums1 and nums2, each of the same length n. Then we have a list of queries, each being a pair [x_i, y_i]. For each query, we need to find the maximum value of nums1[j] + nums2[j] where both nums1[j] >= x_i and nums2[j] >= y_i. If no such j exists, we... |
[
{
"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 integer array nums of length n.\nAn element nums[i] of nums is called special if i divides n, i.e. n % i == 0.\nReturn the sum of the... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 42 | 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 returns the sum of the squares of the "special" elements. The special elements are those whose 1-based index divides the length of the list.
First, I need to understand what a 1-indexed array means. So in 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 positive integer array nums.\nPartition nums into two arrays, nums1 and nums2, such that:\n\nEach element of the array nums belongs to either t... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 43 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to partition the given array into two non-empty subsets such that the absolute difference between the maximum of one subset and the minimum of the other is minimized. Hmm. The examples given seem to suggest that sorting the array might help. Let me think.
In the first example, the array [1,3,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 a 0-indexed array words consisting of distinct strings.\nThe string words[i] can be paired with the string words[j] if:\n\nThe string words[i] is... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 44 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to write a Python function that takes a list of distinct strings called `words` and returns the maximum number of pairs that can be formed. A pair is when one string is the reverse of another, and each string can only be part of one pair.
First, I need to understand the problem better. The exa... |
[
{
"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 n distinct positive integers. A permutation of nums is called special if:\n\nFor all indexes 0 <= i < n... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 45 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to figure out how to count the number of special permutations of a given list of numbers. The problem says a permutation is special if each adjacent pair of numbers satisfies the condition that one divides the other. The answer needs to be modulo 10^9 + 7 because it can get really large.
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.The imbalance number of a 0-indexed integer array arr of length n is defined as the number of indices in sarr = sorted(arr) such that:\n\n0 <= i < n - 1, and\n... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 46 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. The goal is to compute the sum of imbalance numbers for all subarrays of the given array `nums`. The imbalance number of a subarray is the number of adjacent elements in its sorted version where the difference is greater than 1.
First, I need to understand what exactly 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 three integers x, y, and z.\nYou have x strings equal to \"AA\", y strings equal to \"BB\", and z strings equal to \"AB\". You want to choose som... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 47 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to figure out how to maximize the length of a concatenated string using "AA", "BB", and "AB" without having "AAA" or "BBB" as substrings. The counts are x, y, and z for each respective string. Hmm.
First, let's understand the problem. We have three types of strings:
- "AA" (x times)
- "BB" (y ... |
[
{
"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 words containing n strings.\nLet's define a join operation join(x, y) between two strings x and y as concatenating them into xy... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 48 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to figure out how to minimize the length of the final string after joining all the words in the given list using the specified join operation. Let me start by understanding the problem thoroughly.
First, the join operation between two strings x and y. If the last character of x is equal to the first ch... |
[
{
"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 n integers and an integer target.\nYou are initially positioned at index 0. In one step, you can jump from index i to a... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 49 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to solve this problem where I have to jump from the first index to the last index of an array, following some jump conditions related to the target. The goal is to find the maximum number of jumps possible. If it's not possible, return -1.
First, let me understand the problem statement again. ... |
[
{
"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.\nWe call a subarray of an array complete if the following condition is satisfied:\n\nThe number of... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 50 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to find the number of complete subarrays in a given array. A complete subarray is one where the number of distinct elements in the subarray is equal to the number of distinct elements in the entire array. Hmm. So first, I should figure out how many distinct elements are in the whole array. Then,... |
[
{
"content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A truck has two fuel tanks. You are given two integers, mainTank representing the fuel present in the main tank in liters and additionalTank representing the f... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 51 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to figure out how to calculate the maximum distance a truck can travel with two fuel tanks. The main tank has some fuel, and the additional tank has more fuel. The truck gets 10 km per liter. The key part is that every time 5 liters are used from the main tank, if there's fuel left in the additi... |
[
{
"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 threshold.\nFind the length of the longest subarray of nums starting at index l and ending at index... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 52 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. So, we need to find the longest subarray that starts with an even number, alternates between even and odd numbers, and all elements are less than or equal to a given threshold. Hmm, let's break down the requirements.
First, the subarray must start with an even number. 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 binary array nums.\nA subarray of an array is good if it contains exactly one element with the value 1.\nReturn an integer denoting the number ... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 53 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to figure out how to split a binary array into subarrays where each subarray has exactly one '1'. The answer needs to be modulo 10^9 + 7. Hmm. Let's start by understanding the problem better.
First, the examples. For the first example, nums = [0,1,0,0,1], the output is 3. The possible splits 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 integer array nums. A subarray of nums is called continuous if:\n\nLet i, i + 1, ..., j_ be the indices in the subarray. Then, for ea... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 54 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to count all continuous subarrays in a given list where the difference between any two elements in the subarray is at most 2. Hmm. So, a continuous subarray is one where for every pair of elements in the subarray, their absolute difference is between 0 and 2, inclusive.
First, I remember 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 two 0-indexed integer arrays nums1 and nums2 of length n.\nLet's define another 0-indexed integer array, nums3, of length n. For each index i in ... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 55 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. So, we have two arrays, nums1 and nums2, both of the same length n. We need to create a third array, nums3, by choosing elements from either nums1 or nums2 at each index. The goal is to maximize the length of the longest non-decreasing subarray in nums3.
First, I need to ... |
[
{
"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 subarray s of length m is called alternating if:\n\nm is greater than 1.\ns_1 = s_0 + 1.\nThe 0-indexed subarra... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 56 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. So, we need to find the maximum length of an alternating subarray in the given nums array. The definition of an alternating subarray is a bit specific here. Let me make sure I understand it correctly.
First, the subarray must have a length greater than 1. Then, the first 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 consisting of positive integers.\nYou can do the following operation on the array any number of times:\n\nChoose an intege... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 57 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to figure out how to get the largest possible element in the array after performing those operations. The operations allow me to combine two adjacent elements if the first is less than or equal to the second. When I do that, I replace the second element with the sum of both and remove the first ... |
[
{
"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. We say that two integers x and y form a prime number pair if:\n\n1 <= x <= y <= n\nx + y == n\nx and y are prime numbers\n\nReturn ... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 58 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. So, the goal is to find all pairs of prime numbers x and y such that x + y equals a given integer n. The pairs should be in a 2D list sorted by the first element, and each pair should satisfy 1 <= x <= y <= n. If no such pairs exist, we return an empty array.
First, I need... |
[
{
"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 employees in a company, numbered from 0 to n - 1. Each employee i has worked for hours[i] hours in the company.\nThe company requires each employee... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 59 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to write a Python function that takes a list of hours each employee worked and a target number of hours. The function should return how many employees met or exceeded the target hours.
First, I'll start by understanding the problem better. The input is a list called `hours` where each element ... |
[
{
"content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given three strings a, b, and c, your task is to find a string that has the minimum length and contains all three strings as substrings.\nIf there are multiple... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 60 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to create a Python function that takes three strings a, b, and c, and finds the shortest string that contains all three as substrings. If there are multiple such strings, it should return the lexicographically smallest one. Hmm, let's break this down.
First, the problem is about finding a common supers... |
[
{
"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 s... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 61 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to figure out if I can make all elements in the array zero by repeatedly subtracting 1 from any subarray of size k. Hmm. So each operation is choosing a k-length contiguous subarray and decreasing each element by 1. The question is whether doing this any number of times can result in all zeros.
... |
[
{
"content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a string s and an integer k, partition s into k substrings such that the sum of the number of letter changes required to turn each substring into a semi-... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 62 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. So, we need to partition a string s into k substrings such that the total number of character changes required to make each substring a semi-palindrome is minimized. Hmm, first, I need to make sure I fully understand what a semi-palindrome is.
From the notes, a semi-palind... |
[
{
"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 strings words and a character separator, split each string in words by separator.\nReturn an array of strings containing the new strings form... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 63 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to write a Python function that takes a list of strings called `words` and a `separator` character. The function should split each string in `words` by the `separator`, exclude any empty strings, and return a new list with all the resulting strings. The order has to be maintained as in the origi... |
[
{
"content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given two positive integers n and x.\nReturn the number of ways n can be expressed as the sum of the x^th power of unique positive integers, in other words, th... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 64 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem. So, we need to find the number of ways to express a given integer n as the sum of unique integers each raised to the xth power. The result needs to be modulo 10^9 + 7. Hmm, okay. Let's break this down.
First, let's understand the problem with the examples they gave. For n=10 and x=2, t... |
[
{
"content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a binary string s, partition the string into one or more substrings such that each substring is beautiful.\nA string is beautiful if:\n\nIt doesn't conta... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 65 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. So, we need to partition a binary string into the minimum number of substrings, each being a power of 5 in binary form and not having leading zeros. If it's impossible, return -1.
First, let's understand what a "beautiful" substring is. It must be a power of 5, which in b... |
[
{
"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 array of strings forbidden.\nA string is called valid if none of its substrings are present in forbidden.\nReturn the length... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 66 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. So, the goal is to find the length of the longest valid substring in the given word, where a valid substring is one that doesn't contain any of the forbidden substrings.
First, I need to understand the problem thoroughly. The examples given help clarify what's expected. F... |
[
{
"content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Your laptop keyboard is faulty, and whenever you type a character 'i' on it, it reverses the string that you have written. Typing other characters works as exp... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 67 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to write a Python function that takes a string s as input and returns the final string after typing each character on a faulty keyboard. The keyboard reverses the current string whenever the character 'i' is typed. Other characters are added as usual.
First, I'll start by understanding the pro... |
[
{
"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 string s, permute s to get a new string t such that:\n\nAll consonants remain in their original places. More formally, if there is an index i... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 68 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. So, the task is to permute a given string `s` such that all consonants stay in their original positions, and the vowels are sorted in non-decreasing order based on their ASCII values. The vowels can be both uppercase and lowercase, right?
First, I need to identify which c... |
[
{
"content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.An element x of an integer array arr of length m is dominant if freq(x) * 2 > m, where freq(x) is the number of occurrences of x in arr. Note that this definit... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 69 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. The goal is to find the minimum index where we can split the array such that both subarrays have the same dominant element. The dominant element is defined as the one that appears more than n/2 times in the array, where n is the length of the array. Since the original array... |
[
{
"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 a non-negative integer k.\nIn one operation, you can do the following:\n\nChoose an index i that hasn't been chosen be... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 70 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to figure out how to maximize the beauty of the array after replacing each element at most once with a number within [num - k, num + k]. The beauty is the length of the longest subsequence of equal elements.
So, the goal is to make as many elements as possible the same through these replacemen... |
[
{
"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. We consider an array good if it is a permutation of an array base[n].\nbase[n] = [1, 2, ..., n - 1, n, n] (in other words,... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 71 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to write a function that checks if a given array is a permutation of the base[n] array. The base[n] array is defined as [1, 2, ..., n-1, n, n]. So, it's a sequence from 1 to n, but with n appearing twice, making the total length n+1. The task is to determine if the input array nums is a permutat... |
[
{
"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 x.\nYou are initially at position 0 in the array and you can visit other positions accordin... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 72 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to solve this problem where I have an array of integers and a value x. The goal is to start at position 0 and move to other positions, collecting points from each position I visit. However, if I move from a position i to j and their parities (even or odd) differ, I lose x points. The challenge 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. You have to find the maximum sum of a pair of numbers from nums such that the maximum digit in both numbers are e... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 73 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to write a Python function that takes a list of integers and returns the maximum sum of a pair of numbers where both numbers have the same maximum digit. If no such pair exists, return -1. Hmm.
First, I need to understand the problem better. For each number in the list, I have to determine its ... |
[
{
"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, an integer modulo, and an integer k.\nYour task is to find the count of subarrays that are interesting.\nA subarr... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 74 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. So, we need to find the number of subarrays that are "interesting" based on the given conditions. An interesting subarray is one where the count of elements that satisfy nums[i] % modulo == k, when taken modulo the same number, equals k. Hmm, that's a bit of a mouthful, but... |
[
{
"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 an integer m. You need to determine if it is possible to split the array into n non-empty arrays by performing a se... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 75 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to figure out if I can split the given array into n single-element arrays by splitting it step by step, following the given rules. Each time I split a subarray, each resulting part must either be length 1 or have a sum >= m. The key here is that we need to be able to split the array all the way ... |
[
{
"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 integer array nums of length n and an integer target, return the number of pairs (i, j) where 0 <= i < j < n and nums[i] + nums[j] < target.\... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 76 | 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 `target`. The function should return the number of pairs (i, j) where i is less than j, and the sum of nums[i] and nums[j] is less than the target.
First, I need to understand the problem properly. The exampl... |
[
{
"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 usageLimits of length n.\nYour task is to create groups using numbers from 0 to n - 1, ensuring that each number, i, is used no... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 77 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to figure out how to create the maximum number of groups using numbers from 0 to n-1, where each number has a usage limit. Each group must have distinct numbers, and each subsequent group must be larger than the previous one. Hmm.
First, let me understand the problem better. The key constraints... |
[
{
"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 containing n integers.\nAt each second, you perform the following operation on the array:\n\nFor every index i in the rang... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 78 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to figure out the minimum number of seconds required to make all elements in a circular array equal. The operation allowed is replacing each element with either itself, its left neighbor, or its right neighbor, all at the same time. Hmm.
First, let me understand the problem better. The array i... |
[
{
"content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given two positive integers low and high represented as strings, find the count of stepping numbers in the inclusive range [low, high].\nA stepping number is a... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 79 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this stepping numbers problem. So, the task is to find how many stepping numbers are there between two given numbers, low and high, both represented as strings. Stepping numbers are those where each pair of adjacent digits has an absolute difference of 1. For example, 123 is a stepping number because... |
[
{
"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 equal length. Every second, for all indices 0 <= i < nums1.length, value of nums1[i] is increment... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 80 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to figure out how to solve this problem where we have two arrays, nums1 and nums2, and we need to make the sum of nums1 less than or equal to x in the minimum number of seconds. Each second, nums1[i] increases by nums2[i], and after that, we can set one element of nums1 to zero. If it's not poss... |
[
{
"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 integer array coordinates and an integer k, where coordinates[i] = [x_i, y_i] are the coordinates of the i^th point in a 2D plane.\nWe defin... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 81 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. So, we need to find the number of pairs of points where the XOR distance between them equals a given integer k. The distance is defined as (x1 XOR x2) + (y1 XOR y2). Hmm, interesting. Let me break this down.
First, the input is a list of coordinates, each being [x_i, y_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 an integer array nums and two positive integers m and k.\nReturn the maximum sum out of all almost unique subarrays of length k of nums. If no su... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 82 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. So, we need to find the maximum sum of almost unique subarrays of length k in nums, where almost unique means having at least m distinct elements. If no such subarray exists, return 0.
First, I need to understand the problem thoroughly. Let's restate it: given an array nu... |
[
{
"content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Initially, you have a bank account balance of 100 dollars.\nYou are given an integer purchaseAmount representing the amount you will spend on a purchase in dol... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 83 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to create a Python function that calculates the remaining balance after a purchase. The initial balance is $100. The purchase amount is given, but the store rounds it to the nearest multiple of 10. If there's a tie between two multiples, they choose the larger one. Then, subtract that rounded am... |
[
{
"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 strings words and a string s, determine if s is an acronym of words.\nThe string s is considered an acronym of words if it can be formed by c... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 84 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to write a function that checks if a given string `s` is an acronym formed by the first letters of each word in a list called `words`. Hmm. So, for example, if the words are ["alice", "bob", "charlie"], the acronym would be "abc". If `s` is "abc", then it should return True. But if the words are... |
[
{
"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 representing the number of houses on a number line, numbered from 0 to n - 1.\nAdditionally, you are given a 2D integer array offers... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 85 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to figure out how to maximize the gold earned by selling houses to different buyers. The problem says that each buyer wants to buy a range of houses from start_i to end_i for gold_i. The key constraint is that different buyers can't buy the same house, so overlapping ranges aren't allowed. The 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 two positive integers low and high.\nAn integer x consisting of 2 * n digits is symmetric if the sum of the first n digits of x is equal to the s... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 86 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. So, we need to find the number of symmetric integers between two given numbers, low and high. The definition of a symmetric integer here is a number with an even number of digits where the sum of the first half of the digits equals the sum of the second half. Numbers with 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 two strings s1 and s2, both of length 4, consisting of lowercase English letters.\nYou can apply the following operation on any of the two string... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 87 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to figure out if I can make two 4-character strings equal by swapping characters that are two indices apart. So, the operation allowed is swapping characters at positions i and j where j - i = 2.
First, let me understand the problem better. Both strings are of length 4. The operation is simila... |
[
{
"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 x.\nFind the minimum absolute difference between two elements in the array that are at least x indi... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 88 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to find the minimum absolute difference between two elements in the array that are at least x indices apart. Hmm. So, given the array nums and an integer x, I have to look for two indices i and j where the absolute difference between nums[i] and nums[j] is as small as possible, but they have to ... |
[
{
"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": 0,
"temperature": 0.7
} | 0 | 89 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. So, we need to find the number of beautiful integers between low and high inclusive. A beautiful integer has two conditions: equal number of even and odd digits, and it's divisible by k.
First, I need to figure out how to check if a number meets both conditions. Let's bre... |
[
{
"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": 0,
"temperature": 0.7
} | 0 | 90 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to figure out if I can make str2 a subsequence of str1 by incrementing some characters in str1 at most once. Hmm. So, a subsequence means the characters in str2 need to appear in the same order in str1, right? But they don't have to be consecutive. So, for example, if str1 is "abc" and str2 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 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": 0,
"temperature": 0.7
} | 0 | 91 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to figure out the furthest distance from the origin after making all the moves given in the string. The moves can be 'L', 'R', or '_', where '_' means I can choose either direction. The key here is that for each '_', I can pick the direction that will get me the furthest away from the origin. Hm... |
[
{
"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": 0,
"temperature": 0.7
} | 0 | 92 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. So, we have two strings s and t of the same length n, and we need to find the number of ways to transform s into t using exactly k operations. Each operation allows us to take a suffix of length l (where 0 < l < n) and move it to the front. The answer needs to be modulo 10^... |
[
{
"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": 0,
"temperature": 0.7
} | 0 | 93 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. So, we have an array of numbers which are all powers of 2, and a target sum. We need to find the minimum number of operations required to make a subsequence of the array that sums up to the target. Each operation allows us to take a number greater than 1, remove it, and add... |
[
{
"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": 0,
"temperature": 0.7
} | 0 | 94 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to create a function that takes a 2D integer matrix called grid and returns another 2D matrix where each element is the product of all elements in the original grid except for the element at that position, and then take that product modulo 12345. Alright, let's break this down.
First, the problem is si... |
[
{
"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": 0,
"temperature": 0.7
} | 0 | 95 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. So, we need to find the maximum value of f(x) where f(x) is the sum of x and the ids of all players who receive the ball during k passes, starting from x. The receiver array tells us who each player passes to. The challenge here is that n can be up to 10^5 and k can be up 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 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": 0,
"temperature": 0.7
} | 0 | 96 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to figure out how to make two binary strings, s1 and s2, equal with the minimum cost using the given operations. The operations are flipping two indices with a cost x or flipping two adjacent indices with a cost 1. Hmm.
First, I should start by understanding what operations are allowed. The fi... |
[
{
"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": 0,
"temperature": 0.7
} | 0 | 97 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. 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 examples given are like [[3,6],[1,5],[4,7]] which should return 7 because points from 1 to 7 are covered. Another example is [[1,3],[5,8]] which co... |
[
{
"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": 0,
"temperature": 0.7
} | 0 | 98 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to figure out the minimum number of operations required to collect all elements from 1 to k. The operation is removing the last element of the array and adding it to the collection. So, each time I perform an operation, I'm essentially taking the last element of the current array and moving it 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 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": 0,
"temperature": 0.7
} | 0 | 99 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. So, the task is to determine the minimum number of right shifts needed to sort the array in ascending order. If it's not possible, return -1. Hmm, right shifts mean moving each element one position to the right, wrapping around to the front after the last element.
First, ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.