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 1.42k 151k |
|---|---|---|---|---|---|---|
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. The problem is about checking if a given permutation of the three letters a, b, c can be turned into "abc" with at most one swap. So, for each test case, which is a string of three distinct characters a, b, c, we need to determine if it's possible.
Hmm. So first, the initial thou... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. The problem is about finding the maximum product of digits after adding 1 to exactly one digit. Hmm. So, the input is an array of digits, and we have to choose which one to increment by 1 to get the largest possible product.
First, I need to understand the approach here. For eac... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the minimum number of operations to turn all the black cells into white. Each operation can take any k consecutive cells and turn them all white. So the problem is about covering all the B's with as few k-length intervals as possible, right?
Hmm. Let's think about ... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to solve this problem where I have to determine if after removing exactly k characters from a string, the remaining characters can be rearranged into a palindrome. Hmm. So the main idea is to check the conditions for forming a palindrome with the remaining characters.
Firs... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the minimum number of operations to make the product of the array divisible by k. Each operation is incrementing a single element by 1. So the problem is, for each test case, compute the minimal steps required.
Hmm. Let's think about the factors of k. Because the 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.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": ""
} | <|begin_of_thought|>
Okay, let's try to figure out this problem. So the problem is about a game between Vanya and Vova. They start with a number n, and on each turn, a player can add 1 or subtract 1. Vanya goes first. If after Vanya's move the number becomes divisible by 3, he wins. If after 10 moves (so 5 turns each)... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's try to understand this problem. So, the task 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. Then, among all those possible k's, we need to choose th... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the maximum sum of a non-empty subarray where the elements have alternating parities. So, adjacent elements must be even and odd alternately. Hmm. The problem is similar to the maximum subarray problem, but with a parity condition.
First, I should think about how 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.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": ""
} | <|begin_of_thought|>
Okay, let's try to solve this problem. Hmm, the problem is about counting pairs (i, j) where i < j such that b_i^b_j equals b_j^b_i. And each b is 2 raised to a certain a_i. So, we need to find pairs where (2^a_i)^(2^a_j) equals (2^a_j)^(2^a_i).
Wait, let's simplify the equation. Let's write bot... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to write a Python function that counts how many passengers are strictly more than 60 years old. The input is a list of strings called details. Each string has specific positions for different information.
First, I need to figure out where the age is stored in each string.... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to solve this problem where I have a 2D array, and I have to perform operations until the matrix is empty. Each operation involves selecting the largest number from each row, removing them, and then adding the maximum of those selected numbers to the score. The goal is to c... |
[
{
"content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the maximum possible value of the bitwise OR of all elements in the array after performing at most k operations. Each operation allows me to multiply one element by 2. Hmm, so the key is to decide which elements to multiply and how many times to do it (up to k times... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the maximum strength of a non-empty group of students. The strength is the product of their scores. Hmm. So the problem is to select a subset of the array (non-empty) such that their product is as large as possible.
First, I should think about all possible subsets... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the minimum number of extra characters left after breaking the string s into substrings that are in the dictionary. The extra characters are those that are not part of any of the chosen substrings. So the goal is to maximize the number of characters used (i.e., cove... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to solve this problem where I have to buy exactly two chocolates such that the sum of their prices is as small as possible, but also not exceed the given money. If it's possible, return the leftover money. Otherwise, return the original money.
Hmm. So the key points here 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 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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the number of integers x between num1 and num2 (inclusive) such that the sum of their digits is between min_sum and max_sum. And return the count modulo 1e9+7. Hmm.
First, the problem is about counting numbers in a range [A, B] where their digit sum is within a cer... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the distinct difference array for a given nums array. The problem says that for each index i, the diff[i] is the number of distinct elements in the prefix up to i minus the number in the suffix starting from i+1. Hmm.
So, first, I need to figure out for each i, the... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to solve this problem where after each query, I have to compute the number of adjacent elements with the same color. The array starts all zeros, and each query colors an index with a color. But the tricky part is that zeros are considered uncolored and don't contribute to 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 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": ""
} | <|begin_of_thought|>
Okay, let's try to figure out how to solve this problem. The task is to calculate the sum of the power of all non-empty groups of heroes, where the power is defined as the square of the maximum element multiplied by the minimum element in the group. And since the sum can be very large, we 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 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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the minimum number of adjacent swaps required to make a permutation semi-ordered. The semi-ordered permutation is one where the first element is 1 and the last is n. So the problem is to move 1 to the first position and n to the last position with as few swaps as po... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the longest semi-repetitive substring in a given string of digits. A semi-repetitive string allows at most one consecutive pair of the same digits. Hmm. So, for example, if there are two pairs of consecutive same digits, then the substring is invalid. Wait, no. Wait... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to solve this problem where friends are sitting in a circle and passing a ball according to certain rules. The goal is to find out which friends never received the ball, so they are the losers. Hmm.
So the problem says that the game starts with the first friend. Then each ... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to determine if there's a valid binary array original that can produce the given derived array. The derived array is formed by XORing adjacent elements of the original array, with the last element wrapping around to the first. Hmm.
So the problem is to check if such an ori... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the minimum possible length of the string after removing all possible occurrences of "AB" or "CD". And after each removal, the string concatenates, which might create new instances of those substrings. Hmm, how do I approach this?
So the problem is similar to those... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the punishment number of a given integer n. The punishment number is the sum of 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. Hmm, that sounds a bit tricky. Let me break it down.
First, f... |
[
{
"content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given two 0-indexed integer arrays, 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": ""
} | <|begin_of_thought|>
Okay, let's try to figure out this problem. So the task is to find the minimum cost to paint all walls using two painters. The paid painter paints a wall in time[i] units and costs cost[i], while the free painter takes 1 unit but can only work when the paid painter is busy. Hmm.
Wait, the free pa... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's try to understand this problem. So, the task is to find the minimum cost to collect all types of chocolates, given that each operation shifts all chocolates' types and costs x. Hmm.
Wait, the chocolates' types are initially i-th type at index i. Each operation shifts each chocolate's ... |
[
{
"content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given 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": ""
} | <|begin_of_thought|>
Okay, let's try to figure out how to solve this problem. So the task is to find the minimum possible sum of a k-avoiding array of length n. A k-avoiding array is one where no two distinct elements add up to k. And all elements are distinct positive integers. Hmm.
First, I need to understand what ... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's try to understand this problem. So, the task is to find the maximum possible achievable number x given num and t. An achievable x is one that can become equal to num after applying the operation up to t times. The operation allows us to increase or decrease x by 1 and simultaneously do... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the minimum number of operations to turn a string into a palindrome and also make sure that the resulting palindrome is lexicographically smallest if there are multiple options with the same minimal operations. Hmm.
First, I remember that a palindrome reads the sam... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's try to figure out how to solve this problem. So the task is to find the minimum cost to make all characters in a binary string equal by applying certain operations. The operations are flipping bits from the start up to index i (cost i+1) or from index i to the end (cost n-i). Hmm.
Fir... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to write a Python function that takes a string representing a number and returns it without trailing zeros. Hmm. So, the problem is to remove all the zeros that are at the end of the string. Right.
Wait, how do I approach this? Let's think. The examples given are like "512... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to write a Python function to check if a 3-digit number n is fascinating. The fascinating condition is that when you concatenate n, 2n, and 3n, the resulting number has all digits from 1 to 9 exactly once, and no zeros. So first, let's understand the steps.
Hmm, the proble... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's try to figure out this problem. So the task is to find the minimal possible length of a string after performing a certain operation any number of times. The operation is: choose an index i, and delete the closest occurrence of the same character to the left and right of i. We need to d... |
[
{
"content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 0-indexed integer array nums, and 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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to determine if all indices in the array can be connected through a series of traversals where each step requires the gcd of the two numbers to be greater than 1. Hmm. So the problem is essentially checking if the entire graph is connected, where edges exist between indices... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the lexicographically smallest string possible by performing exactly one operation. The operation is to select a non-empty substring and replace each character with the previous one in the alphabet. So, for example, 'b' becomes 'a', 'a' becomes 'z', etc.
Hmm. 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. 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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the number of beautiful pairs in the given array. The definition is a pair i, j where i < j, and the first digit of nums[i] is coprime with the last digit of nums[j].
Hmm. So first, for each number in the array, I need to find its first digit and last digit. Then,... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the longest possible 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 this possible. The goal is to maximize the length of such a 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 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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to solve this problem where I have to find for each query how many servers didn't receive any requests in the interval [query[i] - x, query[i]]. Hmm. Let's break it down.
First, the problem says that for each query, we have to check all servers and count those that have no... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to solve this problem where marbles are moved according to some steps, and then return the sorted list of occupied positions after all moves. Hmm. Let's think through the problem step by step.
First, the initial positions are given in the nums array. Then, for each step in... |
[
{
"content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given 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": ""
} | <|begin_of_thought|>
Okay, let's try to figure out this problem. So the task is to find the minimum number of operations needed to reduce num1 to zero by subtracting 2^i + num2 each time. And if it's impossible, return -1. Hmm.
First, let's understand the operation. Each operation subtracts (2^i + num2) from num1. Wa... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to solve this problem where for each query, I have to find the maximum sum of nums1[j] + nums2[j] for all j where both nums1[j] >= x_i and nums2[j] >= y_i. If there's no such j, return -1. The challenge is to do this efficiently because the constraints are up to 1e5 for bot... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to write a Python function that takes an array called nums and returns the sum of the squares of the special elements. The special elements are those where the index i (which is 1-based) divides the length of the array n. So, first, I need to figure out which indices are 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 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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find a way to partition the array into two non-empty parts such that the absolute difference between the max of the first part and the min of the second part is minimized. Hmm.
Wait, the problem says that the partition's value is |max(nums1) - min(nums2)|. So the goal ... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the maximum number of pairs in the given array of words where each pair consists of a word and its reverse, and each word can be part of at most one pair. Hmm.
So, the first thing that comes to mind is that for each word, I should check if its reverse exists in the... |
[
{
"content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given 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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the number of special permutations of the given array nums. A special permutation is one where each adjacent pair either divides each other. Hmm. So for each consecutive elements in the permutation, one must be a multiple of the other.
The problem is similar to co... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the sum of the imbalance numbers for all subarrays of a given array. The imbalance number is the count of adjacent elements in the sorted version of the subarray that differ by more than 1. Hmm, how do I approach this?
First, let's understand the problem. For each ... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's try to figure out this problem. So the task is to find the maximum possible length of a string formed by concatenating some AA, BB, and AB strings, without having "AAA" or "BBB" as substrings. Hmm.
First, I need to understand the constraints. Each AA is two A's, BB is two B's, and 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 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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the minimum possible length after joining all the words using the specified join operations. The join can be done either by appending the new word to the current string or prepending it, but with possible overlapping of the last and first characters. Hmm.
So the 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 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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the maximum number of jumps from index 0 to the last index, following the given conditions. Hmm. The problem says that each jump from i to j must satisfy 0 <= i < j < n, and the difference between nums[j] and nums[i] must be within the target. So, the difference can... |
[
{
"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": ""
} | <|begin_of_thought|>
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 it is equal to the total number of distinct elements in the entire array. Hmm.
So first, I should figure out the total distinct elements in the en... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the maximum distance the truck can travel given the main tank and additional tank. The mileage is 10 km per liter. The key part is the fuel transfer condition. Every time 5 liters are used from the main tank, if there's at least 1 liter in the additional tank, 1 lit... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the longest subarray in nums that meets certain conditions. Let's break down the problem step by step.
First, the conditions are:
1. The subarray starts with an even number (nums[l] % 2 == 0).
2. Each consecutive element alternates between even and odd. So like ev... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's try to figure out this problem. So the task is to count the number of ways to split a binary array into good subarrays. A good subarray is one that has exactly one '1'. Hmm. So each subarray in the split must contain exactly one '1'. And we need to find all possible ways to split the 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 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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the number of continuous subarrays in a given array where every pair of elements in the subarray has a difference of at most 2. Hmm. So for each possible subarray, I have to check all pairs, but that's going to be O(n^3) time, which is definitely not feasible for n ... |
[
{
"content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given 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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the maximum length of a non-decreasing subarray in nums3, which is formed by choosing either nums1[i] or nums2[i] for each position i. Hmm. So the problem is about making the best choices at each step to maximize the length of such a subarray.
First, I remember tha... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the maximum length of an alternating subarray in the given nums array. Hmm. The problem says that a subarray is alternating if it meets certain conditions. Let me parse the requirements again.
First, the subarray s has length m >1. Then, s_1 must be s_0 +1. Then, 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": ""
} | <|begin_of_thought|>
Okay, let's try to figure out this problem. So the task is to find the largest possible element in the final array after performing any number of operations. The operation allowed is choosing an index i where nums[i] <= nums[i+1], then replacing nums[i+1] with the sum of nums[i] and nums[i+1], 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 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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find all pairs of primes x and y such that x + y = n, and x <= y. Then return them sorted by x. Hmm. So first, I need to generate all primes up to n, maybe? Because x and y have to be primes, and their sum is n. So x can be from 2 up to n/2, since if x is larger than n/2... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to write a Python function that counts how many employees met or exceeded the target hours. Hmm. The input is a list of hours and a target. So for each employee in the list, I check if their hours are >= target. Then sum all those True values.
Wait, right. So the approach ... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find a string that contains all three given strings a, b, and c as substrings. And it should be the shortest possible. If there are multiple with the same length, pick the lex smallest one. Hmm.
First, I need to think about how to combine these three strings into one. 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 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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to determine if it's possible to make all elements of the array zero by applying operations where each operation subtracts 1 from a subarray of size k. Hmm. So the question is about whether there's a sequence of such operations that can bring all elements down to zero.
Fir... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's try to tackle this problem. Hmm, the task is to partition a string into k substrings such that the sum of the changes needed to make each substring a semi-palindrome is minimized. So, first, I need to understand what a semi-palindrome is.
From the note, a semi-palindrome is a string w... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to write a Python function that takes an array of strings and a separator, then splits each string by that separator, excluding any empty strings. The output should be a list of all the non-empty parts in order. Hmm.
So the first thing I think is to loop through each word ... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the number of ways to express n as the sum of unique positive integers each raised to the xth power. Hmm. So for example, if x is 3 and n is 160, there's at least one way. The problem says to return the count modulo 1e9+7.
First, I need to think about how to approa... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to solve this problem where I have to partition a binary string into the minimum number of beautiful substrings. Each substring must not have leading zeros and must be a binary representation of a power of 5. Hmm.
First, I need to understand what makes a binary string a po... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the longest valid substring in the given word where none of the substrings are in the forbidden list. Hmm, the problem says a valid string is one where none of its substrings are present in forbidden. Wait, but that's a bit confusing. Because a substring of the vali... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to solve this problem where each time I type an 'i', the current string is reversed. The other characters are added normally. So the task is to simulate the process of typing each character in the string s and applying the reversal whenever 'i' is encountered. Then return 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 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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to solve this problem where I have to permute a string such that consonants stay in their original positions, and vowels are sorted in non-decreasing ASCII order. Hmm. So first, I need to figure out which characters are vowels. The vowels are a, e, i, o, u in both lowercase... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the minimum index i where splitting the array into two parts (left and right) results in both parts having the same dominant element as the original array. And the original array has exactly one dominant element. So first, I need to find what that dominant element 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 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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the maximum possible beauty of the array after applying the operations. The beauty is the length of the longest subsequence of equal elements. Hmm. So the problem is about choosing, for each element in the array, a value within [nums[i] -k, nums[i]+k], and then find... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to determine if the given array is a permutation of the base array as defined. Hmm. The base array for a given n is [1, 2, ..., n-1, n, n]. So the length of the base array is n+1. So first, I need to figure out what n could be here.
Wait, the maximum element in the input 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 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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the maximum total score possible when moving through the array according to the given rules. The initial position is 0, and each move must be to a higher index. Each time I visit a position, I add its value to the score. But if I move from a position with a certain ... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the maximum sum of a pair of numbers in the array where both numbers have the same maximum digit. Hmm. So first, for each number in the array, I need to determine its maximum digit. Then, group numbers by their maximum digits. For each group, if there are at least 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, 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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the count of interesting subarrays. Hmm. The definition says a subarray is interesting if, for the number of elements in it that satisfy nums[i] % modulo == k, when you take that count modulo the same modulo, you get k. So cnt % modulo == k.
Wait, but modulo can 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 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": ""
} | <|begin_of_thought|>
Okay, let's try to figure out how to solve this problem. So the task is to determine if we can split the given array into n single-element arrays by splitting existing arrays into two parts, following certain rules. Each split must result in two subarrays where each either has length 1 or sum >= m... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the number of pairs (i, j) where i < j and nums[i] + nums[j] is less than the target. Hmm. So the straightforward approach would be to check all possible pairs and count how many meet the condition. But wait, what's the time complexity here? Well, since n can be up ... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's try to figure out this problem. So the task is to create the maximum number of groups where each group has distinct numbers, and each subsequent group is strictly larger than the previous. Also, we can't use more of a number than its usage limit. Hmm.
First, I need to understand the c... |
[
{
"content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 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": ""
} | <|begin_of_thought|>
Okay, let's try to figure out this problem. So the task is to find the minimum number of seconds needed to make all elements in a circular array equal. Each second, every element can be replaced by itself, the previous element, or the next element. And all replacements happen simultaneously. Hmm.
... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the count of stepping numbers between two given strings, low and high. Stepping numbers are those where each adjacent digit has an absolute difference of 1. And leading zeros are not allowed. Hmm.
First, I remember that stepping numbers can be generated by consider... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's try to understand this problem. So, we have two arrays, nums1 and nums2, of the same length. Every second, each element in nums1 is increased by the corresponding element in nums2. Then, we can choose to reset one element of nums1 to zero. We need to find the minimum time (number of se... |
[
{
"content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a 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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the number of pairs (i, j) where i < j and the distance between them is exactly k. The distance is defined as (x1 XOR x2) + (y1 XOR y2). Hmm, right. So for each pair of points, compute that sum and check if it equals k. But with the constraints given, especially whe... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to solve this problem where I have to find the maximum sum of almost unique subarrays of length k in the given array nums. Almost unique here means that the subarray has at least m distinct elements. Hmm.
So the problem is asking for all possible contiguous subarrays of le... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to solve this problem where I calculate the account balance after a purchase. The purchase amount is rounded to the nearest multiple of 10, and if there's a tie, we choose the larger one. The initial balance is 100, so the final balance is 100 minus the rounded amount.
Hmm... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to write a Python function to check if the string s is an acronym of the given list of words. Hmm. The problem says that s should be formed by concatenating the first character of each word in order. So first, I need to make sure that the length of s matches the number of 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 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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the maximum amount of gold by selecting non-overlapping offers. Hmm. So each offer covers a range of houses, and I can't have overlapping ranges. The goal is to choose a subset of these offers such that no two selected offers have overlapping house ranges. And I wan... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the number of symmetric integers between low and high, inclusive. Hmm, what's a symmetric integer? Oh right, it's a number with 2n digits where the sum of the first n digits equals the sum of the last n digits. And numbers with an odd number of digits are automatica... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to determine if two 4-character strings can be made equal by swapping characters at positions that are two apart. So, the allowed operations are swapping indices i and j where j - i = 2. That means for a 4-length string, the possible pairs are (0,2) and (1,3). Because in 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 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": ""
} | <|begin_of_thought|>
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, the problem is to find two indices i and j where the absolute difference of their positions is at least x, and the absolute difference of their values is as... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the number of beautiful integers between low and high, inclusive. A beautiful integer has two conditions: the count of even digits equals the count of odd digits, and it's divisible by k. Hmm.
First, how do I approach this? The brute force way would be to check eve... |
[
{
"content": "Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given 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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to determine if after performing an operation on str1 at most once, str2 becomes a subsequence of str1. The operation allows me to select any set of indices in str1, and for each selected index, increment the character cyclically. So each selected character can be changed 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 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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the furthest point from the origin after making all the moves. The moves can be L, R, or _, and for each _, I can choose to go left or right. The goal is to maximize the distance from 0. Hmm.
So, the key here is to figure out how to handle the underscores. For each... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's try to figure out this problem. So the task is to find the number of ways to transform string s into t in exactly k operations, where each operation is rotating a suffix of length l (1 < l < n) and moving it to the front. Hmm.
First, I need to understand what each operation does. For ... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's try to figure out this problem. So the task is to find the minimum number of operations needed to split elements in the array such that a subsequence sums up to the target. Each operation splits a number into two halves (since they are powers of two). Hmm.
First, I need to understand ... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to generate a Python function that computes the product matrix as described. Hmm. The problem says that each element p[i][j] is the product of all elements in the grid except grid[i][j], and then take modulo 12345. So the straightforward approach would be, for each cell, mu... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the maximum sum f(x) when starting from any player x, passing the ball k times. The sum includes the starting x and each receiver in the sequence for k passes. The problem is that k can be up to 1e10, which is way too big to compute each step naively. So I need an 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 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": ""
} | <|begin_of_thought|>
Okay, let's try to figure out this problem. So the task is to find the minimum cost to make s1 equal to s2 using the allowed operations. Hmm. Let's start by understanding the operations.
First, the two operations. The first one allows flipping two indices i and j with cost x. The second operation... |
[
{
"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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the number of integer points on the number line that are covered by any part of a car. So each car is represented by a start and end point. For example, if a car is [3,6], then the points 3,4,5,6 are covered. The task is to find all such points across all cars and 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 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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the minimum number of operations to collect all elements from 1 to k by repeatedly removing the last element of the array. Each operation removes the last element and adds it to the collection. So the goal is to determine how many elements we need to take from the 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 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": ""
} | <|begin_of_thought|>
Okay, let's see. I need to find the minimum number of right shifts required to sort the array. Hmm. So a right shift moves each element to the next position, and the last element wraps around to the first. So, for example, if the array is [3,4,5,1,2], a right shift would make it [2,3,4,5,1]. Then ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.