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.In a mystic dungeon, n magicians are standing in a line. Each magician has an attribute that gives you energy. Some magicians can give you negative energy, whi... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 500 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to figure out how to solve this problem where you have to start at some magician and then jump k steps each time, collecting energy along the way. The goal is to find the maximum possible energy you can gain. Hmm.
First, let me make sure I understand the problem correctly. We have n magicians ... |
[
{
"content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.An array is considered special if every pair of its adjacent elements contains two numbers with different parity.\nYou are given an array of integers nums. Ret... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 501 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to check if an array is special, meaning every pair of adjacent elements has different parity. So, parity is whether a number is odd or even. That means each neighboring pair must consist of one even and one odd number. If the array has length 1, it's automatically special because there are no 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 an array nums consisting of positive integers where all integers have the same number of digits.\nThe digit difference between two integers is th... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 502 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to write a function that calculates the sum of digit differences between all pairs of integers in an array. The digit difference is the count of different digits in the same position. All numbers have the same number of digits, which is good.
First, I need to figure out how to compute the digi... |
[
{
"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 non-negative integer k. There exists a staircase with an infinite number of stairs, with the lowest stair numbered 0.\nAlice has an integer jum... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 503 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to figure out how to count the number of ways Alice can reach stair k starting from stair 1. The operations she can do are going down one stair (but not consecutively or on stair 0) or going up by 2^jump stairs and then increasing the jump by 1. Hmm, this seems like a dynamic programming problem... |
[
{
"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 2 integer arrays nums1 and nums2 of lengths n and m respectively. You are also given a positive integer k.\nA pair (i, j) is called good if nums1... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 504 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to find the number of good pairs between two arrays, nums1 and nums2, where a pair (i, j) is good if nums1[i] is divisible by nums2[j] multiplied by k.
First, I should understand the problem properly. So, given two arrays and an integer k, I have to check for each possible pair (i, j) whether ... |
[
{
"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 word, compress it using the following algorithm:\n\nBegin with an empty string comp. While word is not empty, use the following operation:\n\n\t... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 505 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to write a Python function that compresses a given string using a specific algorithm. The algorithm says to start with an empty string called comp. Then, while the original word isn't empty, I should repeatedly remove a maximum length prefix made of a single character c, but this prefix can repe... |
[
{
"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 integers. You are also given a 2D array queries, where queries[i] = [pos_i, x_i].\nFor query i, we first set nums[pos... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 506 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. So, we have an array nums and a list of queries. Each query updates a specific position in nums and then asks for the maximum sum of a non-adjacent subsequence. We need to handle all queries and return the sum of their results modulo 10^9 + 7.
First, I need to remember how... |
[
{
"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, you need to partition it into one or more balanced substrings. For example, if s == \"ababcc\" then (\"abab\", \"c\", \"c\"), (\"ab\", \"abc\... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 507 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to figure out how to partition a string into the minimum number of balanced substrings. Each balanced substring requires that every character in it appears the same number of times. So, for example, "ababcc" can be split into "abab", "c", "c" because each character in "abab" (a and b) appear twi... |
[
{
"content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A powerful array for an integer x is the shortest sorted array of powers of two that sum up to x. For example, the powerful array for 11 is [1, 2, 8].\nThe arr... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 508 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem step by step. So, we need to generate a function that can handle multiple queries on the big_nums array, which is formed by concatenating the powerful arrays of all positive integers. Each query asks for the product of a segment of big_nums modulo some number. The challenge 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 an array nums, where each number in the array appears either once or twice.\nReturn the bitwise XOR of all the numbers that appear twice in the a... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 509 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to write a Python function that takes an array of numbers where each number appears either once or twice. The function should return the bitwise XOR of all numbers that appear twice, or 0 if no number appears twice.
First, I need to figure out how to identify which numbers appear twice. Since ... |
[
{
"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, an integer array queries, and an integer x.\nFor each queries[i], you need to find the index of the queries[i]^th occurren... | {
"do_sample": false,
"max_new_tokens": 32768,
"seed": 0,
"temperature": 0.7
} | 0 | 510 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to create a function that takes in three parameters: nums, queries, and x. The goal is to find the index of the queries[i]^th occurrence of x in nums. If there aren't enough occurrences, return -1 for that query.
First, I should think about how to efficiently handle this. The constraints are p... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 0 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to write a Python function that checks if a given permutation of 'a', 'b', 'c' can be sorted into 'abc' with at most one swap. The function should take input from stdin, process each test case, and print "YES" or "NO" accordingly. Let's break down the problem step by step.
First, understanding the prob... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 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. We have multiple test cases,... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 2 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to figure out how to solve this problem where we have a strip of cells, some black (B) and some white (W), and we can turn any k consecutive cells white in one operation. The goal is to find the minimum number of operations needed to make all cells white. Let's break down the problem and think about pos... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 3 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to write a Python function that can determine if it's possible to remove exactly k characters from a given string such that the remaining characters can form a palindrome. The input will have multiple test cases, each with a string s of length n and an integer k. The output should be "YES" or "NO" for e... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 4 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to write a Python function that solves this problem where we have to find the minimum number of increments needed to make the product of an array divisible by k. The function should take standard input, process each test case, and print the results. Let me try to break this down step by step.
First, un... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 5 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to figure out this problem where Vanya and Vova are playing a game with an integer n. The rules are that each player can either add 1 or subtract 1 from the current integer on their turn. Vanya goes first. If after Vanya's move the number is divisible by 3, he wins. If after 10 moves (which would be 5 t... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 6 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's try to figure out how to solve this problem. So, Alex wants to maximize the difference in total weight between any two trucks. Each truck carries exactly k boxes, and we need to consider all possible k from 1 to n, then find the maximum possible difference.
First, let me understand the problem statement a... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 7 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to solve this problem where Yarik wants the maximum sum of a non-empty subarray with alternating parities. Let me try to understand the problem first.
A subarray is a continuous part of the array. The key constraint here is that the subarray must have alternating parities for adjacent elements. That me... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 8 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's try to figure out this problem. So, Yarik has these notes represented by integers which are powers of 2, right? Each note is 2 raised to some exponent ai, where ai is a positive integer. Then, when he combines two notes bi and bj, he denotes it by bi^bj. The question is, given an array of exponents a1, a2, ... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 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 length of 15 characters. The task is to return the number of passengers who are strictly more than 60 years old.
First, I need to figure out how the information is structured in eac... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 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 repeatedly remove the largest element from each row, add the highest among those removed to the score, and repeat until the matrix is empty. The examples given should help test the function.
First, I need to pr... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 11 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to figure out how to maximize the bitwise OR of all elements in an array after multiplying up to k elements by 2. Let's break this down.
First, the problem says we can multiply any element by 2 up to k times. Each multiplication counts as one operation, and we want the maximum possible OR result. 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 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": 1,
"temperature": 0.7
} | 1 | 12 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to write a Python function that takes a list of integers representing students' scores and returns the maximum strength of a group. The strength is the product of the scores in the group. The group can't be empty, and we need to pick the best possible combination.
First, let me understand the problem ... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 13 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to write a Python function that takes a string `s` and a dictionary of words, and returns the minimum number of extra characters left after breaking `s` into non-overlapping substrings that are present in the dictionary. The examples given help clarify: for "leetscode" with dictionary ["leet", "code", "... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 14 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to write a Python function that takes an array 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 just ... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 15 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to write a Python function that counts the number of integers between two given numeric strings, 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, let me understand the problem better. The inputs are two strings re... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 16 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to create a function that takes an array called nums and returns its distinct difference array. The distinct difference array is calculated such that for each index i, the value is the number of distinct elements in the prefix (from the start up to i) minus the number of distinct elements in the suffix ... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 17 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's try to figure out how to solve this problem. So, we have an array that starts all zeros, and we get a bunch of queries where we color a specific index with a given color. After each query, we need to count how many adjacent pairs have the same color. The challenge is to do this efficiently because both n an... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 18 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to solve this problem where I have to calculate the sum of the power of all non-empty groups of heroes. The power of a group is defined as the square of the maximum strength in the group multiplied by the minimum strength in the group. Then, I need to return this sum modulo 10^9 + 7.
First, let me mak... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 19 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to figure out how to solve this problem where I have to make a permutation semi-ordered with the minimum number of adjacent swaps. Let me start by understanding the problem better.
First, a semi-ordered permutation is one where the first element is 1 and the last element is n. The rest can be in any or... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 20 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to write a Python function that finds the longest semi-repetitive substring in a given string s. Semi-repetitive means there's at most one consecutive pair of the same digits. Let me think about how to approach this.
First, I remember that for substring problems, sliding window is a common technique. S... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 21 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to solve this problem where friends are sitting in a circle and passing a ball according to some rules. The goal is to find out which friends never received the ball. Hmm. Let me try to break it down.
First, the setup: there are n friends in a circle, numbered 1 to n clockwise. The game starts ... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 22 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to figure out if there's a binary array 'original' that, when I compute the XOR of adjacent elements (and wrap around the last one with the first), gives the 'derived' array. The problem is asking to determine whether such an original array exists.
Let me start by understanding the problem better. Giv... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 23 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to write a Python function that takes a string s as input and returns the minimum possible length after removing all occurrences of "AB" or "CD" repeatedly. The key here is that after each removal, the remaining parts of the string concatenate, and new "AB" or "CD" substrings might form. The goal is to ... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 24 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to write a Python function that calculates the punishment number for a given positive integer n. The punishment number is 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... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 25 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to figure out how to solve this problem where we have two painters: a paid one and a free one. The goal is to find the minimum cost to paint all the walls. Let's break down the problem step by step.
First, let's understand the problem again. We have two painters. The paid painter can paint any wall i 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 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": 1,
"temperature": 0.7
} | 1 | 26 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to figure out how to solve this problem where we have these chocolates with different costs, and we can rotate their types with some cost x each time. The goal is to collect all types of chocolates with the minimum total cost. Let me try to break this down.
First, let's understand the problem statement... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 27 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to figure out how to create a Python 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 add up to k. Let me think through this step by step.
First, let's unders... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 28 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. The problem is about finding the maximum achievable number x that can be turned into num after applying a certain operation at most t times. The operation allowed is increasing or decreasing x by 1 and simultaneously doing the opposite to num. Hmm, interesting.
So, in each operation, x can be changed ... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 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 among those possible palindromes, choose the lexicographically smallest one. Let me start by understanding the problem better.
First, a palindrome is a string that reads the same forwards and backwards. 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 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": 1,
"temperature": 0.7
} | 1 | 30 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to figure out the minimum cost to make all characters in a binary string equal. The operations allowed are inverting from the start up to some index i (cost i+1) or inverting from some index i to the end (cost n-i). Hmm. Let me think through this step by step.
First, the problem is about transforming 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 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": 1,
"temperature": 0.7
} | 1 | 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 as a string without any trailing zeros. Let me think about how to approach this.
First, the examples given are straightforward. For "51230100", the trailing zeros are at the end, so removing them... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 32 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to write a Python function that checks if a given three-digit number n is fascinating. The definition of fascinating here is that when you concatenate n, 2n, and 3n together, the resulting number contains each digit from 1 to 9 exactly once and doesn't have any zeros.
First, let me make sure I underst... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 33 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so 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. Let me try to understand the problem better.
First, the operation allows me to pick any index i in the stri... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 34 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to figure out if I can traverse between all pairs of indices in the given array nums, where the traversal is allowed only if the gcd of the numbers at those indices is greater than 1. The problem is essentially asking if the graph formed by these connections is strongly connected. But since the graph 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 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": 1,
"temperature": 0.7
} | 1 | 35 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so 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 'a', '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 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": 1,
"temperature": 0.7
} | 1 | 36 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to write a Python function that counts the number of "beautiful pairs" in a given list of integers. A beautiful pair is defined as a pair of indices i and j (with i < j) where the first digit of nums[i] and the last digit of nums[j] are coprime. Coprime means their greatest common divisor (gcd) is 1.
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 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": 1,
"temperature": 0.7
} | 1 | 37 | 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 longest equal subarray after deleting at most k elements. Let me try to understand the problem first.
Given an array nums and an integer k, I need to delete at most k elements to make the longest possible equal subarray. The subarray has ... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 38 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's tackle this problem. Hmm, so we need to find, for each query, how many servers didn't receive any requests in the time interval [query - x, query]. The input is n servers, a list of logs with server IDs and times they received requests, x is the duration before each query, and the queries themselves.
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 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": 1,
"temperature": 0.7
} | 1 | 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 function should simulate moving marbles from certain positions to others as specified by moveFrom and moveTo arrays, and then return the sorted list of occupied positions after all moves are applied.
First, let 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 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": 1,
"temperature": 0.7
} | 1 | 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 have to return -1.
Hmm. Le... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 41 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to write a Python function that takes two lists, nums1 and nums2, and a list of queries. Each query is a pair [xi, yi], and for each query, I have to find the maximum sum of nums1[j] + nums2[j] where both nums1[j] >= xi and nums2[j] >= yi. If no such j exists, the answer should be -1. The function shoul... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 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-based index means. So, if the list is `[1... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 43 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to figure out how to partition an 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. Let's see. The examples given help, but I need to come up with a general approach.
First, let's understand the problem. We ha... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 44 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so 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 consists of two strings where one is the reverse of the other, and each string can only be part of one pair. Let me think through how to approach this.
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 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": 1,
"temperature": 0.7
} | 1 | 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 integers. A special permutation is one where each adjacent pair of numbers satisfies the condition that one divides the other. The problem is similar to counting permutations with certain adjacency constraints, which makes ... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 46 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to write a Python function that calculates the sum of imbalance numbers for all subarrays of a given array `nums`. The imbalance number of a subarray is the number of indices in its sorted version where the difference between consecutive elements is greater than 1.
First, let me make sure I understand... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 47 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to figure out how to create the longest possible string by concatenating some combination of "AA", "BB", and "AB" strings without having "AAA" or "BBB" as substrings. The input is three integers x, y, z representing the number of each string we have. The goal is to return the maximum length possible.
... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 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. The join operation allows either appending the next word to the current string or prepending it, but if the last character of the first string matches 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 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": 1,
"temperature": 0.7
} | 1 | 49 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to figure out how to solve this problem where you have to jump from the first index to the last index of an array, with the number of jumps depending on the difference between the numbers in the array and the target value. The goal is to find the maximum number of jumps you can make while still being ab... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 50 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to figure out how to count 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. Let me break this down step by step.
First, let's understand what a subarray is... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 51 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. So the problem is about a truck with two fuel tanks: a main tank and an additional tank. We need to calculate the maximum distance the truck can travel given the initial amounts of fuel in both tanks. The truck's mileage is 10 km per liter.
The key part here is that whenever 5 liters are used from 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 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": 1,
"temperature": 0.7
} | 1 | 52 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to find the longest subarray that starts with an even number, alternates between even and odd, and all elements are less than or equal to the threshold. Hmm. So, the subarray has to begin at an even index, then each subsequent element must alternate in parity, and none of them can exceed the thr... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 53 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to figure out how to count the number of ways to split a binary array into subarrays where each subarray contains exactly one '1'. The examples given help, but let's break it down.
First, the problem says a "good" subarray has exactly one '1'. So, the entire array must be split into contiguous subarray... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 54 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to figure out how to count all continuous subarrays in a given list where the difference between any two elements in the subarray is at most 2. Let me think about how to approach this.
First, let me make sure I understand the problem correctly. A continuous subarray is a contiguous segment of the 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 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": 1,
"temperature": 0.7
} | 1 | 55 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to figure out how to maximize the length of the longest non-decreasing subarray in nums3, which is constructed by choosing elements from nums1 and nums2 at each index. Let me think step by step.
First, the problem is about dynamic programming, right? Because we have overlapping subproblems where the 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 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": 1,
"temperature": 0.7
} | 1 | 56 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's try to figure out how to solve this problem. So, we need to find the maximum length of an alternating subarray in the given nums array. An alternating subarray is defined as one where each consecutive element alternates between increasing by 1 and decreasing by 1. For example, if the first element is s0, 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 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": 1,
"temperature": 0.7
} | 1 | 57 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to figure out how to solve this problem where you can merge adjacent elements in an array if the current element is less than or equal to the next one. The goal is to get the largest possible element in the final array. Let me think through this step by step.
First, let me make sure I understand the op... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 58 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to write a Python function that takes an integer n and returns all pairs of primes x and y such that x + y = n, with 1 <= x <= y <= n. The output should be a 2D list sorted by the first element of each pair. If there are no such pairs, return an empty list.
First, I should figure out the steps involved... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 59 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to write a Python function that counts how many employees met or exceeded a target number of hours. Let me think about how to approach this.
First, the function should take two inputs: a list of integers called `hours` where each element represents the hours worked by an employee, and an integer `targ... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 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 combining three strings... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 61 | 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 positive integer k. The goal is to determine if I can make all elements of the array zero by repeatedly decreasing any subarray of size k by 1. Let's break this down step by step.
First, let's understand the problem stateme... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 62 | 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 partitions s into k substrings such that the total number of letter changes required to make each substring a semi-palindrome is minimized. The function should return this minimum number of changes. Hmm, let's start by understanding ... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 63 | 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 `separator`. The function should split each string in `words` by the `separator`, exclude any empty strings that result from the split, and return a new list with all the non-empty parts. The order of the resulting st... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 64 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to figure out how to write a Python function that solves this problem where we have to find the number of ways to express a given integer n as the sum of unique integers raised to the xth power. The examples given help clarify: for n=10 and x=2, the output is 1 because 10 can be written as 1² + 3². Simi... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 65 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to write a Python function that takes a binary string `s` and partitions it into the minimum number of substrings, each of which is "beautiful". A beautiful substring can't have leading zeros and must be a power of 5 in binary form. If it's impossible to partition the string into such substrings, 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 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": 1,
"temperature": 0.7
} | 1 | 66 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to figure out how to find the longest valid substring of a given word, where a valid substring is one that doesn't contain any of the forbidden substrings. The constraints are pretty big, so I can't just check every possible substring, which would be O(n^3) time complexity. That's way too slow for the g... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 67 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to write a Python function that processes a string s. The problem is that whenever the character 'i' is typed, it reverses the current string on the screen. Other characters are just appended as usual. The function should return the final string after all characters in s have been processed.
Fi... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 68 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to write a Python function that takes a string `s` and returns a new string `t` where all the consonants stay in their original positions, and the vowels are sorted in non-decreasing order based on their ASCII values. The vowels can be lowercase or uppercase. Let me think about how to approach this step... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 69 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to write a Python function that solves this dominant element split problem. Let me try to understand the problem first.
We have an array with one dominant element. A dominant element is one where its frequency multiplied by 2 is greater than the length of the array. The task is to find the minimum ind... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 70 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to figure out how to solve this problem where we have an array nums and an integer k. The goal is to replace each element at most once with any integer within [nums[i] - k, nums[i] + k], and then find the maximum possible beauty, which is the length of the longest subsequence of equal elements.
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 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": 1,
"temperature": 0.7
} | 1 | 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 list that starts with numbers from 1 to n-1 each appearing once, and then n appears twice. The function should return True if the input 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 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": 1,
"temperature": 0.7
} | 1 | 72 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to solve this problem where I have to maximize the score by jumping through an array, right? Let's see. The rules are that I start at position 0, and I can only move to a higher index. Each time I land on a position, I add its value to my score. But if the parity (even or odd) of the current number 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. 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": 1,
"temperature": 0.7
} | 1 | 73 | 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 sum of two numbers from the list where the maximum digit in both numbers is the same. If no such pair exists, it should return -1.
First, I need to understand the problem thoroughly. Let's go through 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, 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": 1,
"temperature": 0.7
} | 1 | 74 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to solve this problem where I have to count the number of interesting subarrays. An interesting subarray is defined as a subarray where the count of elements that satisfy nums[i] % modulo == k is congruent to k modulo the same modulo.
First, let me make sure I understand the problem correctly. Given 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 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": 1,
"temperature": 0.7
} | 1 | 75 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to figure out how to determine if an array can be split into n non-empty subarrays by following those specific rules. Let me try to understand the problem better.
Given an array nums of length n and an integer m, we need to check if we can split the array into n individual elements through a series of ... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 76 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to write a Python function that counts the number of pairs in a list where the sum of the pair is less than a given target. Let me think about how to approach this.
First, the function should take two parameters: nums, which is a list of integers, and target, which is an integer. The goal is to find al... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 77 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so 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, let's break this down.
First, the problem is similar to creating increas... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 78 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to figure out how to solve this problem where we have to make all elements in a circular array equal with the minimum number of seconds. Each second, every element can be replaced by itself, its left neighbor, or its right neighbor. All replacements happen simultaneously. Let me try to break this down.
... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 79 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to write a Python function that counts the number of stepping numbers between two given numbers, low and high. Stepping numbers are those where each adjacent digit has an absolute difference of 1. For example, 123 is a stepping number because 1 and 2 differ by 1, and 2 and 3 also differ by 1. The functi... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 80 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so 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, every element in nums1 is incremented by the corresponding element in nums2, and after that, we can set one eleme... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 81 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to write a Python function that takes a list of coordinates and an integer k, and returns the number of pairs of points where the distance between them is equal to k. The distance here is defined as (x1 XOR x2) + (y1 XOR y2).
First, let me make sure I understand the problem correctly. We have a list 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 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": 1,
"temperature": 0.7
} | 1 | 82 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to write a Python function that takes an integer array `nums` and two integers `m` and `k`. The function should return the maximum sum of all almost unique subarrays of length `k`. An almost unique subarray here means it has at least `m` distinct elements. If no such subarray exists, return 0.
Let me s... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 83 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, let's see. I need to write 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 amo... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 84 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to write a Python function that checks if a given string `s` is an acronym formed by the first letters of each word in a list called `words`. Let me think about how to approach this.
First, the problem says that the acronym is formed by concatenating the first character of each string in the `words` li... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 85 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to figure out how to solve this problem where I have to maximize the gold earned by selling houses to buyers with different offers. Let me try to understand the problem first.
We have n houses, numbered from 0 to n-1. Then there are these offers, each specified by a start index, end index, and the amou... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 86 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to write a Python function that counts the number of symmetric integers between two given numbers, low and high. Let me first make sure I understand the problem correctly.
A symmetric integer is defined as a number with 2n digits where the sum of the first n digits equals the sum of the last n digits.... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 87 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to figure out how to determine if two 4-character strings can be made equal by swapping characters that are two indices apart. Let me think through this step by step.
First, the problem says we can swap any two indices i and j where j - i = 2. That means we can swap positions 0 and 2, or 1 and 3. For e... |
[
{
"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": 1,
"temperature": 0.7
} | 1 | 88 | LiveCodeBench | {
"expected_answer": "",
"problem_id": "",
"reference_solution": ""
} | Okay, so I need to find the minimum absolute difference between two elements in the array that are at least x indices apart. Let's see. The problem says that for two indices i and j, the absolute difference between their values should be minimized, but they need to be at least x apart in indices.
First, I should thin... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.