id
stringlengths
13
13
content
stringlengths
774
4.21k
test
dict
labels
dict
LeetCode/2752
# Sum Multiples Given a positive integer `n`, find the sum of all integers in the range `[1, n]` **inclusive** that are divisible by `3`, `5`, or `7`. Return *an integer denoting the sum of all numbers in the given range satisfying the constraint.*   **Example 1:** ``` **Input:** n = 7 **Output:** 21 **Explanation:** Numbers in the range [1, 7] that are divisible by 3, 5, or 7 are 3, 5, 6, 7. The sum of these numbers is 21. ``` **Example 2:** ``` **Input:** n = 10 **Output:** 40 **Explanation:** Numbers in the range [1, 10] that are divisible by 3, 5, or 7 are 3, 5, 6, 7, 9, 10. The sum of these numbers is 40. ``` **Example 3:** ``` **Input:** n = 9 **Output:** 30 **Explanation:** Numbers in the range [1, 9] that are divisible by 3, 5, or 7 are 3, 5, 6, 7, 9. The sum of these numbers is 30. ```   **Constraints:** * `1 <= n <= 103` Please make sure your answer follows the type signature below: ```python3 class Solution: def sumOfMultiples(self, n: int) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.sumOfMultiples(*[7]) == 21\nassert my_solution.sumOfMultiples(*[10]) == 40\nassert my_solution.sumOfMultiples(*[9]) == 30\nassert my_solution.sumOfMultiples(*[1]) == 0\nassert my_solution.sumOfMultiples(*[2]) == 0\nassert my_solution.sumOfMultiples(*[3]) == 3\nassert my_solution.sumOfMultiples(*[4]) == 3\nassert my_solution.sumOfMultiples(*[5]) == 8\nassert my_solution.sumOfMultiples(*[6]) == 14\nassert my_solution.sumOfMultiples(*[8]) == 21\nassert my_solution.sumOfMultiples(*[11]) == 40\nassert my_solution.sumOfMultiples(*[12]) == 52\nassert my_solution.sumOfMultiples(*[13]) == 52\nassert my_solution.sumOfMultiples(*[14]) == 66\nassert my_solution.sumOfMultiples(*[15]) == 81\nassert my_solution.sumOfMultiples(*[16]) == 81\nassert my_solution.sumOfMultiples(*[17]) == 81\nassert my_solution.sumOfMultiples(*[18]) == 99\nassert my_solution.sumOfMultiples(*[19]) == 99\nassert my_solution.sumOfMultiples(*[20]) == 119\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2752", "questionFrontendId": "2652", "questionTitle": "Sum Multiples", "stats": { "totalAccepted": "38.5K", "totalSubmission": "48.7K", "totalAcceptedRaw": 38545, "totalSubmissionRaw": 48672, "acRate": "79.2%" } }
LeetCode/2751
# Sliding Subarray Beauty Given an integer array `nums` containing `n` integers, find the **beauty** of each subarray of size `k`. The **beauty** of a subarray is the `xth` **smallest integer** in the subarray if it is **negative**, or `0` if there are fewer than `x` negative integers. Return *an integer array containing* `n - k + 1` *integers, which denote the* **beauty** *of the subarrays **in order** from the first index in the array.* * A subarray is a contiguous **non-empty** sequence of elements within an array.   **Example 1:** ``` **Input:** nums = [1,-1,-3,-2,3], k = 3, x = 2 **Output:** [-1,-2,-2] **Explanation:** There are 3 subarrays with size k = 3. The first subarray is [1, -1, -3] and the 2nd smallest negative integer is -1.  The second subarray is [-1, -3, -2] and the 2nd smallest negative integer is -2.  The third subarray is [-3, -2, 3] and the 2nd smallest negative integer is -2. ``` **Example 2:** ``` **Input:** nums = [-1,-2,-3,-4,-5], k = 2, x = 2 **Output:** [-1,-2,-3,-4] **Explanation:** There are 4 subarrays with size k = 2. For [-1, -2], the 2nd smallest negative integer is -1. For [-2, -3], the 2nd smallest negative integer is -2. For [-3, -4], the 2nd smallest negative integer is -3. For [-4, -5], the 2nd smallest negative integer is -4.  ``` **Example 3:** ``` **Input:** nums = [-3,1,2,-3,0,-3], k = 2, x = 1 **Output:** [-3,0,-3,-3,-3] **Explanation:** There are 5 subarrays with size k = 2**.** For [-3, 1], the 1st smallest negative integer is -3. For [1, 2], there is no negative integer so the beauty is 0. For [2, -3], the 1st smallest negative integer is -3. For [-3, 0], the 1st smallest negative integer is -3. For [0, -3], the 1st smallest negative integer is -3. ```   **Constraints:** * `n == nums.length` * `1 <= n <= 105` * `1 <= k <= n` * `1 <= x <= k` * `-50 <= nums[i] <= 50` Please make sure your answer follows the type signature below: ```python3 class Solution: def getSubarrayBeauty(self, nums: List[int], k: int, x: int) -> List[int]: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.getSubarrayBeauty(*[[1, -1, -3, -2, 3], 3, 2]) == [-1, -2, -2]\nassert my_solution.getSubarrayBeauty(*[[-1, -2, -3, -4, -5], 2, 2]) == [-1, -2, -3, -4]\nassert my_solution.getSubarrayBeauty(*[[-3, 1, 2, -3, 0, -3], 2, 1]) == [-3, 0, -3, -3, -3]\nassert my_solution.getSubarrayBeauty(*[[-43], 1, 1]) == [-43]\nassert my_solution.getSubarrayBeauty(*[[-26], 1, 1]) == [-26]\nassert my_solution.getSubarrayBeauty(*[[-22], 1, 1]) == [-22]\nassert my_solution.getSubarrayBeauty(*[[-20], 1, 1]) == [-20]\nassert my_solution.getSubarrayBeauty(*[[-19], 1, 1]) == [-19]\nassert my_solution.getSubarrayBeauty(*[[-18], 1, 1]) == [-18]\nassert my_solution.getSubarrayBeauty(*[[-17], 1, 1]) == [-17]\nassert my_solution.getSubarrayBeauty(*[[-15], 1, 1]) == [-15]\nassert my_solution.getSubarrayBeauty(*[[-2], 1, 1]) == [-2]\nassert my_solution.getSubarrayBeauty(*[[5], 1, 1]) == [0]\nassert my_solution.getSubarrayBeauty(*[[7], 1, 1]) == [0]\nassert my_solution.getSubarrayBeauty(*[[14], 1, 1]) == [0]\nassert my_solution.getSubarrayBeauty(*[[16], 1, 1]) == [0]\nassert my_solution.getSubarrayBeauty(*[[19], 1, 1]) == [0]\nassert my_solution.getSubarrayBeauty(*[[20], 1, 1]) == [0]\nassert my_solution.getSubarrayBeauty(*[[23], 1, 1]) == [0]\nassert my_solution.getSubarrayBeauty(*[[27], 1, 1]) == [0]\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2751", "questionFrontendId": "2653", "questionTitle": "Sliding Subarray Beauty", "stats": { "totalAccepted": "5.9K", "totalSubmission": "16.2K", "totalAcceptedRaw": 5917, "totalSubmissionRaw": 16235, "acRate": "36.4%" } }
LeetCode/2753
# Minimum Number of Operations to Make All Array Elements Equal to 1 You are given a **0-indexed** array `nums` consisiting of **positive** integers. You can do the following operation on the array **any** number of times: * Select an index `i` such that `0 <= i < n - 1` and replace either of `nums[i]` or `nums[i+1]` with their gcd value. Return *the **minimum** number of operations to make all elements of* `nums` *equal to* `1`. If it is impossible, return `-1`. The gcd of two integers is the greatest common divisor of the two integers.   **Example 1:** ``` **Input:** nums = [2,6,3,4] **Output:** 4 **Explanation:** We can do the following operations: - Choose index i = 2 and replace nums[2] with gcd(3,4) = 1. Now we have nums = [2,6,1,4]. - Choose index i = 1 and replace nums[1] with gcd(6,1) = 1. Now we have nums = [2,1,1,4]. - Choose index i = 0 and replace nums[0] with gcd(2,1) = 1. Now we have nums = [1,1,1,4]. - Choose index i = 2 and replace nums[3] with gcd(1,4) = 1. Now we have nums = [1,1,1,1]. ``` **Example 2:** ``` **Input:** nums = [2,10,6,14] **Output:** -1 **Explanation:** It can be shown that it is impossible to make all the elements equal to 1. ```   **Constraints:** * `2 <= nums.length <= 50` * `1 <= nums[i] <= 106`   **Follow-up:** The `O(n)` time complexity solution works, but could you find an `O(1)` constant time complexity solution? Please make sure your answer follows the type signature below: ```python3 class Solution: def minOperations(self, nums: List[int]) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.minOperations(*[[2, 6, 3, 4]]) == 4\nassert my_solution.minOperations(*[[2, 10, 6, 14]]) == -1\nassert my_solution.minOperations(*[[410193, 229980, 600441]]) == -1\nassert my_solution.minOperations(*[[6, 10, 15]]) == 4\nassert my_solution.minOperations(*[[4, 2, 6, 3]]) == 5\nassert my_solution.minOperations(*[[48841, 93382, 993143, 170438, 48860, 174356, 291531]]) == 7\nassert my_solution.minOperations(*[[565053, 324050, 845500, 764459, 693331, 849602, 379407]]) == 7\nassert my_solution.minOperations(*[[404514, 309109, 640464, 451473, 954489, 240704, 730484, 888313, 126885]]) == 9\nassert my_solution.minOperations(*[[432320, 571622, 553142, 152985, 127988, 46098, 850399, 251987, 660091]]) == 9\nassert my_solution.minOperations(*[[266354, 828118, 333704, 385834]]) == -1\nassert my_solution.minOperations(*[[715086, 420033, 320095, 230175, 359910, 99010, 261428, 561978, 495675, 817898]]) == 10\nassert my_solution.minOperations(*[[846237, 105643, 71480, 567494, 315367, 503911, 836510, 984966, 748650]]) == 9\nassert my_solution.minOperations(*[[591723, 60746, 374246, 765639, 97358, 188339, 225788, 155868]]) == 8\nassert my_solution.minOperations(*[[780304, 789919, 873587, 158393, 298420, 624934, 660252, 787804]]) == 8\nassert my_solution.minOperations(*[[184432, 604193, 195562, 660134, 410026, 780971, 446702, 401480, 567049, 647296, 32815, 819020]]) == 12\nassert my_solution.minOperations(*[[358771, 577201, 359849, 457987, 710497, 21300, 955067, 665670, 180408, 650137, 997097, 677290]]) == 12\nassert my_solution.minOperations(*[[811340, 393975, 627577, 26811, 209797, 500958, 637753, 592871, 449081, 216228, 498803, 730546, 937075, 122352, 610619, 921594, 47754, 242342, 726157]]) == 19\nassert my_solution.minOperations(*[[985732, 437182, 281370, 204922, 295879, 239067, 105852, 967432, 24512, 977516, 566875, 507422, 988409, 155892]]) == 14\nassert my_solution.minOperations(*[[61934, 478887, 397567, 718200, 461668, 936276, 802169, 833144, 749931, 807386, 109400, 501586, 423875, 877463, 26894, 352687, 755053]]) == 17\nassert my_solution.minOperations(*[[865937, 351065, 864096, 504664, 698592, 630262, 38706, 159959, 198626, 161672, 931247, 719751, 722377, 561747, 937783, 835190, 748284]]) == 17\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2753", "questionFrontendId": "2654", "questionTitle": "Minimum Number of Operations to Make All Array Elements Equal to 1", "stats": { "totalAccepted": "3.9K", "totalSubmission": "9.6K", "totalAcceptedRaw": 3885, "totalSubmissionRaw": 9607, "acRate": "40.4%" } }
LeetCode/2737
# Row With Maximum Ones Given a `m x n` binary matrix `mat`, find the **0-indexed** position of the row that contains the **maximum** count of **ones,** and the number of ones in that row. In case there are multiple rows that have the maximum count of ones, the row with the **smallest row number** should be selected. Return *an array containing the index of the row, and the number of ones in it.*   **Example 1:** ``` **Input:** mat = [[0,1],[1,0]] **Output:** [0,1] **Explanation:** Both rows have the same number of 1's. So we return the index of the smaller row, 0, and the maximum count of ones (1). So, the answer is [0,1]. ``` **Example 2:** ``` **Input:** mat = [[0,0,0],[0,1,1]] **Output:** [1,2] **Explanation:** The row indexed 1 has the maximum count of ones (2). So we return its index, 1, and the count. So, the answer is [1,2]. ``` **Example 3:** ``` **Input:** mat = [[0,0],[1,1],[0,0]] **Output:** [1,2] **Explanation:** The row indexed 1 has the maximum count of ones (2). So the answer is [1,2]. ```   **Constraints:** * `m == mat.length` * `n == mat[i].length` * `1 <= m, n <= 100` * `mat[i][j]` is either `0` or `1`. Please make sure your answer follows the type signature below: ```python3 class Solution: def rowAndMaximumOnes(self, mat: List[List[int]]) -> List[int]: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.rowAndMaximumOnes(*[[[0, 1], [1, 0]]]) == [0, 1]\nassert my_solution.rowAndMaximumOnes(*[[[0, 0, 0], [0, 1, 1]]]) == [1, 2]\nassert my_solution.rowAndMaximumOnes(*[[[0, 0], [1, 1], [0, 0]]]) == [1, 2]\nassert my_solution.rowAndMaximumOnes(*[[[1]]]) == [0, 1]\nassert my_solution.rowAndMaximumOnes(*[[[0], [0]]]) == [0, 0]\nassert my_solution.rowAndMaximumOnes(*[[[0, 1]]]) == [0, 1]\nassert my_solution.rowAndMaximumOnes(*[[[0], [1], [1]]]) == [1, 1]\nassert my_solution.rowAndMaximumOnes(*[[[1, 0, 0]]]) == [0, 1]\nassert my_solution.rowAndMaximumOnes(*[[[0], [1], [0], [0]]]) == [1, 1]\nassert my_solution.rowAndMaximumOnes(*[[[0], [1], [1], [0]]]) == [1, 1]\nassert my_solution.rowAndMaximumOnes(*[[[0, 0], [0, 1]]]) == [1, 1]\nassert my_solution.rowAndMaximumOnes(*[[[0, 0], [1, 1]]]) == [1, 2]\nassert my_solution.rowAndMaximumOnes(*[[[0, 0, 0, 0]]]) == [0, 0]\nassert my_solution.rowAndMaximumOnes(*[[[0, 1], [1, 1]]]) == [1, 2]\nassert my_solution.rowAndMaximumOnes(*[[[1, 0, 1, 1]]]) == [0, 3]\nassert my_solution.rowAndMaximumOnes(*[[[1, 1], [0, 1]]]) == [0, 2]\nassert my_solution.rowAndMaximumOnes(*[[[1, 1, 0, 0]]]) == [0, 2]\nassert my_solution.rowAndMaximumOnes(*[[[0], [1], [0], [0], [0]]]) == [1, 1]\nassert my_solution.rowAndMaximumOnes(*[[[0], [1], [1], [1], [0]]]) == [1, 1]\nassert my_solution.rowAndMaximumOnes(*[[[1], [0], [0], [0], [0]]]) == [0, 1]\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2737", "questionFrontendId": "2643", "questionTitle": "Row With Maximum Ones", "stats": { "totalAccepted": "9.8K", "totalSubmission": "12.3K", "totalAcceptedRaw": 9834, "totalSubmissionRaw": 12289, "acRate": "80.0%" } }
LeetCode/2736
# Minimum Additions to Make Valid String Given a string `word` to which you can insert letters "a", "b" or "c" anywhere and any number of times, return *the minimum number of letters that must be inserted so that `word` becomes **valid**.* A string is called **valid** if it can be formed by concatenating the string "abc" several times.   **Example 1:** ``` **Input:** word = "b" **Output:** 2 **Explanation:** Insert the letter "a" right before "b", and the letter "c" right next to "a" to obtain the valid string "**a**b**c**". ``` **Example 2:** ``` **Input:** word = "aaa" **Output:** 6 **Explanation:** Insert letters "b" and "c" next to each "a" to obtain the valid string "a**bc**a**bc**a**bc**". ``` **Example 3:** ``` **Input:** word = "abc" **Output:** 0 **Explanation:** word is already valid. No modifications are needed. ```   **Constraints:** * `1 <= word.length <= 50` * `word` consists of letters "a", "b" and "c" only. Please make sure your answer follows the type signature below: ```python3 class Solution: def addMinimum(self, word: str) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.addMinimum(*['b']) == 2\nassert my_solution.addMinimum(*['aaa']) == 6\nassert my_solution.addMinimum(*['abc']) == 0\nassert my_solution.addMinimum(*['a']) == 2\nassert my_solution.addMinimum(*['aa']) == 4\nassert my_solution.addMinimum(*['aaaa']) == 8\nassert my_solution.addMinimum(*['aaaaa']) == 10\nassert my_solution.addMinimum(*['aaaaaa']) == 12\nassert my_solution.addMinimum(*['aaaaab']) == 9\nassert my_solution.addMinimum(*['aaaaac']) == 9\nassert my_solution.addMinimum(*['aaaab']) == 7\nassert my_solution.addMinimum(*['aaaaba']) == 9\nassert my_solution.addMinimum(*['aaaabb']) == 9\nassert my_solution.addMinimum(*['aaaabc']) == 6\nassert my_solution.addMinimum(*['aaaac']) == 7\nassert my_solution.addMinimum(*['aaaaca']) == 9\nassert my_solution.addMinimum(*['aaaacb']) == 9\nassert my_solution.addMinimum(*['aaaacc']) == 9\nassert my_solution.addMinimum(*['aaab']) == 5\nassert my_solution.addMinimum(*['aaaba']) == 7\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2736", "questionFrontendId": "2645", "questionTitle": "Minimum Additions to Make Valid String", "stats": { "totalAccepted": "27.9K", "totalSubmission": "41.4K", "totalAcceptedRaw": 27943, "totalSubmissionRaw": 41421, "acRate": "67.5%" } }
LeetCode/2675
# Find the Width of Columns of a Grid You are given a **0-indexed** `m x n` integer matrix `grid`. The width of a column is the maximum **length** of its integers. * For example, if `grid = [[-10], [3], [12]]`, the width of the only column is `3` since `-10` is of length `3`. Return *an integer array* `ans` *of size* `n` *where* `ans[i]` *is the width of the* `ith` *column*. The **length** of an integer `x` with `len` digits is equal to `len` if `x` is non-negative, and `len + 1` otherwise.   **Example 1:** ``` **Input:** grid = [[1],[22],[333]] **Output:** [3] **Explanation:** In the 0th column, 333 is of length 3. ``` **Example 2:** ``` **Input:** grid = [[-15,1,3],[15,7,12],[5,6,-2]] **Output:** [3,1,2] **Explanation:** In the 0th column, only -15 is of length 3. In the 1st column, all integers are of length 1. In the 2nd column, both 12 and -2 are of length 2. ```   **Constraints:** * `m == grid.length` * `n == grid[i].length` * `1 <= m, n <= 100` * `-109 <= grid[r][c] <= 109` Please make sure your answer follows the type signature below: ```python3 class Solution: def findColumnWidth(self, grid: List[List[int]]) -> List[int]: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.findColumnWidth(*[[[1], [22], [333]]]) == [3]\nassert my_solution.findColumnWidth(*[[[-15, 1, 3], [15, 7, 12], [5, 6, -2]]]) == [3, 1, 2]\nassert my_solution.findColumnWidth(*[[[0]]]) == [1]\nassert my_solution.findColumnWidth(*[[[0], [0], [0]]]) == [1]\nassert my_solution.findColumnWidth(*[[[0, 0, 0], [0, 0, 0], [0, 0, 0]]]) == [1, 1, 1]\nassert my_solution.findColumnWidth(*[[[0, 3, 0], [2, 3, 0], [1, 3, 0]]]) == [1, 1, 1]\nassert my_solution.findColumnWidth(*[[[-39, -5, -93], [-87, -69, 28], [-88, 25, 23]]]) == [3, 3, 3]\nassert my_solution.findColumnWidth(*[[[37, 86, -11], [85, -65, 83], [69, -93, 52]]]) == [2, 3, 3]\nassert my_solution.findColumnWidth(*[[[93, -20, -4], [6, -20, -19]]]) == [2, 3, 3]\nassert my_solution.findColumnWidth(*[[[-19, -67, -92], [38, -47, -1]]]) == [3, 3, 3]\nassert my_solution.findColumnWidth(*[[[-90, -89, -51]]]) == [3, 3, 3]\nassert my_solution.findColumnWidth(*[[[31, 100, -6], [10, 0, 68], [-42, -37, -36]]]) == [3, 3, 3]\nassert my_solution.findColumnWidth(*[[[73, -24, 41], [-23, 44, -88], [91, -22, 19]]]) == [3, 3, 3]\nassert my_solution.findColumnWidth(*[[[-22, -77, 76], [48, -46, 81]]]) == [3, 3, 2]\nassert my_solution.findColumnWidth(*[[[-34, -87, -54], [46, 98, 82], [-3, -99, -64]]]) == [3, 3, 3]\nassert my_solution.findColumnWidth(*[[[-92, 24, 81], [-20, -20, -14]]]) == [3, 3, 3]\nassert my_solution.findColumnWidth(*[[[-4, 0, -1, 3, 9, 8, 6], [-2, 5, -5, -7, -2, -6, 7], [4, -4, 1, 7, 0, 6, 8], [-6, 2, -5, 0, 9, 1, -6]]]) == [2, 2, 2, 2, 2, 2, 2]\nassert my_solution.findColumnWidth(*[[[51, 84, 31, 44, -22, -70], [71, -37, -33, -48, -97, -32], [18, 95, -62, -63, 5, 63], [-18, -41, -58, -25, -17, -26], [67, -96, -77, 80, 59, -71], [-15, 20, -72, -27, 3, -97], [66, -1, 5, 80, 57, -58]]]) == [3, 3, 3, 3, 3, 3]\nassert my_solution.findColumnWidth(*[[[325, -483, 796, 121], [-757, -920, -928, 783], [73, -136, 628, -724], [979, 224, -39, -884], [-612, -304, 259, 378], [7, 335, -650, -131], [-351, -104, 640, -258]]]) == [4, 4, 4, 4]\nassert my_solution.findColumnWidth(*[[[2911, -805, 5477, -3349, 163, -6644], [4851, 2990, 2578, 1124, 2897, -1781], [-2153, 1774, -8238, -2894, 4845, 9608]]]) == [5, 4, 5, 5, 4, 5]\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2675", "questionFrontendId": "2639", "questionTitle": "Find the Width of Columns of a Grid", "stats": { "totalAccepted": "5.5K", "totalSubmission": "7.2K", "totalAcceptedRaw": 5466, "totalSubmissionRaw": 7171, "acRate": "76.2%" } }
LeetCode/2676
# Find the Score of All Prefixes of an Array We define the **conversion array** `conver` of an array `arr` as follows: * `conver[i] = arr[i] + max(arr[0..i])` where `max(arr[0..i])` is the maximum value of `arr[j]` over `0 <= j <= i`. We also define the **score** of an array `arr` as the sum of the values of the conversion array of `arr`. Given a **0-indexed** integer array `nums` of length `n`, return *an array* `ans` *of length* `n` *where* `ans[i]` *is the score of the prefix* `nums[0..i]`.   **Example 1:** ``` **Input:** nums = [2,3,7,5,10] **Output:** [4,10,24,36,56] **Explanation:** For the prefix [2], the conversion array is [4] hence the score is 4 For the prefix [2, 3], the conversion array is [4, 6] hence the score is 10 For the prefix [2, 3, 7], the conversion array is [4, 6, 14] hence the score is 24 For the prefix [2, 3, 7, 5], the conversion array is [4, 6, 14, 12] hence the score is 36 For the prefix [2, 3, 7, 5, 10], the conversion array is [4, 6, 14, 12, 20] hence the score is 56 ``` **Example 2:** ``` **Input:** nums = [1,1,2,4,8,16] **Output:** [2,4,8,16,32,64] **Explanation:** For the prefix [1], the conversion array is [2] hence the score is 2 For the prefix [1, 1], the conversion array is [2, 2] hence the score is 4 For the prefix [1, 1, 2], the conversion array is [2, 2, 4] hence the score is 8 For the prefix [1, 1, 2, 4], the conversion array is [2, 2, 4, 8] hence the score is 16 For the prefix [1, 1, 2, 4, 8], the conversion array is [2, 2, 4, 8, 16] hence the score is 32 For the prefix [1, 1, 2, 4, 8, 16], the conversion array is [2, 2, 4, 8, 16, 32] hence the score is 64 ```   **Constraints:** * `1 <= nums.length <= 105` * `1 <= nums[i] <= 109` Please make sure your answer follows the type signature below: ```python3 class Solution: def findPrefixScore(self, nums: List[int]) -> List[int]: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.findPrefixScore(*[[2, 3, 7, 5, 10]]) == [4, 10, 24, 36, 56]\nassert my_solution.findPrefixScore(*[[1, 1, 2, 4, 8, 16]]) == [2, 4, 8, 16, 32, 64]\nassert my_solution.findPrefixScore(*[[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]\nassert my_solution.findPrefixScore(*[[1, 2, 3, 4, 4, 5, 6, 7, 7, 9]]) == [2, 6, 12, 20, 28, 38, 50, 64, 78, 96]\nassert my_solution.findPrefixScore(*[[17, 17, 12, 14, 13, 8, 8, 9, 10, 18, 10, 18, 10]]) == [34, 68, 97, 128, 158, 183, 208, 234, 261, 297, 325, 361, 389]\nassert my_solution.findPrefixScore(*[[1, 2, 2, 3, 3, 4, 5, 6, 7, 9, 10, 10, 13, 15, 15, 17, 18, 19, 19]]) == [2, 6, 10, 16, 22, 30, 40, 52, 66, 84, 104, 124, 150, 180, 210, 244, 280, 318, 356]\nassert my_solution.findPrefixScore(*[[16, 11, 11, 11, 19, 6, 6]]) == [32, 59, 86, 113, 151, 176, 201]\nassert my_solution.findPrefixScore(*[[3, 4, 5, 6, 8, 18, 8, 9, 13, 14, 15, 16, 19, 17]]) == [6, 14, 24, 36, 52, 88, 114, 141, 172, 204, 237, 271, 309, 345]\nassert my_solution.findPrefixScore(*[[19, 19, 17, 18, 10, 4, 8, 9, 7, 1, 9, 15, 5, 5]]) == [38, 76, 112, 149, 178, 201, 228, 256, 282, 302, 330, 364, 388, 412]\nassert my_solution.findPrefixScore(*[[1, 1, 3, 4, 4, 6, 8, 13, 15, 20, 10, 10, 10, 11, 11, 11]]) == [2, 4, 10, 18, 26, 38, 54, 80, 110, 150, 180, 210, 240, 271, 302, 333]\nassert my_solution.findPrefixScore(*[[14, 5, 20, 16, 2, 7, 11, 20, 16, 6, 14, 11, 14, 12, 13]]) == [28, 47, 87, 123, 145, 172, 203, 243, 279, 305, 339, 370, 404, 436, 469]\nassert my_solution.findPrefixScore(*[[4, 7, 9, 13, 10, 11, 13, 13, 13, 15, 16]]) == [8, 22, 40, 66, 89, 113, 139, 165, 191, 221, 253]\nassert my_solution.findPrefixScore(*[[17, 4, 2, 12, 1, 13, 4, 10, 18, 4, 20, 15]]) == [34, 55, 74, 103, 121, 151, 172, 199, 235, 257, 297, 332]\nassert my_solution.findPrefixScore(*[[1, 10, 1, 4, 7, 8, 9, 10, 11, 11, 13, 13, 18, 18, 19]]) == [2, 22, 33, 47, 64, 82, 101, 121, 143, 165, 191, 217, 253, 289, 327]\nassert my_solution.findPrefixScore(*[[137381902, 583670185, 232449799, 615240518, 692364261, 339595728, 193558230, 477734537, 408666227, 180093966, 73374595, 401827223, 544402033, 460199809, 967906902, 609720313, 20713685, 466223557, 187038791, 821463819, 44138353, 62610391, 286485490, 475645586, 570010342, 772864005, 789886761, 582447818, 449215930, 79498550, 880611913, 498198623, 98223903, 297927296, 929528075, 151612343, 718714067, 441682283, 950308227, 509793041, 310411982, 271303282, 402560714, 831564217, 492421656, 775074730, 462574919, 266050840, 411725032, 692603442, 88005551, 129970833, 314440283, 513936108, 97431418, 1824470, 655637394, 970780627, 611143448, 77750843]]) == [274763804, 1442104174, 2258224158, 3488705194, 4873433716, 5905393705, 6791316196, 7961414994, 9062445482, 9934903709, 10700642565, 11794834049, 13031600343, 14184164413, 16119978217, 17697605432, 18686226019, 20120356478, 21275302171, 23064672892, 24076718147, 25107235440, 26361627832, 27805180320, 29343097564, 31083868471, 32841662134, 34392016854, 35809139686, 36856545138, 38705063953, 40171169478, 41237300283, 42503134481, 44400569458, 45520088703, 47206709672, 48616298857, 50534513986, 52012213929, 53290532813, 54529742997, 55900210613, 57699681732, 59160010290, 60902991922, 62333473743, 63567431485, 64947063419, 66607573763, 67663486216, 68761363951, 70043711136, 71525554146, 72590892466, 73560623838, 75184168134, 77125729388, 78707653463, 79756184933]\nassert my_solution.findPrefixScore(*[[6323811, 79572964, 99819319, 116527461, 252969478, 734202001, 768031890, 275629005, 295208024, 300512356, 774174207, 776414850, 324278225, 325669533, 339685144, 344126938, 354257474, 357663761, 785925759, 409599439, 411493331, 411868239, 418994259, 467549310, 473094964, 474356043, 786916001, 492642181, 513725623, 552811199, 564725797, 609568459, 614155833, 650995194, 666504049, 666570226, 681144888, 802839692, 803839457, 817466286, 865861102, 901104443, 909938938, 930974107, 932485893, 942075928, 945153455]]) == [12647622, 171793550, 371432188, 604487110, 1110426066, 2578830068, 4114893848, 5158554743, 6221794657, 7290338903, 8838687317, 10391517017, 11492210092, 12594294475, 13710394469, 14830936257, 15961608581, 17095687192, 18667538710, 19863063908, 21060482998, 22258276996, 23463197014, 24716672083, 25975692806, 27235974608, 28809806610, 30089364792, 31390006416, 32729733616, 34081375414, 35477859874, 36878931708, 38316842903, 39770262953, 41223749180, 42691810069, 44297489453, 45905168367, 47540100939, 49271823143, 51074032029, 52893909905, 54755858119, 56620829905, 58504981761, 60395288671]\nassert my_solution.findPrefixScore(*[[912705716, 575045775, 842980131, 861696884, 35893066, 718910479, 72407171, 997631254, 79059851, 416271367, 883775650, 938430994, 338917901, 114596964, 340203807, 150198912, 30187442, 764854446, 638934453, 793648833, 510828034, 229378477, 260323819, 235640587, 182404249, 258016807, 185734475, 661736104, 216762865, 100089712, 643410455, 333678461, 786762411, 784277429, 965427354, 581108075, 385832853, 223920291, 40146986, 208043879, 964977390, 19122210, 27160212, 244394005, 161764012, 914158357, 546136995, 620226375, 378935324, 44097215, 240478137, 259568095, 717400508, 624350543, 429767030, 584705735, 484675838, 813698385, 129834979, 290304382, 419289756, 82443486, 730817933, 619694027, 238415126, 946179865, 900451442, 639115282, 471625414, 226743798, 197708087]]) == [1825411432, 3313162923, 5068848770, 6843251370, 7791850152, 9423466347, 10408579234, 12403841742, 13480532847, 14894435468, 16775842372, 18711904620, 20048453775, 21160681993, 22498517054, 23646347220, 24674165916, 26436651616, 28073217323, 29864497410, 31372956698, 32599966429, 33857921502, 35091193343, 36271228846, 37526876907, 38710242636, 40369609994, 41584004113, 42681725079, 44322766788, 45654076503, 47438470168, 49220378851, 51183437459, 52762176788, 54145640895, 55367192440, 56404970680, 57610645813, 59573254457, 60590007921, 61614799387, 62856824646, 64016219912, 65928009523, 67471777772, 69089635401, 70466201979, 71507930448, 72746039839, 74003239188, 75718270950, 77340252747, 78767651031, 80349988020, 81832295112, 83643624751, 84771090984, 86059026620, 87475947630, 88556022370, 90284471557, 91901796838, 93137843218, 95081654337, 96979737033, 98616483569, 100085740237, 101310115289, 102505454630]\nassert my_solution.findPrefixScore(*[[3138043, 10118896, 20615117, 30593213, 459455345, 494353317, 499748454, 45499138, 502289017, 47920608, 74431736, 507203378, 81752610, 82273380, 85123623, 85585241, 101128713, 102515302, 116945350, 129535560, 140743225, 161843305, 178322627, 184234971, 198230513, 241766391, 292965859, 296182011, 300573681, 529676129, 329981128, 333242100, 340963464, 346255493, 352937907, 403183104, 404156500, 407870687, 531622767, 546963584, 409839743, 458713770, 459360127, 570199596, 597626326, 611355574, 615986973, 618897446, 633373057, 634126267, 647865781, 666021433, 673382547, 679764938, 682550883, 695371081, 704063923, 709571374, 716414187, 721281404, 730079901, 732190737, 779875662, 800036065, 800387729, 808362934, 808729325, 821953324, 840969230, 842767395, 846560706, 848918206, 898002991, 917392740, 928951096, 937710329, 942274746, 959414870, 962277091, 967604721, 973531030, 979986890, 990923329, 994192368]]) == [6276086, 26513878, 67744112, 128930538, 1047841228, 2036547862, 3036044770, 3581292362, 4585870396, 5136080021, 5712800774, 6727207530, 7316163518, 7905640276, 8497967277, 9090755896, 9699087987, 10308806667, 10932955395, 11569694333, 12217640936, 12886687619, 13572213624, 14263651973, 14969085864, 15718055633, 16518224870, 17321610259, 18129387318, 19188739576, 20048396833, 20911315062, 21781954655, 22657886277, 23540500313, 24473359546, 25407192175, 26344738991, 27407984525, 28501911693, 29458715020, 30464392374, 31470716085, 32611115277, 33806367929, 35029079077, 36261053023, 37498847915, 38765594029, 40033846563, 41329578125, 42661620991, 44008386085, 45367915961, 46733017727, 48123759889, 49531887735, 50951030483, 52383858857, 53826421665, 55286581467, 56750962941, 58310714265, 59910786395, 61511561853, 63128287721, 64745746371, 66389653019, 68071591479, 69757126269, 71450247681, 73148084093, 74944090075, 76778875555, 78636777747, 80512198405, 82396747897, 84315577637, 86240131819, 88175341261, 90122403321, 92082377101, 94064223759, 96052608495]\nassert my_solution.findPrefixScore(*[[21306416, 60858267, 584491691, 763910832, 714955473, 306550820, 978211504, 45074731, 100579324, 338213826, 472730617, 783589786, 299653553, 856295657, 348531635, 287703108, 636900930, 274010222, 169427242, 646452329, 371283335, 67875725, 254422734, 74278731, 89696341, 481510120, 799744770, 33114030, 798044444, 947703892, 761847671, 946993175, 479640462, 580235512, 107647706, 899383122]]) == [42612832, 164329366, 1333312748, 2861134412, 4340000717, 5410462369, 7366885377, 8390171612, 9468962440, 10785387770, 12236329891, 13998131181, 15275996238, 17110503399, 18437246538, 19703161150, 21318273584, 22570495310, 23718134056, 25342797889, 26692292728, 27738379957, 28971014195, 30023504430, 31091412275, 32551133899, 34329090173, 35340415707, 37116671655, 39042587051, 40782646226, 42707850905, 44165702871, 45724149887, 46810009097, 48687603723]\nassert my_solution.findPrefixScore(*[[13068671, 58631465, 82995068, 747632243, 84754528, 780141794, 85760974, 95415849, 96063111, 794468933, 104157025, 120428033, 128353233, 129996780, 154986311, 158408595, 169300405, 183923883, 188372631, 193585413, 212073371, 214591544, 219917916, 230526897, 242412365, 257100776, 262411342, 317098963, 817944385, 829760100, 323045560, 351369756, 857211784, 359477270, 862020949, 362584212, 392532059, 403061145, 409781318, 419963598, 430155971, 430655397, 431444770, 441575051, 468545749, 477549122, 479916471, 491241257, 538491062, 541303593, 863083653, 542065562, 548608594, 867799985, 587681610, 622873901, 675014570, 677303011, 686864370, 693187954, 741713748, 868283808, 876284627, 744701638, 902489996, 907773691, 914539198, 948282447, 996132761]]) == [26137342, 143400272, 309390408, 1804654894, 2637041665, 4197325253, 5063228021, 5938785664, 6814990569, 8403928435, 9302554393, 10217451359, 11140273525, 12064739238, 13014194482, 13967072010, 14930841348, 15909234164, 16892075728, 17880130074, 18886672378, 19895732855, 20910119704, 21935115534, 22971996832, 24023566541, 25080446816, 26192014712, 27827903482, 29487423682, 30640229342, 31821359198, 33535782766, 34752471820, 36476513718, 37701118879, 38955671887, 40220753981, 41492556248, 42774540795, 44066717715, 45359394061, 46652859780, 47956455780, 49287022478, 50626592549, 51968529969, 53321792175, 54722304186, 56125628728, 57851796034, 59256945249, 60668637496, 62404237466, 63859719061, 65350392947, 66893207502, 68438310498, 69992974853, 71553962792, 73163476525, 74900044141, 76652613395, 78273599660, 80078579652, 81894127034, 83723205430, 85619770324, 87612035846]\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2676", "questionFrontendId": "2640", "questionTitle": "Find the Score of All Prefixes of an Array", "stats": { "totalAccepted": "5.3K", "totalSubmission": "6.7K", "totalAcceptedRaw": 5263, "totalSubmissionRaw": 6705, "acRate": "78.5%" } }
LeetCode/2721
# Sum of Distances You are given a **0-indexed** integer array `nums`. There exists an array `arr` of length `nums.length`, where `arr[i]` is the sum of `|i - j|` over all `j` such that `nums[j] == nums[i]` and `j != i`. If there is no such `j`, set `arr[i]` to be `0`. Return *the array* `arr`*.*   **Example 1:** ``` **Input:** nums = [1,3,1,1,2] **Output:** [5,0,3,4,0] **Explanation:** When i = 0, nums[0] == nums[2] and nums[0] == nums[3]. Therefore, arr[0] = |0 - 2| + |0 - 3| = 5. When i = 1, arr[1] = 0 because there is no other index with value 3. When i = 2, nums[2] == nums[0] and nums[2] == nums[3]. Therefore, arr[2] = |2 - 0| + |2 - 3| = 3. When i = 3, nums[3] == nums[0] and nums[3] == nums[2]. Therefore, arr[3] = |3 - 0| + |3 - 2| = 4. When i = 4, arr[4] = 0 because there is no other index with value 2. ``` **Example 2:** ``` **Input:** nums = [0,5,3] **Output:** [0,0,0] **Explanation:** Since each element in nums is distinct, arr[i] = 0 for all i. ```   **Constraints:** * `1 <= nums.length <= 105` * `0 <= nums[i] <= 109` Please make sure your answer follows the type signature below: ```python3 class Solution: def distance(self, nums: List[int]) -> List[int]: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.distance(*[[1, 3, 1, 1, 2]]) == [5, 0, 3, 4, 0]\nassert my_solution.distance(*[[0, 5, 3]]) == [0, 0, 0]\nassert my_solution.distance(*[[2, 0, 2, 2, 6, 5, 2]]) == [11, 0, 7, 7, 0, 0, 13]\nassert my_solution.distance(*[[0, 5, 3, 1, 2, 8, 6, 6, 6]]) == [0, 0, 0, 0, 0, 0, 3, 2, 3]\nassert my_solution.distance(*[[1]]) == [0]\nassert my_solution.distance(*[[6, 1, 3, 3, 4, 3, 4]]) == [0, 0, 4, 3, 2, 5, 2]\nassert my_solution.distance(*[[3, 2, 0, 2]]) == [0, 2, 0, 2]\nassert my_solution.distance(*[[2, 7, 2, 5, 2, 5, 4]]) == [6, 0, 4, 2, 6, 2, 0]\nassert my_solution.distance(*[[3, 3, 0, 2]]) == [1, 1, 0, 0]\nassert my_solution.distance(*[[1, 2, 4, 2]]) == [0, 2, 0, 2]\nassert my_solution.distance(*[[1, 5, 2, 2]]) == [0, 0, 1, 1]\nassert my_solution.distance(*[[0, 6, 3, 1, 0, 1, 2]]) == [4, 0, 0, 2, 4, 2, 0]\nassert my_solution.distance(*[[0, 1]]) == [0, 0]\nassert my_solution.distance(*[[0]]) == [0]\nassert my_solution.distance(*[[1, 2, 2, 3, 3, 0]]) == [0, 1, 1, 1, 1, 0]\nassert my_solution.distance(*[[7, 9, 4, 0, 2, 2, 0, 8, 5]]) == [0, 0, 0, 3, 1, 1, 3, 0, 0]\nassert my_solution.distance(*[[5, 5, 3, 2, 5, 5]]) == [10, 8, 0, 0, 8, 10]\nassert my_solution.distance(*[[4, 2, 3, 3, 8, 3]]) == [0, 0, 4, 3, 0, 5]\nassert my_solution.distance(*[[3, 0, 3, 5, 0, 0, 7, 7]]) == [2, 7, 2, 0, 4, 5, 1, 1]\nassert my_solution.distance(*[[7, 4, 9, 1, 8, 5, 5, 7, 2, 6, 5]]) == [7, 0, 0, 0, 0, 6, 5, 7, 0, 0, 9]\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2721", "questionFrontendId": "2615", "questionTitle": "Sum of Distances", "stats": { "totalAccepted": "6.1K", "totalSubmission": "16.8K", "totalAcceptedRaw": 6110, "totalSubmissionRaw": 16839, "acRate": "36.3%" } }
LeetCode/2720
# Minimize the Maximum Difference of Pairs You are given a **0-indexed** integer array `nums` and an integer `p`. Find `p` pairs of indices of `nums` such that the **maximum** difference amongst all the pairs is **minimized**. Also, ensure no index appears more than once amongst the `p` pairs. Note that for a pair of elements at the index `i` and `j`, the difference of this pair is `|nums[i] - nums[j]|`, where `|x|` represents the **absolute** **value** of `x`. Return *the **minimum** **maximum** difference among all* `p` *pairs.* We define the maximum of an empty set to be zero.   **Example 1:** ``` **Input:** nums = [10,1,2,7,1,3], p = 2 **Output:** 1 **Explanation:** The first pair is formed from the indices 1 and 4, and the second pair is formed from the indices 2 and 5. The maximum difference is max(|nums[1] - nums[4]|, |nums[2] - nums[5]|) = max(0, 1) = 1. Therefore, we return 1. ``` **Example 2:** ``` **Input:** nums = [4,2,1,2], p = 1 **Output:** 0 **Explanation:** Let the indices 1 and 3 form a pair. The difference of that pair is |2 - 2| = 0, which is the minimum we can attain. ```   **Constraints:** * `1 <= nums.length <= 105` * `0 <= nums[i] <= 109` * `0 <= p <= (nums.length)/2` Please make sure your answer follows the type signature below: ```python3 class Solution: def minimizeMax(self, nums: List[int], p: int) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.minimizeMax(*[[10, 1, 2, 7, 1, 3], 2]) == 1\nassert my_solution.minimizeMax(*[[4, 2, 1, 2], 1]) == 0\nassert my_solution.minimizeMax(*[[4, 0, 2, 1, 2, 5, 5, 3], 3]) == 1\nassert my_solution.minimizeMax(*[[0, 5, 3, 4], 0]) == 0\nassert my_solution.minimizeMax(*[[4, 1, 3, 3, 0, 4, 3], 1]) == 0\nassert my_solution.minimizeMax(*[[3, 4, 1, 2, 1], 2]) == 1\nassert my_solution.minimizeMax(*[[3, 6, 8, 7, 5, 4, 9, 5], 0]) == 0\nassert my_solution.minimizeMax(*[[5, 6, 0, 5, 4, 0, 0], 1]) == 0\nassert my_solution.minimizeMax(*[[8, 9, 1, 5, 4, 3, 6, 4, 3, 7], 4]) == 1\nassert my_solution.minimizeMax(*[[3, 3, 5, 1, 0, 5, 6, 6], 4]) == 1\nassert my_solution.minimizeMax(*[[5, 10, 6, 9, 12, 3, 8, 1, 3, 0, 7], 3]) == 1\nassert my_solution.minimizeMax(*[[3, 1, 5, 0, 3], 0]) == 0\nassert my_solution.minimizeMax(*[[2, 2, 0, 2, 0], 2]) == 0\nassert my_solution.minimizeMax(*[[3, 4, 2, 3, 2, 1, 2], 3]) == 1\nassert my_solution.minimizeMax(*[[4, 2, 8, 0, 0, 0, 3, 5, 4], 0]) == 0\nassert my_solution.minimizeMax(*[[3, 11, 4, 3, 5, 7, 4, 4, 5, 5], 3]) == 0\nassert my_solution.minimizeMax(*[[1, 2], 1]) == 1\nassert my_solution.minimizeMax(*[[2, 6, 2, 4, 2, 2, 0, 2], 4]) == 2\nassert my_solution.minimizeMax(*[[2, 6, 2, 2, 4, 2, 1, 1], 0]) == 0\nassert my_solution.minimizeMax(*[[0, 4, 4, 6, 5, 5, 0, 3], 0]) == 0\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2720", "questionFrontendId": "2616", "questionTitle": "Minimize the Maximum Difference of Pairs", "stats": { "totalAccepted": "4.7K", "totalSubmission": "11.4K", "totalAcceptedRaw": 4690, "totalSubmissionRaw": 11401, "acRate": "41.1%" } }
LeetCode/2723
# Find the Longest Balanced Substring of a Binary String You are given a binary string `s` consisting only of zeroes and ones. A substring of `s` is considered balanced if **all zeroes are before ones** and the number of zeroes is equal to the number of ones inside the substring. Notice that the empty substring is considered a balanced substring. Return *the length of the longest balanced substring of* `s`. A **substring** is a contiguous sequence of characters within a string.   **Example 1:** ``` **Input:** s = "01000111" **Output:** 6 **Explanation:** The longest balanced substring is "000111", which has length 6. ``` **Example 2:** ``` **Input:** s = "00111" **Output:** 4 **Explanation:** The longest balanced substring is "0011", which has length 4.  ``` **Example 3:** ``` **Input:** s = "111" **Output:** 0 **Explanation:** There is no balanced substring except the empty substring, so the answer is 0. ```   **Constraints:** * `1 <= s.length <= 50` * `'0' <= s[i] <= '1'` Please make sure your answer follows the type signature below: ```python3 class Solution: def findTheLongestBalancedSubstring(self, s: str) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.findTheLongestBalancedSubstring(*['01000111']) == 6\nassert my_solution.findTheLongestBalancedSubstring(*['0011']) == 4\nassert my_solution.findTheLongestBalancedSubstring(*['111']) == 0\nassert my_solution.findTheLongestBalancedSubstring(*['0']) == 0\nassert my_solution.findTheLongestBalancedSubstring(*['1']) == 0\nassert my_solution.findTheLongestBalancedSubstring(*['00']) == 0\nassert my_solution.findTheLongestBalancedSubstring(*['01']) == 2\nassert my_solution.findTheLongestBalancedSubstring(*['10']) == 0\nassert my_solution.findTheLongestBalancedSubstring(*['11']) == 0\nassert my_solution.findTheLongestBalancedSubstring(*['000']) == 0\nassert my_solution.findTheLongestBalancedSubstring(*['001']) == 2\nassert my_solution.findTheLongestBalancedSubstring(*['010']) == 2\nassert my_solution.findTheLongestBalancedSubstring(*['011']) == 2\nassert my_solution.findTheLongestBalancedSubstring(*['100']) == 0\nassert my_solution.findTheLongestBalancedSubstring(*['101']) == 2\nassert my_solution.findTheLongestBalancedSubstring(*['110']) == 0\nassert my_solution.findTheLongestBalancedSubstring(*['0000']) == 0\nassert my_solution.findTheLongestBalancedSubstring(*['0001']) == 2\nassert my_solution.findTheLongestBalancedSubstring(*['0010']) == 2\nassert my_solution.findTheLongestBalancedSubstring(*['0100']) == 2\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2723", "questionFrontendId": "2609", "questionTitle": "Find the Longest Balanced Substring of a Binary String", "stats": { "totalAccepted": "33.5K", "totalSubmission": "57.9K", "totalAcceptedRaw": 33474, "totalSubmissionRaw": 57912, "acRate": "57.8%" } }
LeetCode/2724
# Convert an Array Into a 2D Array With Conditions You are given an integer array `nums`. You need to create a 2D array from `nums` satisfying the following conditions: * The 2D array should contain **only** the elements of the array `nums`. * Each row in the 2D array contains **distinct** integers. * The number of rows in the 2D array should be **minimal**. Return *the resulting array*. If there are multiple answers, return any of them. **Note** that the 2D array can have a different number of elements on each row.   **Example 1:** ``` **Input:** nums = [1,3,4,1,2,3,1] **Output:** [[1,3,4,2],[1,3],[1]] **Explanation:** We can create a 2D array that contains the following rows: - 1,3,4,2 - 1,3 - 1 All elements of nums were used, and each row of the 2D array contains distinct integers, so it is a valid answer. It can be shown that we cannot have less than 3 rows in a valid array. ``` **Example 2:** ``` **Input:** nums = [1,2,3,4] **Output:** [[4,3,2,1]] **Explanation:** All elements of the array are distinct, so we can keep all of them in the first row of the 2D array. ```   **Constraints:** * `1 <= nums.length <= 200` * `1 <= nums[i] <= nums.length` Please make sure your answer follows the type signature below: ```python3 class Solution: def findMatrix(self, nums: List[int]) -> List[List[int]]: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.findMatrix(*[[1, 3, 4, 1, 2, 3, 1]]) == [[1, 3, 4, 2], [1, 3], [1]]\nassert my_solution.findMatrix(*[[2, 1, 1]]) == [[1, 2], [1]]\nassert my_solution.findMatrix(*[[4, 5, 3, 3, 3]]) == [[3, 5, 4], [3], [3]]\nassert my_solution.findMatrix(*[[9, 8, 8, 4, 9, 8, 8, 3, 9]]) == [[8, 9, 4, 3], [8, 9], [8, 9], [8]]\nassert my_solution.findMatrix(*[[8, 8, 8, 8, 2, 4, 4, 2, 4]]) == [[8, 4, 2], [8, 4, 2], [8, 4], [8]]\nassert my_solution.findMatrix(*[[2, 2]]) == [[2], [2]]\nassert my_solution.findMatrix(*[[3, 5, 3, 3, 8, 3, 2, 5]]) == [[3, 5, 8, 2], [3, 5], [3], [3]]\nassert my_solution.findMatrix(*[[4, 4, 4, 4, 2]]) == [[4, 2], [4], [4], [4]]\nassert my_solution.findMatrix(*[[3, 1, 2, 1, 3]]) == [[3, 1, 2], [3, 1]]\nassert my_solution.findMatrix(*[[9, 9, 9, 9, 3, 9, 2, 9, 1]]) == [[9, 3, 2, 1], [9], [9], [9], [9], [9]]\nassert my_solution.findMatrix(*[[3, 3, 4, 3]]) == [[3, 4], [3], [3]]\nassert my_solution.findMatrix(*[[3, 3, 2, 1]]) == [[3, 2, 1], [3]]\nassert my_solution.findMatrix(*[[1, 1]]) == [[1], [1]]\nassert my_solution.findMatrix(*[[3, 3, 3]]) == [[3], [3], [3]]\nassert my_solution.findMatrix(*[[6, 4, 6, 4, 3, 3, 6, 2]]) == [[6, 4, 3, 2], [6, 4, 3], [6]]\nassert my_solution.findMatrix(*[[2, 3, 1, 2]]) == [[2, 3, 1], [2]]\nassert my_solution.findMatrix(*[[8, 7, 8, 8, 1, 8, 8, 7, 9]]) == [[8, 7, 9, 1], [8, 7], [8], [8], [8]]\nassert my_solution.findMatrix(*[[7, 7, 7, 7, 7, 7, 7, 7]]) == [[7], [7], [7], [7], [7], [7], [7], [7]]\nassert my_solution.findMatrix(*[[2, 6, 3, 3, 2, 3, 2, 2, 3]]) == [[3, 2, 6], [3, 2], [3, 2], [3, 2]]\nassert my_solution.findMatrix(*[[1, 2, 2, 1]]) == [[2, 1], [2, 1]]\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2724", "questionFrontendId": "2610", "questionTitle": "Convert an Array Into a 2D Array With Conditions", "stats": { "totalAccepted": "9.1K", "totalSubmission": "10.8K", "totalAcceptedRaw": 9147, "totalSubmissionRaw": 10842, "acRate": "84.4%" } }
LeetCode/2725
# Mice and Cheese There are two mice and `n` different types of cheese, each type of cheese should be eaten by exactly one mouse. A point of the cheese with index `i` (**0-indexed**) is: * `reward1[i]` if the first mouse eats it. * `reward2[i]` if the second mouse eats it. You are given a positive integer array `reward1`, a positive integer array `reward2`, and a non-negative integer `k`. Return ***the maximum** points the mice can achieve if the first mouse eats exactly* `k` *types of cheese.*   **Example 1:** ``` **Input:** reward1 = [1,1,3,4], reward2 = [4,4,1,1], k = 2 **Output:** 15 **Explanation:** In this example, the first mouse eats the 2nd (0-indexed) and the 3rd types of cheese, and the second mouse eats the 0th and the 1st types of cheese. The total points are 4 + 4 + 3 + 4 = 15. It can be proven that 15 is the maximum total points that the mice can achieve. ``` **Example 2:** ``` **Input:** reward1 = [1,1], reward2 = [1,1], k = 2 **Output:** 2 **Explanation:** In this example, the first mouse eats the 0th (0-indexed) and 1st types of cheese, and the second mouse does not eat any cheese. The total points are 1 + 1 = 2. It can be proven that 2 is the maximum total points that the mice can achieve. ```   **Constraints:** * `1 <= n == reward1.length == reward2.length <= 105` * `1 <= reward1[i], reward2[i] <= 1000` * `0 <= k <= n` Please make sure your answer follows the type signature below: ```python3 class Solution: def miceAndCheese(self, reward1: List[int], reward2: List[int], k: int) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.miceAndCheese(*[[1, 1, 3, 4], [4, 4, 1, 1], 2]) == 15\nassert my_solution.miceAndCheese(*[[1, 1], [1, 1], 2]) == 2\nassert my_solution.miceAndCheese(*[[2, 1], [1, 2], 1]) == 4\nassert my_solution.miceAndCheese(*[[3, 3], [3, 5], 1]) == 8\nassert my_solution.miceAndCheese(*[[4, 1, 5, 3, 3], [3, 4, 4, 5, 2], 3]) == 21\nassert my_solution.miceAndCheese(*[[1, 4, 4, 6, 4], [6, 5, 3, 6, 1], 1]) == 24\nassert my_solution.miceAndCheese(*[[1, 2, 1, 2, 1, 2], [2, 1, 1, 2, 2, 1], 0]) == 9\nassert my_solution.miceAndCheese(*[[2, 2, 1, 2], [1, 2, 1, 2], 2]) == 7\nassert my_solution.miceAndCheese(*[[1], [4], 1]) == 1\nassert my_solution.miceAndCheese(*[[1, 2, 2], [2, 1, 2], 2]) == 6\nassert my_solution.miceAndCheese(*[[3, 1, 1, 3], [3, 2, 3, 1], 3]) == 10\nassert my_solution.miceAndCheese(*[[4], [5], 0]) == 5\nassert my_solution.miceAndCheese(*[[2, 3], [3, 3], 2]) == 5\nassert my_solution.miceAndCheese(*[[1, 1], [1, 1], 1]) == 2\nassert my_solution.miceAndCheese(*[[1, 3], [5, 4], 1]) == 8\nassert my_solution.miceAndCheese(*[[2, 1, 4], [1, 4, 2], 0]) == 7\nassert my_solution.miceAndCheese(*[[3, 4, 2, 1, 5], [2, 3, 5, 2, 4], 0]) == 16\nassert my_solution.miceAndCheese(*[[5, 2], [3, 1], 2]) == 7\nassert my_solution.miceAndCheese(*[[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], 5]) == 5\nassert my_solution.miceAndCheese(*[[2, 2, 1, 2, 1], [1, 1, 2, 1, 1], 0]) == 6\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2725", "questionFrontendId": "2611", "questionTitle": "Mice and Cheese", "stats": { "totalAccepted": "28.2K", "totalSubmission": "48.3K", "totalAcceptedRaw": 28248, "totalSubmissionRaw": 48347, "acRate": "58.4%" } }
LeetCode/2726
# Minimum Reverse Operations You are given an integer `n` and an integer `p` in the range `[0, n - 1]`. Representing a **0-indexed** array `arr` of length `n` where all positions are set to `0`'s, except position `p` which is set to `1`. You are also given an integer array `banned` containing some positions from the array. For the **i****th** position in `banned`, `arr[banned[i]] = 0`, and `banned[i] != p`. You can perform **multiple** operations on `arr`. In an operation, you can choose a **subarray** with size `k` and **reverse** the subarray. However, the `1` in `arr` should never go to any of the positions in `banned`. In other words, after each operation `arr[banned[i]]` **remains** `0`. *Return an array* `ans` *where* *for each* `i` *from* `[0, n - 1]`, `ans[i]` *is the **minimum** number of reverse operations needed to bring the* `1` *to position* `i` *in arr*, *or* `-1` *if it is impossible*. * A **subarray** is a contiguous **non-empty** sequence of elements within an array. * The values of `ans[i]` are independent for all `i`'s. * The **reverse** of an array is an array containing the values in **reverse order**.   **Example 1:** ``` **Input:** n = 4, p = 0, banned = [1,2], k = 4 **Output:** [0,-1,-1,1] **Explanation:** In this case k = 4 so there is only one possible reverse operation we can perform, which is reversing the whole array. Initially, 1is placed at position 0 so the amount of operations we need for position 0 is 0. We can never place a 1 on the banned positions, so the answer for positions 1 and 2 is -1. Finally, with one reverse operation we can bring the 1 to index 3, so the answer for position 3 is 1. ``` **Example 2:** ``` **Input:** n = 5, p = 0, banned = [2,4], k = 3 **Output:** [0,-1,-1,-1,-1] **Explanation:** In this case the 1 is initially at position 0, so the answer for that position is 0. We can perform reverse operations of size 3. The 1 is currently located at position 0, so we need to reverse the subarray [0, 2] for it to leave that position, but reversing that subarray makes position 2 have a 1, which shouldn't happen. So, we can't move the 1 from position 0, making the result for all the other positions -1. ``` **Example 3:** ``` **Input:** n = 4, p = 2, banned = [0,1,3], k = 1 **Output:** [-1,-1,0,-1] **Explanation:** In this case we can only perform reverse operations of size 1.So the 1 never changes its position. ```   **Constraints:** * `1 <= n <= 105` * `0 <= p <= n - 1` * `0 <= banned.length <= n - 1` * `0 <= banned[i] <= n - 1` * `1 <= k <= n` * `banned[i] != p` * all values in `banned` are **unique** Please make sure your answer follows the type signature below: ```python3 class Solution: def minReverseOperations(self, n: int, p: int, banned: List[int], k: int) -> List[int]: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.minReverseOperations(*[4, 0, [1, 2], 4]) == [0, -1, -1, 1]\nassert my_solution.minReverseOperations(*[5, 0, [2, 4], 3]) == [0, -1, -1, -1, -1]\nassert my_solution.minReverseOperations(*[4, 2, [0, 1, 3], 1]) == [-1, -1, 0, -1]\nassert my_solution.minReverseOperations(*[5, 0, [], 2]) == [0, 1, 2, 3, 4]\nassert my_solution.minReverseOperations(*[1, 0, [], 1]) == [0]\nassert my_solution.minReverseOperations(*[2, 0, [], 1]) == [0, -1]\nassert my_solution.minReverseOperations(*[2, 0, [], 2]) == [0, 1]\nassert my_solution.minReverseOperations(*[2, 1, [], 1]) == [-1, 0]\nassert my_solution.minReverseOperations(*[2, 1, [], 2]) == [1, 0]\nassert my_solution.minReverseOperations(*[2, 0, [1], 1]) == [0, -1]\nassert my_solution.minReverseOperations(*[2, 0, [1], 2]) == [0, -1]\nassert my_solution.minReverseOperations(*[2, 1, [0], 1]) == [-1, 0]\nassert my_solution.minReverseOperations(*[2, 1, [0], 2]) == [-1, 0]\nassert my_solution.minReverseOperations(*[3, 0, [], 1]) == [0, -1, -1]\nassert my_solution.minReverseOperations(*[3, 0, [], 2]) == [0, 1, 2]\nassert my_solution.minReverseOperations(*[3, 0, [], 3]) == [0, -1, 1]\nassert my_solution.minReverseOperations(*[3, 1, [], 1]) == [-1, 0, -1]\nassert my_solution.minReverseOperations(*[3, 1, [], 2]) == [1, 0, 1]\nassert my_solution.minReverseOperations(*[3, 1, [], 3]) == [-1, 0, -1]\nassert my_solution.minReverseOperations(*[3, 2, [], 1]) == [-1, -1, 0]\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2726", "questionFrontendId": "2612", "questionTitle": "Minimum Reverse Operations", "stats": { "totalAccepted": "2.6K", "totalSubmission": "12.4K", "totalAcceptedRaw": 2650, "totalSubmissionRaw": 12400, "acRate": "21.4%" } }
LeetCode/2668
# Form Smallest Number From Two Digit Arrays Given two arrays of **unique** digits `nums1` and `nums2`, return *the **smallest** number that contains **at least** one digit from each array*.   **Example 1:** ``` **Input:** nums1 = [4,1,3], nums2 = [5,7] **Output:** 15 **Explanation:** The number 15 contains the digit 1 from nums1 and the digit 5 from nums2. It can be proven that 15 is the smallest number we can have. ``` **Example 2:** ``` **Input:** nums1 = [3,5,2,6], nums2 = [3,1,7] **Output:** 3 **Explanation:** The number 3 contains the digit 3 which exists in both arrays. ```   **Constraints:** * `1 <= nums1.length, nums2.length <= 9` * `1 <= nums1[i], nums2[i] <= 9` * All digits in each array are **unique**. Please make sure your answer follows the type signature below: ```python3 class Solution: def minNumber(self, nums1: List[int], nums2: List[int]) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.minNumber(*[[4, 1, 3], [5, 7]]) == 15\nassert my_solution.minNumber(*[[3, 5, 2, 6], [3, 1, 7]]) == 3\nassert my_solution.minNumber(*[[6, 4, 3, 7, 2, 1, 8, 5], [6, 8, 5, 3, 1, 7, 4, 2]]) == 1\nassert my_solution.minNumber(*[[7, 2, 8, 6, 4, 5, 3, 1], [3, 4, 1, 2, 6, 8, 5, 7]]) == 1\nassert my_solution.minNumber(*[[5, 1, 7, 6, 8, 2, 3, 4], [2, 3, 4, 5, 1, 7, 8, 6]]) == 1\nassert my_solution.minNumber(*[[3, 8, 5, 4, 7, 1, 2, 6], [1, 6, 4, 5, 8, 7, 3, 2]]) == 1\nassert my_solution.minNumber(*[[4, 8, 2, 1, 7, 3, 6, 5], [2, 7, 4, 5, 1, 6, 3, 8]]) == 1\nassert my_solution.minNumber(*[[4, 5, 2, 7, 3, 1, 6, 8], [6, 3, 4, 8, 2, 7, 5, 1]]) == 1\nassert my_solution.minNumber(*[[4, 5, 3, 2, 8, 6, 1, 7], [5, 2, 1, 7, 8, 3, 4, 6]]) == 1\nassert my_solution.minNumber(*[[3, 6, 1, 8, 5, 4, 7, 2], [2, 8, 1, 6, 4, 5, 3, 7]]) == 1\nassert my_solution.minNumber(*[[4, 1, 3, 8, 6, 2, 7, 5], [5, 4, 7, 8, 2, 3, 6, 1]]) == 1\nassert my_solution.minNumber(*[[8, 2, 6, 5, 7, 3, 4, 1], [3, 6, 4, 8, 7, 2, 1, 5]]) == 1\nassert my_solution.minNumber(*[[6, 5, 7, 1, 8, 4, 3, 2], [5, 2, 3, 8, 1, 7, 6, 4]]) == 1\nassert my_solution.minNumber(*[[8, 3, 6, 4, 2, 5, 1, 7], [6, 2, 4, 5, 8, 3, 1, 7]]) == 1\nassert my_solution.minNumber(*[[1, 2, 5, 8, 6, 7, 3, 4], [2, 3, 1, 4, 6, 8, 7, 5]]) == 1\nassert my_solution.minNumber(*[[3, 6, 8, 1, 5, 7, 4, 2], [2, 8, 3, 7, 5, 1, 4, 6]]) == 1\nassert my_solution.minNumber(*[[8, 1, 4, 6, 5, 3, 2, 7], [2, 8, 7, 6, 3, 1, 5, 4]]) == 1\nassert my_solution.minNumber(*[[5, 1, 4, 8, 2, 7, 6, 3], [1, 3, 8, 4, 6, 5, 7, 2]]) == 1\nassert my_solution.minNumber(*[[8, 5, 7, 1, 4, 3, 2, 6], [1, 5, 2, 4, 7, 8, 3, 6]]) == 1\nassert my_solution.minNumber(*[[2, 1, 6, 7, 3, 5, 8, 4], [3, 1, 2, 7, 4, 6, 8, 5]]) == 1\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2668", "questionFrontendId": "2605", "questionTitle": "Form Smallest Number From Two Digit Arrays", "stats": { "totalAccepted": "35K", "totalSubmission": "52.1K", "totalAcceptedRaw": 34974, "totalSubmissionRaw": 52146, "acRate": "67.1%" } }
LeetCode/2669
# Find the Substring With Maximum Cost You are given a string `s`, a string `chars` of **distinct** characters and an integer array `vals` of the same length as `chars`. The **cost of the substring** is the sum of the values of each character in the substring. The cost of an empty string is considered `0`. The **value of the character** is defined in the following way: * If the character is not in the string `chars`, then its value is its corresponding position **(1-indexed)** in the alphabet. + For example, the value of `'a'` is `1`, the value of `'b'` is `2`, and so on. The value of `'z'` is `26`. * Otherwise, assuming `i` is the index where the character occurs in the string `chars`, then its value is `vals[i]`. Return *the maximum cost among all substrings of the string* `s`.   **Example 1:** ``` **Input:** s = "adaa", chars = "d", vals = [-1000] **Output:** 2 **Explanation:** The value of the characters "a" and "d" is 1 and -1000 respectively. The substring with the maximum cost is "aa" and its cost is 1 + 1 = 2. It can be proven that 2 is the maximum cost. ``` **Example 2:** ``` **Input:** s = "abc", chars = "abc", vals = [-1,-1,-1] **Output:** 0 **Explanation:** The value of the characters "a", "b" and "c" is -1, -1, and -1 respectively. The substring with the maximum cost is the empty substring "" and its cost is 0. It can be proven that 0 is the maximum cost. ```   **Constraints:** * `1 <= s.length <= 105` * `s` consist of lowercase English letters. * `1 <= chars.length <= 26` * `chars` consist of **distinct** lowercase English letters. * `vals.length == chars.length` * `-1000 <= vals[i] <= 1000` Please make sure your answer follows the type signature below: ```python3 class Solution: def maximumCostSubstring(self, s: str, chars: str, vals: List[int]) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.maximumCostSubstring(*['adaa', 'd', [-1000]]) == 2\nassert my_solution.maximumCostSubstring(*['abc', 'abc', [-1, -1, -1]]) == 0\nassert my_solution.maximumCostSubstring(*['hghhghgghh', 'hg', [2, 3]]) == 24\nassert my_solution.maximumCostSubstring(*['ddzddzd', 'zfd', [-4, 2, -2]]) == 0\nassert my_solution.maximumCostSubstring(*['kqqqqqkkkq', 'kq', [-6, 6]]) == 30\nassert my_solution.maximumCostSubstring(*['pprpf', 'frep', [-5, -4, -4, 3]]) == 6\nassert my_solution.maximumCostSubstring(*['eggggeee', 'ge', [5, 3]]) == 32\nassert my_solution.maximumCostSubstring(*['ssss', 's', [3]]) == 12\nassert my_solution.maximumCostSubstring(*['ffff', 'f', [1]]) == 4\nassert my_solution.maximumCostSubstring(*['xuusmmums', 'sxmu', [-6, 5, 0, 5]]) == 15\nassert my_solution.maximumCostSubstring(*['axaaxxaxa', 'ax', [-6, 1]]) == 2\nassert my_solution.maximumCostSubstring(*['ffkfuft', 'utkf', [3, -6, 3, 6]]) == 30\nassert my_solution.maximumCostSubstring(*['ll', 'il', [3, -6]]) == 0\nassert my_solution.maximumCostSubstring(*['hwwqwwqqqh', 'wihq', [-2, -5, -4, 4]]) == 12\nassert my_solution.maximumCostSubstring(*['qjjjqqq', 'zqj', [-4, 3, 4]]) == 24\nassert my_solution.maximumCostSubstring(*['talaqlt', 'tqla', [4, 3, 3, -2]]) == 13\nassert my_solution.maximumCostSubstring(*['qqqqqqqqqq', 'q', [0]]) == 0\nassert my_solution.maximumCostSubstring(*['tt', 't', [-2]]) == 0\nassert my_solution.maximumCostSubstring(*['zox', 'zoxr', [2, -5, -4, -5]]) == 2\nassert my_solution.maximumCostSubstring(*['ddddddd', 'd', [-3]]) == 0\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2669", "questionFrontendId": "2606", "questionTitle": "Find the Substring With Maximum Cost", "stats": { "totalAccepted": "5.9K", "totalSubmission": "10.4K", "totalAcceptedRaw": 5870, "totalSubmissionRaw": 10432, "acRate": "56.3%" } }
LeetCode/2670
# Make K-Subarray Sums Equal You are given a **0-indexed** integer array `arr` and an integer `k`. The array `arr` is circular. In other words, the first element of the array is the next element of the last element, and the last element of the array is the previous element of the first element. You can do the following operation any number of times: * Pick any element from `arr` and increase or decrease it by `1`. Return *the minimum number of operations such that the sum of each **subarray** of length* `k` *is equal*. A **subarray** is a contiguous part of the array.   **Example 1:** ``` **Input:** arr = [1,4,1,3], k = 2 **Output:** 1 **Explanation:** we can do one operation on index 1 to make its value equal to 3. The array after the operation is [1,3,1,3] - Subarray starts at index 0 is [1, 3], and its sum is 4 - Subarray starts at index 1 is [3, 1], and its sum is 4 - Subarray starts at index 2 is [1, 3], and its sum is 4 - Subarray starts at index 3 is [3, 1], and its sum is 4 ``` **Example 2:** ``` **Input:** arr = [2,5,5,7], k = 3 **Output:** 5 **Explanation:** we can do three operations on index 0 to make its value equal to 5 and two operations on index 3 to make its value equal to 5. The array after the operations is [5,5,5,5] - Subarray starts at index 0 is [5, 5, 5], and its sum is 15 - Subarray starts at index 1 is [5, 5, 5], and its sum is 15 - Subarray starts at index 2 is [5, 5, 5], and its sum is 15 - Subarray starts at index 3 is [5, 5, 5], and its sum is 15 ```   **Constraints:** * `1 <= k <= arr.length <= 105` * `1 <= arr[i] <= 109` Please make sure your answer follows the type signature below: ```python3 class Solution: def makeSubKSumEqual(self, arr: List[int], k: int) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.makeSubKSumEqual(*[[1, 4, 1, 3], 2]) == 1\nassert my_solution.makeSubKSumEqual(*[[2, 5, 5, 7], 3]) == 5\nassert my_solution.makeSubKSumEqual(*[[9], 1]) == 0\nassert my_solution.makeSubKSumEqual(*[[1, 10], 1]) == 9\nassert my_solution.makeSubKSumEqual(*[[4, 6], 2]) == 0\nassert my_solution.makeSubKSumEqual(*[[2, 10, 9], 1]) == 8\nassert my_solution.makeSubKSumEqual(*[[10, 3, 8], 2]) == 7\nassert my_solution.makeSubKSumEqual(*[[3, 3, 9], 3]) == 0\nassert my_solution.makeSubKSumEqual(*[[1, 7, 9, 6], 1]) == 9\nassert my_solution.makeSubKSumEqual(*[[7, 3, 10, 6], 2]) == 6\nassert my_solution.makeSubKSumEqual(*[[1, 5, 8, 10], 3]) == 12\nassert my_solution.makeSubKSumEqual(*[[2, 6, 7, 2], 4]) == 0\nassert my_solution.makeSubKSumEqual(*[[2, 4, 2, 10, 3], 1]) == 10\nassert my_solution.makeSubKSumEqual(*[[9, 1, 5, 10, 6], 2]) == 13\nassert my_solution.makeSubKSumEqual(*[[10, 9, 1, 10, 5], 3]) == 14\nassert my_solution.makeSubKSumEqual(*[[9, 7, 2, 6, 4], 4]) == 10\nassert my_solution.makeSubKSumEqual(*[[10, 5, 10, 2, 9], 5]) == 0\nassert my_solution.makeSubKSumEqual(*[[5, 8, 2, 6, 9, 1], 1]) == 15\nassert my_solution.makeSubKSumEqual(*[[8, 2, 5, 9, 8, 10], 2]) == 11\nassert my_solution.makeSubKSumEqual(*[[9, 4, 8, 8, 5, 8], 3]) == 2\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2670", "questionFrontendId": "2607", "questionTitle": "Make K-Subarray Sums Equal", "stats": { "totalAccepted": "3.2K", "totalSubmission": "8.1K", "totalAcceptedRaw": 3230, "totalSubmissionRaw": 8079, "acRate": "40.0%" } }
LeetCode/2715
# K Items With the Maximum Sum There is a bag that consists of items, each item has a number `1`, `0`, or `-1` written on it. You are given four **non-negative** integers `numOnes`, `numZeros`, `numNegOnes`, and `k`. The bag initially contains: * `numOnes` items with `1`s written on them. * `numZeroes` items with `0`s written on them. * `numNegOnes` items with `-1`s written on them. We want to pick exactly `k` items among the available items. Return *the **maximum** possible sum of numbers written on the items*.   **Example 1:** ``` **Input:** numOnes = 3, numZeros = 2, numNegOnes = 0, k = 2 **Output:** 2 **Explanation:** We have a bag of items with numbers written on them {1, 1, 1, 0, 0}. We take 2 items with 1 written on them and get a sum in a total of 2. It can be proven that 2 is the maximum possible sum. ``` **Example 2:** ``` **Input:** numOnes = 3, numZeros = 2, numNegOnes = 0, k = 4 **Output:** 3 **Explanation:** We have a bag of items with numbers written on them {1, 1, 1, 0, 0}. We take 3 items with 1 written on them, and 1 item with 0 written on it, and get a sum in a total of 3. It can be proven that 3 is the maximum possible sum. ```   **Constraints:** * `0 <= numOnes, numZeros, numNegOnes <= 50` * `0 <= k <= numOnes + numZeros + numNegOnes` Please make sure your answer follows the type signature below: ```python3 class Solution: def kItemsWithMaximumSum(self, numOnes: int, numZeros: int, numNegOnes: int, k: int) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.kItemsWithMaximumSum(*[3, 2, 0, 2]) == 2\nassert my_solution.kItemsWithMaximumSum(*[3, 2, 0, 4]) == 3\nassert my_solution.kItemsWithMaximumSum(*[4, 0, 1, 2]) == 2\nassert my_solution.kItemsWithMaximumSum(*[1, 4, 1, 3]) == 1\nassert my_solution.kItemsWithMaximumSum(*[6, 6, 6, 13]) == 5\nassert my_solution.kItemsWithMaximumSum(*[2, 1, 2, 1]) == 1\nassert my_solution.kItemsWithMaximumSum(*[8, 4, 0, 8]) == 8\nassert my_solution.kItemsWithMaximumSum(*[0, 3, 1, 1]) == 0\nassert my_solution.kItemsWithMaximumSum(*[2, 4, 4, 0]) == 0\nassert my_solution.kItemsWithMaximumSum(*[3, 7, 4, 8]) == 3\nassert my_solution.kItemsWithMaximumSum(*[3, 3, 5, 11]) == -2\nassert my_solution.kItemsWithMaximumSum(*[1, 2, 0, 2]) == 1\nassert my_solution.kItemsWithMaximumSum(*[1, 6, 4, 4]) == 1\nassert my_solution.kItemsWithMaximumSum(*[1, 1, 2, 2]) == 1\nassert my_solution.kItemsWithMaximumSum(*[3, 0, 5, 8]) == -2\nassert my_solution.kItemsWithMaximumSum(*[1, 0, 3, 4]) == -2\nassert my_solution.kItemsWithMaximumSum(*[2, 0, 4, 2]) == 2\nassert my_solution.kItemsWithMaximumSum(*[1, 3, 3, 5]) == 0\nassert my_solution.kItemsWithMaximumSum(*[4, 3, 2, 1]) == 1\nassert my_solution.kItemsWithMaximumSum(*[4, 4, 0, 5]) == 4\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2715", "questionFrontendId": "2600", "questionTitle": "K Items With the Maximum Sum", "stats": { "totalAccepted": "34.1K", "totalSubmission": "50.4K", "totalAcceptedRaw": 34131, "totalSubmissionRaw": 50384, "acRate": "67.7%" } }
LeetCode/2716
# Prime Subtraction Operation You are given a **0-indexed** integer array `nums` of length `n`. You can perform the following operation as many times as you want: * Pick an index `i` that you haven’t picked before, and pick a prime `p` **strictly less than** `nums[i]`, then subtract `p` from `nums[i]`. Return *true if you can make `nums` a strictly increasing array using the above operation and false otherwise.* A **strictly increasing array** is an array whose each element is strictly greater than its preceding element.   **Example 1:** ``` **Input:** nums = [4,9,6,10] **Output:** true **Explanation:** In the first operation: Pick i = 0 and p = 3, and then subtract 3 from nums[0], so that nums becomes [1,9,6,10]. In the second operation: i = 1, p = 7, subtract 7 from nums[1], so nums becomes equal to [1,2,6,10]. After the second operation, nums is sorted in strictly increasing order, so the answer is true. ``` **Example 2:** ``` **Input:** nums = [6,8,11,12] **Output:** true **Explanation:** Initially nums is sorted in strictly increasing order, so we don't need to make any operations. ``` **Example 3:** ``` **Input:** nums = [5,8,3] **Output:** false **Explanation:** It can be proven that there is no way to perform operations to make nums sorted in strictly increasing order, so the answer is false. ```   **Constraints:** * `1 <= nums.length <= 1000` * `1 <= nums[i] <= 1000` * `nums.length == n` Please make sure your answer follows the type signature below: ```python3 class Solution: def primeSubOperation(self, nums: List[int]) -> bool: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.primeSubOperation(*[[4, 9, 6, 10]]) == True\nassert my_solution.primeSubOperation(*[[6, 8, 11, 12]]) == True\nassert my_solution.primeSubOperation(*[[5, 8, 3]]) == False\nassert my_solution.primeSubOperation(*[[2, 2]]) == False\nassert my_solution.primeSubOperation(*[[998, 2]]) == True\nassert my_solution.primeSubOperation(*[[1, 20, 7, 12, 4]]) == False\nassert my_solution.primeSubOperation(*[[17, 20, 5, 15, 6]]) == False\nassert my_solution.primeSubOperation(*[[17, 2]]) == False\nassert my_solution.primeSubOperation(*[[18, 12, 14, 6]]) == False\nassert my_solution.primeSubOperation(*[[11, 2, 10, 15, 19]]) == False\nassert my_solution.primeSubOperation(*[[12]]) == True\nassert my_solution.primeSubOperation(*[[4, 3, 7, 4]]) == False\nassert my_solution.primeSubOperation(*[[6, 17, 2, 9, 20]]) == False\nassert my_solution.primeSubOperation(*[[20, 18, 2]]) == False\nassert my_solution.primeSubOperation(*[[10, 18, 14, 3, 11]]) == False\nassert my_solution.primeSubOperation(*[[19, 10]]) == True\nassert my_solution.primeSubOperation(*[[4, 18, 10, 16, 3]]) == False\nassert my_solution.primeSubOperation(*[[17, 2, 15]]) == False\nassert my_solution.primeSubOperation(*[[9]]) == True\nassert my_solution.primeSubOperation(*[[15, 20, 17, 7, 16]]) == True\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2716", "questionFrontendId": "2601", "questionTitle": "Prime Subtraction Operation", "stats": { "totalAccepted": "7.7K", "totalSubmission": "19.7K", "totalAcceptedRaw": 7730, "totalSubmissionRaw": 19736, "acRate": "39.2%" } }
LeetCode/2718
# Minimum Operations to Make All Array Elements Equal You are given an array `nums` consisting of positive integers. You are also given an integer array `queries` of size `m`. For the `ith` query, you want to make all of the elements of `nums` equal to `queries[i]`. You can perform the following operation on the array **any** number of times: * **Increase** or **decrease** an element of the array by `1`. Return *an array* `answer` *of size* `m` *where* `answer[i]` *is the **minimum** number of operations to make all elements of* `nums` *equal to* `queries[i]`. **Note** that after each query the array is reset to its original state.   **Example 1:** ``` **Input:** nums = [3,1,6,8], queries = [1,5] **Output:** [14,10] **Explanation:** For the first query we can do the following operations: - Decrease nums[0] 2 times, so that nums = [1,1,6,8]. - Decrease nums[2] 5 times, so that nums = [1,1,1,8]. - Decrease nums[3] 7 times, so that nums = [1,1,1,1]. So the total number of operations for the first query is 2 + 5 + 7 = 14. For the second query we can do the following operations: - Increase nums[0] 2 times, so that nums = [5,1,6,8]. - Increase nums[1] 4 times, so that nums = [5,5,6,8]. - Decrease nums[2] 1 time, so that nums = [5,5,5,8]. - Decrease nums[3] 3 times, so that nums = [5,5,5,5]. So the total number of operations for the second query is 2 + 4 + 1 + 3 = 10. ``` **Example 2:** ``` **Input:** nums = [2,9,6,3], queries = [10] **Output:** [20] **Explanation:** We can increase each value in the array to 10. The total number of operations will be 8 + 1 + 4 + 7 = 20. ```   **Constraints:** * `n == nums.length` * `m == queries.length` * `1 <= n, m <= 105` * `1 <= nums[i], queries[i] <= 109` Please make sure your answer follows the type signature below: ```python3 class Solution: def minOperations(self, nums: List[int], queries: List[int]) -> List[int]: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.minOperations(*[[3, 1, 6, 8], [1, 5]]) == [14, 10]\nassert my_solution.minOperations(*[[2, 9, 6, 3], [10]]) == [20]\nassert my_solution.minOperations(*[[47, 50, 97, 58, 87, 72, 41, 63, 41, 51, 17, 21, 7, 100, 69, 66, 79, 92, 84, 9, 57, 26, 26, 28, 83, 38], [50, 84, 76, 41, 64, 82, 20, 22, 64, 7, 38, 92, 39, 28, 22, 3, 41, 46, 47, 50, 88, 51, 9, 49, 38, 67, 26, 65, 89, 27, 71, 25, 77, 72, 65, 41, 84, 68, 51, 26, 84, 24, 79, 41, 96, 83, 92, 9, 93, 84, 35, 70, 74, 79, 37, 38, 26, 26, 41, 26]]) == [607, 855, 747, 655, 633, 825, 943, 905, 633, 1227, 685, 1009, 675, 805, 905, 1331, 655, 625, 619, 607, 929, 605, 1179, 611, 685, 653, 833, 639, 949, 819, 689, 851, 759, 699, 639, 655, 855, 661, 605, 833, 855, 869, 783, 655, 1097, 839, 1009, 1179, 1031, 855, 721, 679, 723, 783, 697, 685, 833, 833, 655, 833]\nassert my_solution.minOperations(*[[39, 21, 5, 58, 11, 73, 93, 87, 4, 63, 66, 64, 77, 60, 24, 2, 6, 82, 97, 94, 100, 92, 67, 52, 82, 97, 9, 99, 29, 31, 100, 67, 56, 28, 8, 81, 41, 18, 63, 43, 22, 60, 96, 91, 33, 22, 92, 16, 89], [82, 99, 21, 5, 91, 97, 85, 67, 33, 87, 92, 67, 33, 22, 64, 81, 44, 63, 43, 31, 56, 74, 62, 4, 57, 20, 9, 32, 30, 63, 39, 92, 6, 16, 92, 89, 60, 73, 38, 81, 56, 2, 39, 22, 63, 67, 1, 97, 66, 9, 37, 2, 32, 88, 2, 21, 2, 78, 87, 33, 9, 92, 96, 88, 92, 16, 41, 60, 32, 82, 67, 28, 99, 67, 19, 4, 45, 59, 100, 91]]) == [1630, 2145, 1901, 2473, 1849, 2059, 1699, 1405, 1637, 1745, 1878, 1405, 1637, 1872, 1382, 1611, 1490, 1377, 1499, 1671, 1390, 1498, 1376, 2518, 1385, 1932, 2309, 1654, 1690, 1377, 1547, 1878, 2430, 2060, 1878, 1795, 1374, 1483, 1562, 1611, 1390, 2612, 1547, 1872, 1377, 1405, 2661, 2059, 1396, 2309, 1577, 2612, 1654, 1770, 2612, 1901, 2612, 1560, 1745, 1637, 2309, 1878, 2020, 1770, 1878, 2060, 1521, 1374, 1654, 1630, 1405, 1730, 2145, 1405, 1963, 2518, 1481, 1377, 2190, 1849]\nassert my_solution.minOperations(*[[67, 53, 67, 35, 88, 76, 92, 99, 12, 80, 78, 11, 59, 49, 52, 50, 10, 89, 46, 100, 74, 90, 7, 76, 34, 78, 85, 74, 38, 12, 75, 46, 60, 43, 88, 32, 5, 61, 53, 99, 13, 82, 11, 75, 83, 80, 53, 98, 46, 95, 67, 70, 90, 21, 10, 23, 43, 80, 22, 23, 62, 74, 78, 4, 50, 47, 39, 82, 90, 73, 34, 47, 78, 89, 99, 76, 45, 64, 58, 14, 3, 57, 30, 21, 73, 32, 11, 76, 46], [59, 60, 14, 62, 61, 83, 45, 73, 45, 76, 73, 12, 50, 11, 55, 92, 22, 74, 73, 23, 32, 80, 73, 84, 92, 76, 82, 43, 22, 62, 80, 22, 53, 46, 82, 79, 75, 53, 76, 5, 51, 83, 77, 3, 50, 76, 98, 78, 49, 76, 19, 9, 6, 5, 27, 42, 41, 90, 52, 53, 75, 67, 76, 97, 49, 32, 76, 78, 99, 83, 23, 21, 72, 10, 73, 35, 25, 34, 34, 60, 66, 88, 13, 46, 49, 73, 38, 34, 78, 12, 99, 82, 89, 74, 14, 85, 47]]) == [2139, 2140, 3852, 2148, 2143, 2699, 2309, 2285, 2309, 2364, 2285, 3984, 2200, 4055, 2153, 3284, 3352, 2306, 2285, 3295, 2822, 2536, 2285, 2758, 3284, 2364, 2642, 2375, 3352, 2148, 2536, 3352, 2163, 2278, 2642, 2489, 2333, 2163, 2364, 4541, 2187, 2699, 2403, 4713, 2200, 2364, 3752, 2442, 2217, 2364, 3537, 4213, 4458, 4541, 3083, 2412, 2449, 3134, 2174, 2163, 2333, 2189, 2364, 3673, 2217, 2822, 2364, 2442, 3833, 2699, 3295, 3411, 2268, 4132, 2285, 2685, 3189, 2728, 2728, 2140, 2180, 3000, 3917, 2278, 2217, 2285, 2562, 2728, 2442, 3984, 3833, 2642, 3065, 2306, 3852, 2817, 2255]\nassert my_solution.minOperations(*[[58, 5, 26, 89, 15, 48, 13, 1, 29, 3, 46, 64, 70, 63, 47, 43, 74, 24, 19, 55, 15, 89, 91, 8, 51, 3], [1, 50, 48, 3, 89, 15, 34, 64, 61, 8, 47, 3, 47, 14, 89, 46, 3, 1, 5, 15, 58, 20, 89, 87, 81, 7, 51, 64, 40, 51, 63, 3, 52, 58, 46, 19, 3, 15, 20, 69, 63, 56, 47, 29, 49, 56, 12, 29, 40, 10, 15, 49, 49, 7, 55, 46, 54, 75, 47, 18, 57, 63, 63, 1, 89, 26, 47, 4, 48, 63, 69, 46, 1, 27, 48, 1, 56, 27, 32, 3, 51, 47, 1, 15, 79, 38, 21, 1, 46, 79, 1, 89]]) == [1023, 659, 647, 975, 1269, 773, 659, 801, 763, 881, 643, 975, 643, 787, 1269, 641, 975, 1023, 935, 773, 727, 725, 1269, 1229, 1109, 899, 665, 801, 647, 665, 787, 975, 673, 727, 641, 733, 975, 773, 725, 881, 787, 707, 643, 669, 653, 707, 817, 669, 647, 849, 773, 653, 653, 899, 697, 641, 689, 989, 643, 743, 717, 787, 787, 1023, 1269, 681, 643, 955, 647, 787, 881, 641, 1023, 677, 647, 1023, 707, 677, 663, 975, 665, 643, 1023, 773, 1069, 651, 717, 1023, 641, 1069, 1023, 1269]\nassert my_solution.minOperations(*[[54, 61, 55, 94, 47, 14, 87, 43, 44, 7, 40, 79, 67, 76, 77, 56, 33, 93, 100, 8, 63, 47, 92, 28, 13, 31, 40, 55, 8, 47, 43, 20, 45, 98, 81, 10, 47, 88, 79, 14, 12, 33, 24, 72, 21, 30, 74, 48, 55, 61, 51, 19, 67, 64, 72, 87, 49, 55, 66, 81, 85, 89, 43, 98, 44, 29, 99, 40, 98, 56, 31, 99, 6, 75, 3, 88, 7, 99, 89, 10, 40, 53, 94, 74, 21, 50, 76, 92], [88, 8, 93, 98, 55, 94, 81, 93, 7, 68, 44, 79, 30]]) == [3135, 4127, 3455, 3821, 2119, 3525, 2775, 3455, 4207, 2325, 2227, 2683, 2765]\nassert my_solution.minOperations(*[[59, 38, 85, 19, 76, 77, 41, 56, 98, 51, 99, 2, 83, 3, 23, 80, 51, 51, 55, 3, 95, 80, 24, 69, 94, 88, 3, 85, 100, 69, 45, 80, 95, 27, 17, 65, 91, 56, 11, 6, 94, 81, 85, 35, 13, 3, 43, 90, 39, 21, 24, 40, 68, 30, 64, 22, 77, 93, 43, 28, 16, 61, 93, 40, 69, 91, 36, 21, 17, 25, 83, 37, 67, 72, 96, 58, 52], [69, 69, 68, 91, 96, 18, 66, 3, 94, 36, 37, 95, 98, 91, 69, 17, 58, 12, 35, 43, 16, 91, 52, 3, 29, 70, 58, 3, 69, 3, 30, 44, 58, 54, 86, 85, 21, 99, 37, 21, 82, 62, 95, 91, 84, 96, 37, 1, 59, 79]]) == [2132, 2132, 2115, 2924, 3233, 2999, 2087, 3948, 3099, 2275, 2246, 3164, 3375, 2924, 2132, 3054, 2017, 3359, 2306, 2118, 3113, 2924, 2021, 3948, 2506, 2155, 2017, 3948, 2132, 3948, 2471, 2105, 2017, 2015, 2671, 2622, 2838, 3448, 2246, 2838, 2497, 2045, 3164, 2924, 2579, 3233, 2246, 4100, 2022, 2390]\nassert my_solution.minOperations(*[[91, 57, 64, 59, 38, 47, 4, 8, 51, 92, 42, 28, 21, 84, 30, 57, 67, 52, 74, 39, 59, 100, 72, 22, 12, 64, 79, 20, 100, 65, 100, 38, 15, 52, 62, 87, 32, 90, 40, 82], [39, 34, 53, 57, 45, 15, 64, 62, 32, 27, 71, 92, 89]]) == [1036, 1132, 908, 900, 968, 1638, 938, 922, 1172, 1290, 1042, 1532, 1442]\nassert my_solution.minOperations(*[[73, 52, 37, 8, 27, 36, 100, 46, 6, 81, 81, 83, 55, 98, 29, 2, 39, 62, 65, 82, 42, 10], [37, 15, 46, 67, 78, 44, 1, 9, 32, 65, 76, 82, 4, 42, 92, 2, 42, 81, 2, 55, 43, 2, 81, 80, 28, 8, 64, 9, 6, 46, 41, 61, 43, 9, 81, 7, 62, 10, 19, 47, 62, 54, 37, 82, 72, 37, 58, 54, 62, 81, 32, 82, 54, 81, 81, 32, 36, 62, 38, 67, 44, 10, 81, 29, 65, 47, 39, 62, 88, 45, 65, 52, 63, 10, 73, 6, 27, 36, 46, 12, 36, 37, 29, 55, 36, 43, 63, 37, 82]]) == [582, 852, 550, 618, 716, 554, 1092, 938, 630, 602, 696, 760, 1030, 558, 938, 1070, 558, 746, 1070, 556, 556, 1070, 746, 736, 672, 954, 596, 938, 990, 550, 562, 580, 556, 938, 746, 972, 584, 922, 796, 550, 584, 554, 582, 760, 658, 582, 568, 554, 584, 746, 630, 760, 554, 746, 746, 630, 590, 584, 576, 618, 554, 922, 746, 660, 602, 550, 570, 584, 866, 552, 602, 550, 590, 922, 666, 990, 684, 590, 550, 894, 590, 582, 660, 556, 590, 556, 590, 582, 760]\nassert my_solution.minOperations(*[[24, 87, 38, 16, 87, 42, 53, 17, 92, 91, 43, 44, 67, 54, 25, 65, 94, 65, 90, 79, 62, 5, 7, 68, 45, 39, 62, 98, 55, 72, 46, 52, 77, 27, 84, 67, 67, 30, 15, 33, 6, 35, 54, 6, 67, 80, 63, 67, 44, 22, 3, 57, 45, 52, 21, 34, 51], [43, 26, 15, 61, 76, 68, 7, 21, 45, 67, 5, 26, 67, 54, 15, 51, 17, 45, 17, 81, 84, 6, 44, 46, 42, 88, 67, 67, 51, 91, 94, 6, 92, 33, 59, 63, 55, 36, 55, 34, 21, 67, 79, 38, 75, 17, 67, 43, 38, 62, 33, 38, 81, 3, 25, 80, 11, 80, 63, 53, 3, 55, 54, 33, 43, 53, 67, 77, 6, 92, 23, 77, 25, 7, 77, 17, 52, 82, 29]]) == [1270, 1699, 2132, 1282, 1687, 1415, 2508, 1880, 1244, 1384, 2610, 1699, 1384, 1213, 2132, 1212, 2044, 1244, 2044, 1876, 1999, 2557, 1255, 1237, 1287, 2175, 1384, 1384, 1212, 2318, 2475, 2557, 2369, 1486, 1260, 1308, 1220, 1411, 1220, 1459, 1880, 1384, 1796, 1365, 1652, 2044, 1384, 1270, 1365, 1293, 1486, 1365, 1876, 2720, 1732, 1835, 2320, 1835, 1308, 1210, 2720, 1220, 1213, 1486, 1270, 1210, 1384, 1722, 2557, 2369, 1804, 1722, 1732, 2508, 1722, 2044, 1209, 1917, 1604]\nassert my_solution.minOperations(*[[8, 98, 26, 17, 45, 64, 68, 82, 58, 29, 58, 7, 40, 6, 16, 62, 46, 85, 64, 9, 72, 28, 34, 77, 5, 53, 9, 92, 39, 15, 95, 7, 41, 73, 27, 48, 44, 76, 6, 59, 59, 54, 55, 20, 86, 96, 69, 11, 86, 42, 83, 27, 94, 36, 64, 97, 24, 33, 50, 42, 52, 17, 5, 27, 76, 63, 30, 34, 62, 3, 36, 47], [64, 73, 9, 7, 73, 45, 64, 42, 86, 86, 94, 20, 54, 40, 1, 5, 8, 48, 27, 64, 77, 42, 29, 9, 76, 41, 27, 29, 77, 90, 76, 76, 58, 72, 16, 25, 42, 7, 62, 11, 48, 97, 65, 76, 54]]) == [1946, 2290, 2770, 2884, 2290, 1678, 1946, 1688, 2936, 2936, 3420, 2246, 1734, 1706, 3296, 3012, 2826, 1684, 1974, 1946, 2470, 1688, 1916, 2770, 2422, 1696, 1974, 1916, 2470, 3176, 2422, 2422, 1796, 2248, 2418, 2048, 1688, 2884, 1888, 2666, 1684, 3618, 1982, 2422, 1734]\nassert my_solution.minOperations(*[[5], [6, 5, 3, 1]]) == [1, 0, 2, 4]\nassert my_solution.minOperations(*[[769, 739, 249, 737, 380, 851, 222, 216, 38, 619, 475, 272, 547, 85, 160, 783, 737, 576, 138, 816, 273, 165, 667, 380, 7, 570, 597, 416, 36, 433, 995, 93, 126, 743, 861, 645, 270, 400, 267, 522, 505, 402, 378, 950, 261, 248, 861, 246, 192, 495, 879, 347, 96, 670, 321, 248, 199, 29, 829, 511, 834, 61, 617, 514, 263, 956, 330, 28, 511, 402, 109, 550, 896, 571, 798, 130, 441, 857, 921, 92, 734, 19, 468, 822, 249, 923, 66, 519, 278, 107, 610, 776, 378, 830, 678, 495, 717, 309, 468, 623, 603, 487, 164, 628, 35, 288, 549, 86, 657, 121, 449, 190, 306, 152, 880, 329, 384, 905, 446, 941, 322, 237, 334, 232, 216, 862, 397, 810, 714, 370, 589, 997, 686, 324, 614, 428, 620, 306, 256, 905, 835, 527, 970, 125, 595, 675, 682, 370, 240, 469, 820, 267, 176, 666, 147, 464, 442], [198, 794, 948, 830, 887, 623, 666, 912, 95, 225, 121, 155, 672, 531, 874, 241, 238, 531, 716, 247, 495, 663, 38, 619, 520, 122, 383, 272, 620, 975, 526, 260, 610, 216, 137, 866, 314, 380, 879, 834, 622, 465, 151, 458, 521, 278, 769, 442, 488, 330, 812, 581, 255, 264, 830, 111, 401, 754, 398, 86, 511, 246, 370, 125, 157, 199, 96, 274, 739, 669, 954, 107, 678, 810, 596, 689, 365, 323, 442, 880, 778, 143, 176, 272, 380, 370, 625, 380, 808, 905, 792, 105, 344, 66, 306, 830, 165, 805, 322, 270, 230, 240, 547, 434, 573, 807, 249, 165, 370, 814, 669, 7, 956, 122, 987, 270, 801, 703, 514, 837, 380, 302, 334, 603, 469, 798, 234, 893, 378, 93, 411, 862, 487, 964, 520, 98, 150, 662, 248, 36, 426, 240, 789, 861, 288, 143, 921, 903, 93, 286, 233, 775, 221, 147, 418, 862, 38, 667, 861, 667, 975, 856, 236, 476, 616, 728, 127, 176, 267, 671, 446, 12, 368, 861, 879, 442, 647, 905, 511, 905, 469, 330, 123, 917, 306, 482, 273, 61, 249, 371, 5, 272, 511, 216, 85, 736, 157, 36, 384, 96, 81, 348, 377, 549, 126, 468, 323, 861, 543, 322, 879, 380, 94, 549, 306, 549, 898, 252, 87, 338, 460, 402, 108, 438, 215, 306, 144, 575, 29, 380, 147, 85, 190, 238, 23, 587, 451, 308, 947, 686, 370, 956, 267, 241, 881, 861, 249, 247, 804, 614, 598, 383, 857, 717, 330, 201, 208, 511, 323, 905, 680, 949, 312, 9, 35, 416, 953, 864, 826, 574, 646, 696, 921, 511, 831, 861, 135, 973, 618, 522, 380, 165, 21, 370, 586, 195, 370, 494, 331, 623, 380, 861, 697, 822, 378, 248, 825, 340, 160, 401, 814, 126, 738, 271, 511, 905, 133, 36, 861, 83, 199, 468, 379, 678, 156, 117, 226, 329, 950, 682, 947, 862, 378, 797, 861, 739, 723, 609, 330, 323, 714, 1, 273, 221, 835, 820, 820, 609, 649, 442, 393, 740, 231, 123, 897, 628, 176, 627, 686, 920, 842, 249, 627, 290, 380, 95, 827, 511, 511, 861, 553, 147, 471, 4, 675, 306, 477, 952, 36, 737, 306, 234, 636, 88, 222, 158, 694, 267, 270, 726, 35, 126, 683, 627, 833, 93, 862, 378, 824, 513, 941, 805, 616, 115, 861, 519, 619, 436, 222, 461, 527, 58, 164, 468, 641, 337, 249, 615, 682, 227, 682, 495, 133, 861, 609, 834, 661, 829, 522, 756, 511, 172, 678, 381, 862, 154, 675, 137, 164, 622, 861, 194, 393, 576, 338, 812, 380, 509, 742, 933, 378, 571, 21, 851, 673, 173, 304, 308, 620, 742, 742, 494, 820, 151, 683, 140, 861, 300, 816, 571, 382, 797, 513, 246, 244, 85, 380, 152, 378, 375, 442, 821, 921, 324, 246, 38, 340, 723, 325, 861, 513, 834, 857, 29, 585, 606, 861, 678, 470, 923, 946, 894, 509, 29, 993, 216, 617, 272, 742, 812, 90, 514, 328, 739, 412, 578, 197, 822, 719, 255, 686, 984, 370, 313, 126, 156, 516, 666, 61, 835, 358, 276, 905, 736, 620, 787, 308, 832, 65, 327, 62, 813, 386, 620, 7, 861, 343, 6, 325, 35, 18, 465, 547, 321, 519, 619, 82, 858, 323, 95, 156, 516, 671, 736, 85, 270, 677, 248, 381, 89, 151, 107, 109, 857, 721, 521, 879, 522, 36, 749, 379, 260, 499, 406, 523, 960, 716, 381, 572, 617, 623, 322, 28, 270, 611, 263, 330, 575, 678, 126, 905, 65, 307, 452, 287, 248, 276, 664, 860, 307, 953, 970, 474, 92, 77, 656, 67, 204, 249, 378, 905, 248, 632, 505, 249, 31, 90, 717, 497, 330, 717, 862, 173, 852, 130, 216, 380, 834, 379, 880, 121, 380, 420, 823, 446, 855, 267, 248, 615, 954, 265, 511, 602, 107, 780, 2, 86, 164, 94, 737, 475, 123, 128, 667, 321, 828, 755, 21, 249, 613, 620, 549, 872, 378, 309, 246, 378, 122, 734, 626, 814, 106, 685, 730, 265, 670, 657, 269, 468, 380, 862, 306, 402, 854, 622, 861, 119, 109, 152, 130, 512, 623, 822, 837, 273, 483, 874, 389, 922, 736, 92, 905, 232, 115, 494, 108, 278, 821, 24, 322, 723, 951, 333, 666, 63, 859, 321, 783, 388, 468, 608, 674, 402, 93, 28, 735, 248, 107, 248, 684, 262, 672, 572, 296, 278, 630, 306, 737, 820, 192, 334, 380, 442, 193, 628, 446, 862, 944, 449, 461, 522, 739, 28, 324, 552, 254, 722, 611, 165, 670, 202, 102, 438, 270, 184, 163, 233, 443, 248, 33, 617, 93, 222, 511, 832, 289, 267, 563, 292, 36, 597, 252, 956, 141, 261, 113, 905, 959, 33, 879, 822, 483, 273, 505, 445, 516, 329, 5, 818, 275, 787, 547, 322, 647, 619, 104, 574, 330, 246, 935, 93, 810, 271, 830, 572, 267, 273, 619, 667, 487, 391, 549, 267, 596, 468, 667, 528, 861, 714, 513, 984, 615, 923, 384, 171, 896, 858, 525, 503, 617, 64, 468, 214, 619, 515, 447, 875, 430, 840, 716, 400, 337, 862, 669, 673, 309, 419, 126, 826, 243, 442, 240, 861, 822, 621, 398, 682, 619, 288, 946, 111, 511, 779, 677, 678, 507, 317, 373, 468, 954, 330, 489, 879, 868, 468, 63, 510, 713, 623, 775, 547, 721, 834, 830]]) == [48233, 55609, 75311, 59487, 66682, 41282, 44127, 70117, 59986, 45654, 56682, 52724, 44567, 37394, 64949, 44226, 44485, 37394, 48157, 43718, 36566, 43920, 67963, 41040, 37071, 56559, 37064, 41927, 41099, 79378, 37241, 42739, 40549, 46485, 54774, 63901, 39613, 37133, 65604, 59955, 41221, 36260, 53170, 36251, 37098, 41571, 53076, 36257, 36475, 38877, 57495, 39190, 43106, 42455, 59487, 57932, 36694, 51621, 36749, 61191, 36850, 43801, 37435, 56190, 52502, 48134, 59855, 41807, 50174, 44344, 76201, 58436, 45023, 57281, 39851, 45912, 37610, 39178, 36257, 65737, 53971, 54082, 50471, 41927, 37133, 37435, 41408, 37133, 57071, 69130, 55403, 58694, 38351, 63969, 40011, 59487, 51626, 56756, 39223, 42053, 45199, 44311, 37890, 36311, 38852, 56966, 43556, 51626, 37435, 57709, 44344, 72682, 76499, 56559, 81214, 42053, 56336, 47074, 36919, 60316, 37133, 40231, 38721, 40192, 36276, 56021, 44839, 67492, 37187, 60248, 36560, 63377, 36462, 77707, 37071, 59597, 53283, 43851, 43635, 68253, 36385, 44311, 55094, 63248, 41001, 54082, 71386, 68856, 60248, 41115, 44928, 53670, 46020, 53622, 36473, 63377, 67963, 44198, 63248, 44198, 79378, 62625, 44661, 36341, 40871, 49199, 55950, 50471, 42248, 44492, 36245, 71907, 37505, 63248, 65604, 36257, 42836, 69130, 36850, 69130, 36276, 38877, 56436, 70822, 40011, 36407, 41866, 64674, 43556, 37404, 72996, 41927, 36850, 46485, 61328, 49899, 52502, 68253, 37041, 59855, 61884, 38205, 37218, 37956, 56069, 36269, 39178, 63248, 37766, 39223, 65604, 37133, 60117, 37956, 40011, 37956, 68171, 43331, 61056, 38573, 36253, 36677, 58309, 36283, 46582, 40011, 53967, 38934, 69294, 37133, 53622, 61328, 49029, 44485, 70210, 39448, 36244, 39909, 75164, 45663, 37435, 76499, 42248, 44226, 65872, 63248, 43556, 43718, 56651, 40761, 39947, 37064, 62748, 48242, 38877, 47940, 47261, 36850, 39178, 69130, 45181, 75458, 39711, 72372, 68400, 36495, 76052, 63639, 59033, 38893, 42769, 46493, 71386, 36850, 59604, 63248, 55008, 79072, 40983, 37125, 37133, 51626, 70516, 37435, 39405, 48530, 37435, 36553, 38838, 41282, 37133, 63248, 46576, 58581, 37187, 43635, 58920, 38499, 52169, 36694, 57709, 56069, 50081, 41990, 36850, 69130, 55242, 68253, 63248, 61606, 48134, 36269, 37160, 45023, 52613, 57182, 45563, 38918, 75605, 45339, 75164, 63377, 37187, 55918, 63248, 50174, 48764, 40498, 38877, 39178, 47987, 73624, 41866, 46020, 60074, 58359, 58359, 40498, 42970, 36257, 36852, 50269, 45108, 56436, 68034, 41597, 50471, 41534, 45663, 71245, 60921, 43556, 41534, 40891, 37133, 59986, 59146, 36850, 36850, 63248, 38102, 53622, 36294, 73153, 44792, 40011, 36352, 75903, 68253, 49988, 40011, 44839, 42117, 60921, 45927, 52391, 46327, 42248, 42053, 49025, 68400, 56069, 45420, 41534, 59838, 60248, 63377, 37187, 58807, 36896, 74282, 56756, 40871, 57432, 63248, 37044, 41040, 36297, 45927, 36254, 37270, 65103, 51733, 36269, 42442, 38610, 43556, 40816, 45339, 45472, 45339, 36566, 55242, 63248, 40498, 59955, 43782, 59372, 37125, 51815, 36850, 50891, 45023, 37110, 63377, 52835, 44792, 54774, 51733, 41221, 63248, 48629, 36852, 38975, 38573, 57495, 37133, 36812, 50459, 73122, 37187, 38770, 70516, 62010, 44642, 50786, 40121, 39909, 41099, 50459, 50459, 36553, 58359, 53170, 45420, 54427, 63248, 40341, 57923, 38770, 37087, 55918, 36896, 43801, 43971, 61328, 37133, 53057, 37187, 37280, 36257, 58470, 71386, 39133, 43801, 67963, 38499, 48764, 39090, 63248, 36896, 59955, 62748, 69294, 39362, 40345, 63248, 45023, 36285, 71672, 75017, 67627, 36812, 69294, 82132, 46485, 40926, 41927, 50459, 57495, 60651, 36919, 38961, 50174, 36547, 39061, 48332, 58581, 48416, 43106, 45663, 80755, 37435, 39662, 56069, 52613, 36969, 44127, 64674, 60074, 37855, 41689, 69130, 49899, 41099, 54888, 39909, 59721, 64110, 39004, 64533, 57602, 36999, 41099, 72682, 63248, 38388, 72839, 39090, 68400, 70977, 36260, 37890, 39270, 37044, 41040, 61745, 62873, 39178, 59986, 52613, 36969, 44492, 49899, 61328, 42053, 44946, 43635, 37110, 60786, 53170, 58436, 58182, 62748, 48590, 37098, 65604, 37125, 68253, 51136, 37160, 42739, 36634, 36625, 37154, 77103, 48157, 37110, 38811, 40926, 41282, 39223, 69445, 42053, 40602, 42524, 38877, 38934, 45023, 56069, 69130, 64110, 39960, 36245, 41058, 43635, 41689, 43989, 63123, 39960, 76052, 78613, 36321, 60381, 62440, 43439, 63830, 47649, 43556, 37187, 69130, 43635, 41857, 36736, 43556, 68996, 60651, 48242, 36600, 38877, 48242, 63377, 50786, 62133, 55593, 46485, 37133, 59955, 37160, 65737, 56682, 37133, 36451, 58694, 36245, 62502, 42248, 43635, 40816, 76201, 42386, 36850, 40143, 58436, 54173, 73467, 61191, 51733, 60117, 49988, 36330, 56436, 55831, 44198, 39270, 59259, 51718, 70516, 43556, 40708, 41099, 37956, 64687, 37187, 39858, 43801, 37187, 56559, 49721, 41471, 57709, 58565, 45582, 49373, 42386, 44417, 43506, 42118, 36269, 37133, 63377, 40011, 36677, 62379, 41221, 63248, 56932, 58182, 53057, 55593, 36873, 41282, 58581, 60316, 41866, 36418, 64949, 36936, 71529, 49899, 60381, 69130, 45017, 57432, 36553, 58309, 41571, 58470, 70057, 39223, 48764, 75754, 38760, 44127, 64392, 62998, 39270, 54476, 36957, 36269, 40447, 44717, 36677, 60248, 69445, 49810, 43635, 58436, 43635, 45501, 42595, 44567, 38811, 40561, 41571, 41727, 40011, 49988, 58359, 48827, 38721, 37133, 36257, 48728, 41597, 36245, 63377, 74723, 36242, 36254, 37125, 50174, 69445, 39133, 38065, 43181, 48677, 40602, 51626, 44417, 47843, 59081, 36283, 42053, 49647, 51842, 44928, 36254, 43635, 68698, 40926, 60248, 45927, 36850, 59721, 40946, 42248, 38472, 40781, 68253, 39898, 43331, 76499, 54312, 42666, 57682, 69130, 76952, 68698, 65604, 58581, 36418, 41866, 36736, 36248, 36969, 38918, 72996, 58141, 41748, 54888, 37890, 39223, 42836, 41040, 58823, 38893, 38877, 43801, 73412, 60248, 57281, 41990, 59487, 38811, 42248, 41866, 41040, 44198, 36462, 36894, 37956, 42248, 39851, 36269, 44198, 37301, 63248, 47987, 36896, 80755, 40816, 71672, 37041, 50996, 67897, 62873, 37212, 36702, 40926, 64251, 36269, 46679, 41040, 36944, 36244, 65080, 36345, 60679, 48157, 36711, 38610, 63377, 44344, 44642, 39858, 36462, 56069, 59033, 44056, 36257, 44311, 63248, 58581, 41160, 36749, 45339, 41040, 41001, 75017, 57932, 36850, 54072, 44946, 45023, 36774, 39466, 37342, 36269, 76201, 38877, 36488, 65604, 64163, 36269, 64392, 36831, 47904, 41282, 53670, 37890, 48590, 59955, 59487]\nassert my_solution.minOperations(*[[544, 178, 526, 934, 40, 8, 560, 787, 695, 22, 542, 550, 11, 506, 858, 257, 370, 313, 405, 379, 580, 581, 736, 449, 835, 174, 442, 226, 256, 812, 685, 671, 287, 277, 639, 173, 576, 912, 150, 135, 425, 961, 520, 276, 21, 5, 932, 583, 200, 957, 213, 409, 572, 861, 975, 867, 504, 631, 875, 625, 829, 409, 719, 257, 567, 258, 592, 828, 833, 513, 551, 156, 481, 782, 856, 613, 4, 534, 280, 967, 95, 958, 234, 240, 71, 302, 401, 193, 435, 85, 258, 414, 629, 122, 518, 273, 514, 91, 981, 260, 213, 681, 746, 256, 689, 49, 370, 692, 447, 566, 196, 26, 621, 809, 740, 523, 312, 16, 185, 299, 232, 72, 831, 342, 74, 478, 736, 459, 978, 510, 240, 127, 568, 56, 284, 715, 674, 511, 670, 873, 338, 633, 786, 856, 541, 108, 390, 515, 21, 968, 458, 779, 767, 140, 517, 2, 743, 481, 123, 592, 733, 124, 139, 811, 174, 615, 63, 49, 670, 608, 492, 119, 687, 120, 380, 978, 723, 934, 404, 544, 980, 901, 195, 280, 542, 568, 332, 500, 422, 780, 77, 252, 625, 362, 686, 877, 574, 442, 842, 846, 665, 366, 310, 733, 169, 590, 910, 769, 15, 499, 520, 350, 25, 857, 779, 641, 216, 629, 632, 181, 738, 208, 101, 149, 827, 374, 517, 411, 127, 770, 603, 62, 872, 83, 714, 414, 610, 962, 888, 469, 411, 140, 593, 394, 807, 748, 28, 15, 899, 483, 168, 500, 363, 227, 133, 329, 114, 97, 792, 694, 917, 245, 895, 822, 186, 341, 169, 587, 288, 43, 618, 645, 987, 859, 251, 591, 193, 428, 150, 531, 732, 21, 260, 691, 105, 559, 97, 141, 889, 692, 128, 972, 195, 172, 57, 836, 880, 223, 918, 209, 334, 224, 447, 17, 408, 452, 81, 690, 433, 1000, 241, 114, 272, 777, 462, 716, 389, 371, 572, 609, 256, 8, 354, 329, 264, 354, 952, 751, 392, 43, 950, 846, 916, 493, 777, 264, 953, 355, 471, 993, 12, 27, 267, 770, 821, 44, 792, 777, 829, 839, 42, 267, 72, 963, 193, 939, 203, 834, 756, 64, 520, 609, 337, 402, 815, 73, 337, 203, 131, 671, 684, 493, 659, 526, 211, 537, 385, 28, 456, 834, 453, 475, 415, 454, 559, 843, 91, 114, 485, 560, 341, 249, 483, 702, 673, 135, 336, 231, 479, 136, 106, 659, 155, 884, 839, 376, 226, 636, 760, 479, 911, 647, 792, 692, 810, 8, 169, 106, 511, 353, 253, 634, 9, 90, 825, 451, 614, 335, 777, 839, 595, 836, 638, 380, 403, 412, 859, 464, 628, 985, 287, 758, 746, 232, 738, 715, 670, 840, 316, 917, 646, 415, 623, 958, 570, 78, 729, 129, 409, 205, 871, 189, 758, 149, 930, 936, 733, 535, 993, 955, 717, 843, 30, 756, 390, 395, 868, 603, 258, 280, 355, 233, 601, 771, 38, 749, 966, 890, 157, 627, 974, 685, 234, 524, 865, 156, 402, 48, 989, 234, 925, 268, 149, 635, 354, 553, 61, 610, 988, 741, 401, 445, 751, 682, 951, 776, 477, 732, 963, 641, 983, 421, 416, 934, 588, 978, 332, 399, 85, 575, 139, 974, 942, 159, 251, 652, 973, 457, 310, 511, 13, 419, 194, 348, 24, 770, 860, 453, 40, 80, 929, 253, 393, 224, 265, 864, 862, 184, 807, 770, 251, 508, 560, 105, 883, 114, 840, 199, 611, 685, 408, 383, 4, 845, 215, 464, 614, 14, 306, 114, 876, 562, 407, 765, 883, 600, 903, 269, 733, 99, 499, 662, 678, 153, 625, 996, 707, 21, 148, 873, 765, 438, 558, 393, 394, 213, 64, 471, 405, 882, 710, 989, 529, 948, 471, 512, 733, 364, 889, 802, 151, 873, 564, 31, 190, 132, 781, 818, 173, 573, 490, 457, 809, 749, 604, 302, 775, 765, 809, 882, 166, 791, 494, 395, 390, 519, 551, 465, 110, 178, 245, 506, 354, 485, 135, 152, 477, 728, 2, 350, 980, 887, 733, 821, 147, 197, 601, 503, 759, 419, 407, 869, 947, 664, 992, 714, 425, 480, 537, 169, 431, 737, 653, 799, 145, 515, 390, 854, 950, 674, 823, 573, 904, 434, 339, 371, 741, 581, 346, 373, 985, 806, 335, 568, 16, 850, 936, 722, 527, 89, 261, 462, 516, 500, 321, 355, 94, 572, 248, 179, 525, 901, 540, 521, 603, 816, 547, 572, 358, 443, 873, 415, 388, 67, 745, 171, 876, 425, 149, 352, 228, 873, 467, 627, 879, 152, 152, 740, 867, 126, 801, 170, 185, 453, 235, 654, 736, 299, 747, 389], [188, 551, 629, 252, 408, 685, 606, 633, 780, 17, 659, 207, 124, 228, 641, 446, 740, 901, 520, 140, 234, 515, 686, 73, 258, 748, 471, 21, 587, 572, 588, 43, 654, 733, 541, 434, 310, 277, 11, 952, 415, 490, 412, 287, 475, 953, 941, 462, 686, 935, 573, 491, 515, 174, 70, 889, 656, 447, 694, 821, 105, 366, 349, 874, 980, 235, 421, 390, 529, 453, 674, 135, 374, 517, 28, 44, 980, 843, 575, 168, 411, 952, 67, 416, 739, 592, 985, 834, 174, 475, 749, 21, 514, 371, 592, 335, 168, 258, 411, 507, 934, 350, 16, 865, 262, 553, 106, 529, 941, 114, 156, 226, 14, 821, 795, 354, 505, 419, 21, 148, 481, 411, 465, 147, 404, 258, 267, 614, 355, 79, 535, 364, 147, 503, 873, 980, 224, 21, 135, 152, 692, 2, 301, 702, 936, 521, 777, 207, 674, 779, 841, 777, 962, 568, 918, 462, 133, 355, 402, 551, 895, 401, 958, 637, 740, 551, 521, 674, 664, 973, 258, 682, 200, 26, 500, 168, 816, 958, 718, 899, 746, 836, 411, 733, 79, 740, 816, 74, 716, 85, 736, 458, 572, 57, 471, 827, 884, 257, 987, 936, 524, 756, 689, 433, 499, 871, 373, 335, 801, 609, 747, 586, 56, 151, 514, 506, 890, 506, 963, 106, 955, 953, 390, 114, 879, 85, 515, 213, 21, 747, 733, 273, 807, 213, 153, 646, 14, 213, 178, 765, 810, 253, 568, 965, 155, 506, 685, 89, 139, 782, 843, 203, 122, 765, 717, 953, 105, 208, 404, 149, 833, 363, 80, 251, 467, 642, 105, 810, 714, 510, 736, 447, 9, 156, 402, 807, 58, 45, 88, 581, 936, 695, 568, 809, 729, 520, 770, 144, 867, 606, 978, 220, 370, 468, 397, 711, 114, 241, 784, 728, 912, 184, 73, 733, 918, 769, 354, 28, 434, 258, 401, 14, 702, 306, 354, 81, 890, 197, 195, 49, 72, 573, 900, 925, 465, 560, 415, 633, 208, 49, 775, 91, 240, 798, 477, 882, 572, 621, 978, 193, 889, 687, 511, 56, 211, 105, 171, 350, 241, 335, 567, 519, 341, 645, 917, 524, 97, 517, 480, 888, 97, 329, 15, 759, 131, 361, 613, 132, 603, 250, 957, 347, 611, 407, 54, 393, 701, 240, 953, 4, 170, 258, 733, 352, 526, 515, 665, 91, 873, 334, 518, 526, 692, 684, 811, 457, 300, 392, 251, 520, 651, 13, 114, 731, 440, 150, 673, 845, 862, 714, 462, 671, 128, 587, 273, 749, 483, 198, 228, 408, 759, 90, 156, 717, 361, 390, 388, 49, 156, 740, 654, 883, 733, 159, 409, 779, 158, 816, 354, 415, 394, 276, 647, 310, 120, 690, 917, 389, 64, 789, 537, 684, 485, 140, 865, 760, 169, 685, 752, 12, 654, 90, 8, 613, 433, 225, 614, 716, 236, 694, 875, 296, 62, 720, 568, 596, 947, 950, 174, 729, 749, 71, 13, 287, 736, 757, 927, 98, 129, 615, 114, 827, 558, 645, 271, 233, 173, 279, 482, 79, 777, 395, 415, 170, 265, 733, 453, 462, 734, 59, 746, 433, 156, 139, 685, 190, 667, 196, 105, 963, 590, 156, 547, 572, 786, 685, 264, 637, 771, 958, 159, 471, 846, 468, 258, 916, 97, 106, 485, 641, 592, 884, 917, 982, 166, 544, 749, 452, 846, 523, 869, 827, 127, 64, 127, 493, 392, 743, 131, 710, 152, 442, 287, 926, 253, 520, 765, 172, 603, 232, 733, 605, 464, 415, 354, 410, 796, 979, 224, 575, 342, 190, 976, 862, 288, 576, 654, 81, 650, 21, 257, 321, 560, 533, 449, 936, 516, 390, 520, 149, 537, 544, 846, 260, 40, 402]]) == [260783, 187893, 200175, 233673, 191639, 214601, 195551, 201077, 249071, 364757, 207469, 252135, 294505, 243141, 202963, 187405, 232677, 314077, 185651, 285345, 240685, 185455, 214897, 326237, 231465, 235739, 185789, 361861, 192369, 190185, 192523, 346425, 206189, 230119, 187019, 188543, 214703, 225009, 369161, 347765, 190679, 185283, 191077, 221797, 185629, 348455, 340281, 186241, 214897, 336237, 190319, 185271, 185455, 267519, 328215, 306503, 206701, 187317, 217331, 268419, 305915, 199715, 203753, 297323, 367619, 240287, 189953, 194683, 186163, 186827, 211469, 288153, 197953, 185525, 356881, 345739, 367619, 279817, 190597, 270517, 191213, 347765, 330201, 190555, 232305, 193153, 371301, 275037, 267519, 185629, 236131, 361861, 185425, 198599, 193153, 207447, 270517, 231465, 191213, 185283, 335567, 203497, 365483, 292069, 230059, 188085, 305301, 186163, 340281, 300441, 276689, 243971, 366947, 268419, 255935, 202495, 185259, 190189, 361861, 280935, 185433, 191213, 186077, 281483, 192255, 231465, 228335, 197063, 202255, 322329, 186569, 200167, 281483, 185241, 296725, 367619, 244811, 361861, 288153, 278785, 216707, 375903, 217435, 219857, 336907, 185701, 247735, 252135, 211469, 248623, 278739, 247735, 354725, 189685, 325031, 186241, 289293, 202255, 192577, 187893, 310281, 192743, 351923, 202009, 232677, 187893, 185701, 211469, 208773, 362547, 231465, 213735, 255251, 358295, 185223, 270517, 265943, 351923, 225017, 312809, 234961, 276083, 191213, 230119, 322329, 232677, 265943, 325583, 224351, 318463, 231199, 186483, 190185, 336899, 185789, 271441, 303397, 231825, 372785, 336907, 185859, 238923, 215795, 188645, 185223, 295551, 198167, 207447, 258735, 196099, 235349, 192217, 337575, 279317, 185425, 185269, 307131, 185269, 355429, 305301, 349839, 348455, 194683, 300441, 300337, 318463, 185455, 249505, 361861, 235349, 230119, 226327, 261567, 249505, 278259, 204185, 366947, 249505, 265567, 242609, 263007, 233299, 189685, 356845, 277211, 185269, 214601, 315911, 285903, 249973, 279817, 253907, 295683, 242609, 224683, 348455, 305915, 251693, 192255, 280389, 274519, 200395, 321681, 234049, 185977, 203207, 305915, 263007, 223695, 185329, 231199, 187317, 370645, 276689, 192577, 261567, 336225, 345055, 316549, 191461, 336907, 217645, 189685, 262523, 228739, 185651, 244707, 283135, 293221, 195551, 366159, 246513, 198819, 185929, 193427, 222729, 300441, 237915, 250881, 228397, 321135, 262679, 326237, 230119, 325031, 244285, 202495, 356881, 188543, 231465, 192743, 366947, 219857, 215911, 202495, 321035, 307131, 256605, 257515, 342321, 326893, 190319, 313443, 329623, 186077, 188779, 190679, 201077, 251693, 342321, 246865, 314641, 238307, 257333, 185553, 302165, 190185, 198481, 366159, 258437, 306503, 215195, 185347, 337575, 250377, 305915, 269005, 203497, 237915, 207447, 189567, 185607, 205827, 203939, 324377, 185859, 310871, 185525, 185459, 305879, 310871, 209149, 366213, 240139, 290439, 200857, 196867, 289865, 195007, 234431, 351227, 204267, 196479, 191789, 338931, 194127, 219541, 238307, 348455, 374391, 269505, 231465, 230119, 202993, 185973, 185455, 209037, 314641, 296725, 207727, 185565, 185973, 216707, 214311, 263493, 186547, 217743, 194311, 234049, 185651, 205433, 367683, 300441, 229427, 187957, 279851, 211191, 280905, 290351, 223695, 186241, 210639, 292169, 192369, 226327, 236131, 185389, 256153, 243141, 191639, 240139, 315275, 276689, 224683, 200857, 194683, 195075, 342321, 276689, 232677, 206189, 302779, 230119, 275139, 191493, 248623, 275655, 265943, 202495, 190679, 193947, 225337, 204433, 214703, 296867, 216097, 324377, 194877, 332193, 253161, 186713, 214311, 185353, 285345, 292069, 240549, 270007, 214601, 237323, 368421, 206189, 315275, 371389, 196867, 188645, 244391, 197063, 224351, 239891, 217331, 297921, 218987, 333531, 225687, 189685, 193817, 344347, 346391, 267519, 228739, 236131, 327553, 367683, 221797, 231199, 239327, 330939, 310249, 291591, 197263, 300441, 271441, 188575, 203939, 226993, 241089, 268011, 224357, 185411, 322329, 247735, 193771, 190679, 269505, 229019, 230119, 186827, 186241, 230479, 335551, 234961, 188645, 276689, 285903, 214601, 259841, 209569, 257059, 305915, 355429, 192835, 276689, 187531, 190185, 251789, 214601, 229363, 202009, 245137, 351923, 275139, 185789, 281451, 185929, 231465, 323727, 310871, 305301, 185353, 202963, 193153, 303397, 324377, 369089, 271541, 187267, 236131, 186905, 281451, 185805, 294383, 271441, 292749, 332193, 292749, 185249, 194311, 233813, 290439, 222407, 278785, 187765, 221797, 330281, 233299, 185651, 242609, 268507, 195007, 241495, 230119, 195369, 186129, 190679, 202495, 191353, 256401, 366889, 244811, 190597, 205565, 259841, 364711, 290351, 221483, 190739, 206189, 321035, 205183, 361861, 231825, 211469, 188779, 186431, 187149, 336907, 185489, 194683, 185651, 280389, 186713, 187267, 281451, 230757, 348499, 192577]\nassert my_solution.minOperations(*[[718, 452, 864, 128, 794, 314, 518, 420, 799, 238, 682, 27, 335, 626, 849, 483, 223, 476, 535, 825, 178, 828, 830, 835, 341, 235, 871, 377, 950, 16, 187, 994, 860, 89, 307, 756, 194, 779, 877, 214, 51, 840, 389, 844, 271, 968, 948, 487, 734, 538, 826, 340, 919, 706, 259, 355, 398, 159, 395, 520, 246, 722, 994, 175, 419, 512, 925, 947, 884, 596, 531, 487, 476, 283, 430, 488, 342, 322, 80, 101, 767, 543, 503, 422, 460, 41, 885, 798, 969, 679, 26, 238, 296, 828, 408, 48, 341, 957, 654, 980, 982, 507, 966, 656, 867, 839, 16, 633, 109, 673, 79, 530, 769, 11, 811, 783, 166, 884, 720, 926, 142, 534, 570, 250, 534, 567, 141, 131, 200, 341, 854, 921, 721, 606, 67, 238, 598, 716, 743, 307, 806, 121, 537, 755, 331, 210, 377, 571, 916, 521, 904, 316, 60, 875, 514, 307, 824, 944, 220, 97, 919, 447, 544, 365, 118, 891, 351, 913, 831, 662, 692, 407, 222, 52, 17, 256, 32, 142, 228, 228, 204, 321, 628, 755, 906, 682, 120, 903, 460, 928, 728, 520, 858, 215, 689, 976, 819, 995, 702, 6, 364, 822, 655, 709, 1000, 872, 109, 51, 539, 993, 316, 360, 618, 908, 446, 680, 192, 876, 437, 9, 790, 378, 451, 966, 989, 523, 59, 232, 864, 323, 230, 626, 235, 887, 759, 376, 10, 350, 588, 235, 772, 659, 747, 352, 827, 804, 145, 279, 579, 473, 296, 806, 489, 89, 925, 653, 898, 734, 767, 861, 281, 611, 268, 33, 451, 810, 606, 508, 243, 24, 680, 234, 938, 478, 783, 686, 296, 984, 576, 654, 632, 645, 98, 346, 262, 937, 899, 873, 589, 440, 604, 397, 300, 67, 206, 150, 508, 271, 745, 924, 862, 922, 665, 737, 907, 372, 599, 389, 31, 566, 230, 445, 895, 357, 610, 88, 654, 78, 295, 157, 671, 631, 693, 842, 623, 689, 449, 122, 770, 176, 241, 1000, 111, 277, 234, 248, 870, 896, 494, 988, 412, 68, 183, 531, 103, 755, 752, 730, 364, 927, 934, 265, 485, 207, 536, 395, 321, 371, 463, 729, 206, 903, 775, 394, 225, 740], [984, 628, 88, 103, 123, 922, 234, 54, 1000, 238, 876, 233, 683, 153, 543, 785, 861, 770, 271, 661, 268, 674, 234, 588, 67, 414, 628, 340, 914, 332, 497, 610, 534, 809, 877, 420, 531, 91, 800, 680, 476, 571, 424, 460, 829, 271, 142, 682, 356, 341, 38, 452, 937, 924, 244, 729, 473, 598, 321, 896, 956, 928, 949, 421, 538, 729, 819, 296, 308, 1000, 682, 456, 307, 243, 110, 806, 477, 262, 48, 791, 230, 571, 781, 873, 88, 871, 632, 203, 859, 79, 654, 877, 734, 464, 722, 408, 631, 672, 335, 823, 299, 991, 738, 223, 460, 447, 476, 831, 922, 109, 529, 806, 776, 512, 869, 321, 926, 250, 509, 594, 695, 995, 477, 206, 394, 929, 193, 968, 846, 386, 908, 78, 712, 59, 714, 602, 262, 985, 225, 215, 667, 922, 314, 265, 893, 903, 175, 523, 827, 321, 234, 925, 371, 49, 839, 993, 770, 896, 670, 196, 587, 21, 390, 142, 446, 452, 214, 408, 487, 597, 536, 910, 119, 243, 279, 884, 395, 692, 296, 487, 296, 641, 234, 26, 439, 296, 626, 611, 79, 241, 482, 680, 867, 657, 718, 631, 131, 537, 586, 357, 154, 770, 321, 366, 640, 51, 364, 719, 806, 734, 938, 234, 512, 532, 460, 708, 228, 990, 220, 825, 78, 7, 389, 907, 745, 359, 234, 2, 142, 531, 937, 368, 828, 539, 656, 205, 207, 296, 349, 822, 925, 300, 377, 689, 488, 418, 570, 78, 576, 279, 11, 839, 721, 595, 222, 606, 230, 534, 925, 780, 540, 885, 122, 629, 247, 296, 534, 734, 121, 862, 987, 341, 757, 598, 412, 611, 307, 938, 783, 32, 568, 659, 861, 553, 537, 514, 176, 895, 119, 568, 452, 516, 258, 601, 364, 307, 867, 525, 821, 24, 530, 142, 831, 875, 707, 857, 895, 24, 680, 618, 248, 737, 341, 120, 489, 307, 136, 802, 627, 685, 234, 100, 414, 568, 855, 605, 271, 406, 371, 804, 507, 925, 912, 142, 587, 925, 235, 629, 314, 225, 307, 850, 54, 283, 885, 721, 745, 606, 263, 473, 847, 341, 825, 296, 860, 705, 945, 341, 10, 280, 938, 228, 309, 462, 891, 356, 350, 827, 446, 861, 89, 919, 981, 994, 230, 532, 247, 350, 983, 508, 148, 903, 268, 503, 927, 904, 173, 865, 109, 350, 582, 68, 606, 596, 419, 937, 828, 534, 904, 487, 78, 871, 588, 521, 250, 451, 606, 307, 632, 452, 881, 519, 925, 480, 859, 862, 536, 824, 932, 895, 680, 171, 350, 675, 88, 830, 79, 16, 210, 235, 241, 411, 471, 26, 772, 51, 885, 906, 796, 729, 913, 918, 570, 297, 831, 222, 568, 903, 724, 206, 912, 740, 372, 567, 966, 355, 10, 771, 654, 885, 238, 998, 465, 686, 17, 23, 536, 872, 731, 365, 802, 842, 246, 740, 218, 523, 720, 238, 828, 518, 556, 159, 49, 654, 452, 923, 51, 716, 228, 230, 89, 533, 846, 233, 176, 67, 261, 654, 3, 413, 361, 570, 865, 81, 764, 988, 819, 876, 815, 232, 68, 235, 292, 215, 461, 947, 235, 875, 566, 92, 184, 101, 728, 799, 316, 994, 645, 48, 488, 485, 764, 967, 537, 985, 832, 923, 530, 332, 919, 207, 530, 99, 980, 156, 25, 444, 316, 150, 922, 801, 244, 350, 356, 192, 352, 830, 903, 102, 842, 24, 997, 287, 944, 821, 238, 865, 966, 645, 389, 10, 277, 806, 389, 346, 395, 858, 187, 408, 632, 395, 342, 827, 352, 537, 983, 159, 235, 459, 951, 377, 101, 238, 487, 207, 229, 682, 892, 529, 493, 755, 903, 925, 246, 875, 377, 333, 542, 520, 67, 289, 121, 266, 521, 419, 345, 638, 482, 905, 567, 754, 149, 16, 507, 882, 483, 626, 68, 101, 766, 655, 133, 563, 26, 599, 748, 806, 829, 871, 213, 26, 543, 508, 963, 994, 238, 999, 861, 389, 822, 146, 448, 806, 947, 323, 207, 223, 223, 673, 218, 955, 944, 941, 907, 738, 653, 994, 995, 950, 24, 29, 876, 375, 936, 719, 449, 281, 29, 755, 443, 570, 283, 895, 17, 921, 628, 995, 350, 968, 257, 589, 777, 826, 29, 660, 281, 307, 845, 515, 995, 915, 585, 781, 898, 97, 819, 689, 843, 147, 238, 821, 536, 411, 680, 728, 300, 283, 873, 794, 5, 177, 235, 222, 144, 576, 92, 770, 682, 872, 503, 130, 904, 770, 541, 365, 506, 307, 230, 779, 693, 831, 273, 154, 767, 67, 79, 408, 313, 567, 876, 520, 969, 534, 492, 21, 414, 36, 654, 296, 200, 89, 961, 430, 867, 775, 206, 887, 689, 571, 855, 200, 397, 680, 472, 877, 985, 862, 565, 194, 840, 913, 32, 925, 19, 690, 900, 119, 174, 274, 22, 459, 977, 721, 51, 9, 243, 558, 515, 598, 825, 622, 741, 112, 357, 922, 341, 430, 50, 855, 507, 335, 980, 408, 447, 505]]) == [168809, 96351, 161747, 157149, 151251, 148343, 122525, 172675, 174503, 121687, 135397, 122743, 101011, 142855, 92881, 115633, 131635, 112957, 115365, 98885, 115911, 100105, 122525, 94247, 168415, 97113, 96351, 104517, 145949, 105611, 92993, 95271, 92713, 120181, 135659, 96671, 92689, 160819, 118431, 100695, 93579, 93627, 96395, 94251, 124281, 115365, 145869, 100903, 102543, 104383, 178061, 94635, 153073, 148955, 120483, 106609, 93699, 94669, 107155, 140775, 159297, 150205, 156975, 96601, 92773, 106609, 122195, 111045, 109123, 174503, 100903, 94443, 109277, 120681, 155053, 119587, 93543, 117021, 174675, 116739, 123401, 93627, 114905, 134621, 161747, 134111, 96625, 129787, 131157, 164575, 98271, 135659, 107307, 94077, 105669, 97565, 96555, 99911, 105197, 123013, 110559, 171269, 107885, 124993, 94251, 94905, 93579, 124719, 148343, 155349, 92683, 119587, 114011, 92737, 133609, 107155, 149575, 119307, 92773, 94497, 102359, 172693, 93543, 129041, 98701, 150523, 132303, 163311, 128109, 99433, 144183, 164893, 104403, 171025, 104651, 94859, 117021, 169159, 124533, 126873, 99439, 148343, 108199, 116463, 139951, 142739, 136957, 92671, 123849, 107155, 122525, 149263, 100893, 174339, 126503, 171977, 112957, 140775, 99721, 131545, 94209, 183935, 99061, 145869, 94963, 94635, 127111, 97565, 93213, 94625, 92739, 144771, 152407, 120681, 113945, 137507, 98613, 102007, 111045, 93213, 111045, 97289, 122525, 182179, 95397, 111045, 96219, 95327, 164575, 121081, 93371, 100695, 133109, 98529, 105151, 96555, 148969, 92755, 94171, 102427, 142583, 112957, 107155, 101423, 97215, 173667, 101637, 105279, 119587, 107307, 153395, 122525, 92737, 92697, 94251, 103909, 123849, 170915, 125693, 123427, 164893, 188937, 99151, 143891, 108921, 102199, 122525, 190765, 145869, 92689, 153073, 101211, 124063, 92793, 98441, 129289, 128797, 111045, 103379, 122807, 149263, 110397, 100281, 101665, 93187, 96817, 93595, 164893, 93797, 113945, 187487, 126503, 105537, 94539, 125225, 95055, 123401, 92713, 149263, 114725, 92815, 137775, 151537, 96419, 119891, 111045, 92713, 107307, 151825, 131877, 169859, 104383, 110789, 94669, 97261, 95327, 109277, 153395, 115265, 180103, 93535, 98705, 131635, 93139, 92755, 92717, 136693, 140499, 152407, 93535, 94635, 92701, 117775, 94811, 101637, 109277, 133109, 92675, 122603, 182879, 92685, 145869, 124719, 135137, 103787, 130683, 140499, 182879, 100695, 95733, 119695, 107739, 104383, 152115, 93163, 109277, 147559, 118815, 96285, 101227, 122525, 158057, 97113, 93535, 130211, 95005, 115365, 97723, 100893, 119199, 92801, 149263, 145359, 145869, 94209, 149263, 122311, 96419, 108199, 124533, 109277, 129039, 172675, 113253, 137775, 105537, 108921, 95055, 116835, 93699, 128341, 104383, 123427, 111045, 131395, 103545, 155665, 104383, 187847, 113771, 153395, 123849, 108969, 94163, 139403, 102543, 103255, 123849, 94963, 131635, 161435, 147435, 167767, 172333, 123401, 92697, 119891, 103255, 168461, 92785, 144219, 142739, 115911, 92873, 149889, 143025, 137489, 132613, 155349, 103255, 94019, 168093, 95055, 94581, 96743, 153073, 124063, 92713, 143025, 93213, 164893, 134111, 94247, 92671, 119307, 94685, 95055, 109277, 96625, 94635, 136715, 92679, 149263, 93439, 131157, 131877, 92739, 123219, 151477, 140499, 100695, 138021, 103255, 100203, 161747, 124499, 164575, 185697, 128071, 122311, 121081, 97337, 93783, 182179, 113305, 173667, 137775, 143601, 117673, 106609, 145653, 147137, 93595, 110883, 124719, 125225, 93535, 142739, 105937, 129041, 145359, 108177, 100789, 93505, 162635, 102659, 187847, 113131, 98271, 137775, 121687, 173779, 94035, 101335, 185343, 183231, 92739, 134365, 106887, 101529, 118815, 127185, 120087, 108177, 126165, 92671, 105407, 121687, 124063, 92685, 93217, 141227, 174339, 98271, 94635, 148649, 173667, 104899, 123849, 123401, 161435, 92705, 128109, 122743, 136693, 168415, 117209, 98271, 190399, 97187, 101973, 93595, 132613, 163945, 111947, 170209, 122195, 135397, 121387, 122961, 168093, 122311, 111723, 126873, 94207, 156317, 122311, 135137, 93477, 160511, 134611, 157753, 106473, 118239, 107895, 172333, 97585, 174675, 93187, 93273, 111947, 162973, 92755, 169159, 124941, 148649, 92685, 105611, 147435, 128797, 92685, 158361, 167421, 142039, 182529, 95085, 107895, 143671, 148343, 118623, 120483, 103255, 102543, 132557, 103013, 124499, 142739, 157451, 127185, 182879, 173417, 112573, 155339, 122603, 121687, 132613, 162635, 97585, 99151, 187847, 114297, 119587, 99151, 103751, 98613, 130919, 133837, 97565, 96625, 98613, 104255, 123849, 103013, 92755, 168461, 141227, 122311, 94299, 157637, 100281, 157753, 121687, 93213, 128797, 123625, 100903, 139677, 92683, 93075, 110463, 142739, 149263, 120087, 135137, 100281, 105473, 92859, 92673, 168415, 112233, 151825, 116279, 92671, 96743, 103877, 97067, 93371, 143313, 93505, 110307, 143945, 185697, 92801, 136979, 93337, 96219, 168093, 157753, 112279, 98355, 148405, 93399, 182179, 94715, 109379, 119587, 124281, 134111, 127351, 182179, 92881, 92785, 161633, 172333, 121687, 174141, 131635, 99151, 122807, 144767, 94849, 119587, 156317, 106869, 128797, 124993, 124993, 100007, 126165, 158965, 155339, 154367, 143891, 107885, 98193, 172333, 172693, 157305, 182879, 181139, 135397, 100483, 152753, 105279, 94793, 113597, 181139, 110463, 95147, 93595, 113253, 140499, 185343, 148039, 96351, 172693, 103255, 163311, 117965, 94287, 114189, 123637, 181139, 98795, 113597, 109277, 127877, 92709, 172693, 146245, 94133, 114905, 141331, 158971, 122195, 101665, 127415, 144493, 121687, 122603, 92739, 97337, 100695, 106473, 110397, 113253, 134621, 117297, 189667, 136431, 122311, 125225, 145317, 93797, 160511, 112957, 100903, 134365, 92873, 149253, 143025, 112957, 92837, 101529, 92819, 109277, 123401, 114545, 102123, 124719, 115009, 142583, 112445, 168415, 164575, 97565, 108353, 93505, 135397, 92673, 163651, 92713, 93097, 183935, 97113, 178741, 98271, 111045, 130537, 161435, 160965, 95987, 133109, 113833, 129041, 138315, 101665, 93627, 130211, 130537, 98445, 100695, 93741, 135659, 169159, 131877, 93451, 132049, 126729, 145653, 180103, 149263, 184639, 101779, 141893, 152407, 137223, 114831, 183583, 94299, 166389, 105537, 173667, 188209, 120681, 93269, 92709, 94669, 123427, 95973, 108325, 154463, 102427, 148343, 104383, 95987, 174003, 130211, 92801, 105197, 167421, 97565, 94905, 92837]\nassert my_solution.minOperations(*[[665, 448, 939, 151, 12, 470, 33, 709, 310, 974, 341, 62, 295, 9, 883, 79, 1, 181, 241, 974, 910, 198, 664, 277, 258, 77, 107, 417, 911, 385, 323, 614, 954, 41, 388, 457, 301, 778, 154, 715, 293, 703, 907, 830, 466, 553, 949, 262, 824, 709, 899, 469, 658, 379, 439, 479, 123, 989, 910, 567, 656, 111, 583, 746, 684, 205, 720, 345, 730, 131, 731, 264, 735, 708, 276, 943, 548, 89, 806, 917, 343, 141, 883, 947, 724, 161, 280, 900, 468, 968, 287, 96, 701, 193, 964, 225, 569, 686, 635, 151, 769, 676, 683, 585, 846, 857, 160, 607, 427, 678, 8, 27, 346, 790, 780, 291, 500, 782, 357, 186, 843, 152, 571, 740, 471, 857, 218, 75, 15, 377, 446, 750, 970, 227, 890, 298, 578, 275, 166, 247, 169, 454, 700, 106, 834, 200, 413, 347, 411, 434, 528, 394, 504, 153, 580, 278, 608, 602, 456, 968, 148, 928, 824, 19, 952, 135, 937, 807, 748, 702, 372, 215, 187, 111, 372, 395, 976, 101, 32, 797, 916, 20, 899, 142, 499, 893, 375, 280, 698, 866, 730, 820, 948, 166, 773, 711, 108, 280, 805, 173, 596, 228, 106, 695, 755, 979, 771, 936, 877, 839, 342, 151, 607, 290, 400, 399, 575, 938, 565, 35, 356, 297, 110, 9, 513, 184, 493, 962, 591, 36, 775, 417, 287, 771, 752], [17, 468, 243, 323, 280, 152, 665, 678, 825, 692, 343, 85, 33, 805, 746, 151, 731, 824, 829, 746, 468, 397, 656, 343, 335, 153, 297, 762, 807, 151, 417, 936, 231, 890, 964, 345, 348, 428, 703, 103, 709, 199, 913, 899, 782, 342, 750, 769, 698, 51, 426, 976, 930, 295, 216, 8, 177, 111, 470, 166, 974, 225, 33, 969, 444, 151, 860, 836, 195, 99, 906, 280, 617, 820, 824, 976, 858, 280, 704, 503, 833, 607, 937, 979, 448, 502, 900, 508, 891, 108, 730, 949, 900, 293, 730, 678, 5, 87, 345, 106, 126, 734, 893, 470, 32, 293, 773, 153, 953, 133, 280, 31, 979, 287, 937, 107, 616, 377, 394, 219, 529, 276, 288, 912, 779, 964, 976, 778, 259, 857, 974, 673, 172, 200, 142, 377, 937, 443, 568, 346, 707, 961, 468, 730, 287, 454, 751, 771, 780, 968, 750, 910, 979, 857, 911, 166, 415, 468, 166, 779, 903, 106, 964, 151, 399, 683, 899, 683, 701, 151, 702, 937, 298, 446, 184, 910, 750, 39, 404, 942, 345, 776, 477, 910, 610, 243, 145, 225, 617, 341, 965, 35, 839, 596, 778, 15, 698, 899, 824, 974, 700, 227, 665, 574, 608, 70, 699, 637, 659, 779, 695, 857, 849, 388, 910, 769, 730, 394, 604, 715, 428, 830, 911, 585, 644, 707, 166, 68, 375, 399, 85, 305, 910, 952, 244, 300, 186, 265, 352, 434, 626, 110, 892, 891, 34, 153, 551, 185, 287, 607, 702, 591, 708, 150, 108, 166, 36, 280, 917, 683, 434, 280, 867, 658, 937, 968, 346, 869, 703, 475, 289, 778, 579, 746, 577, 85, 968, 831, 19, 211, 772, 151, 397, 287, 150, 383, 538, 978, 280, 1, 486, 107, 276, 334, 908, 35, 911, 499, 457, 9, 665, 76, 166, 27, 35, 111, 591, 583, 750, 857, 153, 602, 165, 736, 698, 457, 711, 822, 278, 734, 198, 9, 771, 607, 151, 731, 917, 635, 892, 960, 25, 160, 772, 242, 280, 254, 782, 972, 579, 154, 576, 607, 10, 108, 748, 954, 748, 166, 217, 378, 976, 947, 700, 280, 215, 295, 894, 676, 828, 583, 287, 685, 695, 279, 566, 740, 709, 863, 594, 29, 10, 931, 227, 771, 493, 707, 974, 528, 280, 8, 709, 395, 968, 950, 583, 280, 949, 280, 948, 895, 264, 343, 587, 470, 460, 710, 720, 249, 607, 456, 296, 264, 568, 490, 949, 108, 470, 713, 278, 910, 248, 198, 129, 777, 934, 794, 974, 964, 135, 145, 442, 948, 170, 785, 215, 645, 553, 730, 910, 228, 35, 9, 792, 579, 504, 499, 730, 711, 949, 77, 863, 185, 321, 711, 280, 979, 504, 108, 596, 284, 797, 685, 161, 399, 684, 683, 967, 834, 738, 418, 935, 597, 860, 280, 37, 805, 276, 99, 45, 916, 489, 686, 744, 408, 297, 412, 76, 844, 964, 90, 727, 938, 867, 805, 19, 771, 107, 200, 280, 118, 341, 357, 748, 456, 899, 631, 357, 153, 560, 947, 723, 720, 110, 899, 824, 278, 571, 894, 654, 79, 111, 151, 166, 747, 80, 549, 342, 445, 164, 179, 300, 19, 413, 175, 205, 680, 74, 193, 280, 157, 278, 650, 974, 875, 949, 679, 938, 713, 35, 778, 298, 846, 748, 343, 159, 1, 754, 236, 709, 907, 124, 781, 470, 891, 153, 657, 752, 372, 217, 311, 33, 962, 344, 444, 607, 183, 816, 976, 413, 402, 280, 487, 183, 343, 24, 565, 581, 776, 412, 501, 9, 746, 771, 657, 457, 820, 938, 470, 735, 290, 379, 275, 396, 820, 479, 295, 457, 658, 399, 761, 747, 824, 36, 111, 351, 917, 910, 357, 429, 973, 883, 375, 780, 411, 947, 506, 771, 585, 133, 896, 342, 356, 702, 704, 938, 151, 225, 180, 291, 155, 552, 948, 153, 924, 797, 791, 703, 806, 275, 830, 188, 189, 166, 526, 950, 940, 821, 700, 327, 201, 290, 858, 588, 899, 13, 289, 832, 419, 777, 469, 652, 166, 823, 417, 944, 106, 290, 948, 35, 13, 607, 508, 397, 444, 226, 52, 771, 827, 976, 701, 805, 730, 966, 33, 806, 702, 839, 740, 582, 299, 468, 417, 301, 98, 476, 448, 116, 406, 698, 176, 974, 709, 379, 664, 730, 708, 821, 153, 153, 228, 102, 568, 9, 290, 683, 949, 28, 702, 613, 750, 280, 275, 280, 346, 835, 110, 151, 280, 379, 398, 387, 279, 364, 21, 715, 789, 771, 731, 420, 458, 133, 835, 341, 399, 701, 110, 607, 202, 401, 170, 356, 752, 583, 343, 752, 278, 414, 607, 430, 344, 264, 947, 342, 126, 936, 721, 781, 738, 595, 280, 607, 954, 824, 798, 36, 565, 399, 342, 582, 242, 772, 976, 607, 718, 592, 236, 841, 357, 699, 450, 413, 228, 606, 735, 386, 857, 939, 607, 262, 842, 1, 585, 456, 347, 290, 417, 630, 228, 432, 736, 578, 503, 352, 151, 742, 35, 192, 776, 730, 266, 76, 550, 695, 359, 567, 954, 390, 181, 727, 280, 448, 9, 128, 778, 276, 805, 395, 778, 440, 782, 839, 157, 781, 48, 857, 582, 968, 832, 604, 230, 469, 33, 36, 7, 883, 108, 635, 466, 499, 691, 962, 976, 883, 538, 187, 936, 228, 586, 700, 38, 812, 938, 947, 607, 301, 160, 387, 883, 896, 141, 398, 395, 890, 885, 12, 498, 683, 111, 656, 967, 142, 513, 937, 720, 79, 198, 967, 108, 949, 6, 970, 478, 537, 775, 375, 786, 434, 121, 372, 579, 346, 591, 107, 870, 74, 702, 700, 2, 161, 227, 166, 569, 264, 596, 412, 111, 287, 151, 133, 974, 297, 824, 111, 735, 293, 111, 446, 382, 948, 287, 111, 788, 824, 377, 664, 172, 423, 732, 301, 679, 910, 771, 824, 357, 911, 278, 938, 78, 15, 723, 608, 152, 960, 277, 15, 18, 287]]) == [113622, 61851, 75076, 67590, 71027, 87233, 67350, 68147, 84328, 69103, 66176, 99426, 110122, 81460, 74071, 87394, 72492, 84179, 84924, 74071, 61851, 63406, 66839, 66176, 66738, 87074, 69524, 75901, 81740, 87394, 62756, 103333, 76476, 94763, 109191, 66046, 65863, 62483, 69922, 95890, 70422, 80470, 98892, 96332, 78355, 66243, 74511, 76720, 69535, 106370, 62531, 111871, 102163, 69686, 78299, 115655, 83486, 94382, 61843, 85079, 111413, 77188, 110122, 110290, 62145, 87394, 89771, 85983, 81000, 96666, 97597, 71027, 64808, 83599, 84179, 111871, 89445, 71027, 70005, 61956, 85526, 64314, 103530, 112564, 62073, 61947, 96511, 62009, 94936, 94935, 72391, 105978, 96511, 69852, 72391, 68147, 116354, 99028, 66046, 95311, 91703, 72801, 95282, 61843, 110337, 69852, 77204, 87074, 106824, 90468, 71027, 110554, 112564, 70376, 103530, 95122, 64757, 64258, 63519, 77926, 62274, 71429, 70287, 98703, 77964, 109191, 111871, 77835, 73262, 89282, 111413, 67838, 84203, 80339, 88909, 64258, 103530, 62164, 62937, 65983, 70254, 108542, 61851, 72391, 70376, 61983, 74624, 76958, 78093, 110067, 74511, 98327, 112564, 89282, 98514, 85079, 62814, 61851, 85079, 77964, 97054, 95311, 109191, 87394, 63332, 68472, 96332, 68472, 69762, 87394, 69841, 103530, 69445, 62107, 82491, 98327, 74511, 108858, 63165, 104539, 66046, 77581, 61848, 98327, 64459, 75076, 88402, 77188, 64808, 66312, 109410, 109696, 86442, 63853, 77835, 114068, 69535, 96332, 84179, 111413, 69685, 76946, 67350, 63091, 64361, 102453, 69610, 65832, 67006, 77964, 69316, 89282, 88010, 63765, 98327, 76720, 72391, 63519, 64185, 70964, 62483, 85073, 98514, 63436, 66203, 70254, 85079, 102863, 64356, 63332, 99426, 68914, 98327, 106611, 74961, 69291, 82213, 72604, 65627, 62345, 65267, 94565, 95109, 94936, 109909, 87074, 62610, 82352, 70376, 64314, 69841, 63658, 70337, 87561, 94935, 85079, 109485, 71027, 99650, 68472, 62345, 71027, 90914, 66949, 103530, 110067, 65983, 91244, 69922, 61846, 70198, 77835, 63236, 74071, 63176, 99426, 110067, 85224, 113176, 78932, 77081, 87394, 63406, 70376, 87561, 63984, 62409, 112333, 71027, 117286, 61871, 95122, 71429, 66809, 97961, 109696, 98514, 61922, 61946, 115424, 67350, 101225, 85079, 111422, 109696, 94382, 63658, 63366, 74511, 89282, 87074, 64099, 85230, 73009, 69535, 61946, 70600, 83889, 71225, 72801, 80601, 115424, 76958, 64314, 87394, 72492, 99650, 65726, 95109, 108327, 111860, 85987, 77081, 75191, 71027, 73825, 78355, 110963, 63236, 86917, 63147, 64314, 115197, 94935, 74289, 107037, 74289, 85079, 78174, 64211, 111871, 105562, 69685, 71027, 78424, 69686, 95457, 68021, 84775, 63366, 70376, 68608, 69316, 71126, 62893, 73429, 70422, 90260, 63775, 110988, 115197, 102358, 76946, 76958, 61892, 70254, 111413, 62259, 71027, 115655, 70422, 63480, 110067, 106189, 63366, 71027, 105978, 71027, 105769, 95632, 72711, 66176, 63510, 61843, 61919, 70511, 71429, 74390, 64314, 61957, 69605, 72711, 62937, 61883, 105978, 94935, 61843, 70782, 71225, 98327, 74503, 80601, 91172, 77708, 102943, 79959, 111413, 109191, 90118, 88402, 62183, 105769, 84493, 78754, 78424, 66256, 62644, 72391, 98327, 76827, 109696, 115424, 79689, 63236, 61965, 61922, 72391, 70600, 105978, 101022, 90260, 82352, 67736, 70600, 71027, 112564, 61965, 94935, 63853, 70655, 80364, 68608, 85834, 63332, 68539, 68472, 109848, 85677, 73219, 62731, 103138, 63894, 89771, 71027, 109276, 81460, 71429, 96666, 107612, 99459, 61880, 68677, 73857, 63033, 69524, 62903, 101225, 87219, 109191, 98433, 72100, 103729, 90914, 81460, 113176, 76958, 95122, 80339, 71027, 93129, 66312, 65334, 74289, 61957, 96332, 65522, 65334, 87074, 62777, 105562, 71714, 71429, 94565, 96332, 84179, 71225, 63010, 95457, 66733, 100620, 94382, 87394, 85079, 74180, 100421, 62576, 66243, 62126, 85381, 83200, 69291, 113176, 62872, 83772, 79694, 68277, 101633, 81266, 71027, 86452, 71225, 66521, 111413, 92234, 105978, 68212, 103729, 70782, 109696, 77835, 69445, 87533, 74289, 66176, 86142, 117286, 74967, 75891, 70422, 97778, 92057, 78224, 61843, 94936, 87074, 66894, 74737, 64509, 78174, 68466, 110122, 108757, 66111, 62145, 64314, 82632, 83027, 111871, 62872, 63231, 71027, 61874, 82632, 66176, 112079, 62872, 63300, 77581, 62903, 61938, 115424, 74071, 76958, 66894, 61946, 83599, 103729, 61843, 72904, 70109, 64164, 71534, 63443, 83599, 61850, 69686, 61946, 66949, 63332, 75784, 74180, 84179, 109485, 94382, 65686, 99650, 98327, 65334, 62460, 111188, 93566, 64356, 78093, 62934, 105562, 61987, 76958, 63436, 90468, 95807, 66243, 65391, 69841, 70005, 103729, 87394, 77188, 83057, 70022, 86762, 62627, 105769, 87074, 101001, 80364, 79554, 69922, 81599, 71534, 85073, 81941, 81806, 85079, 62233, 106189, 104133, 83744, 69685, 67306, 80210, 70109, 89445, 63547, 96332, 114518, 70198, 85375, 62706, 77708, 61846, 66627, 85079, 84034, 62756, 104947, 95311, 70109, 105769, 109696, 114518, 64314, 62009, 63406, 62145, 77067, 106163, 76958, 84626, 111871, 69762, 81460, 72391, 109629, 110122, 81599, 69841, 86442, 73429, 63333, 69368, 61851, 62756, 69214, 96861, 61847, 62073, 93487, 63099, 69535, 83629, 111413, 70422, 64164, 67291, 72391, 70337, 83744, 87074, 87074, 76827, 96083, 62937, 115424, 70109, 68472, 105978, 111205, 69841, 64606, 74511, 71027, 71534, 71027, 65983, 85830, 94565, 87394, 71027, 64164, 63369, 63808, 71126, 64949, 112736, 70964, 79286, 76958, 72492, 62681, 61937, 90468, 85830, 66312, 63332, 69762, 94565, 64314, 80081, 63264, 84493, 65391, 74737, 63366, 66176, 74737, 71225, 62843, 64314, 62437, 66111, 72711, 105562, 66243, 91703, 103333, 71524, 78224, 73219, 63814, 71027, 64314, 107037, 84179, 80501, 109485, 62872, 63332, 66243, 63333, 75191, 77081, 111871, 64314, 71243, 63697, 75891, 86752, 65334, 69610, 62043, 62872, 76827, 64271, 72904, 63851, 89282, 103930, 64314, 72929, 86907, 117286, 63436, 61957, 65922, 70109, 62756, 65471, 76827, 62391, 73009, 63205, 61956, 65627, 87394, 73643, 109696, 81401, 77581, 72391, 72497, 101225, 62593, 69316, 65224, 62914, 107037, 63683, 82914, 72100, 71027, 62073, 115424, 91349, 77835, 71429, 81460, 63480, 77835, 62221, 78355, 86442, 86452, 78224, 106991, 89282, 63333, 110067, 85375, 64185, 76593, 61846, 110122, 109485, 115888, 93566, 94935, 65726, 61865, 61922, 69032, 108757, 111871, 93566, 62409, 82076, 103333, 76827, 63473, 69685, 109067, 82455, 103729, 105562, 64314, 69214, 85987, 63808, 93566, 95807, 89080, 63369, 63480, 94763, 93908, 114743, 61917, 68472, 94382, 66839, 109848, 88909, 62064, 103530, 71429, 100620, 80601, 109848, 94935, 105978, 116121, 110513, 61849, 62394, 77454, 64356, 78887, 62345, 92592, 64509, 63236, 65983, 63658, 95122, 91409, 101633, 69841, 69685, 117053, 85834, 76946, 85079, 62960, 72711, 63853, 62903, 94382, 70376, 87394, 90468, 111413, 69524, 84179, 94382, 72904, 69852, 94382, 62107, 64029, 105769, 70376, 94382, 79153, 84179, 64258, 67291, 84203, 62606, 72595, 69214, 68212, 98327, 76958, 84179, 65334, 98514, 71225, 103729, 100821, 114068, 71714, 64361, 87233, 108327, 71326, 114068, 113399, 70376]\nassert my_solution.minOperations(*[[737, 374, 744, 485, 468, 529, 167, 53, 785, 350, 389, 176, 367, 931, 787, 326, 533, 607, 488, 780, 41, 74, 532, 314, 406, 733, 547, 849, 869, 896, 553, 843, 367, 236, 473, 880, 445, 171, 320, 378, 532, 297, 178, 728, 585, 633, 418, 910, 59, 326, 465, 416, 369, 774, 126, 877, 571, 135, 252, 180, 273, 12, 900, 91, 432, 952, 506, 293, 779, 879, 740, 190, 145, 144, 507, 759, 565, 912, 15, 340, 178, 771, 10, 447, 536, 4, 261, 163, 245, 727, 770, 185, 769, 178, 668, 623, 975, 619, 391, 470, 75, 709, 138, 537, 127, 453, 156, 677, 448, 961, 578, 141, 150, 701, 269, 759, 216, 213, 740, 679, 610, 250, 534, 575, 608, 767, 214, 538, 855, 207, 465, 18, 664, 415, 186, 122, 915, 809, 340, 18, 571, 12, 199, 781, 295, 721, 526, 490, 184, 708, 643, 726, 181, 547, 621, 818, 392, 958, 850, 860, 386, 51, 905, 476, 945, 747, 444, 129, 417, 135, 46, 816, 782, 646, 766, 96, 679, 385, 547, 88, 912, 369, 764, 347, 720, 394, 378, 757, 99, 833, 439, 167, 515, 861, 727, 488, 830, 228, 768, 128, 643, 340, 809, 465, 977, 847, 815, 4, 77, 487, 637, 135, 852, 428, 130, 117, 31, 121, 105, 887, 895, 940, 787, 611, 731, 826, 374, 210, 173, 596, 187, 362, 647, 917, 98, 343, 89, 663, 773, 634, 404, 699, 989, 565, 711, 410, 938, 733, 476, 759, 187, 187, 541, 923, 167, 230, 295, 927, 26, 837, 37, 242, 664, 955, 86, 929, 88, 123, 235, 537, 359, 815, 113, 452, 945, 131, 387, 558, 380, 713, 868, 199, 870, 744, 876, 643, 880, 394, 5, 139, 114, 134, 152, 779, 425, 640, 544, 395, 975, 392, 366, 21, 569, 680, 890, 681, 734, 640, 666, 434, 755, 268, 949, 517, 838, 670, 797, 257, 461, 984, 550, 702, 20, 210, 686, 140, 57, 161, 869, 294, 152, 979, 340, 853, 722, 279, 326, 617, 476, 567, 666, 541, 581, 946, 644, 872], [177, 359, 579, 590, 367, 815, 927, 850, 542, 297, 975, 516, 57, 215, 515, 664, 479, 698, 663, 488, 380, 785, 738, 171, 729, 919, 412, 882, 326, 547, 769, 295, 854, 541, 892, 721, 610, 879, 294, 75, 130, 680, 341, 380, 455, 549, 849, 643, 952, 896, 931, 769, 809, 955, 581, 167, 764, 218, 100, 340, 128, 943, 720, 86, 532, 75, 868, 448, 547, 31, 67, 181, 475, 711, 474, 95, 476, 394, 294, 476, 270, 252, 391, 816, 711, 529, 837, 395, 701, 666, 368, 145, 272, 569, 95, 575, 408, 515, 428, 635, 131, 912, 868, 296, 893, 448, 130, 708, 417, 720, 374, 435, 139, 385, 135, 77, 293, 185, 286, 664, 125, 199, 833, 348, 828, 172, 445, 153, 272, 86, 609, 88, 348, 852, 759, 558, 910, 476, 326, 88, 326, 721, 361, 547, 229, 49, 834, 50, 869, 215, 251, 697, 837, 485, 135, 386, 869, 421, 664, 825, 940, 12, 711, 935, 88, 340, 59, 12, 532, 951, 128, 150, 445, 613, 599, 326, 710, 726, 769, 607, 767, 434, 97, 350, 340, 31, 871, 152, 178, 4, 326, 745, 611, 671, 167, 417, 532, 809, 643, 171, 517, 756, 124, 809, 369, 388, 837, 494, 681, 880, 869, 187, 295]]) == [120765, 92675, 87459, 88147, 91807, 120031, 150327, 128477, 85793, 100515, 165909, 85463, 152981, 113497, 85459, 94321, 85583, 98517, 94215, 85483, 90557, 113319, 104397, 122063, 102931, 147871, 88203, 137023, 96607, 85949, 109999, 100791, 129499, 85763, 139877, 101717, 89465, 136175, 100933, 147471, 131787, 96191, 94725, 90557, 86161, 86025, 128225, 92151, 158263, 141031, 151571, 109999, 118663, 159247, 87579, 122943, 109037, 112973, 140097, 94843, 132313, 155355, 101571, 144167, 85575, 147471, 133167, 86403, 85949, 161187, 149917, 119929, 85637, 100279, 85655, 141533, 85619, 89397, 100933, 85619, 104459, 107253, 89623, 120263, 100279, 85545, 125259, 89327, 98911, 94541, 91705, 128043, 104159, 86897, 141533, 87225, 88455, 85459, 87309, 91439, 131527, 145745, 133167, 100653, 140165, 86403, 131787, 99861, 87899, 101571, 91113, 86967, 129499, 90117, 130497, 146867, 101077, 119115, 102099, 94321, 133117, 116431, 124291, 93911, 123095, 121845, 86521, 126149, 104159, 144167, 89395, 143571, 93911, 128985, 108097, 86393, 145149, 85619, 96607, 143571, 96607, 101717, 92455, 85949, 111061, 155473, 124533, 155159, 133433, 113497, 107413, 98387, 125259, 85511, 130497, 90031, 133433, 87681, 94321, 122383, 154401, 167397, 100279, 152827, 143571, 94843, 152365, 167397, 85575, 157937, 132313, 126853, 86521, 89685, 88729, 96607, 100139, 102465, 109999, 89257, 109609, 87013, 140955, 93683, 94843, 161187, 133975, 126381, 120551, 170115, 96607, 105597, 89537, 95119, 122943, 87899, 85575, 118663, 92151, 122063, 85467, 107553, 133387, 118663, 91603, 89865, 125259, 85467, 96317, 136455, 133433, 118717, 100791]\nassert my_solution.minOperations(*[[460, 585, 596, 504, 988, 704, 987, 629, 209, 712, 294, 293, 515, 452, 436, 439, 274, 361, 919, 231, 959, 140, 463, 799, 444, 828, 403, 758, 329, 424, 969, 744, 555, 217, 567, 148, 69, 477, 870, 699, 870, 175, 209, 433, 798, 8, 520, 318, 776, 876, 987, 983, 365, 89, 847, 769, 743, 386, 43, 128, 968, 756, 667, 375, 543, 409, 68, 884, 310, 501, 306, 958, 947, 384, 522, 138, 921, 439, 427, 474, 889, 479, 651, 413, 41, 606, 434, 305, 983, 675, 584, 468, 328, 672, 638, 576, 320, 461, 865, 996, 325, 58, 659, 531, 528, 41, 241, 32, 477, 170, 143, 796, 698, 688, 821, 171, 527, 727, 438, 603, 586, 520, 628, 328, 558, 244, 864, 752, 279, 130, 192, 242, 670, 403, 622, 467, 299, 789, 535, 40, 426, 102, 43, 997, 313, 280, 875, 731, 57, 789, 939, 311, 332, 309, 830, 92, 865, 845, 662, 768, 636, 211, 605, 747, 152, 758, 607, 261, 603, 689, 761, 27, 240, 822, 873, 95, 441, 39, 543, 865, 44, 853, 198, 512, 275, 302, 91, 881, 820, 246, 125, 535, 230, 872, 94, 144, 160, 483, 896, 663, 146, 127, 186, 837, 257, 828, 670, 873, 292, 850, 235, 735, 317, 455, 666, 779, 792, 125, 900, 818, 883, 770, 242, 114, 331, 103, 438, 661, 744, 896, 596, 274, 957, 770, 176, 583, 41, 471, 755, 833, 202, 578, 273, 338, 934, 507, 60, 500, 314, 897, 966, 521, 260, 909, 26, 232, 767, 979, 736, 165, 844, 184, 365, 405, 627, 93, 39, 815, 920, 905, 478, 852, 3, 480, 161, 640, 927, 81, 101, 440, 997, 853, 565, 571, 419, 498, 9, 430, 999, 829, 416, 528, 261, 803, 254, 836, 402, 501, 470, 859, 363, 104, 900, 517, 896, 776, 814, 457, 12, 147, 49, 529, 531, 1000, 57, 834, 834, 298, 212, 495, 360, 435, 943, 212, 549, 193, 937, 408, 815, 907, 896, 160, 842, 943, 522, 332, 255, 630, 863, 206, 973, 827, 633, 719, 456, 770, 511, 242, 59, 543, 461, 436, 261, 537, 57, 375, 835, 255, 328, 540, 628, 627, 260, 686, 15, 569, 75, 308, 332, 12, 675, 991, 327, 693, 141, 35, 634, 641, 679, 134, 636, 633, 948, 149, 649, 958, 49, 760, 294, 452, 438, 291, 438, 398, 819, 919, 324, 86, 582, 928, 32, 812, 401, 786, 200, 933, 602, 507, 569, 999, 382, 775, 999, 417, 872, 11, 402, 6, 322, 910, 791, 332, 467, 356, 65, 117, 400, 462, 743, 129, 189, 895, 974, 465, 83, 501, 979, 18, 508, 328, 770, 1, 127, 666, 99, 933, 152, 553, 956, 566, 327, 149, 86, 964, 19, 959, 139, 664, 89, 996, 496, 888, 177, 140, 780, 538, 791, 669, 615, 224, 496, 139, 208, 286, 714, 700, 604, 18, 661, 925, 951, 307, 108, 905, 990, 128, 739, 292, 824, 904, 251, 54, 210, 804, 595, 683, 141, 321, 440, 4, 176, 878, 191, 935, 647, 519, 261, 239, 989, 494, 721, 808, 704, 366, 744, 544, 554, 507, 169, 645, 344, 133, 247, 859, 570, 312, 333, 85, 249, 466, 3, 86, 862, 815, 853, 429, 606], [313, 144, 176, 896, 456, 703, 471, 628, 854, 582, 518, 232, 743, 935, 91, 853, 18, 889, 760, 797, 9, 834, 859, 959, 89, 312, 242, 242, 756, 50, 138, 915, 361, 515, 318, 896, 152, 565, 847, 383, 570, 86, 442, 415, 306, 815, 583, 596, 744, 323, 71, 926, 203, 722, 132, 498, 242, 474, 687, 242, 403, 744, 7, 143, 15, 883, 987, 637, 820, 943, 815, 744, 329, 94, 895, 365, 57, 461, 58, 466, 897, 60, 57, 199, 670, 981, 18, 328, 883, 247, 479, 104, 926, 876, 919, 95, 85, 915, 739, 329, 776, 425, 176, 312, 99, 905, 191, 735, 828, 364, 672, 437, 496, 306, 144, 567, 141, 682, 643, 439, 85, 461, 878, 834, 212, 846, 522, 331, 311, 966, 776, 94, 596, 483, 3, 528, 41, 670, 989, 75, 760, 86, 471, 669, 293, 815, 152, 779, 659, 596, 622, 125, 32, 700, 418, 744, 442, 427, 155, 462, 280, 799, 853, 496, 926, 117, 117, 900, 569, 493, 520, 186, 169, 73, 356, 847, 873, 478, 527, 832, 446, 895, 957, 42, 645, 576, 139, 250, 375, 549, 933, 281, 495, 242, 959, 670, 407, 161, 440, 117, 609, 133, 416, 176, 628, 294, 605, 937, 317, 431, 139, 149, 523, 224, 836, 95, 10, 275, 521, 677, 937, 993, 999, 242, 292, 900, 807, 569, 499, 139, 852, 430, 579, 896, 207, 702, 209, 595, 987, 452, 897, 667, 163, 522, 361, 313, 504, 480, 169, 251, 327, 872, 306, 43, 255, 94, 117, 937, 146, 498, 943, 630, 272, 58, 474, 987, 328, 324, 332, 968, 823, 823, 501, 18, 261, 86, 987, 853, 295, 169, 709, 18, 872, 399, 772, 1, 583, 169, 933, 993, 405, 549, 430, 57, 400, 632, 434, 564, 538, 440, 687, 537, 735, 171, 324, 850, 254, 86, 663, 967, 128, 235, 244, 561, 864, 770, 241, 473, 529, 666, 85, 791, 832, 934, 208, 543, 94, 519, 432, 128, 899, 261, 855, 101, 636, 404, 628, 10, 177, 194, 770, 790, 641, 321, 195, 666, 942, 468, 507, 909, 467, 859, 625, 841, 819, 439, 578, 292, 735, 261, 149, 18, 209, 829, 465, 149, 293, 405, 328, 261, 332, 692, 210, 168, 198, 776, 43, 210, 628, 261, 404, 480, 853, 427, 734, 647, 935, 481, 212, 804, 851, 966, 676, 460, 423, 582, 896, 584, 758, 667, 40, 322, 43, 567, 361, 438, 988, 919, 675, 308, 309, 651, 292, 528, 605, 504, 274, 544, 875, 242, 900, 999, 482, 879, 496, 996, 872, 511, 40, 674, 314, 743, 569, 776, 661, 607, 95, 834, 640, 19, 438, 306, 177, 39, 209, 72, 524, 964, 704, 756, 501, 967, 210, 828, 718, 583, 915, 338, 450, 365, 569, 294, 544, 877, 712, 744, 627, 401, 937, 231, 744, 919, 365, 675, 331, 44, 479, 895, 477, 41, 160, 948, 8, 438, 629, 228, 872, 661, 477, 954, 888, 528, 149, 633, 452, 138, 764, 595, 909, 209, 328, 495, 422, 996, 438, 475, 795, 320, 550, 774, 669, 501, 169, 792, 293, 192, 770, 873, 758, 981, 833, 761, 554, 460]]) == [155225, 204796, 193328, 216914, 136690, 158185, 136035, 144946, 200362, 139708, 135736, 175458, 167087, 234149, 226575, 199993, 261334, 214021, 171280, 181539, 265997, 193260, 202207, 245485, 227453, 155428, 172534, 172534, 170268, 245402, 207092, 225147, 147135, 135677, 154230, 216914, 201838, 138253, 197831, 144037, 138646, 228782, 137558, 140079, 156688, 187019, 139801, 141104, 167324, 153267, 235597, 230050, 184357, 162310, 209456, 135550, 172534, 135948, 154899, 172534, 141433, 167324, 267049, 205173, 262879, 211567, 259441, 146217, 188610, 237873, 187019, 167324, 152167, 225270, 216499, 146543, 242069, 136425, 241600, 136206, 217337, 240668, 242069, 185649, 151616, 256395, 261334, 152340, 211567, 171137, 135823, 221000, 230050, 208746, 226911, 224839, 229231, 225147, 166155, 152167, 175520, 139037, 193328, 155428, 223123, 220759, 188269, 165233, 191230, 146690, 151990, 137919, 135564, 156688, 204796, 138405, 205931, 153914, 147131, 137761, 229231, 136425, 209548, 193260, 181506, 197474, 135836, 151825, 155633, 248912, 175520, 225270, 141104, 135753, 269165, 136036, 249741, 151616, 260469, 233769, 171280, 228782, 136035, 151433, 159577, 187019, 201838, 176357, 149699, 141104, 144180, 212273, 254228, 157552, 139758, 167324, 137558, 138837, 200755, 136378, 162662, 182135, 199993, 135564, 230050, 215577, 215577, 218612, 138563, 135603, 135780, 189940, 195761, 234683, 147898, 197831, 207553, 135844, 136001, 192580, 137302, 216499, 244519, 249254, 147441, 139166, 206701, 170314, 145131, 137133, 233229, 162423, 135575, 172534, 245485, 151616, 140969, 198593, 137690, 215577, 142567, 209059, 139970, 193328, 144946, 159348, 142083, 235075, 154427, 138455, 206701, 202933, 135869, 177860, 193952, 224839, 265474, 163875, 135807, 152943, 235075, 262547, 265693, 172534, 159808, 218612, 184557, 138563, 135545, 206701, 199630, 138548, 139435, 216914, 183075, 157974, 182439, 141001, 259441, 136924, 217337, 151071, 197883, 135836, 147135, 155225, 135546, 135804, 195761, 170041, 152521, 207160, 156688, 248767, 168959, 225270, 215577, 235075, 204046, 135550, 237873, 145218, 164620, 241600, 135948, 259441, 152340, 153078, 151656, 249898, 189585, 189585, 135537, 261334, 167381, 228782, 259441, 199993, 159123, 195761, 159471, 261334, 207160, 141935, 174426, 270235, 139801, 195761, 233229, 262547, 141199, 137133, 138548, 242069, 141806, 145496, 138178, 138180, 136486, 137690, 154899, 136435, 165233, 195061, 153078, 198908, 169228, 228782, 150369, 249405, 211050, 174573, 171972, 137961, 204078, 173880, 172821, 135977, 136075, 150892, 229231, 179769, 192580, 233688, 182756, 136757, 225270, 135757, 138362, 211050, 218187, 167381, 200731, 222269, 146068, 141316, 144946, 265474, 192987, 187282, 173880, 179480, 146821, 153647, 186955, 150892, 237406, 136132, 135561, 222503, 136167, 202207, 144561, 195705, 188289, 137761, 139344, 159808, 165233, 167381, 202933, 261334, 182439, 191565, 136247, 202933, 159577, 141199, 152340, 167381, 151656, 155908, 182126, 196114, 185974, 175520, 248767, 182126, 144946, 167381, 141316, 135804, 199993, 138837, 165006, 147755, 234149, 135787, 181506, 183642, 199269, 248912, 152750, 136476, 139241, 139708, 216914, 139896, 170770, 151071, 250234, 153456, 248767, 138405, 147135, 137836, 259954, 226911, 152557, 156260, 156049, 148395, 159808, 136036, 142083, 135546, 164120, 136818, 208347, 172534, 218612, 265693, 135770, 209951, 135564, 264110, 207160, 135611, 250234, 152368, 155024, 167087, 138563, 175520, 150029, 142321, 224839, 193260, 146668, 260823, 137836, 156688, 192987, 250729, 182439, 235140, 135902, 247930, 158396, 170268, 135537, 249405, 182126, 191230, 161426, 139801, 225147, 150700, 137050, 146543, 138563, 159348, 136818, 209147, 160116, 167324, 144815, 141679, 235075, 175755, 167324, 226911, 146543, 152557, 151825, 248284, 135823, 216499, 135867, 249741, 198950, 240230, 266522, 137836, 145081, 176656, 207160, 150029, 135867, 243086, 213610, 136036, 202933, 145635, 136924, 207092, 172314, 141001, 222503, 182439, 152340, 135575, 139344, 264110, 137836, 135921, 180947, 153840, 137198, 174972, 151433, 135537, 195761, 180062, 159577, 187938, 173880, 207553, 170770, 256395, 192919, 171537, 137460, 136476]\nassert my_solution.minOperations(*[[308, 371, 776, 732, 673, 897, 457, 147, 301, 923, 890, 966, 775, 122, 79, 225, 253, 120, 564, 396, 292, 311, 652, 568, 445, 792, 620, 44, 599, 15, 669, 653, 84, 58, 865, 259, 188, 771, 18, 961, 885, 801, 516, 709, 219, 244, 744, 764, 856, 887, 611, 9, 993, 337, 626, 494, 944, 977, 640, 77, 322, 740, 539, 739, 589, 239, 825, 761, 538, 880, 339, 993, 773, 394, 851, 425, 230, 171, 995, 343, 216, 167, 3, 298, 142, 747, 505, 162, 456, 831, 673, 374, 300, 917, 729, 543, 420, 665, 17, 981, 895, 537, 594, 924, 780, 184, 554, 738, 558, 207, 854, 851, 244, 916, 730, 22, 986, 597, 578, 395, 730, 786, 774, 925, 671, 846, 836, 908, 41, 82, 999, 361, 96, 375, 849, 210, 729, 181, 341, 490, 297, 774, 864, 814, 415, 59, 439, 196, 912, 776, 940, 440, 486, 904, 259, 847, 293, 79, 8, 546, 13, 973, 594, 181, 134, 202, 217, 820, 283, 763, 584, 795, 902, 856, 391, 710, 425, 778, 421, 994, 668, 499, 715, 966, 718, 60, 613, 505, 297, 921, 133, 286, 745, 917, 1000, 573, 583, 840, 276, 271, 863, 51, 598, 574, 773, 288, 560, 183, 400, 793, 373, 476, 554, 720, 407, 557, 969, 115, 842, 871, 916, 31, 149, 381, 65, 340, 29, 398, 617, 887, 77, 362, 526, 66, 274, 425, 864, 424, 645, 409, 699, 288, 753, 699, 867, 616, 698, 725, 52, 939, 627, 875, 240, 627, 593, 497, 277, 311, 211, 555, 181, 94, 521, 201, 918, 496, 2, 653, 447, 281, 582, 387, 414, 930, 30, 54, 420, 83, 71, 683, 676, 210, 825, 56, 560, 405, 996, 151, 115, 180, 477, 807, 55, 147, 683, 844, 513, 64, 433, 251, 416, 996, 612, 772, 905, 392, 609, 570, 349, 743, 456, 876, 4, 478, 208, 479, 73, 537, 369, 794, 255, 846, 757, 694, 335, 334, 748, 868, 552, 219, 257, 733, 850, 66, 119, 943, 997, 316, 670, 197, 31, 37, 318, 266, 620, 688, 94, 37, 665, 942, 604, 958, 965, 613, 102, 592, 712, 651, 363, 472, 561, 874, 675, 527, 526, 42, 793, 23, 875, 483, 906, 816, 514, 621, 617, 733, 95, 640, 848, 103, 76, 125, 960, 990, 742, 179, 225, 533, 931, 750, 233, 546, 403, 907, 947, 939, 505, 554, 476, 860, 314, 899, 953, 193, 884, 952, 906, 413, 808, 625, 154, 821, 223, 240, 28, 91, 253, 104, 688, 319, 167, 921, 615, 841, 609, 83, 451, 87, 37, 358, 164, 439, 958, 144, 568, 977, 691, 210, 991, 516, 622, 407, 588, 79, 851, 32, 426, 993, 245, 160, 779, 573, 363, 445, 265, 857, 943, 694, 176, 324, 9, 499, 784, 685, 425, 735, 466, 569, 178, 835, 565, 612, 462, 444, 762, 9, 122, 251, 323, 979, 866, 34, 949, 9, 770, 447, 995, 63, 55, 844, 297, 276, 676, 329, 372, 152, 384, 429, 158, 466, 435, 286, 319, 12, 901, 465, 641, 187, 19, 171, 566, 35, 69, 702, 165, 787, 437, 66, 528, 497, 885, 114, 690, 506, 492, 409, 445, 20, 249, 64, 246, 404, 865, 857, 437, 362, 159, 807, 513, 197, 262, 553, 745, 363, 255, 971, 958, 322, 25, 65, 535, 387, 918, 224, 881, 55, 501, 71, 206, 78, 858, 443, 327, 883, 289, 493, 98, 564, 308, 996, 534, 251, 156, 462, 714, 583, 971, 569, 453, 846, 7, 909, 735, 511, 667, 938, 797, 652, 960, 686, 379, 689, 362, 894, 734, 476, 422, 448, 121, 568, 113, 342, 639, 945, 903, 405, 594, 809, 995, 699, 518, 266, 752, 229, 590, 753, 755, 568, 399, 925, 319, 731, 10, 669, 935, 692, 490, 24, 738, 586, 65, 952, 529, 700, 703, 477, 26, 119, 559, 839, 746, 263, 78, 73, 691, 191, 496, 956, 812, 308, 476, 470, 384, 313, 890, 630, 201, 546, 193, 617, 557, 776, 782, 375, 535, 589, 909, 734, 653, 438, 946, 426, 562, 639, 983, 148, 897, 282, 703, 428, 566, 87, 122, 390, 825, 202, 730, 495, 71, 685, 740, 31, 910, 517, 339, 228, 121, 447, 79, 492, 794, 744, 508, 964, 278, 697, 561, 722, 585, 559, 126, 234, 877, 8, 705, 513, 176, 447, 999, 155, 238, 144, 663, 318, 669, 648, 172, 975, 976, 145, 37, 590, 186, 678, 475, 591, 906, 634, 301, 585, 56, 681, 546, 893, 34, 943, 149, 703, 287, 667, 682, 906, 615, 897, 146, 916, 105, 224, 842, 799, 635, 219, 545, 80, 143, 924, 18], [161, 134, 718, 843, 144, 314, 392, 159, 318, 652, 339, 704, 933, 3, 121, 437, 208, 890, 851, 864, 734, 193, 120, 971, 908, 996, 626, 517, 916, 409, 887, 897, 611, 898, 858, 392, 96, 181, 746, 906, 251, 993, 794, 893, 2, 569, 146, 835, 145, 80, 399, 653, 587, 653, 425, 715, 864, 162, 138, 952, 144, 58, 2, 883, 494, 715, 466, 120, 193, 149, 262, 942, 588, 116, 196, 885, 917, 382, 323, 228, 669, 546, 568, 561, 665, 764, 773, 271, 210, 701, 865, 210, 542, 318, 876, 224, 335, 865, 321, 560, 761, 418, 816, 37, 340, 265, 239, 58, 825, 201, 730, 959, 425, 773, 738, 663, 492, 875, 96, 797, 734, 377, 685, 864, 219, 812, 405, 202, 230, 106, 580, 995, 688, 916, 275, 564, 317]]) == [288357, 302760, 225914, 277891, 297276, 226756, 207344, 289381, 225580, 208430, 219827, 221558, 329805, 387535, 309971, 199705, 265898, 303216, 281913, 288736, 231146, 272717, 310538, 355831, 313874, 374120, 203312, 194077, 318842, 204083, 301491, 307287, 200777, 307878, 285552, 207344, 324496, 278387, 235450, 312650, 248123, 371875, 254996, 304953, 388300, 195669, 296196, 274007, 296735, 334144, 205949, 208643, 197483, 208643, 201403, 224963, 288736, 287846, 300564, 342520, 297276, 348324, 388300, 299217, 194688, 224963, 196600, 310538, 272717, 294595, 244018, 335738, 197598, 312826, 271328, 300349, 319471, 209456, 224163, 257318, 212185, 194394, 195582, 195071, 211275, 242406, 246009, 240781, 265012, 220657, 289273, 265012, 194286, 225580, 295296, 258982, 220891, 289273, 224725, 195008, 241221, 202536, 265008, 362681, 219566, 242927, 252837, 348324, 269229, 269039, 229792, 347353, 201403, 246009, 232546, 210833, 194788, 294741, 324496, 256335, 231146, 210553, 216175, 288736, 261105, 263152, 204807, 268586, 256494, 318622, 196734, 373367, 216974, 318842, 239363, 195276, 225873]\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2718", "questionFrontendId": "2602", "questionTitle": "Minimum Operations to Make All Array Elements Equal", "stats": { "totalAccepted": "7.7K", "totalSubmission": "22.2K", "totalAcceptedRaw": 7684, "totalSubmissionRaw": 22174, "acRate": "34.7%" } }
LeetCode/2659
# Number of Even and Odd Bits You are given a **positive** integer `n`. Let `even` denote the number of even indices in the binary representation of `n` (**0-indexed**) with value `1`. Let `odd` denote the number of odd indices in the binary representation of `n` (**0-indexed**) with value `1`. Return *an integer array* `answer` *where* `answer = [even, odd]`.   **Example 1:** ``` **Input:** n = 17 **Output:** [2,0] **Explanation:** The binary representation of 17 is 10001. It contains 1 on the 0th and 4th indices. There are 2 even and 0 odd indices. ``` **Example 2:** ``` **Input:** n = 2 **Output:** [0,1] **Explanation:** The binary representation of 2 is 10. It contains 1 on the 1st index. There are 0 even and 1 odd indices. ```   **Constraints:** * `1 <= n <= 1000` Please make sure your answer follows the type signature below: ```python3 class Solution: def evenOddBit(self, n: int) -> List[int]: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.evenOddBit(*[17]) == [2, 0]\nassert my_solution.evenOddBit(*[2]) == [0, 1]\nassert my_solution.evenOddBit(*[1]) == [1, 0]\nassert my_solution.evenOddBit(*[3]) == [1, 1]\nassert my_solution.evenOddBit(*[4]) == [1, 0]\nassert my_solution.evenOddBit(*[5]) == [2, 0]\nassert my_solution.evenOddBit(*[6]) == [1, 1]\nassert my_solution.evenOddBit(*[7]) == [2, 1]\nassert my_solution.evenOddBit(*[8]) == [0, 1]\nassert my_solution.evenOddBit(*[9]) == [1, 1]\nassert my_solution.evenOddBit(*[10]) == [0, 2]\nassert my_solution.evenOddBit(*[11]) == [1, 2]\nassert my_solution.evenOddBit(*[12]) == [1, 1]\nassert my_solution.evenOddBit(*[13]) == [2, 1]\nassert my_solution.evenOddBit(*[14]) == [1, 2]\nassert my_solution.evenOddBit(*[15]) == [2, 2]\nassert my_solution.evenOddBit(*[16]) == [1, 0]\nassert my_solution.evenOddBit(*[18]) == [1, 1]\nassert my_solution.evenOddBit(*[19]) == [2, 1]\nassert my_solution.evenOddBit(*[20]) == [2, 0]\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2659", "questionFrontendId": "2595", "questionTitle": "Number of Even and Odd Bits", "stats": { "totalAccepted": "11K", "totalSubmission": "15.1K", "totalAcceptedRaw": 11049, "totalSubmissionRaw": 15084, "acRate": "73.2%" } }
LeetCode/2696
# The Number of Beautiful Subsets You are given an array `nums` of positive integers and a **positive** integer `k`. A subset of `nums` is **beautiful** if it does not contain two integers with an absolute difference equal to `k`. Return *the number of **non-empty beautiful** subsets of the array* `nums`. A **subset** of `nums` is an array that can be obtained by deleting some (possibly none) elements from `nums`. Two subsets are different if and only if the chosen indices to delete are different.   **Example 1:** ``` **Input:** nums = [2,4,6], k = 2 **Output:** 4 **Explanation:** The beautiful subsets of the array nums are: [2], [4], [6], [2, 6]. It can be proved that there are only 4 beautiful subsets in the array [2,4,6]. ``` **Example 2:** ``` **Input:** nums = [1], k = 1 **Output:** 1 **Explanation:** The beautiful subset of the array nums is [1]. It can be proved that there is only 1 beautiful subset in the array [1]. ```   **Constraints:** * `1 <= nums.length <= 20` * `1 <= nums[i], k <= 1000` Please make sure your answer follows the type signature below: ```python3 class Solution: def beautifulSubsets(self, nums: List[int], k: int) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.beautifulSubsets(*[[2, 4, 6], 2]) == 4\nassert my_solution.beautifulSubsets(*[[1], 1]) == 1\nassert my_solution.beautifulSubsets(*[[4, 2, 5, 9, 10, 3], 1]) == 23\nassert my_solution.beautifulSubsets(*[[10, 4, 5, 7, 2, 1], 3]) == 23\nassert my_solution.beautifulSubsets(*[[9, 5, 7, 10, 6, 2], 9]) == 63\nassert my_solution.beautifulSubsets(*[[10, 1, 4, 3, 5], 1]) == 19\nassert my_solution.beautifulSubsets(*[[10, 2, 6, 4, 5, 7, 3, 9, 1, 8], 3]) == 199\nassert my_solution.beautifulSubsets(*[[30, 22, 15, 25, 7, 23, 27], 14]) == 127\nassert my_solution.beautifulSubsets(*[[3, 6, 7, 5, 23, 19, 16, 13, 17, 2], 5]) == 767\nassert my_solution.beautifulSubsets(*[[26, 28, 8, 4, 11], 12]) == 31\nassert my_solution.beautifulSubsets(*[[17, 11, 3, 19, 29], 19]) == 31\nassert my_solution.beautifulSubsets(*[[7, 24, 12, 22, 5, 8, 27, 1, 2, 6], 15]) == 575\nassert my_solution.beautifulSubsets(*[[7, 19, 6, 29], 28]) == 15\nassert my_solution.beautifulSubsets(*[[24, 21, 25, 18, 9], 6]) == 23\nassert my_solution.beautifulSubsets(*[[20, 21, 8, 24, 14], 19]) == 31\nassert my_solution.beautifulSubsets(*[[24, 28, 27, 13, 21, 1, 23], 13]) == 127\nassert my_solution.beautifulSubsets(*[[29, 24, 18, 7, 15, 26, 2, 12, 22, 11], 28]) == 1023\nassert my_solution.beautifulSubsets(*[[16, 6, 1, 14, 12, 18, 8, 10, 3, 11, 7, 19, 20], 19]) == 6143\nassert my_solution.beautifulSubsets(*[[1, 14, 16, 13, 11, 19, 8, 2, 18, 15, 9, 3], 5]) == 959\nassert my_solution.beautifulSubsets(*[[9, 12, 2, 4, 10, 5, 14, 8, 19, 15], 8]) == 575\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2696", "questionFrontendId": "2597", "questionTitle": "The Number of Beautiful Subsets", "stats": { "totalAccepted": "7.6K", "totalSubmission": "21.3K", "totalAcceptedRaw": 7576, "totalSubmissionRaw": 21275, "acRate": "35.6%" } }
LeetCode/2661
# Smallest Missing Non-negative Integer After Operations You are given a **0-indexed** integer array `nums` and an integer `value`. In one operation, you can add or subtract `value` from any element of `nums`. * For example, if `nums = [1,2,3]` and `value = 2`, you can choose to subtract `value` from `nums[0]` to make `nums = [-1,2,3]`. The MEX (minimum excluded) of an array is the smallest missing **non-negative** integer in it. * For example, the MEX of `[-1,2,3]` is `0` while the MEX of `[1,0,3]` is `2`. Return *the maximum MEX of* `nums` *after applying the mentioned operation **any number of times***.   **Example 1:** ``` **Input:** nums = [1,-10,7,13,6,8], value = 5 **Output:** 4 **Explanation:** One can achieve this result by applying the following operations: - Add value to nums[1] twice to make nums = [1,**0**,7,13,6,8] - Subtract value from nums[2] once to make nums = [1,0,**2**,13,6,8] - Subtract value from nums[3] twice to make nums = [1,0,2,**3**,6,8] The MEX of nums is 4. It can be shown that 4 is the maximum MEX we can achieve. ``` **Example 2:** ``` **Input:** nums = [1,-10,7,13,6,8], value = 7 **Output:** 2 **Explanation:** One can achieve this result by applying the following operation: - subtract value from nums[2] once to make nums = [1,-10,**0**,13,6,8] The MEX of nums is 2. It can be shown that 2 is the maximum MEX we can achieve. ```   **Constraints:** * `1 <= nums.length, value <= 105` * `-109 <= nums[i] <= 109` Please make sure your answer follows the type signature below: ```python3 class Solution: def findSmallestInteger(self, nums: List[int], value: int) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.findSmallestInteger(*[[1, -10, 7, 13, 6, 8], 5]) == 4\nassert my_solution.findSmallestInteger(*[[1, -10, 7, 13, 6, 8], 7]) == 2\nassert my_solution.findSmallestInteger(*[[1, 3, 5, 7], 2]) == 0\nassert my_solution.findSmallestInteger(*[[3, 0, 3, 2, 4, 2, 1, 1, 0, 4], 5]) == 10\nassert my_solution.findSmallestInteger(*[[3, 2, 3, 1, 0, 1, 4, 2, 3, 1, 4, 1, 3], 5]) == 5\nassert my_solution.findSmallestInteger(*[[0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1], 2]) == 15\nassert my_solution.findSmallestInteger(*[[0, 3, 1, 1, 2, 2, 0, 0, 2, 2, 3, 2], 4]) == 9\nassert my_solution.findSmallestInteger(*[[2, 2, 2, 3, 3, 2, 0, 2, 3, 0, 3, 2, 3, 1, 2, 0], 4]) == 5\nassert my_solution.findSmallestInteger(*[[0, 0, 1, 0, 0, 0, 1, 0], 2]) == 5\nassert my_solution.findSmallestInteger(*[[1, 0, 4, 2, 4, 3, 3, 1, 4], 5]) == 5\nassert my_solution.findSmallestInteger(*[[2, 1, 0, 0, 1, 1, 1, 0, 2, 1, 0, 1, 1], 3]) == 8\nassert my_solution.findSmallestInteger(*[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 1]) == 19\nassert my_solution.findSmallestInteger(*[[0, 3, 2, 2, 0, 3, 3, 0, 2, 1, 1, 2, 1, 0, 1, 0, 3], 4]) == 17\nassert my_solution.findSmallestInteger(*[[2, 2, 1, 2, 0, 1, 2, 0, 0, 0, 1, 2, 2, 1, 0, 1, 2], 3]) == 15\nassert my_solution.findSmallestInteger(*[[0, 3, 3, 2, 0, 1, 0, 3, 2, 3, 0, 4, 3, 1, 4, 4, 4, 2, 1, 1, 0, 4, 2, 4, 1, 2, 4, 0, 4, 1, 2, 1, 2, 3, 3, 4], 5]) == 30\nassert my_solution.findSmallestInteger(*[[0, 2, 2, 3, 1, 2, 1, 0, 1, 3, 2, 2, 3, 2, 1, 1, 2, 1, 0, 1, 3, 1], 4]) == 12\nassert my_solution.findSmallestInteger(*[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 1]) == 34\nassert my_solution.findSmallestInteger(*[[4, 1, 0, 1, 1, 1, 1, 3, 2, 3, 1, 2, 4], 5]) == 5\nassert my_solution.findSmallestInteger(*[[1, 1, 2, 1, 2, 1, 0, 2, 2, 2, 1, 1, 1, 2, 1, 1, 2, 2, 0, 1, 0, 1, 1, 2, 1, 2, 2, 1, 2], 3]) == 9\nassert my_solution.findSmallestInteger(*[[0, -3], 4]) == 2\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2661", "questionFrontendId": "2598", "questionTitle": "Smallest Missing Non-negative Integer After Operations", "stats": { "totalAccepted": "5.7K", "totalSubmission": "14.5K", "totalAcceptedRaw": 5739, "totalSubmissionRaw": 14510, "acRate": "39.6%" } }
LeetCode/2663
# Distribute Money to Maximum Children You are given an integer `money` denoting the amount of money (in dollars) that you have and another integer `children` denoting the number of children that you must distribute the money to. You have to distribute the money according to the following rules: * All money must be distributed. * Everyone must receive at least `1` dollar. * Nobody receives `4` dollars. Return *the **maximum** number of children who may receive **exactly*** `8` *dollars if you distribute the money according to the aforementioned rules*. If there is no way to distribute the money, return `-1`.   **Example 1:** ``` **Input:** money = 20, children = 3 **Output:** 1 **Explanation:** The maximum number of children with 8 dollars will be 1. One of the ways to distribute the money is: - 8 dollars to the first child. - 9 dollars to the second child. - 3 dollars to the third child. It can be proven that no distribution exists such that number of children getting 8 dollars is greater than 1. ``` **Example 2:** ``` **Input:** money = 16, children = 2 **Output:** 2 **Explanation:** Each child can be given 8 dollars. ```   **Constraints:** * `1 <= money <= 200` * `2 <= children <= 30` Please make sure your answer follows the type signature below: ```python3 class Solution: def distMoney(self, money: int, children: int) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.distMoney(*[20, 3]) == 1\nassert my_solution.distMoney(*[16, 2]) == 2\nassert my_solution.distMoney(*[1, 2]) == -1\nassert my_solution.distMoney(*[1, 3]) == -1\nassert my_solution.distMoney(*[1, 4]) == -1\nassert my_solution.distMoney(*[1, 5]) == -1\nassert my_solution.distMoney(*[1, 6]) == -1\nassert my_solution.distMoney(*[1, 7]) == -1\nassert my_solution.distMoney(*[1, 8]) == -1\nassert my_solution.distMoney(*[1, 9]) == -1\nassert my_solution.distMoney(*[1, 10]) == -1\nassert my_solution.distMoney(*[1, 11]) == -1\nassert my_solution.distMoney(*[1, 12]) == -1\nassert my_solution.distMoney(*[1, 13]) == -1\nassert my_solution.distMoney(*[1, 14]) == -1\nassert my_solution.distMoney(*[1, 15]) == -1\nassert my_solution.distMoney(*[1, 16]) == -1\nassert my_solution.distMoney(*[1, 17]) == -1\nassert my_solution.distMoney(*[1, 18]) == -1\nassert my_solution.distMoney(*[1, 19]) == -1\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2663", "questionFrontendId": "2591", "questionTitle": "Distribute Money to Maximum Children", "stats": { "totalAccepted": "29.8K", "totalSubmission": "111.1K", "totalAcceptedRaw": 29794, "totalSubmissionRaw": 111088, "acRate": "26.8%" } }
LeetCode/2664
# Maximize Greatness of an Array You are given a 0-indexed integer array `nums`. You are allowed to permute `nums` into a new array `perm` of your choosing. We define the **greatness** of `nums` be the number of indices `0 <= i < nums.length` for which `perm[i] > nums[i]`. Return *the **maximum** possible greatness you can achieve after permuting* `nums`.   **Example 1:** ``` **Input:** nums = [1,3,5,2,1,3,1] **Output:** 4 **Explanation:** One of the optimal rearrangements is perm = [2,5,1,3,3,1,1]. At indices = 0, 1, 3, and 4, perm[i] > nums[i]. Hence, we return 4. ``` **Example 2:** ``` **Input:** nums = [1,2,3,4] **Output:** 3 **Explanation:** We can prove the optimal perm is [2,3,4,1]. At indices = 0, 1, and 2, perm[i] > nums[i]. Hence, we return 3. ```   **Constraints:** * `1 <= nums.length <= 105` * `0 <= nums[i] <= 109` Please make sure your answer follows the type signature below: ```python3 class Solution: def maximizeGreatness(self, nums: List[int]) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.maximizeGreatness(*[[1, 3, 5, 2, 1, 3, 1]]) == 4\nassert my_solution.maximizeGreatness(*[[1, 2, 3, 4]]) == 3\nassert my_solution.maximizeGreatness(*[[31, 25, 72, 79]]) == 3\nassert my_solution.maximizeGreatness(*[[65, 84, 91, 18, 59, 27, 9, 81, 33, 17]]) == 9\nassert my_solution.maximizeGreatness(*[[42, 8, 75, 28, 35, 21, 13, 21]]) == 6\nassert my_solution.maximizeGreatness(*[[35, 52, 74, 92, 25, 65, 77, 1, 73]]) == 8\nassert my_solution.maximizeGreatness(*[[43, 68, 8, 100]]) == 3\nassert my_solution.maximizeGreatness(*[[14, 88, 42, 53, 98, 69, 64, 40, 60, 23]]) == 9\nassert my_solution.maximizeGreatness(*[[21]]) == 0\nassert my_solution.maximizeGreatness(*[[34, 99, 63, 23, 70, 18, 64, 12, 21, 21]]) == 8\nassert my_solution.maximizeGreatness(*[[36, 58, 88, 58, 99, 26, 92, 91, 53, 10]]) == 8\nassert my_solution.maximizeGreatness(*[[25, 20, 92]]) == 2\nassert my_solution.maximizeGreatness(*[[63, 51, 65, 87, 6, 17, 32, 14, 42, 46]]) == 9\nassert my_solution.maximizeGreatness(*[[43, 9, 75, 76, 25, 96, 46, 85, 19]]) == 8\nassert my_solution.maximizeGreatness(*[[88, 2, 5, 24]]) == 3\nassert my_solution.maximizeGreatness(*[[26, 76, 24, 96, 82, 97, 97, 72]]) == 6\nassert my_solution.maximizeGreatness(*[[21, 77, 82, 30, 94]]) == 4\nassert my_solution.maximizeGreatness(*[[76, 94, 51, 82, 3, 89, 52]]) == 6\nassert my_solution.maximizeGreatness(*[[27, 59, 57, 97, 6, 46, 88, 41, 52]]) == 8\nassert my_solution.maximizeGreatness(*[[4, 17, 2, 95, 6, 62]]) == 5\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2664", "questionFrontendId": "2592", "questionTitle": "Maximize Greatness of an Array", "stats": { "totalAccepted": "5.8K", "totalSubmission": "9.8K", "totalAcceptedRaw": 5752, "totalSubmissionRaw": 9827, "acRate": "58.5%" } }
LeetCode/2695
# Find Score of an Array After Marking All Elements You are given an array `nums` consisting of positive integers. Starting with `score = 0`, apply the following algorithm: * Choose the smallest integer of the array that is not marked. If there is a tie, choose the one with the smallest index. * Add the value of the chosen integer to `score`. * Mark **the chosen element and its two adjacent elements if they exist**. * Repeat until all the array elements are marked. Return *the score you get after applying the above algorithm*.   **Example 1:** ``` **Input:** nums = [2,1,3,4,5,2] **Output:** 7 **Explanation:** We mark the elements as follows: - 1 is the smallest unmarked element, so we mark it and its two adjacent elements: [2,1,3,4,5,2]. - 2 is the smallest unmarked element, so we mark it and its left adjacent element: [2,1,3,4,5,2]. - 4 is the only remaining unmarked element, so we mark it: [2,1,3,4,5,2]. Our score is 1 + 2 + 4 = 7. ``` **Example 2:** ``` **Input:** nums = [2,3,5,1,3,2] **Output:** 5 **Explanation:** We mark the elements as follows: - 1 is the smallest unmarked element, so we mark it and its two adjacent elements: [2,3,5,1,3,2]. - 2 is the smallest unmarked element, since there are two of them, we choose the left-most one, so we mark the one at index 0 and its right adjacent element: [2,3,5,1,3,2]. - 2 is the only remaining unmarked element, so we mark it: [2,3,5,1,3,2]. Our score is 1 + 2 + 2 = 5. ```   **Constraints:** * `1 <= nums.length <= 105` * `1 <= nums[i] <= 106` Please make sure your answer follows the type signature below: ```python3 class Solution: def findScore(self, nums: List[int]) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.findScore(*[[2, 1, 3, 4, 5, 2]]) == 7\nassert my_solution.findScore(*[[2, 3, 5, 1, 3, 2]]) == 5\nassert my_solution.findScore(*[[10, 44, 10, 8, 48, 30, 17, 38, 41, 27, 16, 33, 45, 45, 34, 30, 22, 3, 42, 42]]) == 212\nassert my_solution.findScore(*[[29, 20, 36, 39, 50, 42, 46, 34, 47]]) == 135\nassert my_solution.findScore(*[[26, 18, 27, 13, 42, 14, 50, 34, 45, 22, 47, 50, 9, 43, 30, 9, 24, 6, 25, 43]]) == 168\nassert my_solution.findScore(*[[46, 21, 7, 33]]) == 53\nassert my_solution.findScore(*[[2, 4, 25, 12, 25, 18, 32, 50, 1, 43, 28]]) == 61\nassert my_solution.findScore(*[[22, 32, 3, 40, 33, 49]]) == 58\nassert my_solution.findScore(*[[44, 7, 20, 27, 15, 8, 17, 20, 2, 30, 24]]) == 68\nassert my_solution.findScore(*[[3, 28]]) == 3\nassert my_solution.findScore(*[[39, 43, 12, 15, 6]]) == 57\nassert my_solution.findScore(*[[48, 43, 2, 16, 39, 8, 34, 12, 42, 26, 33]]) == 96\nassert my_solution.findScore(*[[46, 777, 1916, 780, 1857, 1523, 1016, 389, 117, 934, 1121, 191, 471, 399, 949, 763, 517, 928, 463, 438, 1496, 1490, 1552, 211, 280, 122, 200, 1980, 1437, 1496, 879, 866, 609, 1923, 836, 1482, 460, 1080, 1135, 756, 1870, 30, 1841, 1860, 1812, 1121, 1715, 1930, 1997, 1531, 1939, 1674, 346]]) == 17122\nassert my_solution.findScore(*[[1247, 1847, 259, 184, 637, 805, 1364, 643, 1129, 1008, 1378, 554, 371, 765, 1386, 1419, 1023, 1826, 845, 1941, 244, 246, 1118, 981, 1779, 148, 1662, 1991, 212, 1255, 47, 604, 1642, 1273, 1422, 152, 1093, 4, 348, 1224, 277, 126, 1551, 353, 249, 1482, 56, 1590, 256, 1950, 1765, 1980, 1864, 27, 77, 1520, 838, 1383, 1388, 448, 870, 208, 1951, 431, 411, 824, 1325, 1823, 35, 3, 1330, 619]]) == 18128\nassert my_solution.findScore(*[[137, 1063, 1697, 491, 329, 901, 1224, 931, 1493, 1869, 183, 727, 1114, 1647, 1828, 1321, 1926, 1356, 927, 1436, 98, 456, 322, 797, 811, 598, 1807, 660, 525, 1239, 362, 1726, 1276, 1895, 1634, 732, 937, 1966, 402, 321, 218, 990, 653, 727, 1756, 1792, 1687, 534, 1011, 1183, 570, 1431, 882, 1709, 1142, 201, 1699, 149, 791, 1605, 266, 1340, 347, 1383, 1479, 1297, 1812, 1195, 450, 1648, 995, 1148, 1828, 117, 1835, 586, 607, 1705, 426, 39, 1608, 646, 1702, 1009, 873, 1729, 540]]) == 23778\nassert my_solution.findScore(*[[1463, 37, 1728, 1698, 1223, 337, 1821, 232, 70, 613, 1665, 1896, 1509, 1282, 79, 983, 1186, 1164, 886, 723, 1668, 1956, 628, 392, 1397, 788, 304, 1803, 1046, 384, 820, 1804, 504, 1411, 1364, 412, 1136, 922, 1638, 1302, 1799, 1730, 345, 1254, 1897, 1861, 1223, 1356, 355, 1905, 740, 108, 360, 1965, 46, 36, 1691, 1716, 1272, 171, 684, 542, 1455, 54, 1651, 931, 910, 253, 1265, 950, 1981, 142, 190, 440, 886]]) == 24586\nassert my_solution.findScore(*[[1123, 987, 1152, 1366, 1193, 62, 1577, 1117, 791, 896, 728, 442, 1105, 1038, 1907, 1028, 1188, 704, 1841, 1216, 1657, 759, 1624, 845, 1278, 1339, 1842, 1491, 536, 452, 490, 1785, 1942, 939, 789, 1837, 1621, 80]]) == 15174\nassert my_solution.findScore(*[[1242, 423, 1330, 1474, 237, 1574, 79, 962, 1518, 1583, 1332, 930, 69, 1712, 1329, 1388, 747, 584, 410, 1647, 107, 13, 428, 594, 1380, 1389, 749, 426, 414, 653, 1786, 1260]]) == 9174\nassert my_solution.findScore(*[[730, 1721, 1993, 1532, 962, 519, 1365, 1307, 1992, 1623, 1579, 1735, 1015, 1579, 1003, 1277, 1255, 1254, 810, 1767, 206, 1837, 920, 1203, 1876, 521, 625, 483, 572, 922, 1936, 1014, 1835, 694, 19, 209, 1438, 127, 1716, 1272, 444, 1739, 148, 1580, 802, 1093, 1543, 452, 257, 103, 877, 749, 1418, 348, 1555, 1552, 818, 555, 1628, 547, 553, 1742, 1062, 1199, 1987, 818, 491, 1211]]) == 23202\nassert my_solution.findScore(*[[687, 607, 641, 698, 368, 758, 1563, 476, 42, 1977, 770, 1254, 2, 149, 378, 1385, 755, 1258, 1082, 20, 603, 889, 102]]) == 4607\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2695", "questionFrontendId": "2593", "questionTitle": "Find Score of an Array After Marking All Elements", "stats": { "totalAccepted": "4.8K", "totalSubmission": "9.1K", "totalAcceptedRaw": 4759, "totalSubmissionRaw": 9090, "acRate": "52.4%" } }
LeetCode/2665
# Minimum Time to Repair Cars You are given an integer array `ranks` representing the **ranks** of some mechanics. ranksi is the rank of the ith mechanic. A mechanic with a rank `r` can repair n cars in `r * n2` minutes. You are also given an integer `cars` representing the total number of cars waiting in the garage to be repaired. Return *the **minimum** time taken to repair all the cars.* **Note:** All the mechanics can repair the cars simultaneously.   **Example 1:** ``` **Input:** ranks = [4,2,3,1], cars = 10 **Output:** 16 **Explanation:** - The first mechanic will repair two cars. The time required is 4 * 2 * 2 = 16 minutes. - The second mechanic will repair two cars. The time required is 2 * 2 * 2 = 8 minutes. - The third mechanic will repair two cars. The time required is 3 * 2 * 2 = 12 minutes. - The fourth mechanic will repair four cars. The time required is 1 * 4 * 4 = 16 minutes. It can be proved that the cars cannot be repaired in less than 16 minutes.​​​​​ ``` **Example 2:** ``` **Input:** ranks = [5,1,8], cars = 6 **Output:** 16 **Explanation:** - The first mechanic will repair one car. The time required is 5 * 1 * 1 = 5 minutes. - The second mechanic will repair four cars. The time required is 1 * 4 * 4 = 16 minutes. - The third mechanic will repair one car. The time required is 8 * 1 * 1 = 8 minutes. It can be proved that the cars cannot be repaired in less than 16 minutes.​​​​​ ```   **Constraints:** * `1 <= ranks.length <= 105` * `1 <= ranks[i] <= 100` * `1 <= cars <= 106` Please make sure your answer follows the type signature below: ```python3 class Solution: def repairCars(self, ranks: List[int], cars: int) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.repairCars(*[[4, 2, 3, 1], 10]) == 16\nassert my_solution.repairCars(*[[5, 1, 8], 6]) == 16\nassert my_solution.repairCars(*[[1, 1, 3, 3], 74]) == 576\nassert my_solution.repairCars(*[[3, 3, 1, 2, 1, 1, 3, 2, 1], 58]) == 75\nassert my_solution.repairCars(*[[1, 3, 1, 2, 1, 1], 21]) == 18\nassert my_solution.repairCars(*[[2, 2, 3, 3, 1, 3, 3, 1, 3], 32]) == 32\nassert my_solution.repairCars(*[[3, 1, 3, 3, 1, 3], 42]) == 108\nassert my_solution.repairCars(*[[3, 2, 2, 2, 1, 3, 1], 21]) == 18\nassert my_solution.repairCars(*[[2, 2, 1, 3, 1, 2, 1, 1, 1, 3], 36]) == 25\nassert my_solution.repairCars(*[[3, 2, 1, 3, 3, 2, 1, 1], 25]) == 25\nassert my_solution.repairCars(*[[3, 3, 2], 51]) == 768\nassert my_solution.repairCars(*[[3, 1, 1, 1, 1, 2, 2, 3, 2], 9]) == 3\nassert my_solution.repairCars(*[[3, 1, 3, 2, 3, 1, 1, 3, 1, 1], 24]) == 12\nassert my_solution.repairCars(*[[1, 3, 1, 3, 3, 3, 2, 1], 77]) == 192\nassert my_solution.repairCars(*[[3, 2, 3, 3], 51]) == 450\nassert my_solution.repairCars(*[[3], 52]) == 8112\nassert my_solution.repairCars(*[[1, 2, 2, 1, 2, 3, 2, 2, 2], 4]) == 2\nassert my_solution.repairCars(*[[1, 3, 1], 62]) == 588\nassert my_solution.repairCars(*[[1, 2, 1, 1, 3, 2, 2, 1, 2], 78]) == 121\nassert my_solution.repairCars(*[[3, 2, 3], 77]) == 1728\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2665", "questionFrontendId": "2594", "questionTitle": "Minimum Time to Repair Cars", "stats": { "totalAccepted": "27.8K", "totalSubmission": "55.6K", "totalAcceptedRaw": 27803, "totalSubmissionRaw": 55558, "acRate": "50.0%" } }
LeetCode/2654
# Count the Number of Vowel Strings in Range You are given a **0-indexed** array of string `words` and two integers `left` and `right`. A string is called a **vowel string** if it starts with a vowel character and ends with a vowel character where vowel characters are `'a'`, `'e'`, `'i'`, `'o'`, and `'u'`. Return *the number of vowel strings* `words[i]` *where* `i` *belongs to the inclusive range* `[left, right]`.   **Example 1:** ``` **Input:** words = ["are","amy","u"], left = 0, right = 2 **Output:** 2 **Explanation:** - "are" is a vowel string because it starts with 'a' and ends with 'e'. - "amy" is not a vowel string because it does not end with a vowel. - "u" is a vowel string because it starts with 'u' and ends with 'u'. The number of vowel strings in the mentioned range is 2. ``` **Example 2:** ``` **Input:** words = ["hey","aeo","mu","ooo","artro"], left = 1, right = 4 **Output:** 3 **Explanation:** - "aeo" is a vowel string because it starts with 'a' and ends with 'o'. - "mu" is not a vowel string because it does not start with a vowel. - "ooo" is a vowel string because it starts with 'o' and ends with 'o'. - "artro" is a vowel string because it starts with 'a' and ends with 'o'. The number of vowel strings in the mentioned range is 3. ```   **Constraints:** * `1 <= words.length <= 1000` * `1 <= words[i].length <= 10` * `words[i]` consists of only lowercase English letters. * `0 <= left <= right < words.length` Please make sure your answer follows the type signature below: ```python3 class Solution: def vowelStrings(self, words: List[str], left: int, right: int) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.vowelStrings(*[['are', 'amy', 'u'], 0, 2]) == 2\nassert my_solution.vowelStrings(*[['hey', 'aeo', 'mu', 'ooo', 'artro'], 1, 4]) == 3\nassert my_solution.vowelStrings(*[['si'], 0, 0]) == 0\nassert my_solution.vowelStrings(*[['ce', 'ai'], 1, 1]) == 1\nassert my_solution.vowelStrings(*[['n', 'a', 'o'], 0, 2]) == 2\nassert my_solution.vowelStrings(*[['v', 'ab', 'fu', 'nu'], 1, 3]) == 0\nassert my_solution.vowelStrings(*[['vo', 'j', 'i', 's', 'i'], 0, 3]) == 1\nassert my_solution.vowelStrings(*[['o'], 0, 0]) == 1\nassert my_solution.vowelStrings(*[['e', 'ey'], 0, 1]) == 1\nassert my_solution.vowelStrings(*[['m', 'qi', 'ae'], 1, 1]) == 0\nassert my_solution.vowelStrings(*[['p', 'o', 'ud', 'eq'], 0, 0]) == 0\nassert my_solution.vowelStrings(*[['e', 'a', 'o', 'i', 'u'], 0, 0]) == 1\nassert my_solution.vowelStrings(*[['f'], 0, 0]) == 0\nassert my_solution.vowelStrings(*[['i', 'cz'], 0, 1]) == 1\nassert my_solution.vowelStrings(*[['a', 'ui', 'ap'], 1, 2]) == 1\nassert my_solution.vowelStrings(*[['r', 'sa', 'oa', 'v'], 2, 3]) == 1\nassert my_solution.vowelStrings(*[['ez', 'i', 'z', 'ka', 'oi'], 0, 2]) == 1\nassert my_solution.vowelStrings(*[['p', 'b'], 0, 1]) == 0\nassert my_solution.vowelStrings(*[['gs', 'dt', 'v'], 0, 2]) == 0\nassert my_solution.vowelStrings(*[['i', 'or', 'au', 'ii'], 1, 3]) == 2\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2654", "questionFrontendId": "2586", "questionTitle": "Count the Number of Vowel Strings in Range", "stats": { "totalAccepted": "39.6K", "totalSubmission": "48.4K", "totalAcceptedRaw": 39625, "totalSubmissionRaw": 48412, "acRate": "81.8%" } }
LeetCode/2655
# Rearrange Array to Maximize Prefix Score You are given a **0-indexed** integer array `nums`. You can rearrange the elements of `nums` to **any order** (including the given order). Let `prefix` be the array containing the prefix sums of `nums` after rearranging it. In other words, `prefix[i]` is the sum of the elements from `0` to `i` in `nums` after rearranging it. The **score** of `nums` is the number of positive integers in the array `prefix`. Return *the maximum score you can achieve*.   **Example 1:** ``` **Input:** nums = [2,-1,0,1,-3,3,-3] **Output:** 6 **Explanation:** We can rearrange the array into nums = [2,3,1,-1,-3,0,-3]. prefix = [2,5,6,5,2,2,-1], so the score is 6. It can be shown that 6 is the maximum score we can obtain. ``` **Example 2:** ``` **Input:** nums = [-2,-3,0] **Output:** 0 **Explanation:** Any rearrangement of the array will result in a score of 0. ```   **Constraints:** * `1 <= nums.length <= 105` * `-106 <= nums[i] <= 106` Please make sure your answer follows the type signature below: ```python3 class Solution: def maxScore(self, nums: List[int]) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.maxScore(*[[2, -1, 0, 1, -3, 3, -3]]) == 6\nassert my_solution.maxScore(*[[-2, -3, 0]]) == 0\nassert my_solution.maxScore(*[[-687767, -860350, 950296, 52109, 510127, 545329, -291223, -966728, 852403, 828596, 456730, -483632, -529386, 356766, 147293, 572374, 243605, 931468, 641668, 494446]]) == 20\nassert my_solution.maxScore(*[[-559492, 799439, 655260]]) == 3\nassert my_solution.maxScore(*[[-32495, -144584, -270506, -394309, -298138, 922535]]) == 5\nassert my_solution.maxScore(*[[19255, -795874]]) == 1\nassert my_solution.maxScore(*[[402297, -972364, 550108, 139600, 462523, -622496, -195119, 382696, 450472, -255760, 566176, -715438, -232452, 20399, -752064, 188167, 171099, -34126, -574516]]) == 17\nassert my_solution.maxScore(*[[76072, -874872]]) == 1\nassert my_solution.maxScore(*[[26445, 216889, -662096, -545708, -95063, -107719, -808691, -963708, -576067, -465421, 796622, 564374, 531351, 873749]]) == 12\nassert my_solution.maxScore(*[[-556429, 958202, -585868, -840382, 160199, -321739, 955106, -125110, 925159, -9335, 183114, 871457, -435389, -983556, 578458, -365256]]) == 16\nassert my_solution.maxScore(*[[507561, 686087, 380177, -941153, 673790]]) == 5\nassert my_solution.maxScore(*[[-494490, -8984, -868661, 147531, 973998, -946445, -996960, -902835, 135589, 834698, -65960, -10607, -69236, 30873, -905917, -269506, -745174]]) == 12\nassert my_solution.maxScore(*[[-547292, 503919, 956932, 832139, 962781, 930310, 939467, -732808, 222521, 683985, 656751, 937193, -973807, 121691, -75951, 347150, 855122, -836690]]) == 18\nassert my_solution.maxScore(*[[478824, 525321, 408041, 979757, 700602]]) == 5\nassert my_solution.maxScore(*[[-431190, -16946, 152579, -62949]]) == 3\nassert my_solution.maxScore(*[[818792, -366549, -43247, -531702, -226092, 324899, 236120, 155626, -426275, 787361, 982561, -552774, 845275, -302657, -57884, -588883, -914924, 361090, 915994]]) == 19\nassert my_solution.maxScore(*[[919006, -700914, 718735, 241311, 790580]]) == 5\nassert my_solution.maxScore(*[[714687, 274598, -617855, -685869, -996786, 55913, -928553, -804311, -369895, 644737, -507147, -325202, -264518, 445920, -70261, -355051, -880350, 966955, 415314]]) == 15\nassert my_solution.maxScore(*[[854423, -835856, 715142, 639640, -363213, -465280, 829204, 895133, -93827, 213544, 651653, 204731, 812218, -910592, -598457, -143040, 379233]]) == 17\nassert my_solution.maxScore(*[[772991, 157519, -577994, 346632, 43816, 138949, 543121, 555515, -826000, -867924]]) == 10\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2655", "questionFrontendId": "2587", "questionTitle": "Rearrange Array to Maximize Prefix Score", "stats": { "totalAccepted": "9K", "totalSubmission": "21.9K", "totalAcceptedRaw": 9030, "totalSubmissionRaw": 21872, "acRate": "41.3%" } }
LeetCode/2656
# Count the Number of Beautiful Subarrays You are given a **0-indexed** integer array `nums`. In one operation, you can: * Choose two different indices `i` and `j` such that `0 <= i, j < nums.length`. * Choose a non-negative integer `k` such that the `kth` bit (**0-indexed**) in the binary representation of `nums[i]` and `nums[j]` is `1`. * Subtract `2k` from `nums[i]` and `nums[j]`. A subarray is **beautiful** if it is possible to make all of its elements equal to `0` after applying the above operation any number of times. Return *the number of **beautiful subarrays** in the array* `nums`. A subarray is a contiguous **non-empty** sequence of elements within an array.   **Example 1:** ``` **Input:** nums = [4,3,1,2,4] **Output:** 2 **Explanation:** There are 2 beautiful subarrays in nums: [4,3,1,2,4] and [4,3,1,2,4]. - We can make all elements in the subarray [3,1,2] equal to 0 in the following way: - Choose [3, 1, 2] and k = 1. Subtract 21 from both numbers. The subarray becomes [1, 1, 0]. - Choose [1, 1, 0] and k = 0. Subtract 20 from both numbers. The subarray becomes [0, 0, 0]. - We can make all elements in the subarray [4,3,1,2,4] equal to 0 in the following way: - Choose [4, 3, 1, 2, 4] and k = 2. Subtract 22 from both numbers. The subarray becomes [0, 3, 1, 2, 0]. - Choose [0, 3, 1, 2, 0] and k = 0. Subtract 20 from both numbers. The subarray becomes [0, 2, 0, 2, 0]. - Choose [0, 2, 0, 2, 0] and k = 1. Subtract 21 from both numbers. The subarray becomes [0, 0, 0, 0, 0]. ``` **Example 2:** ``` **Input:** nums = [1,10,4] **Output:** 0 **Explanation:** There are no beautiful subarrays in nums. ```   **Constraints:** * `1 <= nums.length <= 105` * `0 <= nums[i] <= 106` Please make sure your answer follows the type signature below: ```python3 class Solution: def beautifulSubarrays(self, nums: List[int]) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.beautifulSubarrays(*[[4, 3, 1, 2, 4]]) == 2\nassert my_solution.beautifulSubarrays(*[[1, 10, 4]]) == 0\nassert my_solution.beautifulSubarrays(*[[0]]) == 1\nassert my_solution.beautifulSubarrays(*[[1]]) == 0\nassert my_solution.beautifulSubarrays(*[[0, 0]]) == 3\nassert my_solution.beautifulSubarrays(*[[0, 1]]) == 1\nassert my_solution.beautifulSubarrays(*[[1, 0]]) == 1\nassert my_solution.beautifulSubarrays(*[[1, 1]]) == 1\nassert my_solution.beautifulSubarrays(*[[0, 0, 0]]) == 6\nassert my_solution.beautifulSubarrays(*[[1, 0, 0]]) == 3\nassert my_solution.beautifulSubarrays(*[[0, 1, 0]]) == 2\nassert my_solution.beautifulSubarrays(*[[1, 1, 0]]) == 3\nassert my_solution.beautifulSubarrays(*[[0, 0, 1]]) == 3\nassert my_solution.beautifulSubarrays(*[[1, 0, 1]]) == 2\nassert my_solution.beautifulSubarrays(*[[0, 1, 1]]) == 3\nassert my_solution.beautifulSubarrays(*[[1, 1, 1]]) == 2\nassert my_solution.beautifulSubarrays(*[[0, 0, 0, 0]]) == 10\nassert my_solution.beautifulSubarrays(*[[1, 0, 0, 0]]) == 6\nassert my_solution.beautifulSubarrays(*[[0, 1, 0, 0]]) == 4\nassert my_solution.beautifulSubarrays(*[[1, 1, 0, 0]]) == 6\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2656", "questionFrontendId": "2588", "questionTitle": "Count the Number of Beautiful Subarrays", "stats": { "totalAccepted": "6.6K", "totalSubmission": "15.4K", "totalAcceptedRaw": 6587, "totalSubmissionRaw": 15386, "acRate": "42.8%" } }
LeetCode/2657
# Minimum Time to Complete All Tasks There is a computer that can run an unlimited number of tasks **at the same time**. You are given a 2D integer array `tasks` where `tasks[i] = [starti, endi, durationi]` indicates that the `ith` task should run for a total of `durationi` seconds (not necessarily continuous) within the **inclusive** time range `[starti, endi]`. You may turn on the computer only when it needs to run a task. You can also turn it off if it is idle. Return *the minimum time during which the computer should be turned on to complete all tasks*.   **Example 1:** ``` **Input:** tasks = [[2,3,1],[4,5,1],[1,5,2]] **Output:** 2 **Explanation:** - The first task can be run in the inclusive time range [2, 2]. - The second task can be run in the inclusive time range [5, 5]. - The third task can be run in the two inclusive time ranges [2, 2] and [5, 5]. The computer will be on for a total of 2 seconds. ``` **Example 2:** ``` **Input:** tasks = [[1,3,2],[2,5,3],[5,6,2]] **Output:** 4 **Explanation:** - The first task can be run in the inclusive time range [2, 3]. - The second task can be run in the inclusive time ranges [2, 3] and [5, 5]. - The third task can be run in the two inclusive time range [5, 6]. The computer will be on for a total of 4 seconds. ```   **Constraints:** * `1 <= tasks.length <= 2000` * `tasks[i].length == 3` * `1 <= starti, endi <= 2000` * `1 <= durationi <= endi - starti + 1` Please make sure your answer follows the type signature below: ```python3 class Solution: def findMinimumTime(self, tasks: List[List[int]]) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.findMinimumTime(*[[[2, 3, 1], [4, 5, 1], [1, 5, 2]]]) == 2\nassert my_solution.findMinimumTime(*[[[1, 3, 2], [2, 5, 3], [5, 6, 2]]]) == 4\nassert my_solution.findMinimumTime(*[[[1, 1, 1]]]) == 1\nassert my_solution.findMinimumTime(*[[[2000, 2000, 1]]]) == 1\nassert my_solution.findMinimumTime(*[[[1, 2000, 1]]]) == 1\nassert my_solution.findMinimumTime(*[[[1, 2000, 2000]]]) == 2000\nassert my_solution.findMinimumTime(*[[[3, 16, 2]]]) == 2\nassert my_solution.findMinimumTime(*[[[1, 18, 5], [3, 15, 1]]]) == 5\nassert my_solution.findMinimumTime(*[[[2, 13, 2], [6, 18, 5], [2, 13, 3]]]) == 5\nassert my_solution.findMinimumTime(*[[[14, 20, 5], [2, 18, 7], [6, 14, 1], [3, 16, 3]]]) == 7\nassert my_solution.findMinimumTime(*[[[8, 19, 6]]]) == 6\nassert my_solution.findMinimumTime(*[[[7, 18, 1], [4, 19, 5]]]) == 5\nassert my_solution.findMinimumTime(*[[[6, 15, 4], [3, 7, 1], [4, 20, 4]]]) == 4\nassert my_solution.findMinimumTime(*[[[8, 19, 1], [3, 20, 1], [1, 20, 2], [6, 13, 3]]]) == 3\nassert my_solution.findMinimumTime(*[[[4, 20, 10]]]) == 10\nassert my_solution.findMinimumTime(*[[[1, 14, 7], [6, 17, 2]]]) == 7\nassert my_solution.findMinimumTime(*[[[10, 18, 2], [1, 8, 1], [10, 20, 8]]]) == 9\nassert my_solution.findMinimumTime(*[[[3, 15, 9], [1, 18, 9], [4, 16, 4], [2, 20, 10]]]) == 10\nassert my_solution.findMinimumTime(*[[[13, 18, 5]]]) == 5\nassert my_solution.findMinimumTime(*[[[3, 17, 2], [3, 20, 1]]]) == 2\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2657", "questionFrontendId": "2589", "questionTitle": "Minimum Time to Complete All Tasks", "stats": { "totalAccepted": "4.2K", "totalSubmission": "9.8K", "totalAcceptedRaw": 4227, "totalSubmissionRaw": 9764, "acRate": "43.3%" } }
LeetCode/2645
# Pass the Pillow There are `n` people standing in a line labeled from `1` to `n`. The first person in the line is holding a pillow initially. Every second, the person holding the pillow passes it to the next person standing in the line. Once the pillow reaches the end of the line, the direction changes, and people continue passing the pillow in the opposite direction. * For example, once the pillow reaches the `nth` person they pass it to the `n - 1th` person, then to the `n - 2th` person and so on. Given the two positive integers `n` and `time`, return *the index of the person holding the pillow after* `time` *seconds*.   **Example 1:** ``` **Input:** n = 4, time = 5 **Output:** 2 **Explanation:** People pass the pillow in the following way: 1 -> 2 -> 3 -> 4 -> 3 -> 2. Afer five seconds, the pillow is given to the 2nd person. ``` **Example 2:** ``` **Input:** n = 3, time = 2 **Output:** 3 **Explanation:** People pass the pillow in the following way: 1 -> 2 -> 3. Afer two seconds, the pillow is given to the 3rd person. ```   **Constraints:** * `2 <= n <= 1000` * `1 <= time <= 1000` Please make sure your answer follows the type signature below: ```python3 class Solution: def passThePillow(self, n: int, time: int) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.passThePillow(*[4, 5]) == 2\nassert my_solution.passThePillow(*[3, 2]) == 3\nassert my_solution.passThePillow(*[9, 4]) == 5\nassert my_solution.passThePillow(*[8, 9]) == 6\nassert my_solution.passThePillow(*[20, 9]) == 10\nassert my_solution.passThePillow(*[6, 8]) == 3\nassert my_solution.passThePillow(*[8, 2]) == 3\nassert my_solution.passThePillow(*[82, 26]) == 27\nassert my_solution.passThePillow(*[18, 38]) == 5\nassert my_solution.passThePillow(*[43, 13]) == 14\nassert my_solution.passThePillow(*[76, 23]) == 24\nassert my_solution.passThePillow(*[36, 20]) == 21\nassert my_solution.passThePillow(*[14, 20]) == 7\nassert my_solution.passThePillow(*[73, 27]) == 28\nassert my_solution.passThePillow(*[53, 46]) == 47\nassert my_solution.passThePillow(*[93, 22]) == 23\nassert my_solution.passThePillow(*[66, 48]) == 49\nassert my_solution.passThePillow(*[2, 341]) == 2\nassert my_solution.passThePillow(*[33, 218]) == 27\nassert my_solution.passThePillow(*[69, 81]) == 56\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2645", "questionFrontendId": "2582", "questionTitle": "Pass the Pillow", "stats": { "totalAccepted": "36.1K", "totalSubmission": "61.8K", "totalAcceptedRaw": 36114, "totalSubmissionRaw": 61773, "acRate": "58.5%" } }
LeetCode/2648
# Number of Ways to Earn Points There is a test that has `n` types of questions. You are given an integer `target` and a **0-indexed** 2D integer array `types` where `types[i] = [counti, marksi]` indicates that there are `counti` questions of the `ith` type, and each one of them is worth `marksi` points. Return *the number of ways you can earn **exactly*** `target` *points in the exam*. Since the answer may be too large, return it **modulo** `109 + 7`. **Note** that questions of the same type are indistinguishable. * For example, if there are `3` questions of the same type, then solving the `1st` and `2nd` questions is the same as solving the `1st` and `3rd` questions, or the `2nd` and `3rd` questions.   **Example 1:** ``` **Input:** target = 6, types = [[6,1],[3,2],[2,3]] **Output:** 7 **Explanation:** You can earn 6 points in one of the seven ways: - Solve 6 questions of the 0th type: 1 + 1 + 1 + 1 + 1 + 1 = 6 - Solve 4 questions of the 0th type and 1 question of the 1st type: 1 + 1 + 1 + 1 + 2 = 6 - Solve 2 questions of the 0th type and 2 questions of the 1st type: 1 + 1 + 2 + 2 = 6 - Solve 3 questions of the 0th type and 1 question of the 2nd type: 1 + 1 + 1 + 3 = 6 - Solve 1 question of the 0th type, 1 question of the 1st type and 1 question of the 2nd type: 1 + 2 + 3 = 6 - Solve 3 questions of the 1st type: 2 + 2 + 2 = 6 - Solve 2 questions of the 2nd type: 3 + 3 = 6 ``` **Example 2:** ``` **Input:** target = 5, types = [[50,1],[50,2],[50,5]] **Output:** 4 **Explanation:** You can earn 5 points in one of the four ways: - Solve 5 questions of the 0th type: 1 + 1 + 1 + 1 + 1 = 5 - Solve 3 questions of the 0th type and 1 question of the 1st type: 1 + 1 + 1 + 2 = 5 - Solve 1 questions of the 0th type and 2 questions of the 1st type: 1 + 2 + 2 = 5 - Solve 1 question of the 2nd type: 5 ``` **Example 3:** ``` **Input:** target = 18, types = [[6,1],[3,2],[2,3]] **Output:** 1 **Explanation:** You can only earn 18 points by answering all questions. ```   **Constraints:** * `1 <= target <= 1000` * `n == types.length` * `1 <= n <= 50` * `types[i].length == 2` * `1 <= counti, marksi <= 50` Please make sure your answer follows the type signature below: ```python3 class Solution: def waysToReachTarget(self, target: int, types: List[List[int]]) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.waysToReachTarget(*[6, [[6, 1], [3, 2], [2, 3]]]) == 7\nassert my_solution.waysToReachTarget(*[5, [[50, 1], [50, 2], [50, 5]]]) == 4\nassert my_solution.waysToReachTarget(*[18, [[6, 1], [3, 2], [2, 3]]]) == 1\nassert my_solution.waysToReachTarget(*[6, [[6, 1], [6, 1]]]) == 7\nassert my_solution.waysToReachTarget(*[6, [[1, 6], [1, 6]]]) == 2\nassert my_solution.waysToReachTarget(*[12, [[6, 6], [6, 6]]]) == 3\nassert my_solution.waysToReachTarget(*[494, [[50, 13], [50, 26], [50, 39]]]) == 140\nassert my_solution.waysToReachTarget(*[495, [[50, 13], [50, 26], [50, 39]]]) == 0\nassert my_solution.waysToReachTarget(*[493, [[50, 13], [50, 26], [50, 39]]]) == 0\nassert my_solution.waysToReachTarget(*[500, [[6, 1], [49, 2], [33, 3], [26, 4], [28, 5], [45, 6], [4, 7], [23, 8], [46, 9], [39, 10], [12, 11], [28, 12], [37, 13], [18, 14], [10, 15], [27, 16], [26, 17], [10, 18], [34, 19], [11, 20], [35, 21], [5, 22], [47, 23], [19, 24], [15, 25], [27, 26], [50, 27], [3, 28], [24, 29], [18, 30], [49, 31], [32, 32], [18, 33], [5, 34], [34, 35]]]) == 342808744\nassert my_solution.waysToReachTarget(*[500, [[50, 1], [50, 2], [50, 3], [50, 4], [50, 5], [50, 6], [50, 7], [50, 8], [50, 9], [50, 10], [50, 11], [50, 12], [50, 13], [50, 14], [50, 15], [50, 16], [50, 17], [50, 18], [50, 19], [50, 20], [50, 21], [50, 22], [50, 23], [50, 24], [50, 25], [50, 26], [50, 27], [50, 28], [50, 29], [50, 30], [50, 31], [50, 32], [50, 33], [50, 34], [50, 35]]]) == 556513829\nassert my_solution.waysToReachTarget(*[500, [[26, 1], [10, 2], [42, 3], [8, 4], [6, 5], [27, 6], [20, 7], [34, 8], [42, 9], [22, 10], [1, 11], [22, 12], [28, 13], [35, 14], [39, 15], [21, 16], [45, 17], [24, 18], [19, 19], [33, 20], [39, 21], [12, 22], [22, 23], [32, 24], [10, 25], [31, 26], [14, 27], [36, 28], [33, 29], [9, 30], [22, 31], [31, 32], [23, 33], [5, 34], [12, 35], [48, 36]]]) == 342947153\nassert my_solution.waysToReachTarget(*[500, [[50, 1], [50, 2], [50, 3], [50, 4], [50, 5], [50, 6], [50, 7], [50, 8], [50, 9], [50, 10], [50, 11], [50, 12], [50, 13], [50, 14], [50, 15], [50, 16], [50, 17], [50, 18], [50, 19], [50, 20], [50, 21], [50, 22], [50, 23], [50, 24], [50, 25], [50, 26], [50, 27], [50, 28], [50, 29], [50, 30], [50, 31], [50, 32], [50, 33], [50, 34], [50, 35], [50, 36]]]) == 446917244\nassert my_solution.waysToReachTarget(*[500, [[33, 1], [29, 2], [30, 3], [29, 4], [30, 5], [29, 6], [45, 7], [38, 8], [37, 9], [25, 10], [13, 11], [24, 12], [22, 13], [36, 14], [22, 15], [8, 16], [6, 17], [38, 18], [19, 19], [20, 20], [39, 21], [13, 22], [9, 23], [45, 24], [35, 25], [19, 26], [19, 27], [32, 28], [18, 29], [35, 30], [9, 31], [36, 32], [42, 33], [22, 34], [33, 35], [7, 36], [24, 37]]]) == 803934613\nassert my_solution.waysToReachTarget(*[500, [[50, 1], [50, 2], [50, 3], [50, 4], [50, 5], [50, 6], [50, 7], [50, 8], [50, 9], [50, 10], [50, 11], [50, 12], [50, 13], [50, 14], [50, 15], [50, 16], [50, 17], [50, 18], [50, 19], [50, 20], [50, 21], [50, 22], [50, 23], [50, 24], [50, 25], [50, 26], [50, 27], [50, 28], [50, 29], [50, 30], [50, 31], [50, 32], [50, 33], [50, 34], [50, 35], [50, 36], [50, 37]]]) == 664430727\nassert my_solution.waysToReachTarget(*[500, [[37, 1], [8, 2], [6, 3], [48, 4], [7, 5], [36, 6], [9, 7], [14, 8], [37, 9], [6, 10], [6, 11], [41, 12], [2, 13], [18, 14], [30, 15], [22, 16], [45, 17], [1, 18], [11, 19], [6, 20], [7, 21], [27, 22], [8, 23], [18, 24], [3, 25], [23, 26], [42, 27], [6, 28], [8, 29], [26, 30], [5, 31], [3, 32], [32, 33], [50, 34], [44, 35], [1, 36], [33, 37], [35, 38]]]) == 162497610\nassert my_solution.waysToReachTarget(*[500, [[50, 1], [50, 2], [50, 3], [50, 4], [50, 5], [50, 6], [50, 7], [50, 8], [50, 9], [50, 10], [50, 11], [50, 12], [50, 13], [50, 14], [50, 15], [50, 16], [50, 17], [50, 18], [50, 19], [50, 20], [50, 21], [50, 22], [50, 23], [50, 24], [50, 25], [50, 26], [50, 27], [50, 28], [50, 29], [50, 30], [50, 31], [50, 32], [50, 33], [50, 34], [50, 35], [50, 36], [50, 37], [50, 38]]]) == 86818393\nassert my_solution.waysToReachTarget(*[500, [[5, 1], [35, 2], [3, 3], [8, 4], [27, 5], [15, 6], [7, 7], [25, 8], [11, 9], [18, 10], [8, 11], [39, 12], [50, 13], [4, 14], [49, 15], [13, 16], [34, 17], [24, 18], [21, 19], [48, 20], [1, 21], [12, 22], [22, 23], [17, 24], [19, 25], [29, 26], [18, 27], [25, 28], [35, 29], [24, 30], [24, 31], [7, 32], [8, 33], [25, 34], [21, 35], [34, 36], [48, 37], [36, 38], [16, 39]]]) == 943634728\nassert my_solution.waysToReachTarget(*[500, [[50, 1], [50, 2], [50, 3], [50, 4], [50, 5], [50, 6], [50, 7], [50, 8], [50, 9], [50, 10], [50, 11], [50, 12], [50, 13], [50, 14], [50, 15], [50, 16], [50, 17], [50, 18], [50, 19], [50, 20], [50, 21], [50, 22], [50, 23], [50, 24], [50, 25], [50, 26], [50, 27], [50, 28], [50, 29], [50, 30], [50, 31], [50, 32], [50, 33], [50, 34], [50, 35], [50, 36], [50, 37], [50, 38], [50, 39]]]) == 632112070\nassert my_solution.waysToReachTarget(*[500, [[24, 1], [31, 2], [12, 3], [2, 4], [29, 5], [6, 6], [18, 7], [34, 8], [50, 9], [3, 10], [14, 11], [5, 12], [5, 13], [1, 14], [34, 15], [23, 16], [10, 17], [48, 18], [50, 19], [25, 20], [9, 21], [9, 22], [32, 23], [35, 24], [43, 25], [39, 26], [23, 27], [28, 28], [12, 29], [15, 30], [15, 31], [40, 32], [20, 33], [20, 34], [15, 35], [49, 36], [32, 37], [8, 38], [20, 39], [38, 40]]]) == 141097726\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2648", "questionFrontendId": "2585", "questionTitle": "Number of Ways to Earn Points", "stats": { "totalAccepted": "6.1K", "totalSubmission": "9.3K", "totalAcceptedRaw": 6103, "totalSubmissionRaw": 9316, "acRate": "65.5%" } }
LeetCode/2650
# Split With Minimum Sum Given a positive integer `num`, split it into two non-negative integers `num1` and `num2` such that: * The concatenation of `num1` and `num2` is a permutation of `num`. + In other words, the sum of the number of occurrences of each digit in `num1` and `num2` is equal to the number of occurrences of that digit in `num`. * `num1` and `num2` can contain leading zeros. Return *the **minimum** possible sum of* `num1` *and* `num2`. **Notes:** * It is guaranteed that `num` does not contain any leading zeros. * The order of occurrence of the digits in `num1` and `num2` may differ from the order of occurrence of `num`.   **Example 1:** ``` **Input:** num = 4325 **Output:** 59 **Explanation:** We can split 4325 so that num1 is 24 and num2 is 35, giving a sum of 59. We can prove that 59 is indeed the minimal possible sum. ``` **Example 2:** ``` **Input:** num = 687 **Output:** 75 **Explanation:** We can split 687 so that num1 is 68 and num2 is 7, which would give an optimal sum of 75. ```   **Constraints:** * `10 <= num <= 109` Please make sure your answer follows the type signature below: ```python3 class Solution: def splitNum(self, num: int) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.splitNum(*[4325]) == 59\nassert my_solution.splitNum(*[687]) == 75\nassert my_solution.splitNum(*[10]) == 1\nassert my_solution.splitNum(*[11]) == 2\nassert my_solution.splitNum(*[12]) == 3\nassert my_solution.splitNum(*[13]) == 4\nassert my_solution.splitNum(*[14]) == 5\nassert my_solution.splitNum(*[15]) == 6\nassert my_solution.splitNum(*[16]) == 7\nassert my_solution.splitNum(*[17]) == 8\nassert my_solution.splitNum(*[18]) == 9\nassert my_solution.splitNum(*[19]) == 10\nassert my_solution.splitNum(*[20]) == 2\nassert my_solution.splitNum(*[21]) == 3\nassert my_solution.splitNum(*[22]) == 4\nassert my_solution.splitNum(*[23]) == 5\nassert my_solution.splitNum(*[24]) == 6\nassert my_solution.splitNum(*[25]) == 7\nassert my_solution.splitNum(*[26]) == 8\nassert my_solution.splitNum(*[27]) == 9\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2650", "questionFrontendId": "2578", "questionTitle": "Split With Minimum Sum", "stats": { "totalAccepted": "30.8K", "totalSubmission": "37.8K", "totalAcceptedRaw": 30786, "totalSubmissionRaw": 37771, "acRate": "81.5%" } }
LeetCode/2651
# Count Ways to Group Overlapping Ranges You are given a 2D integer array `ranges` where `ranges[i] = [starti, endi]` denotes that all integers between `starti` and `endi` (both **inclusive**) are contained in the `ith` range. You are to split `ranges` into **two** (possibly empty) groups such that: * Each range belongs to exactly one group. * Any two **overlapping** ranges must belong to the **same** group. Two ranges are said to be **overlapping** if there exists at least **one** integer that is present in both ranges. * For example, `[1, 3]` and `[2, 5]` are overlapping because `2` and `3` occur in both ranges. Return *the **total number** of ways to split* `ranges` *into two groups*. Since the answer may be very large, return it **modulo** `109 + 7`.   **Example 1:** ``` **Input:** ranges = [[6,10],[5,15]] **Output:** 2 **Explanation:** The two ranges are overlapping, so they must be in the same group. Thus, there are two possible ways: - Put both the ranges together in group 1. - Put both the ranges together in group 2. ``` **Example 2:** ``` **Input:** ranges = [[1,3],[10,20],[2,5],[4,8]] **Output:** 4 **Explanation:** Ranges [1,3], and [2,5] are overlapping. So, they must be in the same group. Again, ranges [2,5] and [4,8] are also overlapping. So, they must also be in the same group. Thus, there are four possible ways to group them: - All the ranges in group 1. - All the ranges in group 2. - Ranges [1,3], [2,5], and [4,8] in group 1 and [10,20] in group 2. - Ranges [1,3], [2,5], and [4,8] in group 2 and [10,20] in group 1. ```   **Constraints:** * `1 <= ranges.length <= 105` * `ranges[i].length == 2` * `0 <= starti <= endi <= 109` Please make sure your answer follows the type signature below: ```python3 class Solution: def countWays(self, ranges: List[List[int]]) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.countWays(*[[[6, 10], [5, 15]]]) == 2\nassert my_solution.countWays(*[[[1, 3], [10, 20], [2, 5], [4, 8]]]) == 4\nassert my_solution.countWays(*[[[0, 1]]]) == 2\nassert my_solution.countWays(*[[[0, 2], [2, 3]]]) == 2\nassert my_solution.countWays(*[[[1, 2], [1, 1], [0, 4]]]) == 2\nassert my_solution.countWays(*[[[0, 0], [8, 9], [12, 13], [1, 3]]]) == 16\nassert my_solution.countWays(*[[[5, 11], [20, 22], [1, 3], [21, 22], [11, 11]]]) == 8\nassert my_solution.countWays(*[[[4, 5], [10, 15], [21, 25], [27, 32], [6, 7], [11, 15]]]) == 32\nassert my_solution.countWays(*[[[5, 12], [16, 28], [32, 41], [7, 15], [17, 26], [41, 46], [1, 12]]]) == 8\nassert my_solution.countWays(*[[[34, 56], [28, 29], [12, 16], [11, 48], [28, 54], [22, 55], [28, 41], [41, 44]]]) == 2\nassert my_solution.countWays(*[[[6, 6], [20, 37], [53, 56], [60, 62], [6, 19], [32, 37], [55, 57], [70, 71], [0, 19]]]) == 32\nassert my_solution.countWays(*[[[3, 10], [15, 19], [22, 28], [34, 40], [54, 54], [55, 56], [77, 77], [77, 88], [97, 98], [2, 7]]]) == 256\nassert my_solution.countWays(*[[[0, 1], [28, 30], [37, 47], [66, 67], [70, 71], [90, 99], [113, 114], [10, 16], [28, 34], [40, 51], [59, 62]]]) == 512\nassert my_solution.countWays(*[[[30, 54], [74, 79], [29, 37], [126, 127], [36, 56], [116, 133], [15, 36], [82, 113], [7, 30], [89, 137], [22, 51], [74, 129]]]) == 4\nassert my_solution.countWays(*[[[10, 11], [25, 28], [29, 34], [49, 51], [58, 66], [77, 84], [91, 91], [100, 104], [120, 121], [127, 128], [151, 151], [156, 168], [0, 8]]]) == 8192\nassert my_solution.countWays(*[[[8, 10], [25, 28], [40, 45], [56, 57], [67, 75], [75, 89], [91, 96], [109, 110], [122, 127], [146, 148], [157, 157], [166, 177], [189, 190], [11, 11]]]) == 8192\nassert my_solution.countWays(*[[[17, 22], [30, 43], [54, 55], [69, 85], [97, 110], [112, 125], [147, 151], [167, 173], [181, 183], [206, 212], [7, 15], [41, 42], [45, 61], [69, 86], [100, 100]]]) == 2048\nassert my_solution.countWays(*[[[1, 15], [20, 34], [36, 44], [52, 55], [75, 83], [87, 99], [110, 117], [120, 125], [148, 148], [155, 157], [181, 186], [187, 189], [210, 213], [230, 232], [240, 254], [13, 15]]]) == 32768\nassert my_solution.countWays(*[[[6, 29], [63, 65], [85, 98], [134, 156], [184, 200], [206, 208], [268, 276], [3, 35], [48, 77], [84, 119], [161, 162], [165, 190], [225, 229], [262, 282], [8, 38], [42, 57], [90, 120]]]) == 512\nassert my_solution.countWays(*[[[21, 22], [27, 36], [54, 80], [93, 108], [113, 119], [137, 149], [173, 183], [210, 211], [233, 241], [257, 267], [271, 284], [300, 309], [10, 23], [49, 51], [68, 77], [97, 99], [128, 132], [142, 146]]]) == 16384\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2651", "questionFrontendId": "2580", "questionTitle": "Count Ways to Group Overlapping Ranges", "stats": { "totalAccepted": "5.4K", "totalSubmission": "14.8K", "totalAcceptedRaw": 5381, "totalSubmissionRaw": 14834, "acRate": "36.3%" } }
LeetCode/2714
# Left and Right Sum Differences Given a **0-indexed** integer array `nums`, find a **0-indexed** integer array `answer` where: * `answer.length == nums.length`. * `answer[i] = |leftSum[i] - rightSum[i]|`. Where: * `leftSum[i]` is the sum of elements to the left of the index `i` in the array `nums`. If there is no such element, `leftSum[i] = 0`. * `rightSum[i]` is the sum of elements to the right of the index `i` in the array `nums`. If there is no such element, `rightSum[i] = 0`. Return *the array* `answer`.   **Example 1:** ``` **Input:** nums = [10,4,8,3] **Output:** [15,1,11,22] **Explanation:** The array leftSum is [0,10,14,22] and the array rightSum is [15,11,3,0]. The array answer is [|0 - 15|,|10 - 11|,|14 - 3|,|22 - 0|] = [15,1,11,22]. ``` **Example 2:** ``` **Input:** nums = [1] **Output:** [0] **Explanation:** The array leftSum is [0] and the array rightSum is [0]. The array answer is [|0 - 0|] = [0]. ```   **Constraints:** * `1 <= nums.length <= 1000` * `1 <= nums[i] <= 105` Please make sure your answer follows the type signature below: ```python3 class Solution: def leftRightDifference(self, nums: List[int]) -> List[int]: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.leftRightDifference(*[[10, 4, 8, 3]]) == [15, 1, 11, 22]\nassert my_solution.leftRightDifference(*[[1]]) == [0]\nassert my_solution.leftRightDifference(*[[7, 3, 21, 31]]) == [55, 45, 21, 31]\nassert my_solution.leftRightDifference(*[[33, 17, 58, 42]]) == [117, 67, 8, 108]\nassert my_solution.leftRightDifference(*[[8, 28, 35, 21, 13, 21, 72, 35, 52, 74]]) == [351, 315, 252, 196, 162, 128, 35, 72, 159, 285]\nassert my_solution.leftRightDifference(*[[25, 65, 77, 1, 73, 32, 43, 68, 8]]) == [367, 277, 135, 57, 17, 122, 197, 308, 384]\nassert my_solution.leftRightDifference(*[[50, 57, 42]]) == [99, 8, 107]\nassert my_solution.leftRightDifference(*[[70, 18, 64, 12, 21, 21, 78, 36, 58, 88, 58, 99, 26, 92, 91, 53, 10, 24, 25, 20, 107, 92, 73, 63, 51, 65, 87, 6, 17, 103, 111, 32, 14, 42, 46, 65, 43, 9, 75, 76, 25, 96, 46, 85, 19, 29, 88, 2, 5, 24, 60, 26, 76, 24, 110, 96, 82, 97, 97, 72, 35, 21, 77, 82, 30, 94, 55, 76, 94, 112, 105, 51, 82, 3, 89, 52, 96, 72, 27, 59, 57, 97, 6, 46, 88, 112, 41, 110, 52]]) == [5151, 5063, 4981, 4905, 4872, 4830, 4731, 4617, 4523, 4377, 4231, 4074, 3949, 3831, 3648, 3504, 3441, 3407, 3358, 3313, 3186, 2987, 2822, 2686, 2572, 2456, 2304, 2211, 2188, 2068, 1854, 1711, 1665, 1609, 1521, 1410, 1302, 1250, 1166, 1015, 914, 793, 651, 520, 416, 368, 251, 161, 154, 125, 41, 45, 147, 247, 381, 587, 765, 944, 1138, 1307, 1414, 1470, 1568, 1727, 1839, 1963, 2112, 2243, 2413, 2619, 2836, 2992, 3125, 3210, 3302, 3443, 3591, 3759, 3858, 3944, 4060, 4214, 4317, 4369, 4503, 4703, 4856, 5007, 5169]\nassert my_solution.leftRightDifference(*[[182, 15, 65, 7, 21, 247, 274, 38, 250, 94, 4, 282, 219, 182, 16, 241, 312, 81, 207, 330, 306, 166, 82, 290, 7, 317, 218, 251, 198, 171, 247, 56, 330, 240, 261, 67, 65, 138, 181, 308, 26, 59, 150, 137, 244, 136, 116, 272, 138, 34, 72, 328, 312, 159, 32, 283, 6, 234, 280, 46, 289, 48, 218, 234, 284, 195, 188, 181, 259, 145, 96, 298, 322, 213, 154, 278, 292, 315, 191, 177, 228, 291, 204, 310, 266, 309, 178, 7, 327, 319, 295, 136, 215, 260, 259, 35, 248]]) == [18112, 17915, 17835, 17763, 17735, 17467, 16946, 16634, 16346, 16002, 15904, 15618, 15117, 14716, 14518, 14261, 13708, 13315, 13027, 12490, 11854, 11382, 11134, 10762, 10465, 10141, 9606, 9137, 8688, 8319, 7901, 7598, 7212, 6642, 6141, 5813, 5681, 5478, 5159, 4670, 4336, 4251, 4042, 3755, 3374, 2994, 2742, 2354, 1944, 1772, 1666, 1266, 626, 155, 36, 351, 640, 880, 1394, 1720, 2055, 2392, 2658, 3110, 3628, 4107, 4490, 4859, 5299, 5703, 5944, 6338, 6958, 7493, 7860, 8292, 8862, 9469, 9975, 10343, 10748, 11267, 11762, 12276, 12852, 13427, 13914, 14099, 14433, 15079, 15693, 16124, 16475, 16950, 17469, 17763, 18046]\nassert my_solution.leftRightDifference(*[[680, 753, 287, 496, 166, 300, 126, 96, 537, 394, 634, 270, 72, 688, 158, 534, 746, 520, 649, 318, 632, 592, 732, 670, 291, 151, 128, 680, 158, 631, 196, 707, 439, 534, 666, 22, 626, 299, 121, 346, 11, 426, 459, 748, 551, 561, 110, 192, 103, 165, 111, 138, 665, 289, 12, 99, 201, 432, 653, 239, 418, 575]]) == [23523, 22090, 21050, 20267, 19605, 19139, 18713, 18491, 17858, 16927, 15899, 14995, 14653, 13893, 13047, 12355, 11075, 9809, 8640, 7673, 6723, 5499, 4175, 2773, 1812, 1370, 1091, 283, 555, 1344, 2171, 3074, 4220, 5193, 6393, 7081, 7729, 8654, 9074, 9541, 9898, 10335, 11220, 12427, 13726, 14838, 15509, 15811, 16106, 16374, 16650, 16899, 17702, 18656, 18957, 19068, 19368, 20001, 21086, 21978, 22635, 23628]\nassert my_solution.leftRightDifference(*[[441, 751, 571, 815, 535, 818, 301, 106, 633, 734, 836, 515, 673, 559, 464, 644, 305, 337, 242, 421, 342, 690, 152, 739, 816, 901, 529, 851, 213, 90, 640, 301, 747, 735, 536, 428, 816, 442, 156, 660, 680, 617, 659, 676, 791, 673, 569, 414, 254, 185, 42, 21, 708, 798, 22, 40, 18, 433, 743, 6, 103, 697, 372, 824, 382, 365, 500, 725, 441, 839, 22, 439, 320, 738, 769, 290, 243, 247]]) == [37709, 36517, 35195, 33809, 32459, 31106, 29987, 29580, 28841, 27474, 25904, 24553, 23365, 22133, 21110, 20002, 19053, 18411, 17832, 17169, 16406, 15374, 14532, 13641, 12086, 10369, 8939, 7559, 6495, 6192, 5462, 4521, 3473, 1991, 720, 244, 1488, 2746, 3344, 4160, 5500, 6797, 8073, 9408, 10875, 12339, 13581, 14564, 15232, 15671, 15898, 15961, 16690, 18196, 19016, 19078, 19136, 19587, 20763, 21512, 21621, 22421, 23490, 24686, 25892, 26639, 27504, 28729, 29895, 31175, 32036, 32497, 33256, 34314, 35821, 36880, 37413, 37903]\nassert my_solution.leftRightDifference(*[[147, 231, 162, 37, 293, 160, 68, 232, 232, 130, 309, 211, 4, 58, 175, 296, 222, 161, 190, 283, 137, 227, 284, 134, 170, 13, 275, 113, 148, 198, 33, 260, 6, 154, 166, 234, 175, 301, 24, 205, 115, 4, 40, 105, 311, 221, 247, 34, 190, 23, 289, 16, 129, 68, 12, 32, 111, 49, 287, 168, 111, 222, 20, 212, 140, 307, 4, 262, 228, 161, 200, 108, 206]]) == [11343, 10965, 10572, 10373, 10043, 9590, 9362, 9062, 8598, 8236, 7797, 7277, 7062, 7000, 6767, 6296, 5778, 5395, 5044, 4571, 4151, 3787, 3276, 2858, 2554, 2371, 2083, 1695, 1434, 1088, 857, 564, 298, 138, 182, 582, 991, 1467, 1792, 2021, 2341, 2460, 2504, 2649, 3065, 3597, 4065, 4346, 4570, 4783, 5095, 5400, 5545, 5742, 5822, 5866, 6009, 6169, 6505, 6960, 7239, 7572, 7814, 8046, 8398, 8845, 9156, 9422, 9912, 10301, 10662, 10970, 11284]\nassert my_solution.leftRightDifference(*[[140, 133, 120, 129, 97, 167, 164, 61, 90, 123, 90, 64, 141, 122, 122, 122, 46, 94, 67, 42, 11, 129, 50, 39, 119, 42, 21, 109, 44, 165, 124, 23, 125, 82, 66, 183, 26, 183, 115, 170, 121, 10, 91, 52, 49, 71, 53, 23, 60, 25, 103, 59, 32, 87, 44, 113, 65, 51, 152, 27, 133, 48, 179, 144, 74, 59, 166, 24, 87]]) == [6022, 5749, 5496, 5247, 5021, 4757, 4426, 4201, 4050, 3837, 3624, 3470, 3265, 3002, 2758, 2514, 2346, 2206, 2045, 1936, 1883, 1743, 1564, 1475, 1317, 1156, 1093, 963, 810, 601, 312, 165, 17, 190, 338, 587, 796, 1005, 1303, 1588, 1879, 2010, 2111, 2254, 2355, 2475, 2599, 2675, 2758, 2843, 2971, 3133, 3224, 3343, 3474, 3631, 3809, 3925, 4128, 4307, 4467, 4648, 4875, 5198, 5416, 5549, 5774, 5964, 6075]\nassert my_solution.leftRightDifference(*[[8, 19, 10, 6, 26, 4, 2, 29, 34, 26, 18, 3, 29, 24, 31, 24, 26, 1, 24, 8, 5, 6, 30, 21, 6, 30, 35, 32, 11, 14, 18, 8, 14, 21, 11, 22, 16, 32, 1, 7, 24, 36, 23, 37, 16, 21, 9, 11, 20, 11, 6, 19, 32, 29, 12, 29, 17, 9, 1, 29, 30, 36, 5, 31, 26, 18, 6, 12, 7, 27, 17, 29, 3, 26, 14, 37, 37, 24, 15, 12, 1, 37, 19, 11, 18, 33, 6, 37, 15, 23, 12, 18]]) == [1717, 1690, 1661, 1645, 1613, 1583, 1577, 1546, 1483, 1423, 1379, 1358, 1326, 1273, 1218, 1163, 1113, 1086, 1061, 1029, 1016, 1005, 969, 918, 891, 855, 790, 723, 680, 655, 623, 597, 575, 540, 508, 475, 437, 389, 356, 348, 317, 257, 198, 138, 85, 48, 18, 2, 33, 64, 81, 106, 157, 218, 259, 300, 346, 372, 382, 412, 471, 537, 578, 614, 671, 715, 739, 757, 776, 810, 854, 900, 932, 961, 1001, 1052, 1126, 1187, 1226, 1253, 1266, 1304, 1360, 1390, 1419, 1470, 1509, 1552, 1604, 1642, 1677, 1707]\nassert my_solution.leftRightDifference(*[[420, 510, 361, 432, 509, 379, 416, 591, 376, 418, 402, 226, 244, 411, 92, 75, 137, 351, 224, 450, 219, 326, 199, 154, 23, 248, 219, 467, 403, 1]]) == [8863, 7933, 7062, 6269, 5328, 4440, 3645, 2638, 1671, 877, 57, 571, 1041, 1696, 2199, 2366, 2578, 3066, 3641, 4315, 4984, 5529, 6054, 6407, 6584, 6855, 7322, 8008, 8878, 9282]\nassert my_solution.leftRightDifference(*[[777, 582, 830, 666, 84, 797, 798, 600, 841, 469, 605, 12, 205, 391, 877, 622, 287, 13, 553, 506, 192, 271, 501, 816, 889, 162, 390, 342, 279, 145, 3, 168, 84, 469, 304, 372, 7, 276, 587, 459, 441, 890, 852]]) == [18637, 17278, 15866, 14370, 13620, 12739, 11144, 9746, 8305, 6995, 5921, 5304, 5087, 4491, 3223, 1724, 815, 515, 51, 1110, 1808, 2271, 3043, 4360, 6065, 7116, 7668, 8400, 9021, 9445, 9593, 9764, 10016, 10569, 11342, 12018, 12397, 12680, 13543, 14589, 15489, 16820, 18562]\nassert my_solution.leftRightDifference(*[[108, 150, 12, 40, 97, 39, 183, 26, 59, 63, 177, 97, 20, 71, 73, 100, 50, 129, 81, 61, 28, 40, 118, 84, 86, 114, 145, 90, 59, 154, 33, 76, 39, 21, 34, 130, 109, 169, 148, 63, 168, 62, 122, 156, 29, 104, 130, 128, 15, 122, 33, 6, 143, 16, 179, 110, 109, 45, 88, 173, 67, 37, 59, 88, 25, 53, 162, 2, 124, 35, 141, 174]]) == [6173, 5915, 5753, 5701, 5564, 5428, 5206, 4997, 4912, 4790, 4550, 4276, 4159, 4068, 3924, 3751, 3601, 3422, 3212, 3070, 2981, 2913, 2755, 2553, 2383, 2183, 1924, 1689, 1540, 1327, 1140, 1031, 916, 856, 801, 637, 398, 120, 197, 408, 639, 869, 1053, 1331, 1516, 1649, 1883, 2141, 2284, 2421, 2576, 2615, 2764, 2923, 3118, 3407, 3626, 3780, 3913, 4174, 4414, 4518, 4614, 4761, 4874, 4952, 5167, 5331, 5457, 5616, 5792, 6107]\nassert my_solution.leftRightDifference(*[[18, 632, 942, 231, 247, 267, 741, 320, 844, 276, 578, 659, 96, 697, 801, 892, 752, 948, 176, 92, 469, 595, 642, 686, 729, 872, 547, 443, 50, 746, 13, 102, 548, 158, 155, 73, 114, 77, 204, 544, 484, 565, 190, 310, 210, 726, 347, 2, 665, 800, 749, 751, 600, 580, 942, 198, 886, 15, 607, 439, 725, 279, 345, 183, 104, 696, 699, 631, 562, 654, 79, 518, 77, 469, 806, 525, 487, 84, 707, 880, 21, 463, 696, 212, 877, 697, 538, 207, 832, 793, 906, 666, 376, 745, 906, 650, 861, 804, 113, 403, 541, 37, 891, 756, 612, 378, 623, 414, 729, 737, 132, 891, 526, 876, 93, 513, 633, 441, 583, 771, 616, 880, 713]]) == [62686, 62036, 60462, 59289, 58811, 58297, 57289, 56228, 55064, 53944, 53090, 51853, 51098, 50305, 48807, 47114, 45470, 43770, 42646, 42378, 41817, 40753, 39516, 38188, 36773, 35172, 33753, 32763, 32270, 31474, 30715, 30600, 29950, 29244, 28931, 28703, 28516, 28325, 28044, 27296, 26268, 25219, 24464, 23964, 23444, 22508, 21435, 21086, 20419, 18954, 17405, 15905, 14554, 13374, 11852, 10712, 9628, 8727, 8105, 7059, 5895, 4891, 4267, 3739, 3452, 2652, 1257, 73, 1266, 2482, 3215, 3812, 4407, 4953, 6228, 7559, 8571, 9142, 9933, 11520, 12421, 12905, 14064, 14972, 16061, 17635, 18870, 19615, 20654, 22279, 23978, 25550, 26592, 27713, 29364, 30920, 32431, 34096, 35013, 35529, 36473, 37051, 37979, 39626, 40994, 41984, 42985, 44022, 45165, 46631, 47500, 48523, 49940, 51342, 52311, 52917, 54063, 55137, 56161, 57515, 58902, 60398, 61991]\nassert my_solution.leftRightDifference(*[[14, 13, 17, 14, 12, 15, 6, 32, 11, 14, 17, 23, 33, 8, 27, 19, 7, 10, 12, 14, 14, 24, 18, 15, 9, 14, 19, 18, 15, 20, 18, 9, 26, 29, 26, 21, 7, 13, 3, 10, 9, 15, 12, 30, 18, 31, 10, 23, 1, 32, 26, 5, 30, 25, 2, 17, 26, 17, 20, 19, 24, 31, 24, 1, 18, 25, 29, 17, 9, 3, 29, 23, 17, 18, 18, 18, 30, 8, 33, 19, 19, 24, 26, 25, 9, 31, 1, 29, 29, 29, 19, 4, 11, 7, 24, 12, 24, 14, 30, 28, 11, 11, 29, 18, 2, 6, 32, 27, 12, 17, 3, 31, 15, 18, 18, 2, 27, 24, 6, 21, 30, 29, 8, 23, 18, 6, 14, 21, 2, 32, 32, 33, 16, 29, 28, 17, 20, 6, 26, 6, 23, 27, 17, 16, 4, 28, 5, 27, 13, 7, 23, 27, 11, 5, 16, 20, 16, 27, 5, 12, 24, 7, 13, 13, 2, 4, 25, 9, 19, 33, 23, 13, 26, 22, 24, 13, 20, 6, 16, 8, 26, 8, 1, 1, 2, 25, 7, 4, 31, 5, 30, 1, 9, 27, 14, 23, 3, 28, 19, 6, 3, 28, 31, 5, 2, 19, 26, 27, 3, 23, 10, 20, 33, 8, 6, 28, 12, 30, 6, 21, 14, 31, 11, 14, 6, 12, 17, 17, 2, 27, 30, 28, 24, 20, 4, 15, 22, 13, 23, 31, 25, 3, 17, 9, 14, 4, 7, 15, 10, 25, 7, 6, 4, 9, 14, 17, 10, 28, 10, 18, 18, 3, 24, 14, 11, 13, 32, 31, 32, 12, 24, 9, 32, 8, 20, 33, 5, 30, 20, 26, 30, 30, 32, 31, 33, 23, 4, 29, 22, 8, 8, 11, 21, 9, 2, 19, 30, 27, 10, 27, 22, 23, 14, 18, 7, 31, 3, 32, 25, 21, 22, 26, 14, 1, 21, 29, 31, 28, 2, 4, 16, 33, 3, 6, 22, 15, 24, 32, 14, 18, 23, 27, 8, 27, 25, 32, 9, 18, 2, 26, 15, 3, 2, 33, 6, 11, 27, 7, 5, 7, 26, 13, 8, 32, 30, 23, 2, 12, 12, 19, 20, 28, 8, 24, 14, 2, 22, 26, 1, 14, 27, 22, 26, 25, 21, 21, 16, 21, 32, 5, 10, 29, 33, 11, 33, 19, 29, 20, 8, 12, 13, 28, 9, 12, 3, 1, 17, 22, 1, 27, 18, 31, 9, 6, 14, 32, 28, 19, 24, 32, 16, 12, 16, 21, 14, 26, 5, 22, 6, 15, 20, 16, 15, 32, 27, 19, 12, 22, 9, 33, 17, 4, 4, 32, 11, 12, 20, 33, 1, 13, 32, 19, 33, 30, 32, 8, 10, 1, 23, 6, 28, 19, 20, 12, 10, 20, 22, 29, 5, 7]]) == [8034, 8007, 7977, 7946, 7920, 7893, 7872, 7834, 7791, 7766, 7735, 7695, 7639, 7598, 7563, 7517, 7491, 7474, 7452, 7426, 7398, 7360, 7318, 7285, 7261, 7238, 7205, 7168, 7135, 7100, 7062, 7035, 7000, 6945, 6890, 6843, 6815, 6795, 6779, 6766, 6747, 6723, 6696, 6654, 6606, 6557, 6516, 6483, 6459, 6426, 6368, 6337, 6302, 6247, 6220, 6201, 6158, 6115, 6078, 6039, 5996, 5941, 5886, 5861, 5842, 5799, 5745, 5699, 5673, 5661, 5629, 5577, 5537, 5502, 5466, 5430, 5382, 5344, 5303, 5251, 5213, 5170, 5120, 5069, 5035, 4995, 4963, 4933, 4875, 4817, 4769, 4746, 4731, 4713, 4682, 4646, 4610, 4572, 4528, 4470, 4431, 4409, 4369, 4322, 4302, 4294, 4256, 4197, 4158, 4129, 4109, 4075, 4029, 3996, 3960, 3940, 3911, 3860, 3830, 3803, 3752, 3693, 3656, 3625, 3584, 3560, 3540, 3505, 3482, 3448, 3384, 3319, 3270, 3225, 3168, 3123, 3086, 3060, 3028, 2996, 2967, 2917, 2873, 2840, 2820, 2788, 2755, 2723, 2683, 2663, 2633, 2583, 2545, 2529, 2508, 2472, 2436, 2393, 2361, 2344, 2308, 2277, 2257, 2231, 2216, 2210, 2181, 2147, 2119, 2067, 2011, 1975, 1936, 1888, 1842, 1805, 1772, 1746, 1724, 1700, 1666, 1632, 1623, 1621, 1618, 1591, 1559, 1548, 1513, 1477, 1442, 1411, 1401, 1365, 1324, 1287, 1261, 1230, 1183, 1158, 1149, 1118, 1059, 1023, 1016, 995, 950, 897, 867, 841, 808, 778, 725, 684, 670, 636, 596, 554, 518, 491, 456, 411, 369, 344, 324, 306, 277, 243, 224, 195, 138, 80, 28, 16, 40, 59, 96, 131, 167, 221, 277, 305, 325, 351, 374, 392, 403, 425, 450, 485, 517, 530, 540, 553, 576, 607, 634, 672, 710, 738, 774, 795, 822, 860, 885, 909, 954, 1017, 1080, 1124, 1160, 1193, 1234, 1274, 1302, 1355, 1393, 1428, 1478, 1524, 1580, 1640, 1702, 1765, 1829, 1885, 1912, 1945, 1996, 2026, 2042, 2061, 2093, 2123, 2134, 2155, 2204, 2261, 2298, 2335, 2384, 2429, 2466, 2498, 2523, 2561, 2595, 2630, 2687, 2733, 2776, 2824, 2864, 2879, 2901, 2951, 3011, 3070, 3100, 3106, 3126, 3175, 3211, 3220, 3248, 3285, 3324, 3380, 3426, 3458, 3499, 3549, 3584, 3619, 3671, 3728, 3769, 3796, 3816, 3844, 3885, 3903, 3908, 3943, 3982, 3999, 4037, 4071, 4083, 4095, 4128, 4167, 4188, 4228, 4290, 4343, 4368, 4382, 4406, 4437, 4476, 4524, 4560, 4592, 4630, 4646, 4670, 4718, 4745, 4760, 4801, 4850, 4898, 4949, 4995, 5037, 5074, 5111, 5164, 5201, 5216, 5255, 5317, 5361, 5405, 5457, 5505, 5554, 5582, 5602, 5627, 5668, 5705, 5726, 5741, 5745, 5763, 5802, 5825, 5853, 5898, 5947, 5987, 6002, 6022, 6068, 6128, 6175, 6218, 6274, 6322, 6350, 6378, 6415, 6450, 6490, 6521, 6548, 6576, 6597, 6632, 6668, 6699, 6746, 6805, 6851, 6882, 6916, 6947, 6989, 7039, 7060, 7068, 7104, 7147, 7170, 7202, 7255, 7289, 7303, 7348, 7399, 7451, 7514, 7576, 7616, 7634, 7645, 7669, 7698, 7732, 7779, 7818, 7850, 7872, 7902, 7944, 7995, 8029, 8041]\nassert my_solution.leftRightDifference(*[[1, 8, 20, 25, 11, 1, 26, 19, 11, 25, 8, 14, 26, 24, 27, 23, 14, 22, 17, 11, 17, 15, 9, 3, 9, 10, 1, 12, 11, 18, 19, 13, 17, 19, 17, 20, 2, 14, 11, 7, 17, 10, 14, 15, 18, 22, 25, 13, 4, 26, 22, 20, 27, 13, 17, 19, 24, 20, 1, 15, 1, 19, 21, 18, 5, 23, 10, 24, 26, 12, 22, 12, 2, 26, 16, 7, 25, 17, 12, 22, 27, 4, 26, 5, 17, 25, 20, 12, 15, 14, 6, 12, 1, 16, 27, 12, 15, 23, 17, 5, 6, 23, 25, 28, 14, 21, 14, 23, 10, 22, 5, 6, 21, 20, 24, 17, 25, 18, 5, 12, 15, 28, 14, 28, 9, 15, 17, 26, 6, 19, 20, 24, 28, 19, 4, 22, 2, 17, 13, 15, 3, 26, 6, 7, 24, 16, 27, 7, 9, 23, 17, 10, 4, 3, 12, 9, 13, 2, 23, 9, 17, 26, 21, 25, 13, 25, 15, 1, 23, 24, 1, 2, 20, 16, 10, 26, 26, 22, 15, 15, 13, 11, 10, 6, 12, 19, 28, 15, 18, 9, 8, 9, 18, 22, 17, 3, 16, 9, 1, 21, 18, 13, 16, 7]]) == [3129, 3120, 3092, 3047, 3011, 2999, 2972, 2927, 2897, 2861, 2828, 2806, 2766, 2716, 2665, 2615, 2578, 2542, 2503, 2475, 2447, 2415, 2391, 2379, 2367, 2348, 2337, 2324, 2301, 2272, 2235, 2203, 2173, 2137, 2101, 2064, 2042, 2026, 2001, 1983, 1959, 1932, 1908, 1879, 1846, 1806, 1759, 1721, 1704, 1674, 1626, 1584, 1537, 1497, 1467, 1431, 1388, 1344, 1323, 1307, 1291, 1271, 1231, 1192, 1169, 1141, 1108, 1074, 1024, 986, 952, 918, 904, 876, 834, 811, 779, 737, 708, 674, 625, 594, 564, 533, 511, 469, 424, 392, 365, 336, 316, 298, 285, 268, 225, 186, 159, 121, 81, 59, 48, 19, 29, 82, 124, 159, 194, 231, 264, 296, 323, 334, 361, 402, 446, 487, 529, 572, 595, 612, 639, 682, 724, 766, 803, 827, 859, 902, 934, 959, 998, 1042, 1094, 1141, 1164, 1190, 1214, 1233, 1263, 1291, 1309, 1338, 1370, 1383, 1414, 1454, 1497, 1531, 1547, 1579, 1619, 1646, 1660, 1667, 1682, 1703, 1725, 1740, 1765, 1797, 1823, 1866, 1913, 1959, 1997, 2035, 2075, 2091, 2115, 2162, 2187, 2190, 2212, 2248, 2274, 2310, 2362, 2410, 2447, 2477, 2505, 2529, 2550, 2566, 2584, 2615, 2662, 2705, 2738, 2765, 2782, 2799, 2826, 2866, 2905, 2925, 2944, 2969, 2979, 3001, 3040, 3071, 3100, 3123]\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2714", "questionFrontendId": "2574", "questionTitle": "Left and Right Sum Differences", "stats": { "totalAccepted": "13.6K", "totalSubmission": "16.2K", "totalAcceptedRaw": 13571, "totalSubmissionRaw": 16194, "acRate": "83.8%" } }
LeetCode/2713
# Find the Divisibility Array of a String You are given a **0-indexed** string `word` of length `n` consisting of digits, and a positive integer `m`. The **divisibility array** `div` of `word` is an integer array of length `n` such that: * `div[i] = 1` if the **numeric value** of `word[0,...,i]` is divisible by `m`, or * `div[i] = 0` otherwise. Return *the divisibility array of*`word`.   **Example 1:** ``` **Input:** word = "998244353", m = 3 **Output:** [1,1,0,0,0,1,1,0,0] **Explanation:** There are only 4 prefixes that are divisible by 3: "9", "99", "998244", and "9982443". ``` **Example 2:** ``` **Input:** word = "1010", m = 10 **Output:** [0,1,0,1] **Explanation:** There are only 2 prefixes that are divisible by 10: "10", and "1010". ```   **Constraints:** * `1 <= n <= 105` * `word.length == n` * `word` consists of digits from `0` to `9` * `1 <= m <= 109` Please make sure your answer follows the type signature below: ```python3 class Solution: def divisibilityArray(self, word: str, m: int) -> List[int]: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.divisibilityArray(*['998244353', 3]) == [1, 1, 0, 0, 0, 1, 1, 0, 0]\nassert my_solution.divisibilityArray(*['1010', 10]) == [0, 1, 0, 1]\nassert my_solution.divisibilityArray(*['529282143571', 4]) == [0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0]\nassert my_solution.divisibilityArray(*['86217457695827338571', 8]) == [1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\nassert my_solution.divisibilityArray(*['557935154', 5]) == [1, 1, 0, 0, 0, 1, 0, 1, 0]\nassert my_solution.divisibilityArray(*['4868438856666666', 6]) == [0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1]\nassert my_solution.divisibilityArray(*['50133106238031313', 3]) == [0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0]\nassert my_solution.divisibilityArray(*['18954947', 9]) == [0, 1, 1, 0, 1, 1, 0, 0]\nassert my_solution.divisibilityArray(*['18585981675', 9]) == [0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1]\nassert my_solution.divisibilityArray(*['8917171717276217174131', 17]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\nassert my_solution.divisibilityArray(*['91221181269244172125025075166510211202115152121212341281327', 21]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\nassert my_solution.divisibilityArray(*['7868205589194669874752725752302277383438913984791442994468197914214982419363653138241991147060048767', 7]) == [1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0]\nassert my_solution.divisibilityArray(*['1846144763121714446244534222231', 4]) == [0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]\nassert my_solution.divisibilityArray(*['1616412162147459716167458879161697161616161616169716', 16]) == [0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0]\nassert my_solution.divisibilityArray(*['99279188694541449102636980112687808869272736870543', 9]) == [1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1]\nassert my_solution.divisibilityArray(*['4065582576255570359135118255554163128235573295923545700491253287387', 5]) == [0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]\nassert my_solution.divisibilityArray(*['913171304401315412211278171271512225417127194015111276212919174061222302198217122291222212122252190131501919127664122251380201229125461341250019170171512', 2]) == [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]\nassert my_solution.divisibilityArray(*['641770318471366266679729826266679777211350732329811266679745308703298458572010861577626667968134562136326667976028761918809582469329982666796698426667978152666797884951266679774262666797857121803678266679750689', 266679793]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\nassert my_solution.divisibilityArray(*['576800583845489999997103018935926636901851801756528499999965070034732345369623399999997028720306907497957049999996947980048974057753028962619575676872761308199357299999954163688537365570631382714715664981969999996128389999997629868330', 999999781]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\nassert my_solution.divisibilityArray(*['6224816282262828286517286222831242828284024282620288020281720226282828127407172828282842478132828691328282828622721622924643671528283520127352028820282828282142128288202872132528282828721365001472192828212528282822695142521286222262828273166228695422282042462272142419117288202872128424226289192872128522128523919287021127282828282828289198515285075882334894340535652528127281819577189883523424491528461828284242828283252818441172194152891962228205212841481122628282', 28]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2713", "questionFrontendId": "2575", "questionTitle": "Find the Divisibility Array of a String", "stats": { "totalAccepted": "8.5K", "totalSubmission": "25.5K", "totalAcceptedRaw": 8520, "totalSubmissionRaw": 25479, "acRate": "33.4%" } }
LeetCode/2712
# Find the Maximum Number of Marked Indices You are given a **0-indexed** integer array `nums`. Initially, all of the indices are unmarked. You are allowed to make this operation any number of times: * Pick two **different unmarked** indices `i` and `j` such that `2 * nums[i] <= nums[j]`, then mark `i` and `j`. Return *the maximum possible number of marked indices in `nums` using the above operation any number of times*.   **Example 1:** ``` **Input:** nums = [3,5,2,4] **Output:** 2 **Explanation:** In the first operation: pick i = 2 and j = 1, the operation is allowed because 2 * nums[2] <= nums[1]. Then mark index 2 and 1. It can be shown that there's no other valid operation so the answer is 2. ``` **Example 2:** ``` **Input:** nums = [9,2,5,4] **Output:** 4 **Explanation:** In the first operation: pick i = 3 and j = 0, the operation is allowed because 2 * nums[3] <= nums[0]. Then mark index 3 and 0. In the second operation: pick i = 1 and j = 2, the operation is allowed because 2 * nums[1] <= nums[2]. Then mark index 1 and 2. Since there is no other operation, the answer is 4. ``` **Example 3:** ``` **Input:** nums = [7,6,8] **Output:** 0 **Explanation:** There is no valid operation to do, so the answer is 0. ```   **Constraints:** * `1 <= nums.length <= 105` * `1 <= nums[i] <= 109`   .spoilerbutton {display:block; border:dashed; padding: 0px 0px; margin:10px 0px; font-size:150%; font-weight: bold; color:#000000; background-color:cyan; outline:0; } .spoiler {overflow:hidden;} .spoiler > div {-webkit-transition: all 0s ease;-moz-transition: margin 0s ease;-o-transition: all 0s ease;transition: margin 0s ease;} .spoilerbutton[value="Show Message"] + .spoiler > div {margin-top:-500%;} .spoilerbutton[value="Hide Message"] + .spoiler {padding:5px;} Please make sure your answer follows the type signature below: ```python3 class Solution: def maxNumOfMarkedIndices(self, nums: List[int]) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.maxNumOfMarkedIndices(*[[3, 5, 2, 4]]) == 2\nassert my_solution.maxNumOfMarkedIndices(*[[9, 2, 5, 4]]) == 4\nassert my_solution.maxNumOfMarkedIndices(*[[7, 6, 8]]) == 0\nassert my_solution.maxNumOfMarkedIndices(*[[1, 78, 27, 48, 14, 86, 79, 68, 77, 20, 57, 21, 18, 67, 5, 51, 70, 85, 47, 56, 22, 79, 41, 8, 39, 81, 59, 74, 14, 45, 49, 15, 10, 28, 16, 77, 22, 65, 8, 36, 79, 94, 44, 80, 72, 8, 96, 78, 39, 92, 69, 55, 9, 44, 26, 76, 40, 77, 16, 69, 40, 64, 12, 48, 66, 7, 59, 10]]) == 64\nassert my_solution.maxNumOfMarkedIndices(*[[72, 97, 60, 79, 68, 25, 63, 82, 88, 60, 37, 60, 44, 14, 62, 36, 52, 73, 26, 98, 86, 50, 74, 68, 53, 80, 90, 60, 78, 56, 53, 84, 2]]) == 14\nassert my_solution.maxNumOfMarkedIndices(*[[42, 83, 48, 10, 24, 55, 9, 100, 10, 17, 17, 99, 51, 32, 16, 98, 99, 31, 28, 68, 71, 14, 64, 29, 15, 40]]) == 26\nassert my_solution.maxNumOfMarkedIndices(*[[57, 40, 57, 51, 90, 51, 68, 100, 24, 39, 11, 85, 2, 22, 67, 29, 74, 82, 10, 96, 14, 35, 25, 76, 26, 54, 29, 44, 63, 49, 73, 50, 95, 89, 43, 62, 24, 88, 88, 36, 6, 16, 14, 2, 42, 42, 60, 25, 4, 58, 23, 22, 27, 26, 3, 79, 64, 20, 92]]) == 58\nassert my_solution.maxNumOfMarkedIndices(*[[56, 92, 98, 34, 47, 91, 91, 23, 88, 43, 53, 29, 70, 23, 77, 24, 22, 4, 79, 38, 13, 36, 94, 19, 91, 44, 8, 56, 97, 77, 93, 55, 59, 77, 8, 95, 48, 50, 59, 32, 76, 78, 31, 3, 81, 44, 5, 52, 53, 88, 86, 87, 92, 69, 58, 82, 50, 82, 34, 72, 56, 46, 35]]) == 50\nassert my_solution.maxNumOfMarkedIndices(*[[4, 16, 58, 52, 51, 53, 67, 29, 12, 42, 67, 76, 95, 51, 31, 49, 9, 72, 83, 84, 12, 85, 78, 73, 3, 48, 22, 59, 99, 63, 10, 21, 43, 77, 43, 74, 75, 27, 13, 29, 73, 13, 20, 6, 56, 75, 83, 26, 24, 53, 56, 61, 96, 57, 33, 89, 99, 93, 81, 28, 49, 80, 88, 29, 51, 26, 95, 35, 61, 31, 96, 15, 65, 87, 12, 15, 81, 38, 96, 58, 23, 85, 5, 81, 26]]) == 76\nassert my_solution.maxNumOfMarkedIndices(*[[66, 53, 92, 87, 23, 29, 53, 83, 63, 63, 25, 25, 72, 47, 34, 24, 63, 8, 43, 100, 80, 17, 72, 69, 7, 7, 32, 80, 8, 58, 70, 81, 79, 67, 66, 24, 64, 66, 9, 67, 33, 11, 62, 86, 5, 84, 78, 85, 69, 3, 92, 14, 67, 90, 31, 40, 54, 63, 99, 88, 28, 100, 5, 72, 89, 60, 90, 71, 97, 16, 7, 60, 6, 57, 73, 84, 17, 8, 77, 60, 7, 74, 74, 24, 52, 43, 94, 48, 9, 99, 84, 89, 96, 40, 15, 29, 80, 19]]) == 78\nassert my_solution.maxNumOfMarkedIndices(*[[75, 49, 27, 87, 95, 22, 28, 54, 66, 55, 99, 17, 75, 39, 90, 47, 14, 9, 63, 18, 51, 15, 50, 24, 86, 30, 44, 51, 13, 91, 95, 52, 50, 99, 38, 74, 67, 34, 75, 31, 91, 47, 6, 37, 62, 72, 42, 85, 95, 10, 8, 43, 21, 63]]) == 52\nassert my_solution.maxNumOfMarkedIndices(*[[45, 23, 69, 16, 99, 92, 5, 97, 69, 33, 44, 8, 33, 38, 60, 60, 52, 18, 97, 28, 61, 77, 27, 68, 57, 26]]) == 26\nassert my_solution.maxNumOfMarkedIndices(*[[90, 37, 51, 92, 50, 50, 93, 49, 34, 53, 3, 32, 3, 95, 80, 79, 76, 39, 35, 35, 83, 100, 84, 24, 6, 50, 97, 82, 67, 31, 99, 94, 19]]) == 28\nassert my_solution.maxNumOfMarkedIndices(*[[1, 69, 22, 35, 3, 56, 81, 80, 37, 28, 34, 59, 92, 31, 34, 19, 96, 6, 58, 98, 14, 94, 4, 95, 41, 23, 98, 26, 69, 35, 52, 92, 26, 32, 61, 60, 19, 43, 22, 59, 96, 40, 42, 59, 48, 36, 41, 14, 100, 68, 63, 42, 55, 93, 4, 55, 57, 32, 81, 75, 34, 59, 11, 98, 41, 40, 78, 21, 41, 40, 75, 3, 10, 91, 10, 3, 48, 3]]) == 78\nassert my_solution.maxNumOfMarkedIndices(*[[100, 5, 97, 36, 93, 81, 29, 80, 14, 6, 20, 95, 33, 37, 9, 49, 94, 80, 1, 33, 2, 18, 68, 97, 78, 52, 62, 63, 48, 15, 78, 35, 13, 14, 94, 4, 95, 62, 4, 74, 78, 43, 57, 1, 17, 30, 23, 98, 13, 26, 64, 72, 69, 7, 1, 30, 32, 92, 26, 84, 30, 15, 20, 40, 92, 85, 28, 54, 67, 27, 59, 74, 2, 51, 12, 46, 39, 97, 13, 76, 91, 63, 92, 40, 17, 54, 74, 52, 30, 50, 5, 41, 23, 46, 23, 15]]) == 96\nassert my_solution.maxNumOfMarkedIndices(*[[36]]) == 0\nassert my_solution.maxNumOfMarkedIndices(*[[40]]) == 0\nassert my_solution.maxNumOfMarkedIndices(*[[36, 22, 53, 86, 95, 84]]) == 4\nassert my_solution.maxNumOfMarkedIndices(*[[58, 57, 42, 83, 24, 73, 63, 76, 44, 30, 11, 16, 71, 87, 10, 49, 32, 72, 53, 89, 96, 93, 27, 49, 20, 53, 30, 70, 70, 79, 100, 99, 96, 58, 51, 21, 22, 39, 33, 27, 44, 46, 47, 41, 73, 20, 75, 36, 48, 19, 54, 47]]) == 50\nassert my_solution.maxNumOfMarkedIndices(*[[48, 20, 34, 88, 74, 64, 38, 20, 73, 59, 27, 12, 74, 12, 19, 98, 59, 23, 8, 43, 70, 54, 33, 5, 33, 98, 55, 11, 92, 76, 17, 34, 35, 20, 22, 5, 58, 75, 90, 54, 58, 32, 49, 46, 31, 53, 14, 41, 47, 61, 1, 73, 37, 72, 37, 4, 78, 73, 3, 89, 52, 53, 29, 92, 31]]) == 64\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2712", "questionFrontendId": "2576", "questionTitle": "Find the Maximum Number of Marked Indices", "stats": { "totalAccepted": "7.6K", "totalSubmission": "20K", "totalAcceptedRaw": 7618, "totalSubmissionRaw": 19969, "acRate": "38.1%" } }
LeetCode/2707
# Merge Two 2D Arrays by Summing Values You are given two **2D** integer arrays `nums1` and `nums2.` * `nums1[i] = [idi, vali]` indicate that the number with the id `idi` has a value equal to `vali`. * `nums2[i] = [idi, vali]` indicate that the number with the id `idi` has a value equal to `vali`. Each array contains **unique** ids and is sorted in **ascending** order by id. Merge the two arrays into one array that is sorted in ascending order by id, respecting the following conditions: * Only ids that appear in at least one of the two arrays should be included in the resulting array. * Each id should be included **only once** and its value should be the sum of the values of this id in the two arrays. If the id does not exist in one of the two arrays then its value in that array is considered to be `0`. Return *the resulting array*. The returned array must be sorted in ascending order by id.   **Example 1:** ``` **Input:** nums1 = [[1,2],[2,3],[4,5]], nums2 = [[1,4],[3,2],[4,1]] **Output:** [[1,6],[2,3],[3,2],[4,6]] **Explanation:** The resulting array contains the following: - id = 1, the value of this id is 2 + 4 = 6. - id = 2, the value of this id is 3. - id = 3, the value of this id is 2. - id = 4, the value of this id is 5 + 1 = 6. ``` **Example 2:** ``` **Input:** nums1 = [[2,4],[3,6],[5,5]], nums2 = [[1,3],[4,3]] **Output:** [[1,3],[2,4],[3,6],[4,3],[5,5]] **Explanation:** There are no common ids, so we just include each id with its value in the resulting list. ```   **Constraints:** * `1 <= nums1.length, nums2.length <= 200` * `nums1[i].length == nums2[j].length == 2` * `1 <= idi, vali <= 1000` * Both arrays contain unique ids. * Both arrays are in strictly ascending order by id. Please make sure your answer follows the type signature below: ```python3 class Solution: def mergeArrays(self, nums1: List[List[int]], nums2: List[List[int]]) -> List[List[int]]: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.mergeArrays(*[[[1, 2], [2, 3], [4, 5]], [[1, 4], [3, 2], [4, 1]]]) == [[1, 6], [2, 3], [3, 2], [4, 6]]\nassert my_solution.mergeArrays(*[[[2, 4], [3, 6], [5, 5]], [[1, 3], [4, 3]]]) == [[1, 3], [2, 4], [3, 6], [4, 3], [5, 5]]\nassert my_solution.mergeArrays(*[[[148, 597], [165, 623], [306, 359], [349, 566], [403, 646], [420, 381], [566, 543], [730, 209], [757, 875], [788, 208], [932, 695]], [[74, 669], [87, 399], [89, 165], [99, 749], [122, 401], [138, 16], [144, 714], [148, 206], [177, 948], [211, 653], [285, 775], [309, 289], [349, 396], [386, 831], [403, 318], [405, 119], [420, 153], [468, 433], [504, 101], [566, 128], [603, 688], [618, 628], [622, 586], [641, 46], [653, 922], [672, 772], [691, 823], [693, 900], [756, 878], [757, 952], [770, 795], [806, 118], [813, 88], [919, 501], [935, 253], [982, 385]]]) == [[74, 669], [87, 399], [89, 165], [99, 749], [122, 401], [138, 16], [144, 714], [148, 803], [165, 623], [177, 948], [211, 653], [285, 775], [306, 359], [309, 289], [349, 962], [386, 831], [403, 964], [405, 119], [420, 534], [468, 433], [504, 101], [566, 671], [603, 688], [618, 628], [622, 586], [641, 46], [653, 922], [672, 772], [691, 823], [693, 900], [730, 209], [756, 878], [757, 1827], [770, 795], [788, 208], [806, 118], [813, 88], [919, 501], [932, 695], [935, 253], [982, 385]]\nassert my_solution.mergeArrays(*[[[7, 571], [63, 743], [149, 42], [278, 622], [361, 276], [554, 608], [616, 28], [719, 955], [778, 377], [1000, 853]], [[278, 784], [891, 546]]]) == [[7, 571], [63, 743], [149, 42], [278, 1406], [361, 276], [554, 608], [616, 28], [719, 955], [778, 377], [891, 546], [1000, 853]]\nassert my_solution.mergeArrays(*[[[13, 43], [52, 654], [81, 634], [135, 661], [148, 164], [171, 646], [185, 785], [220, 205], [234, 183], [279, 546], [285, 2], [287, 158], [311, 71], [364, 480], [370, 903], [450, 968], [471, 63], [502, 679], [510, 256], [546, 51], [573, 932], [579, 445], [599, 919], [666, 836], [699, 222], [705, 568], [707, 141], [719, 978], [747, 160], [753, 818], [758, 266], [806, 33], [818, 508], [828, 412], [851, 44], [906, 833], [940, 575], [960, 105]], [[159, 982], [171, 221], [311, 610], [364, 620], [471, 233], [510, 207], [573, 909], [599, 925], [707, 478], [719, 788], [747, 178], [828, 528]]]) == [[13, 43], [52, 654], [81, 634], [135, 661], [148, 164], [159, 982], [171, 867], [185, 785], [220, 205], [234, 183], [279, 546], [285, 2], [287, 158], [311, 681], [364, 1100], [370, 903], [450, 968], [471, 296], [502, 679], [510, 463], [546, 51], [573, 1841], [579, 445], [599, 1844], [666, 836], [699, 222], [705, 568], [707, 619], [719, 1766], [747, 338], [753, 818], [758, 266], [806, 33], [818, 508], [828, 940], [851, 44], [906, 833], [940, 575], [960, 105]]\nassert my_solution.mergeArrays(*[[[182, 108], [184, 211], [253, 162], [428, 279], [430, 645]], [[27, 775], [79, 228], [113, 107], [121, 440], [132, 156], [155, 382], [182, 381], [184, 546], [188, 909], [204, 882], [208, 290], [225, 866], [253, 590], [273, 175], [285, 401], [295, 248], [300, 552], [311, 628], [361, 357], [369, 482], [381, 505], [398, 584], [428, 676], [430, 485], [434, 316], [437, 824], [529, 459], [549, 481], [566, 219], [590, 710], [677, 883], [741, 40], [765, 761], [783, 664], [784, 560], [786, 303], [797, 492], [811, 110], [836, 94], [885, 980], [888, 415], [899, 310], [922, 960], [933, 56], [970, 649], [978, 346]]]) == [[27, 775], [79, 228], [113, 107], [121, 440], [132, 156], [155, 382], [182, 489], [184, 757], [188, 909], [204, 882], [208, 290], [225, 866], [253, 752], [273, 175], [285, 401], [295, 248], [300, 552], [311, 628], [361, 357], [369, 482], [381, 505], [398, 584], [428, 955], [430, 1130], [434, 316], [437, 824], [529, 459], [549, 481], [566, 219], [590, 710], [677, 883], [741, 40], [765, 761], [783, 664], [784, 560], [786, 303], [797, 492], [811, 110], [836, 94], [885, 980], [888, 415], [899, 310], [922, 960], [933, 56], [970, 649], [978, 346]]\nassert my_solution.mergeArrays(*[[[52, 966], [53, 511], [69, 965], [96, 222], [133, 663], [136, 733], [168, 385], [213, 978], [220, 44], [253, 333], [315, 598], [335, 438], [362, 770], [373, 266], [391, 927], [424, 107], [538, 949], [556, 678], [574, 334], [756, 978], [909, 973], [918, 685], [944, 794], [969, 492], [970, 753]], [[69, 699], [96, 926], [168, 908], [315, 84], [424, 736], [756, 1], [909, 126], [969, 358], [970, 801]]]) == [[52, 966], [53, 511], [69, 1664], [96, 1148], [133, 663], [136, 733], [168, 1293], [213, 978], [220, 44], [253, 333], [315, 682], [335, 438], [362, 770], [373, 266], [391, 927], [424, 843], [538, 949], [556, 678], [574, 334], [756, 979], [909, 1099], [918, 685], [944, 794], [969, 850], [970, 1554]]\nassert my_solution.mergeArrays(*[[[66, 301], [104, 426], [161, 161], [165, 612], [213, 549], [257, 737], [281, 631], [285, 415], [316, 46], [321, 98], [339, 382], [370, 225], [379, 102], [450, 823], [459, 71], [473, 538], [482, 409], [485, 433], [503, 854], [513, 930], [533, 354], [645, 274], [659, 395], [689, 468], [696, 914], [712, 762], [727, 835], [746, 881], [751, 915], [758, 287], [771, 231], [818, 883], [862, 802], [864, 299], [919, 473], [979, 811], [998, 851]], [[66, 649], [165, 463], [213, 732], [228, 798], [245, 755], [251, 908], [314, 913], [342, 648], [379, 131], [426, 184], [459, 464], [469, 546], [471, 856], [473, 832], [503, 268], [506, 916], [515, 915], [533, 406], [562, 626], [603, 834], [606, 595], [653, 139], [689, 649], [697, 351], [712, 873], [724, 996], [727, 656], [728, 438], [756, 940], [758, 574], [818, 163], [829, 411], [860, 778], [886, 59], [922, 412], [979, 660], [998, 319]]]) == [[66, 950], [104, 426], [161, 161], [165, 1075], [213, 1281], [228, 798], [245, 755], [251, 908], [257, 737], [281, 631], [285, 415], [314, 913], [316, 46], [321, 98], [339, 382], [342, 648], [370, 225], [379, 233], [426, 184], [450, 823], [459, 535], [469, 546], [471, 856], [473, 1370], [482, 409], [485, 433], [503, 1122], [506, 916], [513, 930], [515, 915], [533, 760], [562, 626], [603, 834], [606, 595], [645, 274], [653, 139], [659, 395], [689, 1117], [696, 914], [697, 351], [712, 1635], [724, 996], [727, 1491], [728, 438], [746, 881], [751, 915], [756, 940], [758, 861], [771, 231], [818, 1046], [829, 411], [860, 778], [862, 802], [864, 299], [886, 59], [919, 473], [922, 412], [979, 1471], [998, 1170]]\nassert my_solution.mergeArrays(*[[[29, 870], [74, 501], [118, 505], [122, 916], [188, 531], [318, 724], [329, 394], [330, 98], [334, 158], [475, 692], [575, 893], [585, 953], [587, 630], [647, 840], [679, 477], [687, 1], [717, 278], [745, 77], [763, 18], [866, 195], [937, 141], [985, 165]], [[5, 815], [29, 15], [53, 32], [113, 290], [118, 437], [122, 918], [134, 282], [161, 728], [188, 471], [248, 25], [275, 992], [301, 101], [318, 730], [334, 722], [387, 687], [477, 553], [502, 403], [548, 681], [561, 618], [575, 382], [587, 164], [647, 705], [654, 86], [687, 209], [717, 333], [753, 43], [763, 413], [776, 310], [801, 115], [828, 809], [861, 610], [926, 435], [937, 902]]]) == [[5, 815], [29, 885], [53, 32], [74, 501], [113, 290], [118, 942], [122, 1834], [134, 282], [161, 728], [188, 1002], [248, 25], [275, 992], [301, 101], [318, 1454], [329, 394], [330, 98], [334, 880], [387, 687], [475, 692], [477, 553], [502, 403], [548, 681], [561, 618], [575, 1275], [585, 953], [587, 794], [647, 1545], [654, 86], [679, 477], [687, 210], [717, 611], [745, 77], [753, 43], [763, 431], [776, 310], [801, 115], [828, 809], [861, 610], [866, 195], [926, 435], [937, 1043], [985, 165]]\nassert my_solution.mergeArrays(*[[[18, 68], [152, 947], [158, 199], [169, 45], [222, 33], [256, 185], [353, 217], [418, 32], [419, 846], [457, 593], [461, 135], [462, 766], [529, 425], [536, 300], [565, 339], [621, 854], [625, 316], [736, 309], [858, 660], [935, 169], [939, 764], [962, 230], [967, 261]], [[158, 771], [457, 152], [967, 69]]]) == [[18, 68], [152, 947], [158, 970], [169, 45], [222, 33], [256, 185], [353, 217], [418, 32], [419, 846], [457, 745], [461, 135], [462, 766], [529, 425], [536, 300], [565, 339], [621, 854], [625, 316], [736, 309], [858, 660], [935, 169], [939, 764], [962, 230], [967, 330]]\nassert my_solution.mergeArrays(*[[[17, 458], [56, 457], [77, 384], [90, 886], [138, 658], [143, 745], [147, 700], [186, 456], [274, 389], [308, 810], [374, 986], [439, 770], [451, 89], [633, 382], [675, 972], [683, 605], [704, 949], [786, 362], [806, 789], [821, 503], [844, 937], [922, 873], [925, 934], [964, 490], [988, 89]], [[90, 886], [147, 300], [633, 538], [683, 319], [786, 200], [789, 342], [795, 995], [844, 551]]]) == [[17, 458], [56, 457], [77, 384], [90, 1772], [138, 658], [143, 745], [147, 1000], [186, 456], [274, 389], [308, 810], [374, 986], [439, 770], [451, 89], [633, 920], [675, 972], [683, 924], [704, 949], [786, 562], [789, 342], [795, 995], [806, 789], [821, 503], [844, 1488], [922, 873], [925, 934], [964, 490], [988, 89]]\nassert my_solution.mergeArrays(*[[[11, 629], [44, 221], [171, 139], [200, 833], [240, 840], [310, 175], [373, 938], [495, 902], [600, 452], [676, 395], [697, 670], [711, 83], [743, 583], [808, 565], [839, 656], [863, 813], [950, 902]], [[278, 210], [365, 1000], [373, 909], [944, 824]]]) == [[11, 629], [44, 221], [171, 139], [200, 833], [240, 840], [278, 210], [310, 175], [365, 1000], [373, 1847], [495, 902], [600, 452], [676, 395], [697, 670], [711, 83], [743, 583], [808, 565], [839, 656], [863, 813], [944, 824], [950, 902]]\nassert my_solution.mergeArrays(*[[[29, 422], [36, 578], [75, 654], [79, 887], [106, 814], [150, 863], [224, 211], [280, 708], [314, 961], [332, 546], [352, 557], [389, 926], [424, 870], [482, 771], [539, 997], [561, 968], [565, 204], [567, 17], [613, 91], [710, 448], [715, 406], [720, 611], [745, 954], [769, 951], [790, 150], [797, 98], [806, 258], [812, 32], [880, 678], [889, 208], [901, 422], [928, 849], [955, 349], [960, 64], [993, 22]], [[29, 615], [75, 184], [150, 353], [224, 776], [332, 743], [482, 891], [769, 700], [955, 128], [993, 445]]]) == [[29, 1037], [36, 578], [75, 838], [79, 887], [106, 814], [150, 1216], [224, 987], [280, 708], [314, 961], [332, 1289], [352, 557], [389, 926], [424, 870], [482, 1662], [539, 997], [561, 968], [565, 204], [567, 17], [613, 91], [710, 448], [715, 406], [720, 611], [745, 954], [769, 1651], [790, 150], [797, 98], [806, 258], [812, 32], [880, 678], [889, 208], [901, 422], [928, 849], [955, 477], [960, 64], [993, 467]]\nassert my_solution.mergeArrays(*[[[15, 522], [165, 873], [190, 322], [249, 196], [368, 672], [511, 219], [539, 152], [558, 102], [563, 495], [565, 588], [602, 711], [608, 900], [667, 968], [712, 420], [755, 901], [808, 574], [900, 340], [971, 585], [973, 666], [999, 862]], [[15, 464], [83, 161], [89, 867], [119, 255], [165, 689], [180, 104], [190, 154], [236, 420], [301, 92], [324, 305], [334, 335], [368, 627], [379, 559], [396, 627], [459, 636], [506, 903], [511, 641], [534, 298], [536, 295], [592, 951], [602, 351], [608, 938], [618, 841], [667, 877], [684, 730], [711, 382], [712, 523], [741, 439], [751, 345], [755, 446], [795, 616], [808, 60], [843, 854], [869, 293], [872, 448], [895, 995], [917, 229], [935, 212], [955, 226], [971, 970], [973, 514], [978, 732]]]) == [[15, 986], [83, 161], [89, 867], [119, 255], [165, 1562], [180, 104], [190, 476], [236, 420], [249, 196], [301, 92], [324, 305], [334, 335], [368, 1299], [379, 559], [396, 627], [459, 636], [506, 903], [511, 860], [534, 298], [536, 295], [539, 152], [558, 102], [563, 495], [565, 588], [592, 951], [602, 1062], [608, 1838], [618, 841], [667, 1845], [684, 730], [711, 382], [712, 943], [741, 439], [751, 345], [755, 1347], [795, 616], [808, 634], [843, 854], [869, 293], [872, 448], [895, 995], [900, 340], [917, 229], [935, 212], [955, 226], [971, 1555], [973, 1180], [978, 732], [999, 862]]\nassert my_solution.mergeArrays(*[[[27, 409], [46, 589], [77, 299], [81, 268], [98, 98], [123, 7], [148, 946], [174, 215], [199, 863], [274, 768], [289, 360], [320, 472], [356, 914], [370, 364], [383, 950], [394, 690], [403, 336], [407, 972], [431, 43], [446, 423], [484, 177], [518, 419], [557, 501], [562, 481], [585, 409], [604, 161], [634, 365], [664, 50], [683, 549], [691, 228], [706, 800], [710, 986], [746, 880], [752, 305], [772, 877], [820, 424], [827, 347], [845, 886], [868, 957], [879, 86], [889, 723], [910, 810], [924, 775], [935, 106], [955, 367], [962, 335], [992, 207], [993, 564], [994, 846]], [[27, 248], [256, 894], [274, 9], [289, 858], [338, 676], [356, 868], [377, 776], [389, 637], [394, 573], [416, 685], [446, 524], [460, 264], [475, 119], [506, 656], [562, 481], [702, 157], [706, 804], [724, 821], [746, 701], [772, 43], [799, 298], [845, 983], [847, 305], [889, 368], [920, 709], [935, 346], [955, 970], [962, 79], [992, 163], [994, 200]]]) == [[27, 657], [46, 589], [77, 299], [81, 268], [98, 98], [123, 7], [148, 946], [174, 215], [199, 863], [256, 894], [274, 777], [289, 1218], [320, 472], [338, 676], [356, 1782], [370, 364], [377, 776], [383, 950], [389, 637], [394, 1263], [403, 336], [407, 972], [416, 685], [431, 43], [446, 947], [460, 264], [475, 119], [484, 177], [506, 656], [518, 419], [557, 501], [562, 962], [585, 409], [604, 161], [634, 365], [664, 50], [683, 549], [691, 228], [702, 157], [706, 1604], [710, 986], [724, 821], [746, 1581], [752, 305], [772, 920], [799, 298], [820, 424], [827, 347], [845, 1869], [847, 305], [868, 957], [879, 86], [889, 1091], [910, 810], [920, 709], [924, 775], [935, 452], [955, 1337], [962, 414], [992, 370], [993, 564], [994, 1046]]\nassert my_solution.mergeArrays(*[[[30, 573], [47, 797], [58, 951], [102, 571], [106, 201], [148, 89], [176, 428], [179, 595], [189, 637], [201, 152], [202, 772], [247, 836], [253, 647], [283, 776], [332, 988], [359, 470], [364, 348], [386, 913], [562, 667], [573, 699], [574, 184], [584, 264], [610, 979], [613, 568], [664, 828], [665, 911], [682, 15], [709, 919], [734, 492], [737, 647], [740, 324], [758, 842], [763, 320], [768, 836], [779, 764], [797, 232], [800, 79], [801, 858], [832, 438], [898, 82], [928, 581], [933, 802], [945, 103], [956, 147], [962, 803], [967, 291]], [[47, 366], [58, 612], [132, 579], [179, 697], [201, 214], [658, 732]]]) == [[30, 573], [47, 1163], [58, 1563], [102, 571], [106, 201], [132, 579], [148, 89], [176, 428], [179, 1292], [189, 637], [201, 366], [202, 772], [247, 836], [253, 647], [283, 776], [332, 988], [359, 470], [364, 348], [386, 913], [562, 667], [573, 699], [574, 184], [584, 264], [610, 979], [613, 568], [658, 732], [664, 828], [665, 911], [682, 15], [709, 919], [734, 492], [737, 647], [740, 324], [758, 842], [763, 320], [768, 836], [779, 764], [797, 232], [800, 79], [801, 858], [832, 438], [898, 82], [928, 581], [933, 802], [945, 103], [956, 147], [962, 803], [967, 291]]\nassert my_solution.mergeArrays(*[[[2, 914], [17, 827], [51, 986], [61, 494], [92, 43], [131, 430], [134, 606], [153, 172], [165, 735], [232, 695], [347, 722], [349, 870], [367, 331], [389, 279], [396, 472], [402, 279], [415, 206], [419, 758], [420, 646], [447, 351], [460, 262], [475, 659], [525, 798], [547, 376], [585, 947], [638, 411], [650, 648], [651, 889], [673, 886], [708, 747], [728, 614], [742, 404], [752, 108], [757, 340], [776, 459], [791, 930], [866, 950], [887, 8], [891, 597], [917, 568], [924, 798], [931, 151], [936, 706], [950, 814], [955, 265], [960, 60], [971, 777], [986, 364], [992, 308], [998, 772]], [[26, 959], [92, 171], [154, 510], [174, 744], [232, 641], [447, 864], [533, 437], [547, 829], [752, 945], [776, 953], [789, 921], [791, 603], [866, 995], [891, 729], [906, 613], [971, 847]]]) == [[2, 914], [17, 827], [26, 959], [51, 986], [61, 494], [92, 214], [131, 430], [134, 606], [153, 172], [154, 510], [165, 735], [174, 744], [232, 1336], [347, 722], [349, 870], [367, 331], [389, 279], [396, 472], [402, 279], [415, 206], [419, 758], [420, 646], [447, 1215], [460, 262], [475, 659], [525, 798], [533, 437], [547, 1205], [585, 947], [638, 411], [650, 648], [651, 889], [673, 886], [708, 747], [728, 614], [742, 404], [752, 1053], [757, 340], [776, 1412], [789, 921], [791, 1533], [866, 1945], [887, 8], [891, 1326], [906, 613], [917, 568], [924, 798], [931, 151], [936, 706], [950, 814], [955, 265], [960, 60], [971, 1624], [986, 364], [992, 308], [998, 772]]\nassert my_solution.mergeArrays(*[[[15, 134], [17, 740], [66, 6], [73, 988], [75, 6], [76, 962], [82, 197], [92, 275], [149, 350], [159, 822], [166, 840], [181, 528], [195, 167], [206, 340], [209, 400], [210, 9], [213, 848], [235, 970], [244, 373], [261, 701], [274, 662], [279, 244], [285, 352], [298, 240], [300, 191], [314, 276], [342, 436], [400, 322], [440, 907], [453, 5], [476, 756], [482, 858], [497, 810], [499, 520], [507, 508], [508, 906], [510, 402], [534, 232], [542, 438], [555, 664], [565, 188], [597, 314], [600, 587], [606, 415], [628, 859], [682, 671], [687, 735], [702, 267], [724, 325], [726, 216], [752, 359], [755, 485], [778, 516], [792, 533], [801, 946], [803, 784], [818, 621], [833, 379], [842, 425], [853, 843], [856, 644], [863, 268], [864, 926], [880, 738], [882, 225], [887, 55], [961, 105], [978, 48], [993, 740], [994, 449], [997, 63]], [[1, 802], [15, 809], [16, 449], [17, 153], [24, 749], [66, 942], [73, 845], [82, 386], [149, 943], [158, 892], [159, 642], [160, 160], [166, 718], [181, 234], [195, 840], [211, 586], [257, 815], [342, 703], [400, 67], [453, 429], [461, 182], [497, 703], [507, 861], [523, 630], [534, 260], [535, 341], [539, 217], [546, 653], [555, 238], [565, 350], [589, 477], [597, 446], [606, 681], [628, 733], [643, 609], [682, 988], [687, 370], [692, 779], [726, 747], [752, 8], [755, 705], [760, 962], [778, 985], [833, 19], [842, 185], [844, 502], [845, 702], [860, 806], [864, 739], [883, 76], [997, 752]]]) == [[1, 802], [15, 943], [16, 449], [17, 893], [24, 749], [66, 948], [73, 1833], [75, 6], [76, 962], [82, 583], [92, 275], [149, 1293], [158, 892], [159, 1464], [160, 160], [166, 1558], [181, 762], [195, 1007], [206, 340], [209, 400], [210, 9], [211, 586], [213, 848], [235, 970], [244, 373], [257, 815], [261, 701], [274, 662], [279, 244], [285, 352], [298, 240], [300, 191], [314, 276], [342, 1139], [400, 389], [440, 907], [453, 434], [461, 182], [476, 756], [482, 858], [497, 1513], [499, 520], [507, 1369], [508, 906], [510, 402], [523, 630], [534, 492], [535, 341], [539, 217], [542, 438], [546, 653], [555, 902], [565, 538], [589, 477], [597, 760], [600, 587], [606, 1096], [628, 1592], [643, 609], [682, 1659], [687, 1105], [692, 779], [702, 267], [724, 325], [726, 963], [752, 367], [755, 1190], [760, 962], [778, 1501], [792, 533], [801, 946], [803, 784], [818, 621], [833, 398], [842, 610], [844, 502], [845, 702], [853, 843], [856, 644], [860, 806], [863, 268], [864, 1665], [880, 738], [882, 225], [883, 76], [887, 55], [961, 105], [978, 48], [993, 740], [994, 449], [997, 815]]\nassert my_solution.mergeArrays(*[[[2, 941], [11, 218], [35, 747], [44, 455], [61, 383], [77, 135], [79, 312], [88, 80], [92, 453], [95, 916], [102, 461], [106, 500], [118, 478], [121, 900], [127, 322], [132, 186], [147, 544], [171, 321], [197, 301], [229, 854], [231, 886], [242, 416], [265, 680], [269, 745], [277, 555], [285, 627], [315, 820], [322, 276], [325, 239], [334, 668], [338, 103], [358, 821], [361, 762], [407, 221], [411, 624], [445, 53], [453, 638], [469, 64], [478, 578], [491, 735], [494, 347], [520, 553], [531, 716], [536, 463], [539, 186], [540, 573], [574, 518], [601, 347], [604, 884], [620, 799], [626, 671], [628, 986], [634, 650], [637, 741], [638, 124], [658, 102], [673, 315], [685, 683], [687, 964], [718, 864], [727, 373], [728, 849], [735, 115], [736, 454], [738, 921], [740, 414], [757, 635], [782, 586], [783, 130], [800, 740], [812, 877], [861, 407], [876, 989], [884, 859], [891, 924], [895, 635], [908, 174], [931, 301], [940, 960], [943, 897], [949, 824], [958, 755], [963, 755], [965, 723], [966, 923], [967, 136], [988, 507], [1000, 985]], [[9, 53], [15, 617], [33, 261], [35, 76], [44, 968], [48, 940], [54, 145], [57, 436], [61, 390], [72, 616], [88, 306], [91, 753], [95, 63], [106, 638], [118, 910], [121, 423], [127, 37], [132, 569], [142, 782], [147, 237], [196, 176], [215, 818], [229, 727], [237, 625], [259, 350], [285, 914], [289, 433], [299, 189], [315, 128], [317, 132], [322, 636], [361, 618], [393, 743], [407, 317], [410, 320], [414, 848], [418, 439], [424, 413], [428, 615], [440, 660], [455, 771], [459, 665], [465, 302], [478, 967], [491, 875], [504, 819], [515, 657], [531, 443], [539, 472], [540, 807], [555, 575], [574, 578], [591, 727], [606, 130], [621, 559], [628, 802], [633, 979], [637, 476], [648, 36], [654, 924], [673, 551], [685, 125], [687, 914], [689, 954], [718, 621], [735, 318], [738, 346], [740, 726], [782, 804], [789, 448], [800, 933], [803, 373], [828, 180], [838, 350], [841, 432], [861, 492], [876, 686], [882, 994], [884, 91], [891, 953], [895, 398], [903, 449], [908, 223], [940, 269], [943, 462], [963, 201], [965, 679], [967, 353], [983, 420], [1000, 480]]]) == [[2, 941], [9, 53], [11, 218], [15, 617], [33, 261], [35, 823], [44, 1423], [48, 940], [54, 145], [57, 436], [61, 773], [72, 616], [77, 135], [79, 312], [88, 386], [91, 753], [92, 453], [95, 979], [102, 461], [106, 1138], [118, 1388], [121, 1323], [127, 359], [132, 755], [142, 782], [147, 781], [171, 321], [196, 176], [197, 301], [215, 818], [229, 1581], [231, 886], [237, 625], [242, 416], [259, 350], [265, 680], [269, 745], [277, 555], [285, 1541], [289, 433], [299, 189], [315, 948], [317, 132], [322, 912], [325, 239], [334, 668], [338, 103], [358, 821], [361, 1380], [393, 743], [407, 538], [410, 320], [411, 624], [414, 848], [418, 439], [424, 413], [428, 615], [440, 660], [445, 53], [453, 638], [455, 771], [459, 665], [465, 302], [469, 64], [478, 1545], [491, 1610], [494, 347], [504, 819], [515, 657], [520, 553], [531, 1159], [536, 463], [539, 658], [540, 1380], [555, 575], [574, 1096], [591, 727], [601, 347], [604, 884], [606, 130], [620, 799], [621, 559], [626, 671], [628, 1788], [633, 979], [634, 650], [637, 1217], [638, 124], [648, 36], [654, 924], [658, 102], [673, 866], [685, 808], [687, 1878], [689, 954], [718, 1485], [727, 373], [728, 849], [735, 433], [736, 454], [738, 1267], [740, 1140], [757, 635], [782, 1390], [783, 130], [789, 448], [800, 1673], [803, 373], [812, 877], [828, 180], [838, 350], [841, 432], [861, 899], [876, 1675], [882, 994], [884, 950], [891, 1877], [895, 1033], [903, 449], [908, 397], [931, 301], [940, 1229], [943, 1359], [949, 824], [958, 755], [963, 956], [965, 1402], [966, 923], [967, 489], [983, 420], [988, 507], [1000, 1465]]\nassert my_solution.mergeArrays(*[[[12, 447], [19, 270], [28, 181], [29, 102], [33, 34], [51, 404], [56, 798], [84, 551], [107, 672], [108, 453], [121, 694], [129, 105], [130, 640], [131, 880], [147, 629], [150, 921], [185, 454], [188, 926], [232, 504], [253, 459], [279, 944], [340, 374], [409, 987], [435, 116], [440, 222], [464, 427], [482, 226], [491, 153], [502, 856], [504, 234], [506, 253], [519, 548], [536, 845], [553, 556], [571, 459], [587, 383], [596, 804], [622, 172], [677, 566], [680, 105], [698, 867], [699, 317], [727, 962], [734, 473], [735, 173], [743, 836], [747, 336], [757, 689], [775, 200], [776, 554], [789, 878], [818, 9], [821, 102], [832, 806], [841, 924], [850, 514], [858, 539], [886, 442], [897, 236], [901, 57], [903, 711], [906, 288], [913, 735], [922, 865], [928, 919], [932, 512], [945, 49], [964, 702], [968, 368]], [[12, 979], [33, 674], [51, 162], [56, 482], [73, 783], [84, 822], [110, 470], [121, 217], [129, 382], [130, 257], [144, 367], [160, 969], [168, 150], [171, 731], [173, 666], [175, 72], [206, 199], [209, 946], [235, 503], [237, 431], [246, 710], [250, 684], [251, 105], [253, 759], [267, 232], [278, 177], [279, 808], [290, 408], [299, 707], [311, 852], [327, 681], [333, 771], [368, 937], [385, 19], [386, 587], [404, 770], [407, 463], [409, 347], [419, 311], [430, 420], [440, 962], [474, 104], [484, 429], [496, 592], [502, 794], [512, 385], [519, 567], [535, 526], [536, 610], [545, 498], [547, 980], [553, 623], [587, 280], [596, 766], [600, 678], [615, 626], [650, 370], [653, 168], [654, 743], [680, 617], [698, 195], [699, 923], [705, 464], [707, 737], [743, 648], [747, 53], [757, 191], [762, 466], [770, 434], [775, 126], [776, 772], [800, 784], [801, 940], [818, 312], [821, 363], [832, 101], [841, 506], [842, 74], [845, 738], [869, 543], [877, 75], [899, 166], [906, 518], [921, 422], [922, 256], [928, 974], [951, 419], [961, 1000], [977, 251]]]) == [[12, 1426], [19, 270], [28, 181], [29, 102], [33, 708], [51, 566], [56, 1280], [73, 783], [84, 1373], [107, 672], [108, 453], [110, 470], [121, 911], [129, 487], [130, 897], [131, 880], [144, 367], [147, 629], [150, 921], [160, 969], [168, 150], [171, 731], [173, 666], [175, 72], [185, 454], [188, 926], [206, 199], [209, 946], [232, 504], [235, 503], [237, 431], [246, 710], [250, 684], [251, 105], [253, 1218], [267, 232], [278, 177], [279, 1752], [290, 408], [299, 707], [311, 852], [327, 681], [333, 771], [340, 374], [368, 937], [385, 19], [386, 587], [404, 770], [407, 463], [409, 1334], [419, 311], [430, 420], [435, 116], [440, 1184], [464, 427], [474, 104], [482, 226], [484, 429], [491, 153], [496, 592], [502, 1650], [504, 234], [506, 253], [512, 385], [519, 1115], [535, 526], [536, 1455], [545, 498], [547, 980], [553, 1179], [571, 459], [587, 663], [596, 1570], [600, 678], [615, 626], [622, 172], [650, 370], [653, 168], [654, 743], [677, 566], [680, 722], [698, 1062], [699, 1240], [705, 464], [707, 737], [727, 962], [734, 473], [735, 173], [743, 1484], [747, 389], [757, 880], [762, 466], [770, 434], [775, 326], [776, 1326], [789, 878], [800, 784], [801, 940], [818, 321], [821, 465], [832, 907], [841, 1430], [842, 74], [845, 738], [850, 514], [858, 539], [869, 543], [877, 75], [886, 442], [897, 236], [899, 166], [901, 57], [903, 711], [906, 806], [913, 735], [921, 422], [922, 1121], [928, 1893], [932, 512], [945, 49], [951, 419], [961, 1000], [964, 702], [968, 368], [977, 251]]\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2707", "questionFrontendId": "2570", "questionTitle": "Merge Two 2D Arrays by Summing Values", "stats": { "totalAccepted": "9.6K", "totalSubmission": "13.8K", "totalAcceptedRaw": 9604, "totalSubmissionRaw": 13795, "acRate": "69.6%" } }
LeetCode/2710
# Minimum Operations to Reduce an Integer to 0 You are given a positive integer `n`, you can do the following operation **any** number of times: * Add or subtract a **power** of `2` from `n`. Return *the **minimum** number of operations to make* `n` *equal to* `0`. A number `x` is power of `2` if `x == 2i` where `i >= 0`*.*   **Example 1:** ``` **Input:** n = 39 **Output:** 3 **Explanation:** We can do the following operations: - Add 20 = 1 to n, so now n = 40. - Subtract 23 = 8 from n, so now n = 32. - Subtract 25 = 32 from n, so now n = 0. It can be shown that 3 is the minimum number of operations we need to make n equal to 0. ``` **Example 2:** ``` **Input:** n = 54 **Output:** 3 **Explanation:** We can do the following operations: - Add 21 = 2 to n, so now n = 56. - Add 23 = 8 to n, so now n = 64. - Subtract 26 = 64 from n, so now n = 0. So the minimum number of operations is 3. ```   **Constraints:** * `1 <= n <= 105` Please make sure your answer follows the type signature below: ```python3 class Solution: def minOperations(self, n: int) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.minOperations(*[39]) == 3\nassert my_solution.minOperations(*[54]) == 3\nassert my_solution.minOperations(*[38]) == 3\nassert my_solution.minOperations(*[70]) == 3\nassert my_solution.minOperations(*[26]) == 3\nassert my_solution.minOperations(*[27]) == 3\nassert my_solution.minOperations(*[1]) == 1\nassert my_solution.minOperations(*[71]) == 3\nassert my_solution.minOperations(*[15]) == 2\nassert my_solution.minOperations(*[25]) == 3\nassert my_solution.minOperations(*[33]) == 2\nassert my_solution.minOperations(*[84]) == 3\nassert my_solution.minOperations(*[30]) == 2\nassert my_solution.minOperations(*[82]) == 3\nassert my_solution.minOperations(*[16]) == 1\nassert my_solution.minOperations(*[88]) == 3\nassert my_solution.minOperations(*[533]) == 4\nassert my_solution.minOperations(*[580]) == 3\nassert my_solution.minOperations(*[668]) == 4\nassert my_solution.minOperations(*[404]) == 4\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2710", "questionFrontendId": "2571", "questionTitle": "Minimum Operations to Reduce an Integer to 0", "stats": { "totalAccepted": "8K", "totalSubmission": "14.5K", "totalAcceptedRaw": 8047, "totalSubmissionRaw": 14516, "acRate": "55.4%" } }
LeetCode/2709
# Count the Number of Square-Free Subsets You are given a positive integer **0-indexed** array `nums`. A subset of the array `nums` is **square-free** if the product of its elements is a **square-free integer**. A **square-free integer** is an integer that is divisible by no square number other than `1`. Return *the number of square-free non-empty subsets of the array* **nums**. Since the answer may be too large, return it **modulo** `109 + 7`. A **non-empty** **subset** of `nums` is an array that can be obtained by deleting some (possibly none but not all) elements from `nums`. Two subsets are different if and only if the chosen indices to delete are different.   **Example 1:** ``` **Input:** nums = [3,4,4,5] **Output:** 3 **Explanation:** There are 3 square-free subsets in this example: - The subset consisting of the 0th element [3]. The product of its elements is 3, which is a square-free integer. - The subset consisting of the 3rd element [5]. The product of its elements is 5, which is a square-free integer. - The subset consisting of 0th and 3rd elements [3,5]. The product of its elements is 15, which is a square-free integer. It can be proven that there are no more than 3 square-free subsets in the given array. ``` **Example 2:** ``` **Input:** nums = [1] **Output:** 1 **Explanation:** There is 1 square-free subset in this example: - The subset consisting of the 0th element [1]. The product of its elements is 1, which is a square-free integer. It can be proven that there is no more than 1 square-free subset in the given array. ```   **Constraints:** * `1 <= nums.length <= 1000` * `1 <= nums[i] <= 30` Please make sure your answer follows the type signature below: ```python3 class Solution: def squareFreeSubsets(self, nums: List[int]) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.squareFreeSubsets(*[[3, 4, 4, 5]]) == 3\nassert my_solution.squareFreeSubsets(*[[1]]) == 1\nassert my_solution.squareFreeSubsets(*[[11, 2, 19, 7, 9, 27]]) == 15\nassert my_solution.squareFreeSubsets(*[[26, 6, 4, 27, 6, 18]]) == 3\nassert my_solution.squareFreeSubsets(*[[9, 13, 19, 23, 7, 27]]) == 15\nassert my_solution.squareFreeSubsets(*[[17, 27, 20, 1, 19]]) == 7\nassert my_solution.squareFreeSubsets(*[[8, 11, 17, 2, 25, 29, 21, 20, 4, 22]]) == 39\nassert my_solution.squareFreeSubsets(*[[11, 14, 25, 18, 29, 16]]) == 7\nassert my_solution.squareFreeSubsets(*[[10, 15, 6, 25]]) == 3\nassert my_solution.squareFreeSubsets(*[[26, 21, 2, 6, 19, 9, 29]]) == 27\nassert my_solution.squareFreeSubsets(*[[25, 16, 6, 18, 5]]) == 3\nassert my_solution.squareFreeSubsets(*[[16, 3, 6, 6, 20, 9, 15, 30, 22, 15]]) == 10\nassert my_solution.squareFreeSubsets(*[[22, 2, 5, 26, 28, 8, 4, 11, 12, 17, 11, 3, 19, 29, 19, 7, 24, 12, 22, 5, 8, 22]]) == 1727\nassert my_solution.squareFreeSubsets(*[[1, 2, 6, 15, 7, 19, 6, 29, 28, 24, 21, 25, 25, 18, 9, 6, 20, 21, 8, 24, 14, 19, 24, 28, 30, 27, 13, 21, 1, 23, 13, 29, 24, 29, 18, 7]]) == 9215\nassert my_solution.squareFreeSubsets(*[[15, 15, 25, 2, 12, 22, 28, 11, 28, 13, 26, 12, 1, 5]]) == 95\nassert my_solution.squareFreeSubsets(*[[1, 24, 2, 16, 18, 3, 26, 29, 16, 6, 1, 28, 18, 14, 12, 1, 16, 20, 27, 6, 22]]) == 191\nassert my_solution.squareFreeSubsets(*[[13, 21, 20, 11, 6, 19, 1, 20, 27, 25, 25, 23, 14, 24, 16, 13, 11, 27, 16, 4, 21, 30]]) == 431\nassert my_solution.squareFreeSubsets(*[[23, 15, 17, 5, 5, 9, 12, 20, 2, 4, 10, 9, 27, 16, 23, 9, 8, 17, 9]]) == 80\nassert my_solution.squareFreeSubsets(*[[3, 5, 21, 20, 10, 2, 29, 18, 28, 1, 29, 15, 18, 3, 22, 19, 3, 14, 22, 15, 18, 13, 12, 26, 12, 26, 17, 10, 6, 19, 21, 14, 10, 26, 18, 19, 20, 28, 12, 12, 15, 28, 19, 13, 20, 17]]) == 31589\nassert my_solution.squareFreeSubsets(*[[20, 12, 1, 21, 20, 19, 9, 14, 17, 17, 27, 28, 3, 16, 29, 22, 24, 9, 16, 6, 10, 4, 30, 3, 17, 13, 20, 9, 3, 22, 5, 30, 17, 24, 17, 21, 10, 20, 19, 23, 21]]) == 19583\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2709", "questionFrontendId": "2572", "questionTitle": "Count the Number of Square-Free Subsets", "stats": { "totalAccepted": "4K", "totalSubmission": "13K", "totalAcceptedRaw": 4016, "totalSubmissionRaw": 12968, "acRate": "31.0%" } }
LeetCode/2708
# Find the String with LCP We define the `lcp` matrix of any **0-indexed** string `word` of `n` lowercase English letters as an `n x n` grid such that: * `lcp[i][j]` is equal to the length of the **longest common prefix** between the substrings `word[i,n-1]` and `word[j,n-1]`. Given an `n x n` matrix `lcp`, return the alphabetically smallest string `word` that corresponds to `lcp`. If there is no such string, return an empty string. A string `a` is lexicographically smaller than a string `b` (of the same length) if in the first position where `a` and `b` differ, string `a` has a letter that appears earlier in the alphabet than the corresponding letter in `b`. For example, `"aabd"` is lexicographically smaller than `"aaca"` because the first position they differ is at the third letter, and `'b'` comes before `'c'`.   **Example 1:** ``` **Input:** lcp = [[4,0,2,0],[0,3,0,1],[2,0,2,0],[0,1,0,1]] **Output:** "abab" **Explanation:** lcp corresponds to any 4 letter string with two alternating letters. The lexicographically smallest of them is "abab". ``` **Example 2:** ``` **Input:** lcp = [[4,3,2,1],[3,3,2,1],[2,2,2,1],[1,1,1,1]] **Output:** "aaaa" **Explanation:** lcp corresponds to any 4 letter string with a single distinct letter. The lexicographically smallest of them is "aaaa". ``` **Example 3:** ``` **Input:** lcp = [[4,3,2,1],[3,3,2,1],[2,2,2,1],[1,1,1,3]] **Output:** "" **Explanation:** lcp[3][3] cannot be equal to 3 since word[3,...,3] consists of only a single letter; Thus, no answer exists. ```   **Constraints:** * `1 <= n ==``lcp.length ==` `lcp[i].length` `<= 1000` * `0 <= lcp[i][j] <= n` Please make sure your answer follows the type signature below: ```python3 class Solution: def findTheString(self, lcp: List[List[int]]) -> str: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.findTheString(*[[[4, 0, 2, 0], [0, 3, 0, 1], [2, 0, 2, 0], [0, 1, 0, 1]]]) == abab\nassert my_solution.findTheString(*[[[4, 3, 2, 1], [3, 3, 2, 1], [2, 2, 2, 1], [1, 1, 1, 1]]]) == aaaa\nassert my_solution.findTheString(*[[[4, 3, 2, 1], [3, 3, 2, 1], [2, 2, 2, 1], [1, 1, 1, 3]]]) == \nassert my_solution.findTheString(*[[[1]]]) == a\nassert my_solution.findTheString(*[[[0]]]) == \nassert my_solution.findTheString(*[[[2, 0], [0, 1]]]) == ab\nassert my_solution.findTheString(*[[[2, 0], [1, 1]]]) == \nassert my_solution.findTheString(*[[[2, 0], [2, 1]]]) == \nassert my_solution.findTheString(*[[[2, 1], [0, 1]]]) == \nassert my_solution.findTheString(*[[[2, 1], [1, 1]]]) == aa\nassert my_solution.findTheString(*[[[2, 1], [2, 1]]]) == \nassert my_solution.findTheString(*[[[2, 2], [0, 1]]]) == \nassert my_solution.findTheString(*[[[2, 2], [1, 1]]]) == \nassert my_solution.findTheString(*[[[2, 2], [2, 1]]]) == \nassert my_solution.findTheString(*[[[4, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]]) == \nassert my_solution.findTheString(*[[[4, 1, 1, 1], [1, 3, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]]) == \nassert my_solution.findTheString(*[[[4, 1, 1, 1], [1, 3, 1, 1], [1, 1, 2, 1], [1, 1, 1, 1]]]) == \nassert my_solution.findTheString(*[[[8, 0, 0, 0, 0, 1, 2, 0], [0, 7, 0, 1, 1, 0, 0, 1], [0, 0, 6, 0, 0, 0, 0, 0], [0, 1, 0, 5, 1, 0, 0, 1], [0, 1, 0, 1, 4, 0, 0, 1], [1, 0, 0, 0, 0, 3, 1, 0], [2, 0, 0, 0, 0, 1, 2, 0], [0, 1, 0, 1, 1, 0, 0, 1]]]) == abcbbaab\nassert my_solution.findTheString(*[[[9, 1, 0, 1, 0, 1, 0, 0, 1], [1, 8, 0, 4, 0, 2, 0, 0, 1], [0, 0, 7, 0, 3, 0, 1, 2, 0], [1, 4, 0, 6, 0, 2, 0, 0, 1], [0, 0, 3, 0, 5, 0, 1, 2, 0], [1, 2, 0, 2, 0, 4, 0, 0, 1], [0, 0, 1, 0, 1, 0, 3, 1, 0], [0, 0, 2, 0, 2, 0, 1, 2, 0], [1, 1, 0, 1, 0, 1, 0, 0, 1]]]) == aabababba\nassert my_solution.findTheString(*[[[14, 2, 1, 0, 0, 0, 1, 0, 0, 0, 2, 1, 0, 0], [2, 13, 1, 0, 0, 0, 1, 0, 0, 0, 4, 1, 0, 0], [1, 1, 12, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0, 0], [0, 0, 0, 11, 1, 0, 0, 0, 2, 1, 0, 0, 2, 1], [0, 0, 0, 1, 10, 0, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 9, 0, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 8, 0, 0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0, 7, 0, 0, 0, 0, 0, 0], [0, 0, 0, 2, 1, 0, 0, 0, 6, 1, 0, 0, 2, 1], [0, 0, 0, 1, 1, 0, 0, 0, 1, 5, 0, 0, 1, 1], [2, 4, 1, 0, 0, 0, 1, 0, 0, 0, 4, 1, 0, 0], [1, 1, 3, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0, 0], [0, 0, 0, 2, 1, 0, 0, 0, 2, 1, 0, 0, 2, 1], [0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1]]]) == aaabbcacbbaabb\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2708", "questionFrontendId": "2573", "questionTitle": "Find the String with LCP", "stats": { "totalAccepted": "2K", "totalSubmission": "5.5K", "totalAcceptedRaw": 1972, "totalSubmissionRaw": 5511, "acRate": "35.8%" } }
LeetCode/2704
# Maximum Difference by Remapping a Digit You are given an integer `num`. You know that Bob will sneakily **remap** one of the `10` possible digits (`0` to `9`) to another digit. Return *the difference between the maximum and minimum values Bob can make by remapping **exactly** **one** digit in* `num`. **Notes:** * When Bob remaps a digit d1 to another digit d2, Bob replaces all occurrences of `d1` in `num` with `d2`. * Bob can remap a digit to itself, in which case `num` does not change. * Bob can remap different digits for obtaining minimum and maximum values respectively. * The resulting number after remapping can contain leading zeroes.   **Example 1:** ``` **Input:** num = 11891 **Output:** 99009 **Explanation:** To achieve the maximum value, Bob can remap the digit 1 to the digit 9 to yield 99899. To achieve the minimum value, Bob can remap the digit 1 to the digit 0, yielding 890. The difference between these two numbers is 99009. ``` **Example 2:** ``` **Input:** num = 90 **Output:** 99 **Explanation:** The maximum value that can be returned by the function is 99 (if 0 is replaced by 9) and the minimum value that can be returned by the function is 0 (if 9 is replaced by 0). Thus, we return 99. ```   **Constraints:** * `1 <= num <= 108` Please make sure your answer follows the type signature below: ```python3 class Solution: def minMaxDifference(self, num: int) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.minMaxDifference(*[11891]) == 99009\nassert my_solution.minMaxDifference(*[90]) == 99\nassert my_solution.minMaxDifference(*[22222]) == 99999\nassert my_solution.minMaxDifference(*[99999]) == 99999\nassert my_solution.minMaxDifference(*[456]) == 900\nassert my_solution.minMaxDifference(*[999]) == 999\nassert my_solution.minMaxDifference(*[909]) == 999\nassert my_solution.minMaxDifference(*[900]) == 999\nassert my_solution.minMaxDifference(*[199]) == 900\nassert my_solution.minMaxDifference(*[911]) == 988\nassert my_solution.minMaxDifference(*[867]) == 900\nassert my_solution.minMaxDifference(*[100000000]) == 900000000\nassert my_solution.minMaxDifference(*[95334529]) == 94000409\nassert my_solution.minMaxDifference(*[70682999]) == 90000000\nassert my_solution.minMaxDifference(*[90693669]) == 99090009\nassert my_solution.minMaxDifference(*[97746064]) == 92200000\nassert my_solution.minMaxDifference(*[72792650]) == 90900000\nassert my_solution.minMaxDifference(*[51734886]) == 90000000\nassert my_solution.minMaxDifference(*[39004871]) == 90000000\nassert my_solution.minMaxDifference(*[77448854]) == 99000000\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2704", "questionFrontendId": "2566", "questionTitle": "Maximum Difference by Remapping a Digit", "stats": { "totalAccepted": "6.1K", "totalSubmission": "9.6K", "totalAcceptedRaw": 6136, "totalSubmissionRaw": 9620, "acRate": "63.8%" } }
LeetCode/2706
# Minimum Score by Changing Two Elements You are given a **0-indexed** integer array `nums`. * The **low** score of `nums` is the minimum value of `|nums[i] - nums[j]|` over all `0 <= i < j < nums.length`. * The **high** score of `nums` is the maximum value of `|nums[i] - nums[j]|` over all `0 <= i < j < nums.length`. * The **score** of `nums` is the sum of the **high** and **low** scores of nums. To minimize the score of `nums`, we can change the value of **at most two** elements of `nums`. Return *the **minimum** possible **score** after changing the value of **at most two** elements o*f `nums`. Note that `|x|` denotes the absolute value of `x`.   **Example 1:** ``` **Input:** nums = [1,4,3] **Output:** 0 **Explanation:** Change value of nums[1] and nums[2] to 1 so that nums becomes [1,1,1]. Now, the value of |nums[i] - nums[j]| is always equal to 0, so we return 0 + 0 = 0. ``` **Example 2:** ``` **Input:** nums = [1,4,7,8,5] **Output:** 3 **Explanation:** Change nums[0] and nums[1] to be 6. Now nums becomes [6,6,7,8,5]. Our low score is achieved when i = 0 and j = 1, in which case |nums[i] - nums[j]| = |6 - 6| = 0. Our high score is achieved when i = 3 and j = 4, in which case |nums[i] - nums[j]| = |8 - 5| = 3. The sum of our high and low score is 3, which we can prove to be minimal. ```   **Constraints:** * `3 <= nums.length <= 105` * `1 <= nums[i] <= 109` Please make sure your answer follows the type signature below: ```python3 class Solution: def minimizeSum(self, nums: List[int]) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.minimizeSum(*[[1, 4, 3]]) == 0\nassert my_solution.minimizeSum(*[[1, 4, 7, 8, 5]]) == 3\nassert my_solution.minimizeSum(*[[31, 25, 72, 79, 74, 65]]) == 14\nassert my_solution.minimizeSum(*[[59, 27, 9, 81, 33]]) == 24\nassert my_solution.minimizeSum(*[[58, 42, 8, 75, 28]]) == 30\nassert my_solution.minimizeSum(*[[21, 13, 21, 72, 35, 52, 74]]) == 39\nassert my_solution.minimizeSum(*[[65, 77, 1, 73, 32, 43]]) == 34\nassert my_solution.minimizeSum(*[[100, 84, 80]]) == 0\nassert my_solution.minimizeSum(*[[88, 42, 53, 98]]) == 10\nassert my_solution.minimizeSum(*[[40, 60, 23, 99, 83, 5, 21, 76, 34, 99]]) == 76\nassert my_solution.minimizeSum(*[[23, 70, 18, 64, 12, 21, 21, 78, 36, 58]]) == 52\nassert my_solution.minimizeSum(*[[99, 26, 92, 91, 53, 10, 24, 25, 20, 92]]) == 72\nassert my_solution.minimizeSum(*[[51, 65, 87, 6, 17, 32, 14, 42, 46, 65]]) == 51\nassert my_solution.minimizeSum(*[[9, 75, 76, 25, 96, 46, 85, 19]]) == 66\nassert my_solution.minimizeSum(*[[88, 2, 5, 24, 60, 26]]) == 24\nassert my_solution.minimizeSum(*[[96, 82, 97, 97, 72]]) == 1\nassert my_solution.minimizeSum(*[[21, 77, 82, 30, 94, 55, 76]]) == 39\nassert my_solution.minimizeSum(*[[82, 3, 89, 52, 96, 72, 27, 59, 57]]) == 44\nassert my_solution.minimizeSum(*[[46, 88, 41]]) == 0\nassert my_solution.minimizeSum(*[[46, 4, 17, 2, 95, 6, 62, 69, 10]]) == 60\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2706", "questionFrontendId": "2567", "questionTitle": "Minimum Score by Changing Two Elements", "stats": { "totalAccepted": "4.5K", "totalSubmission": "8.4K", "totalAcceptedRaw": 4464, "totalSubmissionRaw": 8441, "acRate": "52.9%" } }
LeetCode/2705
# Minimum Impossible OR You are given a **0-indexed** integer array `nums`. We say that an integer x is **expressible** from `nums` if there exist some integers `0 <= index1 < index2 < ... < indexk < nums.length` for which `nums[index1] | nums[index2] | ... | nums[indexk] = x`. In other words, an integer is expressible if it can be written as the bitwise OR of some subsequence of `nums`. Return *the minimum **positive non-zero integer** that is not* *expressible from* `nums`.   **Example 1:** ``` **Input:** nums = [2,1] **Output:** 4 **Explanation:** 1 and 2 are already present in the array. We know that 3 is expressible, since nums[0] | nums[1] = 2 | 1 = 3. Since 4 is not expressible, we return 4. ``` **Example 2:** ``` **Input:** nums = [5,3,2] **Output:** 1 **Explanation:** We can show that 1 is the smallest number that is not expressible. ```   **Constraints:** * `1 <= nums.length <= 105` * `1 <= nums[i] <= 109` Please make sure your answer follows the type signature below: ```python3 class Solution: def minImpossibleOR(self, nums: List[int]) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.minImpossibleOR(*[[2, 1]]) == 4\nassert my_solution.minImpossibleOR(*[[5, 3, 2]]) == 1\nassert my_solution.minImpossibleOR(*[[1, 25, 2, 72]]) == 4\nassert my_solution.minImpossibleOR(*[[4, 32, 16, 8, 8, 75, 1, 2]]) == 64\nassert my_solution.minImpossibleOR(*[[25, 2, 1, 92, 8, 4, 16]]) == 32\nassert my_solution.minImpossibleOR(*[[4, 1, 2, 8, 8, 16]]) == 32\nassert my_solution.minImpossibleOR(*[[2, 64, 1, 32, 4, 8, 16]]) == 128\nassert my_solution.minImpossibleOR(*[[1, 4, 2]]) == 8\nassert my_solution.minImpossibleOR(*[[4, 2, 1]]) == 8\nassert my_solution.minImpossibleOR(*[[21, 1]]) == 2\nassert my_solution.minImpossibleOR(*[[2, 4, 16, 1, 128, 64, 32, 8]]) == 256\nassert my_solution.minImpossibleOR(*[[1, 2, 4]]) == 8\nassert my_solution.minImpossibleOR(*[[4, 2, 8, 1, 87, 16, 6]]) == 32\nassert my_solution.minImpossibleOR(*[[96, 1]]) == 2\nassert my_solution.minImpossibleOR(*[[2, 1, 88]]) == 4\nassert my_solution.minImpossibleOR(*[[76, 2, 96, 82, 4, 8, 24, 1]]) == 16\nassert my_solution.minImpossibleOR(*[[1]]) == 2\nassert my_solution.minImpossibleOR(*[[6, 8, 46, 57, 59, 97, 4, 2, 1]]) == 16\nassert my_solution.minImpossibleOR(*[[2, 46, 1, 1, 24, 55, 71, 63]]) == 4\nassert my_solution.minImpossibleOR(*[[2, 8, 32, 1, 4, 16, 43, 64]]) == 128\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2705", "questionFrontendId": "2568", "questionTitle": "Minimum Impossible OR", "stats": { "totalAccepted": "4.1K", "totalSubmission": "6.8K", "totalAcceptedRaw": 4147, "totalSubmissionRaw": 6761, "acRate": "61.3%" } }
LeetCode/2703
# Handling Sum Queries After Update You are given two **0-indexed** arrays `nums1` and `nums2` and a 2D array `queries` of queries. There are three types of queries: 1. For a query of type 1, `queries[i] = [1, l, r]`. Flip the values from `0` to `1` and from `1` to `0` in `nums1` from index `l` to index `r`. Both `l` and `r` are **0-indexed**. 2. For a query of type 2, `queries[i] = [2, p, 0]`. For every index `0 <= i < n`, set `nums2[i] = nums2[i] + nums1[i] * p`. 3. For a query of type 3, `queries[i] = [3, 0, 0]`. Find the sum of the elements in `nums2`. Return *an array containing all the answers to the third type queries.*   **Example 1:** ``` **Input:** nums1 = [1,0,1], nums2 = [0,0,0], queries = [[1,1,1],[2,1,0],[3,0,0]] **Output:** [3] **Explanation:** After the first query nums1 becomes [1,1,1]. After the second query, nums2 becomes [1,1,1], so the answer to the third query is 3. Thus, [3] is returned. ``` **Example 2:** ``` **Input:** nums1 = [1], nums2 = [5], queries = [[2,0,0],[3,0,0]] **Output:** [5] **Explanation:** After the first query, nums2 remains [5], so the answer to the second query is 5. Thus, [5] is returned. ```   **Constraints:** * `1 <= nums1.length,nums2.length <= 105` * `nums1.length = nums2.length` * `1 <= queries.length <= 105` * `queries[i].length = 3` * `0 <= l <= r <= nums1.length - 1` * `0 <= p <= 106` * `0 <= nums1[i] <= 1` * `0 <= nums2[i] <= 109` Please make sure your answer follows the type signature below: ```python3 class Solution: def handleQuery(self, nums1: List[int], nums2: List[int], queries: List[List[int]]) -> List[int]: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.handleQuery(*[[1, 0, 1], [0, 0, 0], [[1, 1, 1], [2, 1, 0], [3, 0, 0]]]) == [3]\nassert my_solution.handleQuery(*[[1], [5], [[2, 0, 0], [3, 0, 0]]]) == [5]\nassert my_solution.handleQuery(*[[1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0], [48, 2, 32, 25, 30, 37, 32, 18, 48, 39, 34, 19, 46, 43, 30, 22, 20, 35, 28, 3, 5, 45, 39, 21, 46, 45, 12, 15], [[3, 0, 0], [2, 3, 0], [1, 10, 26], [2, 4, 0], [2, 18, 0]]]) == [819]\nassert my_solution.handleQuery(*[[0, 1, 0, 1, 0, 1, 0, 0, 0, 1], [35, 34, 38, 28, 38, 20, 18, 12, 2, 30], [[1, 2, 4], [1, 1, 9], [3, 0, 0]]]) == [255]\nassert my_solution.handleQuery(*[[1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0], [33, 13, 37, 28, 42, 5, 39, 31, 12, 1, 7, 23, 21], [[1, 1, 3], [3, 0, 0], [1, 0, 9], [3, 0, 0], [3, 0, 0], [3, 0, 0], [3, 0, 0], [1, 0, 1], [3, 0, 0], [1, 9, 9], [2, 3, 0], [2, 27, 0], [1, 0, 9], [1, 3, 5]]]) == [292, 292, 292, 292, 292, 292]\nassert my_solution.handleQuery(*[[0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1], [30, 46, 43, 34, 39, 16, 14, 41, 22, 11, 32, 2, 44, 12, 22, 36, 44, 49, 50, 10, 33, 7, 42], [[1, 15, 21], [3, 0, 0], [3, 0, 0], [2, 21, 0], [2, 13, 0], [3, 0, 0]]]) == [679, 679, 1053]\nassert my_solution.handleQuery(*[[0, 0, 0, 0, 1, 0, 1, 1, 1], [35, 29, 21, 34, 8, 48, 22, 43, 37], [[1, 4, 7], [3, 0, 0], [2, 27, 0], [3, 0, 0], [1, 0, 3], [3, 0, 0], [2, 6, 0], [1, 3, 8], [2, 13, 0], [3, 0, 0], [3, 0, 0], [3, 0, 0], [2, 2, 0], [2, 28, 0], [3, 0, 0], [3, 0, 0], [2, 25, 0], [3, 0, 0], [3, 0, 0], [1, 2, 5]]]) == [277, 331, 331, 445, 445, 445, 625, 625, 775, 775]\nassert my_solution.handleQuery(*[[1, 0, 1], [44, 28, 35], [[1, 0, 1], [2, 10, 0], [2, 2, 0], [2, 7, 0], [3, 0, 0], [3, 0, 0], [1, 2, 2], [1, 1, 2], [2, 1, 0], [1, 0, 2], [1, 2, 2], [1, 0, 2], [3, 0, 0], [1, 1, 2], [3, 0, 0], [1, 0, 1], [2, 21, 0], [1, 0, 1], [2, 26, 0], [1, 1, 1]]]) == [145, 145, 146, 146]\nassert my_solution.handleQuery(*[[1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0], [7, 17, 2, 13, 35, 23, 47, 45, 40, 23, 13, 37, 0, 9, 21, 50, 45, 21, 2, 10, 37], [[2, 13, 0], [3, 0, 0], [1, 9, 10], [2, 24, 0], [1, 1, 10], [1, 16, 16], [2, 13, 0], [2, 10, 0], [2, 4, 0], [1, 17, 20]]]) == [653]\nassert my_solution.handleQuery(*[[1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0], [21, 30, 44, 27, 19, 47, 10, 40, 4, 12, 3, 0, 25, 28, 50, 27], [[2, 8, 0], [2, 19, 0], [1, 13, 13]]]) == []\nassert my_solution.handleQuery(*[[0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1], [4, 33, 48, 7, 25, 13, 13, 6, 29, 23, 6, 9], [[2, 21, 0], [3, 0, 0], [2, 29, 0], [3, 0, 0], [2, 22, 0], [2, 27, 0], [2, 16, 0], [3, 0, 0], [3, 0, 0], [1, 8, 9], [1, 5, 10], [3, 0, 0], [2, 27, 0], [2, 2, 0], [3, 0, 0], [1, 4, 6], [2, 19, 0], [2, 23, 0], [3, 0, 0]]]) == [321, 466, 791, 791, 791, 994, 1246]\nassert my_solution.handleQuery(*[[1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0], [4, 33, 4, 8, 19, 48, 21, 9, 23, 33, 36, 43, 47, 48, 18, 30, 38, 1, 47, 19, 21, 31, 19, 24, 3, 41], [[1, 9, 19], [1, 1, 16], [2, 5, 0], [2, 29, 0], [3, 0, 0]]]) == [1280]\nassert my_solution.handleQuery(*[[0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1], [43, 22, 2, 24, 3, 30, 1, 38, 40, 6, 12, 50, 7, 39, 39, 41, 43, 50, 24, 47, 33, 2, 28], [[1, 14, 19], [3, 0, 0], [1, 1, 2], [2, 9, 0], [1, 16, 21], [3, 0, 0], [3, 0, 0], [1, 7, 9], [3, 0, 0], [3, 0, 0], [3, 0, 0], [3, 0, 0]]]) == [624, 714, 714, 714, 714, 714, 714]\nassert my_solution.handleQuery(*[[1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0], [7, 27, 5, 26, 6, 49, 46, 50, 27, 1, 20, 5, 4, 22], [[2, 12, 0]]]) == []\nassert my_solution.handleQuery(*[[0, 1, 0, 0, 0, 0], [14, 4, 13, 13, 47, 18], [[3, 0, 0], [1, 4, 4], [1, 1, 4], [1, 3, 4], [3, 0, 0], [2, 5, 0], [1, 1, 3], [2, 16, 0], [2, 10, 0], [3, 0, 0], [3, 0, 0], [2, 6, 0]]]) == [109, 109, 197, 197]\nassert my_solution.handleQuery(*[[0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1], [6, 10, 9, 14, 32, 15, 18, 26, 8, 25, 44, 8, 19, 47, 37, 19, 5, 28, 40], [[1, 12, 15], [1, 13, 18], [2, 15, 0], [1, 11, 15], [2, 3, 0], [1, 3, 11], [1, 17, 17], [3, 0, 0], [2, 30, 0], [2, 6, 0], [2, 14, 0], [1, 7, 14], [2, 30, 0], [3, 0, 0], [1, 11, 18], [3, 0, 0], [3, 0, 0]]]) == [539, 1279, 1279, 1279]\nassert my_solution.handleQuery(*[[1, 0, 0], [48, 18, 44], [[3, 0, 0], [2, 1, 0], [1, 1, 1], [3, 0, 0], [2, 18, 0], [3, 0, 0], [1, 1, 2], [1, 2, 2], [1, 2, 2], [2, 21, 0], [1, 0, 1], [3, 0, 0], [1, 0, 1], [2, 17, 0], [3, 0, 0]]]) == [110, 111, 147, 189, 223]\nassert my_solution.handleQuery(*[[1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1], [28, 47, 22, 48, 38, 2, 50, 19, 7, 48, 4, 18, 33, 36, 34, 26, 47, 18, 23, 10, 44, 24, 37], [[1, 17, 22], [2, 12, 0], [3, 0, 0], [2, 24, 0], [2, 7, 0], [2, 16, 0], [3, 0, 0], [3, 0, 0], [2, 16, 0], [3, 0, 0], [1, 14, 18], [1, 15, 15], [3, 0, 0], [1, 0, 11], [2, 13, 0]]]) == [795, 1312, 1312, 1488, 1488]\nassert my_solution.handleQuery(*[[0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0], [33, 43, 43, 0, 2, 39, 17, 46, 9, 12, 27, 45, 24, 21, 41, 9, 45, 33, 8, 11, 22, 27, 24, 50, 28, 37, 24, 14, 11], [[1, 23, 28], [3, 0, 0], [1, 7, 26], [2, 20, 0], [1, 22, 28], [3, 0, 0], [2, 25, 0], [2, 14, 0], [2, 2, 0], [3, 0, 0], [3, 0, 0], [3, 0, 0]]]) == [745, 925, 1417, 1417, 1417]\nassert my_solution.handleQuery(*[[1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0], [37, 31, 45, 13, 17, 2, 10, 0, 41, 8, 50, 43, 38, 35, 29, 21, 38, 50, 20, 20, 1, 12], [[1, 6, 17], [1, 6, 14], [3, 0, 0], [3, 0, 0], [3, 0, 0], [2, 10, 0], [3, 0, 0], [2, 9, 0], [2, 12, 0], [3, 0, 0], [1, 1, 10], [3, 0, 0]]]) == [561, 561, 561, 711, 1026, 1026]\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2703", "questionFrontendId": "2569", "questionTitle": "Handling Sum Queries After Update", "stats": { "totalAccepted": "13.1K", "totalSubmission": "30.9K", "totalAcceptedRaw": 13094, "totalSubmissionRaw": 30870, "acRate": "42.4%" } }
LeetCode/2698
# Find the Array Concatenation Value You are given a **0-indexed** integer array `nums`. The **concatenation** of two numbers is the number formed by concatenating their numerals. * For example, the concatenation of `15`, `49` is `1549`. The **concatenation value** of `nums` is initially equal to `0`. Perform this operation until `nums` becomes empty: * If there exists more than one number in `nums`, pick the first element and last element in `nums` respectively and add the value of their concatenation to the **concatenation value** of `nums`, then delete the first and last element from `nums`. * If one element exists, add its value to the **concatenation value** of `nums`, then delete it. Return *the concatenation value of the `nums`*.   **Example 1:** ``` **Input:** nums = [7,52,2,4] **Output:** 596 **Explanation:** Before performing any operation, nums is [7,52,2,4] and concatenation value is 0. - In the first operation: We pick the first element, 7, and the last element, 4. Their concatenation is 74, and we add it to the concatenation value, so it becomes equal to 74. Then we delete them from nums, so nums becomes equal to [52,2]. - In the second operation: We pick the first element, 52, and the last element, 2. Their concatenation is 522, and we add it to the concatenation value, so it becomes equal to 596. Then we delete them from the nums, so nums becomes empty. Since the concatenation value is 596 so the answer is 596. ``` **Example 2:** ``` **Input:** nums = [5,14,13,8,12] **Output:** 673 **Explanation:** Before performing any operation, nums is [5,14,13,8,12] and concatenation value is 0. - In the first operation: We pick the first element, 5, and the last element, 12. Their concatenation is 512, and we add it to the concatenation value, so it becomes equal to 512. Then we delete them from the nums, so nums becomes equal to [14,13,8]. - In the second operation: We pick the first element, 14, and the last element, 8. Their concatenation is 148, and we add it to the concatenation value, so it becomes equal to 660. Then we delete them from the nums, so nums becomes equal to [13]. - In the third operation: nums has only one element, so we pick 13 and add it to the concatenation value, so it becomes equal to 673. Then we delete it from nums, so nums become empty. Since the concatenation value is 673 so the answer is 673. ```   **Constraints:** * `1 <= nums.length <= 1000` * `1 <= nums[i] <= 104`   .spoilerbutton {display:block; border:dashed; padding: 0px 0px; margin:10px 0px; font-size:150%; font-weight: bold; color:#000000; background-color:cyan; outline:0;  } .spoiler {overflow:hidden;} .spoiler > div {-webkit-transition: all 0s ease;-moz-transition: margin 0s ease;-o-transition: all 0s ease;transition: margin 0s ease;} .spoilerbutton[value="Show Message"] + .spoiler > div {margin-top:-500%;} .spoilerbutton[value="Hide Message"] + .spoiler {padding:5px;} Please make sure your answer follows the type signature below: ```python3 class Solution: def findTheArrayConcVal(self, nums: List[int]) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.findTheArrayConcVal(*[[7, 52, 2, 4]]) == 596\nassert my_solution.findTheArrayConcVal(*[[5, 14, 13, 8, 12]]) == 673\nassert my_solution.findTheArrayConcVal(*[[1, 78, 27, 48, 14, 86, 79, 68, 77, 20, 57, 21, 18, 67, 5, 51, 70, 85, 47, 56, 22, 79, 41, 8, 39, 81, 59, 74, 14, 45, 49, 15, 10, 28]]) == 74322\nassert my_solution.findTheArrayConcVal(*[[77, 22, 65, 8, 36, 79, 94, 44]]) == 17453\nassert my_solution.findTheArrayConcVal(*[[72, 8, 96, 78, 39, 92, 69, 55, 9, 44, 26, 76, 40, 77, 16, 69, 40, 64, 12, 48, 66, 7, 59, 10, 33, 72, 97, 60, 79, 68, 25, 63, 82, 88, 60, 37, 60, 44, 14, 62]]) == 103006\nassert my_solution.findTheArrayConcVal(*[[52, 73, 26, 98, 86, 50, 74, 68, 53, 80, 90, 60, 78, 56, 53, 84, 2, 26]]) == 51959\nassert my_solution.findTheArrayConcVal(*[[83, 48, 10, 24, 55, 9, 100, 10, 17, 17, 99, 51, 32, 16, 98, 99, 31, 28, 68, 71, 14]]) == 37907\nassert my_solution.findTheArrayConcVal(*[[29, 15, 40, 59, 57, 40, 57, 51, 90, 51, 68, 100, 24, 39, 11, 85, 2, 22, 67, 29, 74, 82, 10, 96, 14, 35, 25, 76, 26, 54, 29, 44]]) == 74635\nassert my_solution.findTheArrayConcVal(*[[49, 73, 50, 95, 89, 43, 62, 24, 88, 88, 36, 6, 16, 14, 2, 42, 42, 60, 25, 4, 58, 23, 22, 27, 26, 3, 79, 64, 20, 92, 63, 56]]) == 71344\nassert my_solution.findTheArrayConcVal(*[[98, 34, 47, 91, 91, 23, 88, 43, 53, 29, 70, 23, 77, 24, 22, 4, 79, 38, 13, 36, 94, 19, 91, 44, 8, 56, 97, 77, 93, 55, 59, 77, 8, 95, 48, 50, 59, 32, 76, 78, 31, 3, 81, 44, 5, 52]]) == 104808\nassert my_solution.findTheArrayConcVal(*[[88, 86, 87, 92, 69, 58, 82, 50, 82, 34, 72, 56, 46, 35, 85, 4, 16, 58, 52, 51, 53, 67, 29, 12, 42, 67, 76]]) == 85807\nassert my_solution.findTheArrayConcVal(*[[51, 31, 49, 9, 72, 83, 84, 12, 85, 78, 73, 3, 48, 22, 59, 99, 63, 10, 21, 43, 77, 43, 74, 75, 27, 13, 29, 73, 13, 20, 6, 56, 75, 83, 26, 24, 53, 56, 61, 96, 57, 33, 89, 99, 93, 81, 28, 49]]) == 126740\nassert my_solution.findTheArrayConcVal(*[[88, 29, 51, 26, 95, 35, 61, 31, 96, 15, 65, 87, 12, 15, 81, 38, 96, 58, 23, 85, 5, 81, 26, 98, 66, 53, 92, 87, 23, 29, 53, 83, 63, 63, 25, 25, 72, 47, 34, 24]]) == 102099\nassert my_solution.findTheArrayConcVal(*[[8, 43, 100, 80, 17, 72, 69, 7, 7, 32, 80, 8, 58, 70, 81, 79, 67, 66, 24, 64, 66, 9, 67, 33, 11, 62, 86, 5, 84, 78, 85, 69]]) == 73246\nassert my_solution.findTheArrayConcVal(*[[92, 14]]) == 9214\nassert my_solution.findTheArrayConcVal(*[[90, 31, 40, 54, 63, 99, 88, 28, 100, 5, 72, 89, 60, 90, 71, 97, 16, 7, 60, 6, 57, 73, 84, 17, 8, 77, 60, 7, 74, 74, 24, 52, 43, 94]]) == 93917\nassert my_solution.findTheArrayConcVal(*[[9, 99, 84, 89, 96, 40, 15, 29, 80, 19, 54, 75, 49, 27, 87, 95, 22, 28, 54, 66, 55, 99, 17, 75]]) == 69574\nassert my_solution.findTheArrayConcVal(*[[90, 47, 14, 9, 63, 18, 51, 15, 50, 24, 86, 30, 44, 51, 13, 91, 95, 52, 50, 99]]) == 38711\nassert my_solution.findTheArrayConcVal(*[[74, 67, 34, 75, 31, 91, 47, 6, 37, 62, 72, 42, 85, 95, 10, 8, 43, 21, 63]]) == 39951\nassert my_solution.findTheArrayConcVal(*[[45, 23, 69, 16, 99, 92, 5, 97, 69, 33, 44, 8, 33]]) == 32619\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2698", "questionFrontendId": "2562", "questionTitle": "Find the Array Concatenation Value", "stats": { "totalAccepted": "34.8K", "totalSubmission": "46.1K", "totalAcceptedRaw": 34830, "totalSubmissionRaw": 46076, "acRate": "75.6%" } }
LeetCode/2699
# Count the Number of Fair Pairs Given a **0-indexed** integer array `nums` of size `n` and two integers `lower` and `upper`, return *the number of fair pairs*. A pair `(i, j)` is **fair** if: * `0 <= i < j < n`, and * `lower <= nums[i] + nums[j] <= upper`   **Example 1:** ``` **Input:** nums = [0,1,7,4,4,5], lower = 3, upper = 6 **Output:** 6 **Explanation:** There are 6 fair pairs: (0,3), (0,4), (0,5), (1,3), (1,4), and (1,5). ``` **Example 2:** ``` **Input:** nums = [1,7,9,2,5], lower = 11, upper = 11 **Output:** 1 **Explanation:** There is a single fair pair: (2,3). ```   **Constraints:** * `1 <= nums.length <= 105` * `nums.length == n` * `-109 <= nums[i] <= 109` * `-109 <= lower <= upper <= 109` Please make sure your answer follows the type signature below: ```python3 class Solution: def countFairPairs(self, nums: List[int], lower: int, upper: int) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.countFairPairs(*[[0, 1, 7, 4, 4, 5], 3, 6]) == 6\nassert my_solution.countFairPairs(*[[1, 7, 9, 2, 5], 11, 11]) == 1\nassert my_solution.countFairPairs(*[[-1, 0], 1, 1]) == 0\nassert my_solution.countFairPairs(*[[-1, -1, 0, 0], 1, 1]) == 0\nassert my_solution.countFairPairs(*[[0, 0, 0, 0, 0, 0], 0, 0]) == 15\nassert my_solution.countFairPairs(*[[0, 0, 0, 0, 0, 0], -1000000000, 1000000000]) == 15\nassert my_solution.countFairPairs(*[[6, 5, 10, 2, 4, 9, 0, 7], 20, 20]) == 0\nassert my_solution.countFairPairs(*[[6, 9, 4, 2, 7, 5, 10, 3], 13, 13]) == 3\nassert my_solution.countFairPairs(*[[5, 7, 5, 7, 5], 12, 12]) == 6\nassert my_solution.countFairPairs(*[[-5, -7, -5, -7, -5], -12, -12]) == 6\nassert my_solution.countFairPairs(*[[7, 9, 8, 6, -1000000000, -1000000000, -1000000000, -1000000000], -14, 11]) == 0\nassert my_solution.countFairPairs(*[[-2, -6, 4, 0, -1000000000, -1000000000, -1000000000, -1000000000], -15, 15]) == 6\nassert my_solution.countFairPairs(*[[7, -2, 2, 8, -1000000000, -1000000000, -1000000000, -1000000000], -15, 11]) == 5\nassert my_solution.countFairPairs(*[[-3, 0, 6, -9, 10, 9, -7, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000], -15, 14]) == 17\nassert my_solution.countFairPairs(*[[10, -9, -5, 8, -2, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000], -12, 11]) == 8\nassert my_solution.countFairPairs(*[[9, -2, 4, -1000000000, -1000000000, -1000000000], -14, 11]) == 2\nassert my_solution.countFairPairs(*[[3, -8, -5, -4, -1000000000, -1000000000, -1000000000, -1000000000], -10, 15]) == 4\nassert my_solution.countFairPairs(*[[-9, -6, -3, -7, 0, 1, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000], -11, 15]) == 11\nassert my_solution.countFairPairs(*[[-3, -10, -9, -5, 4, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000], -10, 11]) == 5\nassert my_solution.countFairPairs(*[[10, -3, 3, 8, 2, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000], -14, 14]) == 9\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2699", "questionFrontendId": "2563", "questionTitle": "Count the Number of Fair Pairs", "stats": { "totalAccepted": "8.5K", "totalSubmission": "24.2K", "totalAcceptedRaw": 8511, "totalSubmissionRaw": 24223, "acRate": "35.1%" } }
LeetCode/2700
# Substring XOR Queries You are given a **binary string** `s`, and a **2D** integer array `queries` where `queries[i] = [firsti, secondi]`. For the `ith` query, find the **shortest substring** of `s` whose **decimal value**, `val`, yields `secondi` when **bitwise XORed** with `firsti`. In other words, `val ^ firsti == secondi`. The answer to the `ith` query is the endpoints (**0-indexed**) of the substring `[lefti, righti]` or `[-1, -1]` if no such substring exists. If there are multiple answers, choose the one with the **minimum** `lefti`. *Return an array* `ans` *where* `ans[i] = [lefti, righti]` *is the answer to the* `ith` *query.* A **substring** is a contiguous non-empty sequence of characters within a string.   **Example 1:** ``` **Input:** s = "101101", queries = [[0,5],[1,2]] **Output:** [[0,2],[2,3]] **Explanation:** For the first query the substring in range [0,2] is **"101"** which has a decimal value of **`5`**, and **`5 ^ 0 = 5`**, hence the answer to the first query is [0,2]. In the second query, the substring in range [2,3] is **"11",** and has a decimal value of **3**, and **3 `^ 1 = 2`**. So, [2,3] is returned for the second query. ``` **Example 2:** ``` **Input:** s = "0101", queries = [[12,8]] **Output:** [[-1,-1]] **Explanation:** In this example there is no substring that answers the query, hence [-1,-1] is returned. ``` **Example 3:** ``` **Input:** s = "1", queries = [[4,5]] **Output:** [[0,0]] **Explanation:** For this example, the substring in range [0,0] has a decimal value of **`1`**, and **`1 ^ 4 = 5`**. So, the answer is [0,0]. ```   **Constraints:** * `1 <= s.length <= 104` * `s[i]` is either `'0'` or `'1'`. * `1 <= queries.length <= 105` * `0 <= firsti, secondi <= 109` Please make sure your answer follows the type signature below: ```python3 class Solution: def substringXorQueries(self, s: str, queries: List[List[int]]) -> List[List[int]]: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.substringXorQueries(*['101101', [[0, 5], [1, 2]]]) == [[0, 2], [2, 3]]\nassert my_solution.substringXorQueries(*['0101', [[12, 8]]]) == [[-1, -1]]\nassert my_solution.substringXorQueries(*['1', [[4, 5]]]) == [[0, 0]]\nassert my_solution.substringXorQueries(*['001', [[1, 0], [1, 0], [9, 8], [1, 0], [4, 5], [9, 8], [3, 2], [2, 3], [5, 4], [6, 7], [2, 3], [2, 3], [2, 3], [4, 5]]]) == [[2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2]]\nassert my_solution.substringXorQueries(*['111010110', [[4, 2], [3, 3], [6, 4], [9, 9], [10, 28], [0, 470], [5, 83], [10, 28], [8, 15], [6, 464], [0, 3], [5, 8], [7, 7], [8, 8], [6, 208], [9, 15], [2, 2], [9, 95]]]) == [[1, 3], [3, 3], [2, 3], [3, 3], [4, 8], [0, 8], [2, 8], [4, 8], [0, 2], [0, 8], [0, 1], [1, 4], [3, 3], [3, 3], [1, 8], [1, 3], [3, 3], [2, 8]]\nassert my_solution.substringXorQueries(*['11101010111', [[4, 19], [9, 30], [4, 19], [2, 853], [4, 3], [9, 94], [10, 861], [7, 18], [8, 1887], [0, 3], [2, 5], [5, 4], [0, 87], [2, 21], [4, 5], [4, 15], [0, 7], [5, 4]]]) == [[6, 10], [6, 10], [6, 10], [1, 10], [0, 2], [4, 10], [1, 10], [2, 6], [0, 10], [0, 1], [0, 2], [0, 0], [4, 10], [6, 10], [0, 0], [6, 9], [0, 2], [0, 0]]\nassert my_solution.substringXorQueries(*['0000001111101001010', [[0, 3914], [2, 4], [2, 2], [3, 8009], [4, 3918], [7, 26]]]) == [[7, 18], [9, 11], [0, 0], [6, 18], [7, 18], [8, 12]]\nassert my_solution.substringXorQueries(*['1001101111001110001010', [[2, 0], [9, 899], [6, 5004], [6, 7], [10, 4992], [10, 10], [9, 899], [9, 899], [1, 1]]]) == [[0, 1], [12, 21], [9, 21], [0, 0], [9, 21], [1, 1], [12, 21], [12, 21], [1, 1]]\nassert my_solution.substringXorQueries(*['1110100011011111110011', [[8, 59], [10, 11], [3, 112], [3, 2], [5, 502], [9, 3573]]]) == [[16, 21], [0, 0], [15, 21], [0, 0], [13, 21], [8, 19]]\nassert my_solution.substringXorQueries(*['01110001101000011000010', [[0, 49], [6, 577732], [9, 11], [6, 68], [4, 1076], [2, 53440], [7, 5], [2, 0]]]) == [[2, 7], [3, 22], [3, 4], [16, 22], [10, 20], [7, 22], [3, 4], [3, 4]]\nassert my_solution.substringXorQueries(*['0001001110111101100101100', [[10, 10], [3, 7663], [7, 43], [1, 45], [7, 3], [3, 15], [9, 37], [9, 148], [4, 4], [6, 48528], [8, 9], [7, 15147], [10, 61295], [9, 485], [4, 0], [9, 37], [8, 8]]]) == [[0, 0], [6, 18], [13, 18], [13, 18], [3, 5], [15, 18], [13, 18], [3, 10], [0, 0], [8, 23], [3, 3], [11, 24], [6, 21], [10, 18], [3, 5], [13, 18], [0, 0]]\nassert my_solution.substringXorQueries(*['111100000011011100010000111', [[2, 14469], [9, 142], [4, 789952], [5, 491965], [1, 6], [9, 14], [9, 747], [2, 4], [8, 14], [0, 3], [1, 56386], [9, 120], [9, 142], [3, 7685]]]) == [[13, 26], [19, 26], [2, 21], [0, 18], [0, 2], [0, 2], [11, 20], [2, 4], [2, 4], [0, 1], [10, 25], [13, 19], [19, 26], [0, 12]]\nassert my_solution.substringXorQueries(*['01010011000111011011100010111', [[2, 1], [10, 11], [1, 0], [6, 243473], [2, 2340629], [4, 787], [5, 3801]]]) == [[6, 7], [1, 1], [1, 1], [11, 28], [7, 28], [19, 28], [11, 22]]\nassert my_solution.substringXorQueries(*['101111010010100100111101111111', [[1, 20350], [9, 8], [2, 3], [6, 27], [7, 38041], [1, 60], [10, 675701], [2, 675709], [0, 895], [8, 20343], [10, 9], [7, 6], [8, 11], [8, 20343], [9, 675702], [5, 3962], [2, 168925], [5, 20346], [4, 6]]]) == [[15, 29], [0, 0], [0, 0], [3, 7], [7, 22], [2, 7], [10, 29], [10, 29], [20, 29], [15, 29], [2, 3], [0, 0], [2, 3], [15, 29], [10, 29], [18, 29], [10, 27], [15, 29], [0, 1]]\nassert my_solution.substringXorQueries(*['11111111011010011101000110010111110', [[1, 63], [4, 186], [3, 5]]]) == [[3, 8], [27, 34], [6, 8]]\nassert my_solution.substringXorQueries(*['001000010111100100000100011100110010', [[5, 18231], [6, 132], [4, 54], [5, 2363849], [1, 3088527], [3, 126895921]]]) == [[21, 35], [15, 22], [11, 16], [12, 33], [7, 28], [9, 35]]\nassert my_solution.substringXorQueries(*['00000001010101001110000100010001111010', [[2, 13], [2, 639521], [7, 22339862], [9, 17523], [0, 4], [10, 1136], [4, 1150], [3, 9], [0, 2], [4, 5], [5, 7], [1, 3], [6, 1148], [0, 43632], [2, 4380], [9, 9], [2, 626]]]) == [[31, 34], [13, 32], [7, 31], [23, 37], [13, 15], [27, 37], [27, 37], [7, 10], [7, 8], [7, 7], [7, 8], [7, 8], [27, 37], [7, 22], [23, 35], [0, 0], [13, 22]]\nassert my_solution.substringXorQueries(*['00010100110111000001011110110010110000111000', [[10, 10], [4, 5], [8, 12070765], [5, 61], [8, 56], [9, 230143], [7, 63], [3, 11323], [10, 1436], [4, 6], [4, 185], [1, 47]]]) == [[0, 0], [3, 3], [9, 32], [11, 16], [12, 17], [11, 28], [11, 16], [30, 43], [24, 34], [3, 4], [19, 26], [9, 14]]\nassert my_solution.substringXorQueries(*['01110111011100111001110010111010000110010011', [[3, 15656762], [2, 13360], [0, 403], [5, 9]]]) == [[1, 24], [27, 40], [35, 43], [10, 13]]\nassert my_solution.substringXorQueries(*['01111111001011010011100101000010011100101100', [[6, 165091], [0, 1021596], [3, 720], [2, 510796], [9, 1665475], [2, 1320750], [0, 26486572], [6, 272170], [3, 3886], [2, 12], [7, 272171], [0, 1320748], [2, 55464094], [6, 42], [10, 46319], [6, 14], [1, 151], [10, 10022], [4, 13243282]]]) == [[23, 40], [3, 22], [10, 19], [3, 21], [6, 26], [23, 43], [19, 43], [25, 43], [4, 15], [5, 8], [25, 43], [23, 43], [12, 37], [38, 43], [10, 25], [25, 28], [7, 14], [30, 43], [19, 42]]\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2700", "questionFrontendId": "2564", "questionTitle": "Substring XOR Queries", "stats": { "totalAccepted": "5.3K", "totalSubmission": "14K", "totalAcceptedRaw": 5265, "totalSubmissionRaw": 14030, "acRate": "37.5%" } }
LeetCode/2701
# Subsequence With the Minimum Score You are given two strings `s` and `t`. You are allowed to remove any number of characters from the string `t`. The score of the string is `0` if no characters are removed from the string `t`, otherwise: * Let `left` be the minimum index among all removed characters. * Let `right` be the maximum index among all removed characters. Then the score of the string is `right - left + 1`. Return *the minimum possible score to make* `t`*a subsequence of* `s`*.* A **subsequence** of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i.e., `"ace"` is a subsequence of `"abcde"` while `"aec"` is not).   **Example 1:** ``` **Input:** s = "abacaba", t = "bzaa" **Output:** 1 **Explanation:** In this example, we remove the character "z" at index 1 (0-indexed). The string t becomes "baa" which is a subsequence of the string "abacaba" and the score is 1 - 1 + 1 = 1. It can be proven that 1 is the minimum score that we can achieve. ``` **Example 2:** ``` **Input:** s = "cde", t = "xyz" **Output:** 3 **Explanation:** In this example, we remove characters "x", "y" and "z" at indices 0, 1, and 2 (0-indexed). The string t becomes "" which is a subsequence of the string "cde" and the score is 2 - 0 + 1 = 3. It can be proven that 3 is the minimum score that we can achieve. ```   **Constraints:** * `1 <= s.length, t.length <= 105` * `s` and `t` consist of only lowercase English letters. Please make sure your answer follows the type signature below: ```python3 class Solution: def minimumScore(self, s: str, t: str) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.minimumScore(*['abacaba', 'bzaa']) == 1\nassert my_solution.minimumScore(*['cde', 'xyz']) == 3\nassert my_solution.minimumScore(*['abecdebe', 'eaebceae']) == 6\nassert my_solution.minimumScore(*['acdedcdbabecdbebda', 'bbecddb']) == 1\nassert my_solution.minimumScore(*['dabbbeddeabbaccecaee', 'bcbbaabdbebecbebded']) == 16\nassert my_solution.minimumScore(*['adebddaccdcabaade', 'adbae']) == 0\nassert my_solution.minimumScore(*['dcadebdecbeaedd', 'dcdadeb']) == 1\nassert my_solution.minimumScore(*['bcceaaccd', 'cbe']) == 1\nassert my_solution.minimumScore(*['cabecaeadeaeadd', 'edcce']) == 2\nassert my_solution.minimumScore(*['cbedceeeccd', 'ed']) == 0\nassert my_solution.minimumScore(*['eeecaeecdeeadcdbcaa', 'edecabe']) == 2\nassert my_solution.minimumScore(*['eceecbabe', 'bdeaec']) == 4\nassert my_solution.minimumScore(*['caaa', 'aaa']) == 0\nassert my_solution.minimumScore(*['cbaa', 'a']) == 0\nassert my_solution.minimumScore(*['bcabcbcccbacccc', 'cbcbb']) == 0\nassert my_solution.minimumScore(*['eddbeedbbaaaaadaacccddadccbbcdc', 'aecbddcedaaced']) == 12\nassert my_solution.minimumScore(*['ccecdeccaebcdaeaccdceadbaabeddacaeacbaabaec', 'bdadc']) == 0\nassert my_solution.minimumScore(*['eaedcdbdeededbcdcbedddbccbaebbdbadbdadccaddacbbcbabadbacbdcbeaebecbacacbadaadedcadcdcdaceaaad', 'cadedebbcabecbcbd']) == 1\nassert my_solution.minimumScore(*['aacecebcbbcbacddbdcbaddeadd', 'cab']) == 0\nassert my_solution.minimumScore(*['adcdaedbeeecbbaecebceaebcbcddecddcedecddbbdaabcbdbcbbabbddaeaedeabdecaedbcdbdccb', 'abadccaced']) == 0\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2701", "questionFrontendId": "2565", "questionTitle": "Subsequence With the Minimum Score", "stats": { "totalAccepted": "3.2K", "totalSubmission": "8.8K", "totalAcceptedRaw": 3211, "totalSubmissionRaw": 8792, "acRate": "36.5%" } }
LeetCode/2692
# Take Gifts From the Richest Pile You are given an integer array `gifts` denoting the number of gifts in various piles. Every second, you do the following: * Choose the pile with the maximum number of gifts. * If there is more than one pile with the maximum number of gifts, choose any. * Leave behind the floor of the square root of the number of gifts in the pile. Take the rest of the gifts. Return *the number of gifts remaining after* `k` *seconds.*   **Example 1:** ``` **Input:** gifts = [25,64,9,4,100], k = 4 **Output:** 29 **Explanation:** The gifts are taken in the following way: - In the first second, the last pile is chosen and 10 gifts are left behind. - Then the second pile is chosen and 8 gifts are left behind. - After that the first pile is chosen and 5 gifts are left behind. - Finally, the last pile is chosen again and 3 gifts are left behind. The final remaining gifts are [5,8,9,4,3], so the total number of gifts remaining is 29. ``` **Example 2:** ``` **Input:** gifts = [1,1,1,1], k = 4 **Output:** 4 **Explanation:** In this case, regardless which pile you choose, you have to leave behind 1 gift in each pile. That is, you can't take any pile with you. So, the total gifts remaining are 4. ```   **Constraints:** * `1 <= gifts.length <= 103` * `1 <= gifts[i] <= 109` * `1 <= k <= 103` Please make sure your answer follows the type signature below: ```python3 class Solution: def pickGifts(self, gifts: List[int], k: int) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.pickGifts(*[[25, 64, 9, 4, 100], 4]) == 29\nassert my_solution.pickGifts(*[[1, 1, 1, 1], 4]) == 4\nassert my_solution.pickGifts(*[[54, 6, 34, 66, 63, 52, 39, 62, 46, 75, 28, 65, 18, 37, 18, 13, 33, 69, 19, 40, 13, 10, 43, 61, 72], 7]) == 618\nassert my_solution.pickGifts(*[[56, 41, 27, 71, 62, 57, 67, 34, 8, 71, 2, 12, 52, 1, 64, 43, 32, 42, 9, 25, 73, 29, 31], 52]) == 32\nassert my_solution.pickGifts(*[[70, 58, 12, 11, 41, 66, 63, 14, 39, 71], 19]) == 19\nassert my_solution.pickGifts(*[[71, 43, 70, 27, 71, 37, 57, 12], 39]) == 8\nassert my_solution.pickGifts(*[[41, 74, 31, 38, 24, 25, 24, 5, 34, 61, 9, 12, 17, 20, 5, 11, 70, 51, 68, 36, 67, 31, 28, 54, 75], 18]) == 191\nassert my_solution.pickGifts(*[[64, 46, 11, 42, 15, 63, 43, 25, 32, 3, 35, 15, 29, 48, 22, 43, 55, 8, 13, 19, 29, 6, 74, 69, 10, 4, 16, 25, 74], 8]) == 503\nassert my_solution.pickGifts(*[[12, 48, 15, 5, 3, 25, 24, 16, 62, 27, 8, 3, 70, 55, 13, 34, 9, 29, 10, 39, 45, 56, 24, 8, 65, 60], 3]) == 591\nassert my_solution.pickGifts(*[[13, 51, 26, 34, 46, 61, 73, 22, 27, 8, 21, 21, 44, 68, 33, 16, 57, 23, 2, 61, 53, 73, 66, 40, 46, 50, 33, 20, 72, 2, 59, 11, 43, 6, 70, 36, 18, 31, 62], 23]) == 422\nassert my_solution.pickGifts(*[[37, 46, 17, 40, 50, 54, 11, 1, 25, 43, 21, 31, 29, 58, 49, 73, 54, 5, 52, 73, 54, 6, 22, 58, 9, 34, 21, 58, 68, 63, 72, 1, 5, 64, 42, 40, 60, 7, 54, 25], 36]) == 220\nassert my_solution.pickGifts(*[[17, 2, 52, 54, 41, 1], 14]) == 6\nassert my_solution.pickGifts(*[[1], 53]) == 1\nassert my_solution.pickGifts(*[[13, 25, 16, 26, 39, 36, 24, 13, 61, 51, 11, 3, 36, 58, 15, 33, 18, 67, 45, 15, 20, 36, 3, 6, 6, 27, 34, 72, 41, 47, 73, 6, 64, 59], 41]) == 122\nassert my_solution.pickGifts(*[[48, 69, 23, 27, 49, 38, 2, 18, 20, 35, 43, 44, 48, 12, 44, 5, 6, 35, 21, 20, 75, 38, 47, 51, 71, 17, 38, 15], 31]) == 118\nassert my_solution.pickGifts(*[[7, 40, 23, 67, 10, 39, 52, 43, 39, 54, 14, 13, 72, 62, 61, 44], 54]) == 16\nassert my_solution.pickGifts(*[[16, 62, 15, 64, 55, 5, 39, 43, 20, 22, 73, 49, 12, 9, 11, 26, 29, 8, 50, 2, 13, 51], 36]) == 47\nassert my_solution.pickGifts(*[[38, 58, 63, 75, 28, 55, 11, 48, 29, 34, 75, 22, 56, 25, 46, 15, 9, 4, 68, 58, 26, 16, 64, 51, 33, 27, 6, 28, 19, 14, 26, 59, 49, 47], 35]) == 173\nassert my_solution.pickGifts(*[[14, 63, 19, 73, 52, 55, 67, 64, 42, 64], 32]) == 10\nassert my_solution.pickGifts(*[[70, 29, 2, 44, 41, 42, 5, 68, 19, 33, 20, 49, 75], 19]) == 36\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2692", "questionFrontendId": "2558", "questionTitle": "Take Gifts From the Richest Pile", "stats": { "totalAccepted": "29.7K", "totalSubmission": "41.5K", "totalAcceptedRaw": 29699, "totalSubmissionRaw": 41520, "acRate": "71.5%" } }
LeetCode/2691
# Count Vowel Strings in Ranges You are given a **0-indexed** array of strings `words` and a 2D array of integers `queries`. Each query `queries[i] = [li, ri]` asks us to find the number of strings present in the range `li` to `ri` (both **inclusive**) of `words` that start and end with a vowel. Return *an array* `ans` *of size* `queries.length`*, where* `ans[i]` *is the answer to the* `i`th *query*. **Note** that the vowel letters are `'a'`, `'e'`, `'i'`, `'o'`, and `'u'`.   **Example 1:** ``` **Input:** words = ["aba","bcb","ece","aa","e"], queries = [[0,2],[1,4],[1,1]] **Output:** [2,3,0] **Explanation:** The strings starting and ending with a vowel are "aba", "ece", "aa" and "e". The answer to the query [0,2] is 2 (strings "aba" and "ece"). to query [1,4] is 3 (strings "ece", "aa", "e"). to query [1,1] is 0. We return [2,3,0]. ``` **Example 2:** ``` **Input:** words = ["a","e","i"], queries = [[0,2],[0,1],[2,2]] **Output:** [3,2,1] **Explanation:** Every string satisfies the conditions, so we return [3,2,1]. ```   **Constraints:** * `1 <= words.length <= 105` * `1 <= words[i].length <= 40` * `words[i]` consists only of lowercase English letters. * `sum(words[i].length) <= 3 * 105` * `1 <= queries.length <= 105` * `0 <= li <= ri < words.length` Please make sure your answer follows the type signature below: ```python3 class Solution: def vowelStrings(self, words: List[str], queries: List[List[int]]) -> List[int]: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.vowelStrings(*[['aba', 'bcb', 'ece', 'aa', 'e'], [[0, 2], [1, 4], [1, 1]]]) == [2, 3, 0]\nassert my_solution.vowelStrings(*[['a', 'e', 'i'], [[0, 2], [0, 1], [2, 2]]]) == [3, 2, 1]\nassert my_solution.vowelStrings(*[['bzmxvzjxfddcuznspdcbwiojiqf', 'mwguoaskvramwgiweogzulcinycosovozppl', 'uigevazgbrddbcsvrvnngfrvkhmqszjicpieahs', 'uivcdsboxnraqpokjzaayedf', 'yalc', 'bbhlbmpskgxmxosft', 'vigplemkoni', 'krdrlctodtmprpxwditvcps', 'gqjwokkskrb', 'bslxxpabivbvzkozzvdaykaatzrpe', 'qwhzcwkchluwdnqjwhabroyyxbtsrsxqjnfpadi', 'siqbezhkohmgbenbkikcxmvz', 'ddmaireeouzcvffkcohxus', 'kjzguljbwsxlrd', 'gqzuqcljvcpmoqlnrxvzqwoyas', 'vadguvpsubcwbfbaviedr', 'nxnorutztxfnpvmukpwuraen', 'imgvujjeygsiymdxp', 'rdzkpk', 'cuap', 'qcojjumwp', 'pyqzshwykhtyzdwzakjejqyxbganow', 'cvxuskhcloxykcu', 'ul', 'axzscbjajazvbxffrydajapweci'], [[4, 4], [6, 17], [10, 17], [9, 18], [17, 22], [5, 23], [2, 5], [17, 21], [5, 17], [4, 8], [7, 17], [16, 19], [7, 12], [9, 20], [13, 23], [1, 5], [19, 19]]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\nassert my_solution.vowelStrings(*[['sdhky', 'kqcljybkksifhmyuhorulktlglydmqmfasqaht', 'oesmrtgthzdwbgnpkcgh', 'pauhingxekhno', 'nkqkuuhjqesjpd', 'jmkmsiqbhtbqamxanbwr', 'abqzwssfthcliekxllsndxluku', 'sulfsxaqwjtrghcwtuwkbsrqo', 'pmsfgbeardurzkxlicwuiliabjfn', 'vgshnkmwghoam', 'bvzldcctkxlcltvbemdwyilohofhl', 'mqhapsekfwzanlbkhzofsohtxbhijmpdanjqvwe', 'nbtuuosftvtj', 'dmxqapmiyoewvtoscdkeihyfitgwrrfieaobqj', 'qabfrbbzkxfljeiztjkgntrmbxkkadwn', 'cgveyyxtvo', 'lwcqsp', 'gut', 'qx', 'chdgjtkhmkixozuogrlskmatarpuhrfn', 'kvgdzuygrnwewdwvpbeihh', 'upzadbdyymyvuteolyeerecnuptghlzs', 'nozeuuvteryojyokp', 'xjzefjsatogetko', 'tlnusyeyyqygwupc', 'mt'], [[24, 25], [12, 18], [24, 25], [22, 22], [18, 25], [11, 24], [18, 20], [18, 22], [10, 10], [12, 19], [16, 18], [1, 3], [18, 23]]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\nassert my_solution.vowelStrings(*[['b', 'rmivyakd', 'kddwnexxssssnvrske', 'vceguisunlxtldqenxiyfupvnsxdubcnaucpoi', 'nzwdiataxfkbikbtsjvcbjxtr', 'wlelgybcaakrxiutsmwnkuyanvcjczenuyaiy', 'eueryyiayq', 'bghegfwmwdoayakuzavnaucpur', 'ukorsxjfkdojcxgjxgmxbghno', 'pmgbiuzcwbsakwkyspeikpzhnyiqtqtfyephqhl', 'gsjdpelkbsruooeffnvjwtsidzw', 'ugeqzndjtogxjkmhkkczdpqzwcu', 'ppngtecadjsirj', 'rvfeoxunxaqezkrlr', 'adkxoxycpinlmcvmq', 'gfjhpxlzmokcmvhjcrbrpfakspscmju', 'rgmzhaj', 'ychktzwdhfuruhpvdjwfsqjhztshcxdey', 'yifrzmmyzvfk', 'mircixfzzobcficujgbj', 'd', 'pxcmwnqknyfkmafzbyajjildngccadudfziknos', 'dxmlikjoivggmyasaktllgmfhqpyznc', 'yqdbiiqexkemebyuitve'], [[5, 21], [17, 22], [19, 23], [13, 15], [20, 23], [21, 23], [6, 20], [1, 8], [15, 20], [17, 22], [6, 6], [1, 2], [4, 11], [14, 23], [7, 10], [16, 22], [20, 22], [21, 22], [15, 18], [5, 16], [17, 23]]]) == [2, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 2, 0, 1, 0, 0, 0, 0, 2, 0]\nassert my_solution.vowelStrings(*[['kzizbfceyysfjbkckouoqyrnxiobp', 'tfqjcavpwpyjmclwzjtyfpybipmynlkw', 'lrztxdla', 'gdhqqtobnaxvqgdzco', 'gcbzd', 'nuj', 'vferffslesxzofmidouariwuicauehfowcnv', 'czzeglsa', 'q', 'bzizqhugxngbkhfyxn', 'slebsmaccedlxjknmglsyexnfduue', 'oewsysetdvrtnuuws', 'su', 'benfnmdcavczz', 'lhkiksxegfbwnbllutdqnadrjz', 'qgauywpihdvysiwpkkxhvoglgedptnxvq', 'ghxnufgrapwzyvfxqxrpgr', 'ax', 'vivkmjjpust', 'p', 'jfxfeerpnpywxbxaqy', 'ciqqvebziztmmxhqltxnoklrpkdryupce', 'hsrlhcjvuapzyxkumaqdsqtffxxbudt'], [[13, 19], [17, 17], [14, 22], [4, 21], [4, 10], [18, 19], [2, 20], [15, 19], [8, 12], [6, 18], [21, 21], [20, 20], [16, 22], [2, 2], [20, 21], [4, 8], [16, 17], [3, 13], [0, 10], [4, 14]]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\nassert my_solution.vowelStrings(*[['cflrm', 'cijkmlbfqvndbejornojrskvtxmiuajzin', 'omjtganzobjimtwk', 'rmsiuvsxtmryvsrp', 'xszpzelpzowqnk', 'jgggpyjlpqdgvgespxlfejgu', 'mfknjktbypeocnrkirywkwcbztpoixwmfrs', 'narnyv', 'xgbcyiv', 'suoypywheeydwgudqfdvkyfpjr', 'ttcsqrhpf', 'vtrkdonyrl', 'gqtrejhozfobjyxcwsxlkxnteblin', 'vksousorhltzffzcknmqagc', 'kxonfcycdfoqlkqguqpaitfqz', 'frvdlchqktyxhrpvjqcwkwwmdvjrd', 'isjveznlsjalhrnvmedog', 'delwleatorqcmn', 'wr', 'cvtgojgdvyuemygfsrwwzwvpeccqpgkbbvljgk', 'zq', 'updwfiwtknzssr', 'yhlqgqxhjlkqbuhqlponeackg', 'wgkpgwsfgsvrlisfkyzdjsmevlljccud', 'y', 'wkmkskrhehdrizaiiwgwogelaaifonhcoh', 'gvrl', 'mxslvajycct', 'gjmpojlupzphnm', 'wsghewxiamusracsvevypoakmylaob', 'rssykhcam', 'taqvwukssbbiqjqtuhzoqq', 'erlzszzvppmjkxqeallbfijqevmbcyaq', 'anxrrekineex', 'mtthkpgt', 'bqvfy', 'ofwlbyjhbabwwmcdyoub', 'prfcm'], [[7, 22], [28, 36], [10, 27], [6, 14], [23, 34], [27, 35]]]) == [0, 0, 0, 0, 0, 0]\nassert my_solution.vowelStrings(*[['qysocu', 'xnisoxgsdkujhjjadtsqddmmd', 'vwervizcudgedrguu', 'uzoaikzkhuxbzszqar', 'rzvuejyncmwpbhs', 'gap', 'ekpvxaowewrpzzjdukewfr', 'tawetkkelzvtqfbyxaxtceegx', 'ismdpgsjnmqyfhrkaaoyhvarkno'], [[7, 8], [2, 8], [0, 5], [3, 5], [6, 6], [3, 3], [2, 8], [7, 7], [7, 8], [7, 7], [7, 8], [7, 8], [8, 8], [0, 5], [8, 8], [6, 8], [1, 5], [2, 6], [2, 3], [1, 6], [3, 3], [0, 7], [7, 7], [8, 8], [2, 7], [7, 7], [4, 4], [4, 6], [2, 5], [5, 5], [5, 5], [1, 2], [4, 6], [5, 6]]]) == [1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\nassert my_solution.vowelStrings(*[['kqcwylmjlflugvmjulgldifenpserey'], [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\nassert my_solution.vowelStrings(*[['ebnnporwiufimntatuaoadwbxrtrt', 'xjjqnrjkkbto', 'tkubqyxihhxikigwlnkikxhsfxmhl', 'xeezqycyn', 'ewrdylevbatctcydoqjcmixffplhdvcxy', 'erhrezicc', 'b', 'lgildbphjsiechluqedoor', 'vsuvhhkaxvdvipmlpxkawyuektwwyq', 'xvirozecg', 'mxzreujgplnza', 'lvwtmnpkswiyoheshvyjjhgzvwayv', 'ykbonftzsuuv', 'tpbyufbbqpe', 'nozcjouwqrxup', 'o', 'bzvicojsvpvaglmveonqabc', 'jefoabkhvaikfnjgamzbvisoff', 'tihdokbjutzwmuukkol', 'rjbqfnmoccwhidzzqekaudnsrhkybggicvmvbgch'], [[7, 10], [6, 9], [12, 13], [17, 18], [5, 10], [12, 12], [17, 19], [1, 18], [13, 18], [3, 11], [6, 14], [9, 10], [3, 19], [13, 18], [17, 18], [5, 7], [3, 12], [9, 11], [15, 17], [7, 15], [18, 18], [2, 17]]]) == [0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1]\nassert my_solution.vowelStrings(*[['lyyzudvjdyltipmhkumetwg', 'lqphoab', 'nfueqyndjnldpwzeradnpgtxzcr', 'pxmiqfqknizxgusbvuacyhtgatqvszxsfk', 'nkpowilcdroztjzcflqshbhyfsleaorbjbffgo', 'tnzumynvbdfgdbopspllaqqq', 'sfporptloygrtvozznlcp', 'ibliaczsvcfrayatcrat', 'wnugyklmitopphickg', 'hxytsolgcyzoujwjjizwbni', 'tqbvvvvexhgaejgwbl', 'qpaaazfectkbcbgnupuipggtg', 'srjbzftoatzdsoollejrwtqfawtydzioau'], [[9, 10], [1, 3], [2, 10], [2, 8], [6, 6], [5, 9], [5, 5], [3, 12], [0, 5], [12, 12], [5, 6]]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\nassert my_solution.vowelStrings(*[['jkjygdvedvucpoqqjmlkjigu', 'lcugrvkfelprpgadlzozvz', 'qfasfpmypzybewinlok', 'gylumjtiv', 'shjwqyfawpdgypouxkvwymxvmsdtkviu', 'ygspumyfetltvknrlie', 'hefpubdyohbovc', 'ipngcoobilmirudkr', 'zgtiszbdvvjipxvpoxcqfiodwcajwoqkicsuhy', 'fwlwankuyct', 'wqiggpoorgquciqzcwhocmxf', 'dsbmolgqcehlfqgm', 'rpvklkdpmupiwhhwzffpavltauoab', 'yhiaochtubjutdrwwncoofpvcew', 'gmpgfnmbfkylgwzewmgvooskstvbhprpuiqn', 'hngyz', 'gnhuiivfchcknikmwhyk', 'pmrzq', 'vgkfpukilsbyroacdqoewidhtmqhqgaslh', 'amqueewnjziywsgzbwyefcocfuwwyigpir', 'xxypvelajleseetxyw', 'hypbatrjgvshn', 'zblctzekosqgwauyykzcvkut', 'vdtkoalhcqlxxpourbftqkoafhfbjs', 'dfhfhblraeckwgkjecfbkthzn', 'oouufeegcgkqapsx', 'ohj', 'rrclfpujlehcawpwmmosnyealwqsyeoziqsrkezn', 'yprmmsrjmbitzmldrxbqfdrhcswp', 'yumevxlhbxblzczmfgambaylzevgfoaumdb', 'bbfwtgagyocsqwzwrwqfnhgebhwnncydzebyahr', 'zygayauiqvqshmzcghupstxojxgjbhzjwamfb', 'nbeqvcynubjmoznxzxjwiss', 'qwaxtqckjdxyysxssefuvebvyqxcpqjemiyhitz', 'rdoqiaxdj', 'dxjbswzwpamgfx', 'fjhhribecrxxdlzrijcmagbcjkwoxoawafeezla'], [[2, 34], [30, 33], [24, 28], [29, 34], [34, 36], [6, 30], [10, 28], [2, 30], [31, 34], [17, 30], [14, 15], [2, 22], [24, 31], [15, 34], [1, 35], [12, 30], [21, 27], [9, 34], [18, 35], [34, 36], [11, 24], [6, 28], [16, 28], [13, 15], [23, 36], [25, 27], [26, 34], [31, 31], [16, 29], [22, 34], [23, 36], [25, 30], [26, 36], [16, 16], [13, 27], [23, 26], [5, 25], [0, 24], [26, 29], [27, 30], [26, 31], [7, 7], [13, 33], [19, 21], [13, 22], [5, 18], [10, 17], [36, 36], [20, 29], [10, 17]]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\nassert my_solution.vowelStrings(*[['adqbhlgnodwriduksjmkpftqvmiumqij', 'xzvwhwqvxqzjlqokjauapypfsznnp', 'rndbibrunaqupg', 'pnrhgzytzzhixsduff', 'pvwmhcttsfbclijfonpxikdzxqppkjgddydgrqry', 'oytsussafuarpocczkhfmqxph', 'mzcxatlnbyevzxqdpryreaujijxvumzpxzp', 'mhimrruswxpjxpeiwimjiysvjiwfktolmebema', 'eftrwex', 'jdwnflcfczy', 'qaygln', 'irvofhdtmi', 'gtxmbeuhvldxh', 'allmhrsmiwrwp', 'lslagyvtishaksgziqccupckqullwpu', 'edipbgtxzdcgxfgbcdzwgdcfqgdfwqcjoaqo', 'xssysowxy', 'qvyuzrmofvavwto', 'tyhnfacslpyaphcpxwydbgsyvzvpuqipumnrpmvh', 'ajveebaxuovdzsvgaptydfpvhkscmgajhxoghnzh', 'mskzezrfwqzllqufowcfmytva', 'rsgoq', 'nchmwboowjmrfqlggprhk', 'iplkgjvlzygdsafhglymienafnw', 'ugfqtbjhhqayydxaspqhrema', 'piogsxjuvdhmlffmueflhfqmdllsxbot', 'obqyapxbaiahkjttsvgwlwilzdothqd', 'zgntkotwmcdgwugjrfyg', 'znf', 'vemfljhfnmkwhctqfnbetdgfajmyiicq', 'rmqij', 'ctrdougcchjvmtgszkwbcbwvtwhu', 'wsfniovdljzsctyzjiiqlxvzqatuliygdibzldn', 'cwgzlkzobxhkdzqxqwwytyrty'], [[0, 15], [7, 9], [2, 14], [15, 19], [13, 23], [26, 32], [5, 16]]]) == [2, 0, 1, 1, 1, 0, 2]\nassert my_solution.vowelStrings(*[['iudibb', 'suejjertqtckmzloneax', 'adwocnu', 'idwstzyhpmhbasdag', 'qfsnlums', 'zokfvsjeualkidcbydbcsdjypacppoueoghpvevp', 'cddephdgmufwpllzfockd', 'vqowwarakfflbsmwhzzjedbb', 'jmlukjrjrlokgypqhqopogrcihlafwuapnctjjj', 'sjfyacnqqcifisjiciuvqqwkkpfylxuyybgirds', 'hyfi', 'gmktyoc', 'dhvpwwzz', 'kwjxwvigcukmcbvoeejgdaylrosxira', 'elxdlsqtarlhpmcwjyv', 'mloiczxrlxmqyetykoiy', 'emejlyduwciherxfmohukc', 'ojhlfmgaalhbvcivtltgkviu', 'gqrhceguhccfbrnbpmxerfpyvxaw', 'wmhn', 'euxnspekzbtqomdpynwreveyekvj', 'kkfkksflarmaiuzzqoxtwnbbhehgcyehgnyadgls', 'txjfymocufymepgcmnsxfvldtkoagpadnfsxej', 'kftsm', 'hevhskgwskqdztvfviirwrhvdys', 'vjyfdernzdabdvwrjmundmviwmwdsqjibfrt', 'c', 'ufiimkekbmaffinctkexccpbkht', 'prntvrqrighrajmjxetxnpehllfvsrdhm', 'd', 'sbawxagjpqzhkjvfxrmsfbw', 'zetmyxgyadthxkzpgsycjin', 'spswgaestqizviowilhgn', 'zvilwxo', 'vgegoiydmpkgbpiorwxyupyklrvhdaftbci', 'udcfeffnwnruzhyffucxxs', 'gpvavrxaqumtqnivftptnebmmpgtawq', 'zbraiomlywxufrjxi'], [[21, 25], [21, 25], [7, 30], [22, 24], [17, 28], [25, 26], [20, 24], [24, 32], [18, 26], [22, 27], [36, 36], [7, 13], [30, 31], [20, 27], [16, 30], [10, 23], [13, 30], [33, 37], [29, 31], [31, 36], [8, 23], [30, 35], [32, 37], [2, 15], [10, 12], [20, 32], [31, 34], [33, 36], [2, 22], [9, 14], [16, 36], [10, 28], [10, 37], [29, 30], [22, 29], [34, 37], [20, 24], [37, 37], [33, 33]]]) == [0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 2, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0]\nassert my_solution.vowelStrings(*[['hlruqkczmlttszvqdvnpofomx', 'znh', 'umlxgbo', 'tpirloqwbffqqznekgctaimdxjtzhjr', 'rmiwygiizotiitvdwqhfynlhrax', 'vwzznjjcuwvaduywibpgdupqplitrmdagcbyxkjn', 'e', 'iateezlzmsuqjealljagxzfuji', 'ku', 'qexhvripjpuspsujfrfrtift', 'twmgcdhudzboonemwgjhkpnymhahvzom', 'rspdilnfcddjnmpzyerkfaqjr', 'wceobkpgwcufvrtnvetag', 'ahujky', 'qfa', 'fnkkic', 'iqeusnplnnihjcat', 'ihtxbe', 'gnytogf', 'wtbwxm', 'mjbdcikaxkemmjqurfvbwcezgu', 'zrcmqaeqbsdluqfosfbe', 'f', 'uutsamkutlsewbmivkdrexstiykgqvyktcya', 'msoqjyngxfgyglhadmoorxmpowascvoodoq', 'udrgpxvlhrfsfvbuwpfx'], [[25, 25], [16, 25], [22, 22], [15, 19], [17, 20], [0, 11], [12, 18], [14, 22], [11, 17], [22, 24], [8, 25], [9, 19], [18, 22], [0, 23], [0, 11]]]) == [0, 2, 0, 1, 1, 3, 1, 1, 1, 1, 2, 1, 0, 5, 3]\nassert my_solution.vowelStrings(*[['vjpusoeapvzdxxhmsfbdfjxvr', 'mqgzkybbvfrzv', 'nwlkndumbxbaaoibbmbftiayyqtyi', 'bwlx', 'bxaebmuznbldybexxcrsinqlo', 'btmrhswpavfmckxm', 'lmhrfxvgnywckjwzuqgglksk', 'xxwoxpk'], [[0, 5], [2, 5], [4, 4], [5, 7], [0, 0], [0, 3], [5, 5], [1, 2], [0, 3], [2, 4], [4, 7], [1, 6], [7, 7], [6, 6], [5, 5], [7, 7], [0, 0], [4, 5], [2, 7], [6, 7], [7, 7], [3, 5], [7, 7], [6, 7], [6, 7], [4, 7], [1, 6], [0, 0], [4, 7], [6, 6], [0, 6], [0, 5], [7, 7], [5, 7], [5, 7], [0, 0], [3, 6], [6, 7], [4, 6], [1, 1], [4, 4], [1, 2], [5, 5], [2, 5], [6, 6], [5, 5]]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\nassert my_solution.vowelStrings(*[['wdvyujkiyn', 'irvzenhcktzis', 'jpzrjaysvgvhrolgt', 'jnjfwbjunncftitpshkwebuwevfurmkwfpeyc', 'xzsyajnoawddbxfqxsrvcrksqi', 'ocrgxkdwtfythbqkhyakaohajoqtmucbkgvac'], [[1, 2], [3, 4], [4, 5], [5, 5], [5, 5], [3, 4], [3, 5], [3, 4], [2, 3], [0, 1], [1, 4], [3, 3], [5, 5], [2, 2], [3, 4], [1, 1], [3, 4], [1, 1], [5, 5], [5, 5], [3, 5], [2, 4], [1, 2], [4, 4], [3, 3], [3, 5], [4, 4], [5, 5], [0, 1], [4, 5], [2, 4], [4, 5], [4, 5], [5, 5], [1, 3], [0, 1], [2, 4], [1, 1], [2, 2], [2, 4], [4, 4], [0, 2], [1, 4], [2, 4], [0, 4], [0, 4], [1, 5], [0, 0]]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\nassert my_solution.vowelStrings(*[['pdxrcutvvjgmsgwt', 'ffmgaughzdiowcipurh', 'hac', 'rlkqpncvlhmxswxzc', 'gkdkdnxffhhlxpihsmazaschnqxzy', 'nygcjswlauemfjudmmeirevblnltlnrchpymee', 'li', 'ceihxcoiqwdiughaguqqf', 'yalknuszrrmhlfscjcswkiumidhsadwoipkfi', 'ewhtfuuurkrdvlrcaifvr', 'ejfxswzxa', 'pdh', 'zfchnrrsnxipbmoysqlpguuoopvbpkxfilpzmvo', 'wkseztelfyrrkykjhh', 'jxetnjyabr', 'vosuxnmawelsdhnueewzdoxfkmqnblsv', 'dzbarfcdrnbht', 'ulpjo', 'vpu', 'essppvxi', 'rmhmbguhgrzfzzwqgwvxneueo', 'rlxufbdtulwnvowykgirsbpcwbibkhkinpbh', 'mvqbsfphbs', 'lepcbeiicqjywasvpqpdcuvxrolvlmitrmfim', 'dhwicdpbtmigvmcuaqkpkpbchpv', 'sjejysvtolgzqlgcsaq', 'ubheniqoibiczmvwphovghr', 'aqmrtaaejmoukyuzvtmzjewmwmvcbmvvcdre', 'abjdkpcfweakdqsdyrkdnspcvcbriecdfwroc', 'yrimnyqjx', 'rsj', 'gphyqsyuydgwwtswmcsgpo', 'fuyegcewpwkkgovcclhmzkkka', 'ibiicovpcghiskbsfza', 'pvfgucxmattwuljiudqatfvltqznwupxr'], [[12, 24], [15, 18], [26, 26], [4, 30], [20, 25], [19, 24], [8, 27], [1, 16], [5, 14], [2, 16], [11, 24], [26, 31], [7, 22], [4, 25], [24, 34], [30, 34], [3, 9], [10, 25], [26, 30], [13, 26], [19, 24], [5, 8], [29, 34], [1, 19], [10, 30], [8, 20], [9, 16], [7, 19], [9, 15], [10, 25], [23, 32], [6, 6], [24, 24], [26, 30], [16, 26], [32, 34], [5, 11], [22, 33], [4, 15], [2, 17], [32, 34], [25, 26], [4, 20], [4, 23], [19, 20], [24, 24]]]) == [2, 1, 0, 4, 0, 1, 4, 1, 1, 1, 2, 1, 3, 3, 2, 1, 0, 3, 1, 2, 1, 0, 1, 3, 4, 3, 1, 3, 1, 3, 1, 0, 0, 1, 2, 1, 1, 2, 1, 2, 1, 0, 3, 3, 1, 0]\nassert my_solution.vowelStrings(*[['kviyfwtuuaedglemhgtkbqonjpcxhfxpf', 'efggogoqurtmaiqmxealfvosqgkvgyun', 'rsjtjmvamgxfmhcszrobrbdqwnunopbyjtu', 'cn', 'pvillikmtlogezdjqyrtxhbljpjqfjefki', 'juwrtyovdwbafuswixvlwipfhtxavvzrdyxtn', 'ztekbrpjewjqqsxtjpwnvguraaprxyddgudgn', 'teixnqgthpnoyjadurcglmqkajlhika', 'vdmptwozbiufklndtzqsgfjh', 'wcvkgdegzackpuubsxerrqelhuz', 'chwlshuqziggmwvcsermnujnpplihttv', 'cxldnlucddylmvikzhsruv', 'o', 'rshlmadebgajfnhnp', 'qkrxxqdppuocvl', 'mpbedbdiasfdcjxuwqphvlwijynfqdwrvdhtbv', 'jqgoadfjplly', 'qjzdodolhsbpkijomlyjkekgialocibhfwch', 'xucbiycgvbeqtqtegzolabqiwjkgvfomrzw', 'nhsdnztyzbvmflepneus', 'me', 'qpxks', 'akexnubpemhodpapyeturvpsixsrirpl', 'frajkqquvzsdmwxhoouysuhuczdlnzbnvgtf', 'curpeaveeopbexkwrteqonhdrwdeuevjlg', 'ktqhnczjxgixyqpcszoyfzorcusop', 'kmbtclpivdhrydenqmdflowfgrefgmrnhjdezg', 'hhfdalmqdilceommorakayfrxeuqdpyjpgupqolm', 'tqefxcuieylvekwbnzeqrrzijgexvpcgfnhrk', 'yipyqncxpsbriz', 'skqkkpdtjbevqjnyjzxfdeczsgkanpa', 'meovymx', 'wtgtjwnbsnljnbltm', 'vwpquradseboueebizzoqziseamgatfuy', 'nsfffwyaclpnrzautsgcsatwefijzuighjavk', 'godevqgrgwlbsnz', 'rgqapallbkvojducfojxfsqz'], [[8, 17], [17, 22], [2, 6], [24, 27], [4, 17], [24, 36], [28, 28], [1, 25], [16, 22], [4, 10], [36, 36], [6, 20], [27, 32], [13, 30], [24, 29], [2, 29], [0, 27], [32, 36], [0, 3], [0, 14], [18, 24], [1, 20], [7, 28], [14, 27], [15, 24], [35, 36], [31, 34], [23, 34], [0, 1], [4, 21], [18, 31], [33, 34], [28, 34], [25, 29], [16, 16], [16, 27], [11, 21]]]) == [1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1]\nassert my_solution.vowelStrings(*[['joltuyuheoekaqmggmpdkynngneisl', 'zjvisze', 'kllebi', 'zijkcvimjrwmdxgzrogrejzyfhr', 'euecxiecok', 'zppcflaeswvcnugnqshkkhwaw', 'gsmopobusefrlzapu', 'btpeighitnayhmczlmak', 'akzyvnit', 'nnvudmufjhzsamyqnjsuiwjukwbxkbspqrqlvcu', 'vpaanntn', 'buxwhpxxwwsyxwjcdqbuzrx', 'vdfenhnaklyufjxgmiohhacgwhprzqklpb', 'qitvikjxygnxmrxkctxwziyfovcnk', 'jmhsaanfrndkvkrdepfqvnat', 'mqgdrvjigubizrfdkz', 'odvkaneairirvtqivzyongekboggbkbfkzmdwcut', 'bycedgrirsygqncdgiemfmr', 'jazjyhvcaeoejhbvsxlnbcofdpare', 'ododnsrx', 'hm', 'wyj'], [[20, 20], [2, 8], [16, 17], [15, 16], [17, 17], [3, 17], [4, 4], [18, 19], [6, 14], [9, 12], [15, 19], [10, 14], [4, 6], [12, 12], [16, 19], [7, 19], [1, 2], [21, 21], [2, 20], [19, 20], [16, 18], [21, 21], [11, 16], [6, 7], [20, 20], [6, 16], [10, 20]]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2691", "questionFrontendId": "2559", "questionTitle": "Count Vowel Strings in Ranges", "stats": { "totalAccepted": "24.7K", "totalSubmission": "38.8K", "totalAcceptedRaw": 24661, "totalSubmissionRaw": 38794, "acRate": "63.6%" } }
LeetCode/2690
# House Robber IV There are several consecutive houses along a street, each of which has some money inside. There is also a robber, who wants to steal money from the homes, but he **refuses to steal from adjacent homes**. The **capability** of the robber is the maximum amount of money he steals from one house of all the houses he robbed. You are given an integer array `nums` representing how much money is stashed in each house. More formally, the `ith` house from the left has `nums[i]` dollars. You are also given an integer `k`, representing the **minimum** number of houses the robber will steal from. It is always possible to steal at least `k` houses. Return *the **minimum** capability of the robber out of all the possible ways to steal at least* `k` *houses*.   **Example 1:** ``` **Input:** nums = [2,3,5,9], k = 2 **Output:** 5 **Explanation:** There are three ways to rob at least 2 houses: - Rob the houses at indices 0 and 2. Capability is max(nums[0], nums[2]) = 5. - Rob the houses at indices 0 and 3. Capability is max(nums[0], nums[3]) = 9. - Rob the houses at indices 1 and 3. Capability is max(nums[1], nums[3]) = 9. Therefore, we return min(5, 9, 9) = 5. ``` **Example 2:** ``` **Input:** nums = [2,7,9,3,1], k = 2 **Output:** 2 **Explanation:** There are 7 ways to rob the houses. The way which leads to minimum capability is to rob the house at index 0 and 4. Return max(nums[0], nums[4]) = 2. ```   **Constraints:** * `1 <= nums.length <= 105` * `1 <= nums[i] <= 109` * `1 <= k <= (nums.length + 1)/2` Please make sure your answer follows the type signature below: ```python3 class Solution: def minCapability(self, nums: List[int], k: int) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.minCapability(*[[2, 3, 5, 9], 2]) == 5\nassert my_solution.minCapability(*[[2, 7, 9, 3, 1], 2]) == 2\nassert my_solution.minCapability(*[[2, 2], 1]) == 2\nassert my_solution.minCapability(*[[7, 3, 9, 5], 2]) == 5\nassert my_solution.minCapability(*[[1, 4, 5], 1]) == 1\nassert my_solution.minCapability(*[[1], 1]) == 1\nassert my_solution.minCapability(*[[7, 1, 8, 11], 1]) == 1\nassert my_solution.minCapability(*[[4, 22, 11, 14, 25], 3]) == 25\nassert my_solution.minCapability(*[[10, 15, 6, 2], 1]) == 2\nassert my_solution.minCapability(*[[9, 25, 16, 6, 18], 1]) == 6\nassert my_solution.minCapability(*[[3, 6, 6, 9], 2]) == 6\nassert my_solution.minCapability(*[[7, 14, 3, 6], 1]) == 3\nassert my_solution.minCapability(*[[4, 4], 1]) == 4\nassert my_solution.minCapability(*[[2, 1], 1]) == 1\nassert my_solution.minCapability(*[[9, 6, 2], 1]) == 2\nassert my_solution.minCapability(*[[3, 4, 1], 1]) == 1\nassert my_solution.minCapability(*[[4, 2], 1]) == 2\nassert my_solution.minCapability(*[[9, 6, 20, 21, 8], 3]) == 20\nassert my_solution.minCapability(*[[13, 1, 13, 7], 2]) == 7\nassert my_solution.minCapability(*[[2, 12, 11, 13], 2]) == 11\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2690", "questionFrontendId": "2560", "questionTitle": "House Robber IV", "stats": { "totalAccepted": "24.8K", "totalSubmission": "41.2K", "totalAcceptedRaw": 24797, "totalSubmissionRaw": 41152, "acRate": "60.3%" } }
LeetCode/2689
# Rearranging Fruits You have two fruit baskets containing `n` fruits each. You are given two **0-indexed** integer arrays `basket1` and `basket2` representing the cost of fruit in each basket. You want to make both baskets **equal**. To do so, you can use the following operation as many times as you want: * Chose two indices `i` and `j`, and swap the `ith`fruit of `basket1` with the `jth` fruit of `basket2`. * The cost of the swap is `min(basket1[i],basket2[j])`. Two baskets are considered equal if sorting them according to the fruit cost makes them exactly the same baskets. Return *the minimum cost to make both the baskets equal or* `-1` *if impossible.*   **Example 1:** ``` **Input:** basket1 = [4,2,2,2], basket2 = [1,4,1,2] **Output:** 1 **Explanation:** Swap index 1 of basket1 with index 0 of basket2, which has cost 1. Now basket1 = [4,1,2,2] and basket2 = [2,4,1,2]. Rearranging both the arrays makes them equal. ``` **Example 2:** ``` **Input:** basket1 = [2,3,4,1], basket2 = [3,2,5,1] **Output:** -1 **Explanation:** It can be shown that it is impossible to make both the baskets equal. ```   **Constraints:** * `basket1.length == basket2.length` * `1 <= basket1.length <= 105` * `1 <= basket1[i],basket2[i] <= 109` Please make sure your answer follows the type signature below: ```python3 class Solution: def minCost(self, basket1: List[int], basket2: List[int]) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.minCost(*[[4, 2, 2, 2], [1, 4, 1, 2]]) == 1\nassert my_solution.minCost(*[[2, 3, 4, 1], [3, 2, 5, 1]]) == -1\nassert my_solution.minCost(*[[4, 4, 4, 4, 3], [5, 5, 5, 5, 3]]) == 8\nassert my_solution.minCost(*[[5, 8, 15, 7], [5, 7, 8, 15]]) == 0\nassert my_solution.minCost(*[[1], [1]]) == 0\nassert my_solution.minCost(*[[3, 2, 9], [3, 2, 9]]) == 0\nassert my_solution.minCost(*[[84, 80, 43, 8, 80, 88, 43, 14, 100, 88], [32, 32, 42, 68, 68, 100, 42, 84, 14, 8]]) == 48\nassert my_solution.minCost(*[[8, 8, 8], [5, 5, 8]]) == 5\nassert my_solution.minCost(*[[183, 259, 304, 201, 128, 68, 289, 346, 257, 259, 300, 167, 167, 289, 33, 304, 382, 21, 183, 252], [97, 128, 169, 21, 382, 169, 201, 68, 365, 183, 346, 97, 300, 257, 56, 183, 252, 365, 33, 56]]) == 168\nassert my_solution.minCost(*[[3350, 1104, 2004, 1577, 1365, 2088, 2249, 1948, 2621, 750, 31, 2004, 1749, 3365, 3350, 3843, 3365, 1656, 3168, 3106, 2820, 3557, 1095, 2446, 573, 2464, 2172, 1326, 2712, 467, 1104, 1446, 1577, 53, 2492, 2638, 1200, 2997, 3454, 2492, 1926, 1452, 2712, 446, 2997, 2820, 750, 2529, 3847, 656, 272, 3873, 530, 1749, 1743, 251, 3847, 31, 251, 515, 2858, 126, 2491], [530, 1920, 2529, 2317, 1969, 2317, 1095, 2249, 2858, 2636, 3772, 53, 3106, 2638, 1267, 1926, 2882, 515, 3772, 1969, 3454, 2446, 656, 2621, 1365, 1743, 3557, 1656, 3447, 446, 1098, 1446, 467, 2636, 1088, 1098, 2882, 1088, 1326, 644, 3873, 3843, 3926, 1920, 2464, 2088, 205, 1200, 1267, 272, 925, 925, 2172, 2491, 3168, 644, 1452, 573, 1948, 3926, 205, 126, 3447]]) == 837\nassert my_solution.minCost(*[[3697, 172, 5406, 5644, 5588, 4541, 2078, 172, 6492, 6152, 4545, 5660, 3310, 4525, 1971, 6655, 6562, 1793, 5938, 2317, 3459, 6889, 5799, 5237, 2027, 4545, 203, 3681, 6587, 3031, 3710, 6152, 578, 818, 3370, 5381, 88, 4525, 1971, 4157, 5439, 2078, 2590, 6712, 2786, 3681, 3618, 4396, 5268, 3459, 5570, 2916, 4396, 3525, 1085, 3618, 3525, 4934, 5406, 2707, 3995, 64, 5938, 3161, 2364, 2590, 527, 1943, 6587, 2184, 6383, 5268, 6492, 922, 3697, 578, 2184, 3710, 6889, 1473, 6712, 4674, 3995], [2317, 3053, 2916, 6655, 6325, 3511, 4929, 3161, 5660, 2027, 2557, 2343, 2563, 5588, 6562, 5466, 5570, 5572, 314, 331, 922, 6504, 2559, 1793, 6504, 6086, 2563, 818, 3031, 2559, 2975, 2557, 2454, 4721, 2143, 5572, 3511, 2143, 3549, 331, 4674, 176, 2454, 5237, 6383, 1943, 527, 3370, 140, 88, 176, 1085, 2364, 4541, 2975, 1473, 2707, 4721, 5439, 3053, 64, 314, 5381, 5904, 6086, 3310, 3549, 4157, 166, 140, 2343, 5799, 203, 4934, 44, 4929, 2786, 44, 166, 5644, 6325, 5904, 5466]]) == 2068\nassert my_solution.minCost(*[[4, 114, 114, 116, 144, 18, 128, 4, 34, 34, 144, 118], [75, 66, 18, 113, 118, 128, 47, 66, 113, 116, 75, 47]]) == 28\nassert my_solution.minCost(*[[6374, 1232, 3450, 4041, 5, 1748, 184, 2291, 7043, 4912, 1977, 670, 3222, 5669, 6638, 6724, 3128, 6829, 3730, 1746, 5598, 1636, 4912, 2607, 768, 735, 6786, 6063, 1591, 4041, 92, 1452, 5676, 1804, 1452, 3593, 2886, 100, 5131, 3730, 3214, 1535, 670, 6962, 1788, 5669, 6910, 1860, 6374, 2291, 5753, 6830, 6830, 100, 4850, 5995, 1788, 3750, 5598, 3593, 2607, 6037, 6962, 1535, 6063, 1977, 3214, 7009, 2164, 5324, 1952, 768, 4077, 4725, 2807, 2238, 1232, 3450, 5, 4976, 6786, 6450, 3354, 4725], [3284, 4067, 3342, 4141, 599, 3030, 2904, 599, 1860, 6530, 3750, 4141, 3006, 3030, 2904, 4652, 6381, 1591, 1746, 6530, 4976, 6993, 6037, 5357, 4833, 2807, 3006, 92, 2189, 5643, 6638, 1804, 5131, 184, 6714, 2886, 7009, 6714, 4727, 1096, 3326, 5643, 4067, 4727, 4423, 2164, 1636, 4652, 3326, 3222, 4423, 1096, 6993, 4850, 4833, 6724, 5995, 4797, 6210, 1748, 6910, 3284, 3354, 735, 2238, 5324, 6829, 6450, 5357, 6210, 6381, 7035, 7043, 3128, 3342, 5753, 6595, 2189, 1952, 4797, 7035, 4077, 5676, 6595]]) == 245\nassert my_solution.minCost(*[[2781, 848, 2788, 2152, 826, 3325, 3172, 2661, 1504, 2980, 2598, 3213, 452, 1611, 2163, 146, 3023, 2447, 1510, 2492, 1656, 2913, 2948, 528, 2101, 372, 2052, 2529, 1763, 2331, 3082, 2462, 2852, 835, 786, 2511, 1057, 848, 2484, 714, 933, 353, 2035, 3233, 2210, 2887, 3183, 2206, 671, 839, 2798, 1067, 2863, 1445, 2162, 2064, 472, 1692], [1208, 394, 618, 728, 877, 3186, 2873, 862, 1536, 1131, 918, 567, 3222, 870, 2415, 1196, 1139, 945, 1275, 2718, 1112, 569, 2786, 1621, 1856, 1658, 1297, 396, 2544, 2307, 2802, 820, 149, 614, 518, 926, 750, 3323, 1867, 1110, 1966, 633, 1472, 2288, 3176, 60, 2019, 3066, 2246, 1653, 257, 1889, 3362, 1600, 71, 1038, 1640, 2458]]) == -1\nassert my_solution.minCost(*[[2781, 848, 2788, 2152, 826, 3325, 3172, 2661, 1504, 2980, 2598, 3213, 452, 1611, 2163, 146, 3023, 2447, 1510, 2492, 1656, 2913, 2948, 528, 2101, 372, 2052, 2529, 1763, 2331, 3082, 2462, 2852, 835, 786, 2511, 1057, 848, 2484, 714, 933, 353, 2035, 3233, 2210, 2887, 3183, 2206, 671, 839, 2798, 1067, 2863, 1445, 2162, 2064, 472, 1692], [2781, 848, 2788, 2152, 826, 3325, 3172, 2661, 1504, 2980, 2598, 3213, 452, 1611, 2163, 146, 3023, 2447, 1510, 2492, 1656, 2913, 2948, 528, 2101, 372, 2052, 2529, 1763, 2331, 3082, 2462, 2852, 835, 786, 2511, 1057, 848, 2484, 714, 933, 353, 2035, 3233, 2210, 2887, 3183, 2206, 671, 839, 2798, 1067, 2863, 1445, 2162, 2064, 472, 1692]]) == 0\nassert my_solution.minCost(*[[1086, 635, 593, 737, 989, 758, 3, 566, 793, 926, 542, 263, 79, 903, 731, 538, 551, 566, 1126, 562, 943, 228, 1030, 605, 608, 763, 803, 797, 1135, 282, 976, 28, 903, 918], [927, 1151, 604, 102, 347, 193, 750, 1073, 382, 739, 418, 956, 884, 1103, 341, 336, 1119, 919, 570, 35, 192, 1024, 839, 366, 533, 79, 982, 464, 555, 554, 38, 838, 767, 170]]) == -1\nassert my_solution.minCost(*[[1086, 635, 593, 737, 989, 758, 3, 566, 793, 926, 542, 263, 79, 903, 731, 538, 551, 566, 1126, 562, 943, 228, 1030, 605, 608, 763, 803, 797, 1135, 282, 976, 28, 903, 918], [1086, 635, 593, 737, 989, 758, 3, 566, 793, 926, 542, 263, 79, 903, 731, 538, 551, 566, 1126, 562, 943, 228, 1030, 605, 608, 763, 803, 797, 1135, 282, 976, 28, 903, 918]]) == 0\nassert my_solution.minCost(*[[4446, 2662, 3739, 3585, 935, 2825, 4378, 4882, 4706, 2264, 699, 1775, 2677, 4800, 239, 4032, 4067, 4236, 4155, 4540, 2018, 3622, 4295, 3509, 2067, 2466, 714, 3265, 661, 2865, 4721, 3437, 2094, 4475, 1941, 420, 3574, 637, 3345, 1579, 874, 2914, 3449, 1304, 612, 5017, 1951, 2520, 4849, 2021, 3415, 543, 4753, 1520, 2996, 894, 1575, 4853, 1611, 4253, 4826, 4695, 142, 452, 3102, 1149, 2383, 4212, 2922, 1632, 3208], [2812, 2971, 1552, 2487, 742, 1988, 962, 3224, 1011, 9, 113, 218, 3157, 887, 454, 3945, 581, 3821, 69, 1106, 3406, 1769, 2849, 304, 4617, 3508, 2341, 4524, 721, 373, 3549, 3849, 4490, 514, 4977, 4633, 175, 2344, 4503, 3261, 3416, 340, 2843, 1228, 2485, 4103, 971, 4947, 650, 3508, 4713, 4267, 1500, 3793, 4456, 763, 2619, 4828, 1745, 3939, 1325, 1712, 733, 1468, 4361, 2087, 2175, 189, 3369, 4308, 3824]]) == -1\nassert my_solution.minCost(*[[4446, 2662, 3739, 3585, 935, 2825, 4378, 4882, 4706, 2264, 699, 1775, 2677, 4800, 239, 4032, 4067, 4236, 4155, 4540, 2018, 3622, 4295, 3509, 2067, 2466, 714, 3265, 661, 2865, 4721, 3437, 2094, 4475, 1941, 420, 3574, 637, 3345, 1579, 874, 2914, 3449, 1304, 612, 5017, 1951, 2520, 4849, 2021, 3415, 543, 4753, 1520, 2996, 894, 1575, 4853, 1611, 4253, 4826, 4695, 142, 452, 3102, 1149, 2383, 4212, 2922, 1632, 3208], [4446, 2662, 3739, 3585, 935, 2825, 4378, 4882, 4706, 2264, 699, 1775, 2677, 4800, 239, 4032, 4067, 4236, 4155, 4540, 2018, 3622, 4295, 3509, 2067, 2466, 714, 3265, 661, 2865, 4721, 3437, 2094, 4475, 1941, 420, 3574, 637, 3345, 1579, 874, 2914, 3449, 1304, 612, 5017, 1951, 2520, 4849, 2021, 3415, 543, 4753, 1520, 2996, 894, 1575, 4853, 1611, 4253, 4826, 4695, 142, 452, 3102, 1149, 2383, 4212, 2922, 1632, 3208]]) == 0\nassert my_solution.minCost(*[[2845, 1522, 1261, 215, 904, 2673, 3050, 1372, 2280, 2977, 827, 1409, 1976, 2562, 1575, 176, 2770, 1085, 2365, 543, 847, 2327, 211, 2750, 393, 944, 2412, 592, 1581, 445, 2330, 363, 2691, 214, 547, 869, 2294, 2191, 2262, 2762, 1054, 612, 2812, 2917, 2837, 1742, 619, 1147, 1138, 189, 2681, 1519, 838, 691, 815, 2026], [2360, 1938, 2026, 767, 2423, 2795, 1522, 2648, 557, 2026, 2560, 466, 1247, 2886, 2487, 2052, 273, 2639, 1880, 1269, 2339, 1625, 2382, 1917, 1860, 2000, 2472, 1935, 2095, 2590, 1439, 229, 1808, 2779, 1401, 453, 475, 644, 1283, 525, 99, 2345, 1159, 1907, 2354, 1673, 640, 2336, 2702, 1679, 3019, 1352, 1454, 2314, 3087, 2877]]) == -1\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2689", "questionFrontendId": "2561", "questionTitle": "Rearranging Fruits", "stats": { "totalAccepted": "3.4K", "totalSubmission": "9.1K", "totalAcceptedRaw": 3428, "totalSubmissionRaw": 9076, "acRate": "37.8%" } }
LeetCode/2639
# Separate the Digits in an Array Given an array of positive integers `nums`, return *an array* `answer` *that consists of the digits of each integer in* `nums` *after separating them in **the same order** they appear in* `nums`. To separate the digits of an integer is to get all the digits it has in the same order. * For example, for the integer `10921`, the separation of its digits is `[1,0,9,2,1]`.   **Example 1:** ``` **Input:** nums = [13,25,83,77] **Output:** [1,3,2,5,8,3,7,7] **Explanation:** - The separation of 13 is [1,3]. - The separation of 25 is [2,5]. - The separation of 83 is [8,3]. - The separation of 77 is [7,7]. answer = [1,3,2,5,8,3,7,7]. Note that answer contains the separations in the same order. ``` **Example 2:** ``` **Input:** nums = [7,1,3,9] **Output:** [7,1,3,9] **Explanation:** The separation of each integer in nums is itself. answer = [7,1,3,9]. ```   **Constraints:** * `1 <= nums.length <= 1000` * `1 <= nums[i] <= 105` Please make sure your answer follows the type signature below: ```python3 class Solution: def separateDigits(self, nums: List[int]) -> List[int]: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.separateDigits(*[[13, 25, 83, 77]]) == [1, 3, 2, 5, 8, 3, 7, 7]\nassert my_solution.separateDigits(*[[7, 1, 3, 9]]) == [7, 1, 3, 9]\nassert my_solution.separateDigits(*[[9, 81, 33, 17, 58, 42, 8, 75]]) == [9, 8, 1, 3, 3, 1, 7, 5, 8, 4, 2, 8, 7, 5]\nassert my_solution.separateDigits(*[[28, 35, 21, 13, 21, 72, 35, 52]]) == [2, 8, 3, 5, 2, 1, 1, 3, 2, 1, 7, 2, 3, 5, 5, 2]\nassert my_solution.separateDigits(*[[74, 92, 25, 65, 77, 1, 73]]) == [7, 4, 9, 2, 2, 5, 6, 5, 7, 7, 1, 7, 3]\nassert my_solution.separateDigits(*[[32, 43, 68, 8, 100, 84, 80, 14, 88, 42, 53, 98, 69, 64, 40, 60, 23, 99]]) == [3, 2, 4, 3, 6, 8, 8, 1, 0, 0, 8, 4, 8, 0, 1, 4, 8, 8, 4, 2, 5, 3, 9, 8, 6, 9, 6, 4, 4, 0, 6, 0, 2, 3, 9, 9]\nassert my_solution.separateDigits(*[[83, 5, 21, 76, 34, 99, 63, 23, 70, 18, 64, 12, 21, 21, 78, 36, 58, 88, 58, 99]]) == [8, 3, 5, 2, 1, 7, 6, 3, 4, 9, 9, 6, 3, 2, 3, 7, 0, 1, 8, 6, 4, 1, 2, 2, 1, 2, 1, 7, 8, 3, 6, 5, 8, 8, 8, 5, 8, 9, 9]\nassert my_solution.separateDigits(*[[26, 92, 91, 53, 10, 24, 25, 20, 92, 73, 63, 51, 65, 87, 6, 17, 32, 14, 42]]) == [2, 6, 9, 2, 9, 1, 5, 3, 1, 0, 2, 4, 2, 5, 2, 0, 9, 2, 7, 3, 6, 3, 5, 1, 6, 5, 8, 7, 6, 1, 7, 3, 2, 1, 4, 4, 2]\nassert my_solution.separateDigits(*[[46, 65, 43, 9, 75, 76, 25, 96, 46, 85, 19, 29, 88, 2, 5, 24, 60]]) == [4, 6, 6, 5, 4, 3, 9, 7, 5, 7, 6, 2, 5, 9, 6, 4, 6, 8, 5, 1, 9, 2, 9, 8, 8, 2, 5, 2, 4, 6, 0]\nassert my_solution.separateDigits(*[[26, 76, 24, 96, 82]]) == [2, 6, 7, 6, 2, 4, 9, 6, 8, 2]\nassert my_solution.separateDigits(*[[97, 97, 72, 35, 21, 77, 82, 30, 94, 55, 76, 94, 51, 82, 3]]) == [9, 7, 9, 7, 7, 2, 3, 5, 2, 1, 7, 7, 8, 2, 3, 0, 9, 4, 5, 5, 7, 6, 9, 4, 5, 1, 8, 2, 3]\nassert my_solution.separateDigits(*[[89, 52, 96, 72, 27, 59, 57]]) == [8, 9, 5, 2, 9, 6, 7, 2, 2, 7, 5, 9, 5, 7]\nassert my_solution.separateDigits(*[[30, 130, 14, 754, 41, 494, 548, 76, 825, 899, 499, 188, 982, 8, 890, 563, 438, 363, 32, 482, 623, 864, 161, 962, 678, 414, 659, 612, 332, 164, 580, 14, 633, 842, 969, 792, 777, 705, 436, 750, 501, 395, 342, 838]]) == [3, 0, 1, 3, 0, 1, 4, 7, 5, 4, 4, 1, 4, 9, 4, 5, 4, 8, 7, 6, 8, 2, 5, 8, 9, 9, 4, 9, 9, 1, 8, 8, 9, 8, 2, 8, 8, 9, 0, 5, 6, 3, 4, 3, 8, 3, 6, 3, 3, 2, 4, 8, 2, 6, 2, 3, 8, 6, 4, 1, 6, 1, 9, 6, 2, 6, 7, 8, 4, 1, 4, 6, 5, 9, 6, 1, 2, 3, 3, 2, 1, 6, 4, 5, 8, 0, 1, 4, 6, 3, 3, 8, 4, 2, 9, 6, 9, 7, 9, 2, 7, 7, 7, 7, 0, 5, 4, 3, 6, 7, 5, 0, 5, 0, 1, 3, 9, 5, 3, 4, 2, 8, 3, 8]\nassert my_solution.separateDigits(*[[493, 998, 112, 660, 961, 943, 721, 480, 522, 133, 129, 276, 362, 616, 52, 117, 300, 274, 862, 487, 715]]) == [4, 9, 3, 9, 9, 8, 1, 1, 2, 6, 6, 0, 9, 6, 1, 9, 4, 3, 7, 2, 1, 4, 8, 0, 5, 2, 2, 1, 3, 3, 1, 2, 9, 2, 7, 6, 3, 6, 2, 6, 1, 6, 5, 2, 1, 1, 7, 3, 0, 0, 2, 7, 4, 8, 6, 2, 4, 8, 7, 7, 1, 5]\nassert my_solution.separateDigits(*[[272, 232, 543, 275, 68, 144, 656, 623, 317, 63, 908, 565, 880, 12, 920, 467, 559, 91, 698, 577, 95, 436, 700, 467, 568, 389, 376, 830, 361, 818, 517]]) == [2, 7, 2, 2, 3, 2, 5, 4, 3, 2, 7, 5, 6, 8, 1, 4, 4, 6, 5, 6, 6, 2, 3, 3, 1, 7, 6, 3, 9, 0, 8, 5, 6, 5, 8, 8, 0, 1, 2, 9, 2, 0, 4, 6, 7, 5, 5, 9, 9, 1, 6, 9, 8, 5, 7, 7, 9, 5, 4, 3, 6, 7, 0, 0, 4, 6, 7, 5, 6, 8, 3, 8, 9, 3, 7, 6, 8, 3, 0, 3, 6, 1, 8, 1, 8, 5, 1, 7]\nassert my_solution.separateDigits(*[[290, 191, 596, 644, 425, 308, 825, 555, 583, 996, 630, 886, 382, 354, 455, 883, 581, 408, 619, 531, 618, 355, 14, 653, 638, 589, 271, 430, 519, 517, 851, 875, 69, 496, 924, 680, 753, 287, 496, 166, 300]]) == [2, 9, 0, 1, 9, 1, 5, 9, 6, 6, 4, 4, 4, 2, 5, 3, 0, 8, 8, 2, 5, 5, 5, 5, 5, 8, 3, 9, 9, 6, 6, 3, 0, 8, 8, 6, 3, 8, 2, 3, 5, 4, 4, 5, 5, 8, 8, 3, 5, 8, 1, 4, 0, 8, 6, 1, 9, 5, 3, 1, 6, 1, 8, 3, 5, 5, 1, 4, 6, 5, 3, 6, 3, 8, 5, 8, 9, 2, 7, 1, 4, 3, 0, 5, 1, 9, 5, 1, 7, 8, 5, 1, 8, 7, 5, 6, 9, 4, 9, 6, 9, 2, 4, 6, 8, 0, 7, 5, 3, 2, 8, 7, 4, 9, 6, 1, 6, 6, 3, 0, 0]\nassert my_solution.separateDigits(*[[126, 935, 96, 537, 394, 634, 270, 72, 688, 158, 930, 534, 746, 520, 649, 318, 632, 592, 732, 670, 291, 151, 128, 841, 680, 158, 631, 196, 707, 439, 534, 666, 22, 626, 299, 121, 346, 11, 426, 827, 459, 748, 551, 561, 110, 192, 103]]) == [1, 2, 6, 9, 3, 5, 9, 6, 5, 3, 7, 3, 9, 4, 6, 3, 4, 2, 7, 0, 7, 2, 6, 8, 8, 1, 5, 8, 9, 3, 0, 5, 3, 4, 7, 4, 6, 5, 2, 0, 6, 4, 9, 3, 1, 8, 6, 3, 2, 5, 9, 2, 7, 3, 2, 6, 7, 0, 2, 9, 1, 1, 5, 1, 1, 2, 8, 8, 4, 1, 6, 8, 0, 1, 5, 8, 6, 3, 1, 1, 9, 6, 7, 0, 7, 4, 3, 9, 5, 3, 4, 6, 6, 6, 2, 2, 6, 2, 6, 2, 9, 9, 1, 2, 1, 3, 4, 6, 1, 1, 4, 2, 6, 8, 2, 7, 4, 5, 9, 7, 4, 8, 5, 5, 1, 5, 6, 1, 1, 1, 0, 1, 9, 2, 1, 0, 3]\nassert my_solution.separateDigits(*[[165, 111, 798, 138, 665, 289, 874, 12, 99, 201, 432, 653, 239, 418, 941, 575, 441, 751, 571, 815, 535, 818, 301, 914, 106, 633, 734, 836, 931, 515]]) == [1, 6, 5, 1, 1, 1, 7, 9, 8, 1, 3, 8, 6, 6, 5, 2, 8, 9, 8, 7, 4, 1, 2, 9, 9, 2, 0, 1, 4, 3, 2, 6, 5, 3, 2, 3, 9, 4, 1, 8, 9, 4, 1, 5, 7, 5, 4, 4, 1, 7, 5, 1, 5, 7, 1, 8, 1, 5, 5, 3, 5, 8, 1, 8, 3, 0, 1, 9, 1, 4, 1, 0, 6, 6, 3, 3, 7, 3, 4, 8, 3, 6, 9, 3, 1, 5, 1, 5]\nassert my_solution.separateDigits(*[[673, 559, 464, 644, 305, 337, 242, 421, 342, 690, 152, 739, 816, 974, 901, 529, 851, 213, 90, 640, 301, 747, 735, 536, 428, 816, 442, 156, 660, 680, 617, 659, 676, 914, 791, 673, 569, 414, 254, 185, 42, 21, 708, 798, 22, 40, 18]]) == [6, 7, 3, 5, 5, 9, 4, 6, 4, 6, 4, 4, 3, 0, 5, 3, 3, 7, 2, 4, 2, 4, 2, 1, 3, 4, 2, 6, 9, 0, 1, 5, 2, 7, 3, 9, 8, 1, 6, 9, 7, 4, 9, 0, 1, 5, 2, 9, 8, 5, 1, 2, 1, 3, 9, 0, 6, 4, 0, 3, 0, 1, 7, 4, 7, 7, 3, 5, 5, 3, 6, 4, 2, 8, 8, 1, 6, 4, 4, 2, 1, 5, 6, 6, 6, 0, 6, 8, 0, 6, 1, 7, 6, 5, 9, 6, 7, 6, 9, 1, 4, 7, 9, 1, 6, 7, 3, 5, 6, 9, 4, 1, 4, 2, 5, 4, 1, 8, 5, 4, 2, 2, 1, 7, 0, 8, 7, 9, 8, 2, 2, 4, 0, 1, 8]\nassert my_solution.separateDigits(*[[433, 975, 743, 6, 103, 697, 372, 824, 382, 365, 500, 725, 441, 839, 22, 439, 320, 738, 769, 290, 243, 247, 821, 812, 293, 461, 324, 73, 923, 974, 909, 585]]) == [4, 3, 3, 9, 7, 5, 7, 4, 3, 6, 1, 0, 3, 6, 9, 7, 3, 7, 2, 8, 2, 4, 3, 8, 2, 3, 6, 5, 5, 0, 0, 7, 2, 5, 4, 4, 1, 8, 3, 9, 2, 2, 4, 3, 9, 3, 2, 0, 7, 3, 8, 7, 6, 9, 2, 9, 0, 2, 4, 3, 2, 4, 7, 8, 2, 1, 8, 1, 2, 2, 9, 3, 4, 6, 1, 3, 2, 4, 7, 3, 9, 2, 3, 9, 7, 4, 9, 0, 9, 5, 8, 5]\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2639", "questionFrontendId": "2553", "questionTitle": "Separate the Digits in an Array", "stats": { "totalAccepted": "7.6K", "totalSubmission": "9.6K", "totalAcceptedRaw": 7627, "totalSubmissionRaw": 9605, "acRate": "79.4%" } }
LeetCode/2640
# Maximum Number of Integers to Choose From a Range I You are given an integer array `banned` and two integers `n` and `maxSum`. You are choosing some number of integers following the below rules: * The chosen integers have to be in the range `[1, n]`. * Each integer can be chosen **at most once**. * The chosen integers should not be in the array `banned`. * The sum of the chosen integers should not exceed `maxSum`. Return *the **maximum** number of integers you can choose following the mentioned rules*.   **Example 1:** ``` **Input:** banned = [1,6,5], n = 5, maxSum = 6 **Output:** 2 **Explanation:** You can choose the integers 2 and 4. 2 and 4 are from the range [1, 5], both did not appear in banned, and their sum is 6, which did not exceed maxSum. ``` **Example 2:** ``` **Input:** banned = [1,2,3,4,5,6,7], n = 8, maxSum = 1 **Output:** 0 **Explanation:** You cannot choose any integer while following the mentioned conditions. ``` **Example 3:** ``` **Input:** banned = [11], n = 7, maxSum = 50 **Output:** 7 **Explanation:** You can choose the integers 1, 2, 3, 4, 5, 6, and 7. They are from the range [1, 7], all did not appear in banned, and their sum is 28, which did not exceed maxSum. ```   **Constraints:** * `1 <= banned.length <= 104` * `1 <= banned[i], n <= 104` * `1 <= maxSum <= 109` Please make sure your answer follows the type signature below: ```python3 class Solution: def maxCount(self, banned: List[int], n: int, maxSum: int) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.maxCount(*[[1, 6, 5], 5, 6]) == 2\nassert my_solution.maxCount(*[[1, 2, 3, 4, 5, 6, 7], 8, 1]) == 0\nassert my_solution.maxCount(*[[11], 7, 50]) == 7\nassert my_solution.maxCount(*[[176, 36, 104, 125, 188, 152, 101, 47, 51, 65, 39, 174, 29, 55, 13, 138, 79, 81, 175, 178, 42, 108, 24, 80, 183, 190, 123, 20, 139, 22, 140, 62, 58, 137, 68, 148, 172, 76, 173, 189, 151, 186, 153, 57, 142, 105, 133, 114, 165, 118, 56, 59, 124, 82, 49, 94, 8, 146, 109, 14, 85, 44, 60, 181, 95, 23, 150, 97, 28, 182, 157, 46, 160, 155, 12, 67, 135, 117, 2, 25, 74, 91, 71, 98, 127, 120, 130, 107, 168, 18, 69, 110, 61, 147, 145, 38], 3016, 240]) == 17\nassert my_solution.maxCount(*[[87, 193, 85, 55, 14, 69, 26, 133, 171, 180, 4, 8, 29, 121, 182, 78, 157, 53, 26, 7, 117, 138, 57, 167, 8, 103, 32, 110, 15, 190, 139, 16, 49, 138, 68, 69, 92, 89, 140, 149, 107, 104, 2, 135, 193, 87, 21, 194, 192, 9, 161, 188, 73, 84, 83, 31, 86, 33, 138, 63, 127, 73, 114, 32, 66, 64, 19, 175, 108, 80, 176, 52, 124, 94, 33, 55, 130, 147, 39, 76, 22, 112, 113, 136, 100, 134, 155, 40, 170, 144, 37, 43, 151, 137, 82, 127, 73], 1079, 87]) == 9\nassert my_solution.maxCount(*[[78, 121, 219, 281, 165, 277, 227, 257, 66, 148, 125, 254, 129, 258, 98, 191, 4, 63, 172, 253, 40, 221, 45, 264, 194, 332, 88, 37, 152, 38, 333, 174, 237, 338, 77, 308, 137, 158, 197, 167, 295, 319, 74, 224, 54, 132, 122, 111, 110, 279, 190, 299, 193, 139, 41, 305, 208, 105, 162, 7, 19, 31, 181, 252, 207, 217, 133, 155, 231, 84, 213, 294, 97, 107, 186, 101, 118, 195, 315, 234, 102, 182, 335, 65, 248, 336, 320, 34, 61, 225, 112, 304, 267, 59, 176, 103, 270, 317, 86, 340, 291, 178, 204, 62, 273, 99, 55, 220, 256, 127, 3, 296, 26, 285, 242, 303, 124, 230, 48, 128, 8, 68, 341, 255, 51, 288, 334, 313, 10, 32, 75, 113, 14, 23, 76, 157, 166, 67, 306, 80, 206, 246, 276, 321, 145, 9, 202, 222, 261, 138, 73, 240, 278, 282, 280, 15, 71, 286, 287, 90, 226, 236, 330, 28, 12, 96, 177, 123, 115, 85, 233], 3600, 117]) == 10\nassert my_solution.maxCount(*[[179, 266, 77, 196, 59, 313, 286, 41, 21, 201, 57, 237, 74, 333, 101, 281, 227, 25, 138, 10, 304, 55, 50, 72, 244, 113, 159, 330, 154, 156, 311, 170, 283, 9, 224, 46, 197, 2, 325, 237, 54, 168, 275, 166, 236, 30, 250, 48, 274, 331, 240, 153, 312, 63, 303, 342, 79, 37, 165, 20, 79, 293, 103, 152, 215, 44, 56, 196, 29, 251, 264, 210, 212, 135, 296, 123, 289, 257, 208, 309, 67, 114, 170, 119, 337, 163, 242, 162, 109, 318, 51, 105, 272, 240, 107, 226, 224, 188, 224, 317, 27, 102, 63, 128, 3, 133, 27, 134, 186, 220, 198, 24, 274, 287, 267, 8, 13, 322, 278, 166, 304, 165, 342, 89, 184, 300, 312, 339, 163, 307, 123, 137, 293, 227, 229, 57, 66, 13, 71, 233, 260, 79, 228, 301, 4, 4, 89, 196, 193, 337, 205, 51, 144, 99, 104, 73, 10, 311, 240, 168, 77, 244, 114, 217, 186, 134, 229, 241, 46, 89, 54, 127], 4085, 109718563]) == 3953\nassert my_solution.maxCount(*[[266, 530, 595, 264, 331, 462, 268, 521, 401, 9, 464, 275, 166, 527, 218, 219, 107, 34, 367, 117, 42, 193, 363, 335, 233, 215, 519, 180, 167, 10, 501, 591, 471, 421, 425, 344, 533, 555, 477, 59, 28, 92, 66, 172, 291, 392, 35, 160, 294, 192, 342, 168, 349, 328, 578, 240, 470, 301, 574, 222, 173, 438, 318, 476, 546, 64, 542, 339, 137, 585, 39, 5, 312, 103, 87, 372, 589, 513, 217, 90, 379, 161, 506, 487, 326, 139, 452, 525, 223, 232, 429, 31, 245, 198, 76, 423, 255, 243, 141, 303, 150, 273, 529, 176, 231, 73, 337, 165, 494, 400, 136, 142, 33, 495, 369, 430, 511, 498, 465, 582, 199, 409, 347, 537, 602, 395, 83, 209, 346, 548, 485, 109, 333, 382, 30, 248, 146, 63, 315, 415, 325, 327, 186, 490, 133, 262, 187, 360, 155, 356, 532, 17, 127, 13, 512, 37, 386, 220, 422, 457, 202, 545, 373, 178, 442, 428, 552, 417, 113, 522, 310, 330, 491, 140, 260, 147, 292, 507, 441, 517, 3, 132, 324, 469, 188, 7, 461, 299, 376, 115, 284, 68, 480, 229, 19, 162, 46, 444, 394, 305, 189, 18, 535, 154, 263, 427, 288, 420, 570, 404, 478, 190, 607, 49, 135, 381, 343, 371, 560, 144, 524, 283, 259, 431, 196, 278, 298, 112, 316, 80, 405, 29, 432, 354, 86, 234, 411, 447, 157, 58, 85, 48, 27, 104, 365, 120, 397, 267, 433, 253, 1, 562, 221, 276, 489, 575, 350, 368, 52, 391, 170, 252, 448, 272, 443, 608, 210, 446, 101, 314, 16, 60, 455, 138, 580, 541, 99, 93, 295, 601, 102, 515, 62, 539, 111, 364, 598, 70, 466, 274, 75, 399, 370, 44, 45, 473, 378, 282, 481, 216, 171, 551, 323, 317], 124, 292541445]) == 63\nassert my_solution.maxCount(*[[397, 305, 171, 199, 412, 556, 348, 229, 274, 18, 200, 350, 541, 367, 302, 477, 381, 410, 541, 415, 281, 166, 224, 40, 272, 585, 583, 417, 353, 243, 167, 335, 565, 494, 52, 253, 178, 198, 221, 99, 126, 529, 433, 322, 63, 252, 131, 524, 148, 355, 257, 23, 224, 353, 426, 593, 95, 262, 332, 81, 431, 359, 381, 245, 219, 330, 150, 488, 442, 36, 57, 173, 432, 55, 61, 589, 68, 350, 540, 424, 174, 593, 378, 364, 286, 35, 27, 446, 504, 523, 179, 25, 333, 231, 137, 81, 176, 516, 64, 440, 484, 254, 54, 337, 76, 233, 26, 23, 8, 601, 147, 591, 93, 352, 211, 336, 553, 32, 61, 492, 132, 179, 148, 434, 69, 526, 57, 345, 234, 334, 205, 286, 586, 501, 574, 196, 563, 218, 253, 462, 139, 138, 436, 468, 508, 416, 103, 103, 408, 176, 278, 299, 124, 60, 204, 162, 529, 19, 420, 163, 188, 142, 163, 382, 361, 58, 315, 397, 268, 33, 268, 589, 505, 309, 559, 186, 534, 253, 521, 82, 38, 595, 592, 533, 288, 368, 510, 433, 424, 185, 60, 251, 509, 45, 491, 271, 54, 85, 295, 569, 559, 385, 182, 314, 62, 116, 547, 472, 214, 95, 538, 538, 447, 266, 323, 16, 372, 361, 503, 556, 3, 316, 439, 394, 306, 128, 163, 258, 519, 228, 233, 389, 518, 326, 130, 152, 326, 86, 87, 347, 170, 155, 349, 537, 300, 433, 206, 214, 392, 101, 401, 1, 504, 473, 567, 283, 412, 509, 150, 388, 306, 488, 327, 54, 309, 255, 218, 550, 584, 55, 91, 430, 446, 417, 279, 546, 203, 281, 407, 237, 443, 211, 553, 225, 525, 591, 431, 156, 335, 203, 166, 471, 208, 60, 487, 358, 178, 314, 290, 581, 337, 224, 471, 38, 176], 7362, 911846577]) == 7121\nassert my_solution.maxCount(*[[152, 227, 518, 324, 508, 446, 203, 16, 278, 385, 312, 22, 425, 130, 293, 233, 365, 199, 87, 613, 280, 589, 479, 297, 207, 523, 428, 448, 25, 298, 103, 649, 104, 17, 608, 139, 474, 77, 254, 464, 376, 629, 602, 487, 512, 496, 119, 70, 165, 52, 82, 94, 378, 422, 476, 93, 596, 406, 272, 630, 309, 565, 285, 266, 495, 101, 361, 314, 442, 432, 594, 621, 106, 37, 294, 536, 517, 11, 140, 478, 457, 550, 645, 423, 451, 8, 163, 531, 230, 235, 341, 267, 362, 527, 234, 609, 444, 323, 336, 411, 169, 292, 19, 50, 569, 501, 632, 279, 459, 225, 595, 261, 325, 71, 436, 84, 216, 342, 241, 206, 269, 556, 315, 99, 543, 405, 56, 503, 20, 123, 410, 4, 379, 452, 164, 27, 528, 310, 524, 640, 525, 218, 299, 370, 322, 514, 244, 289, 219, 350, 245, 372, 409, 33, 153, 126, 340, 122, 2, 223, 72, 347, 424, 270, 186, 188, 367, 577, 461, 626, 623, 317, 386, 213, 149, 29, 477, 345, 319, 229, 9, 147, 606, 113, 58, 39, 120, 548, 15, 526, 32, 288, 502, 209, 567, 416, 443, 198, 412, 639, 511, 408, 537, 148, 150, 374, 21, 45, 546, 296, 580, 417, 36, 55, 86, 42, 538, 473, 90, 529, 211, 196, 193, 175, 391, 472, 619, 490, 23, 593, 313, 352, 562, 585, 554, 445, 283, 301, 190, 403, 530, 157, 469, 540, 83, 111, 364, 506, 208, 48, 250, 371, 489, 363, 275, 381, 108, 204, 41, 246, 605, 492, 185, 114, 603, 329, 320, 136, 573, 338, 276, 18, 344, 507, 256, 271, 485, 467, 81, 652, 162, 351, 239, 404, 89, 57, 505, 458, 366, 328, 238, 125, 295, 463, 610, 615, 237, 586, 141, 308, 460, 648, 80, 318, 437, 429, 497, 560, 121, 160, 311, 273, 158, 534, 583, 221, 545, 98, 286, 105, 182, 291, 633, 588, 635, 255], 312, 608]) == 23\nassert my_solution.maxCount(*[[541, 194, 109, 373, 569, 564, 523, 475, 598, 386, 202, 250, 173, 476, 350, 443, 389, 192, 448, 353, 320, 20, 531, 408, 79, 598, 175, 262, 363, 540, 256, 562, 143, 506, 277, 431, 316, 214, 388, 30, 518, 158, 152, 448, 188, 133, 636, 139, 518, 63, 502, 19, 362, 383, 311, 428, 313, 528, 609, 407, 182, 646, 588, 157, 11, 289, 466, 178, 498, 426, 363, 389, 85, 47, 145, 601, 120, 278, 544, 653, 92, 189, 452, 515, 93, 398, 380, 532, 178, 368, 472, 304, 63, 369, 270, 80, 373, 46, 134, 380, 507, 364, 224, 221, 180, 328, 4, 162, 330, 197, 241, 527, 359, 68, 349, 224, 644, 532, 369, 37, 373, 225, 636, 335, 508, 390, 634, 357, 531, 307, 504, 253, 109, 628, 6, 255, 420, 274, 112, 79, 343, 587, 99, 147, 445, 210, 284, 58, 546, 218, 355, 274, 23, 286, 160, 151, 9, 324, 251, 243, 500, 525, 28, 1, 619, 354, 480, 557, 429, 405, 23, 71, 563, 297, 234, 202, 616, 597, 620, 78, 467, 485, 197, 625, 38, 108, 552, 15, 111, 319, 444, 260, 497, 622, 530, 435, 154, 362, 77, 554, 639, 83, 565, 525, 406, 504, 202, 567, 16, 189, 497, 95, 348, 367, 641, 438, 609, 12, 250, 577, 540, 71, 592, 176, 257, 42, 181, 85, 645, 649, 86, 168, 457, 600, 118, 131, 463, 642, 233, 294, 597, 646, 98, 374, 361, 292, 411, 502, 131, 540, 474, 15, 307, 58, 481, 213, 47, 87, 440, 394, 437, 204, 548, 286, 42, 579, 445, 602, 168, 116, 575, 245, 165, 445, 156, 168, 398, 224, 86, 643, 430, 214, 440, 13, 480, 560, 306, 131, 17, 629, 269, 463, 590, 163, 2, 130, 127, 560, 46, 243, 32, 253, 637, 247, 66, 46, 50, 323, 56, 131, 127, 25, 371, 251, 225, 470, 131, 176, 200, 551, 497, 583, 33, 300, 236, 176, 478], 7913, 317]) == 16\nassert my_solution.maxCount(*[[512, 233, 22, 699, 458, 74, 482, 16, 455, 560, 389, 301, 4, 291, 145, 501, 333, 660, 538, 444, 496, 602, 509, 591, 124, 659, 336, 120, 475, 445, 36, 416, 192, 67, 341, 44, 399, 154, 630, 628, 140, 51, 626, 549, 187, 361, 388, 694, 421, 554, 411, 600, 105, 526, 102, 182, 479, 49, 125, 682, 258, 403, 417, 93, 309, 183, 32, 412, 170, 261, 159, 546, 569, 460, 661, 438, 179, 668, 338, 645, 566, 202, 35, 222, 275, 487, 313, 352, 163, 56, 252, 282, 259, 225, 109, 223, 690, 292, 502, 375, 299, 95, 316, 335, 307, 398, 293, 238, 190, 208, 382, 85, 436, 290, 21, 273, 675, 181, 138, 337, 63, 688, 485, 45, 563, 117, 197, 101, 99, 29, 8, 624, 242, 461, 524, 177, 46, 667, 494, 255, 243, 358, 405, 576, 98, 114, 593, 60, 315, 483, 543, 195, 664, 196, 47, 191, 545, 251, 26, 390, 507, 324, 695, 62, 303, 583, 466, 540, 52, 91, 369, 394, 305, 59, 622, 579, 110, 294, 635, 226, 146, 380, 123, 42, 269, 227, 86, 55, 158, 119, 489, 448, 199, 548, 520, 634, 20, 651, 378, 534, 328, 557, 700, 544, 592, 329, 564, 447, 141, 433, 497, 107, 677, 153, 621, 623, 642, 116, 96, 679, 221, 401, 6, 266, 267, 137, 268, 532, 601, 274, 72, 609, 250, 156, 257, 180, 353, 304, 212, 311, 671, 53, 652, 37, 94, 547, 348, 696, 325, 332, 373, 611, 678, 139, 142, 559, 449, 342, 504, 476, 536, 355, 278, 302, 528, 103, 3, 539, 201, 435, 219, 368, 427, 240, 452, 641, 350, 347, 615, 408, 648, 393, 13, 446, 568, 326, 80, 97, 283, 5, 24, 414, 473, 666, 171, 597, 54, 672, 616, 367, 83, 204, 456, 104, 537, 402, 314, 12, 147, 58, 468, 595, 206, 429, 577, 43, 638, 558, 284, 649, 587, 573, 131, 620, 30, 28, 450, 306, 572, 387, 371, 541, 143, 627, 586, 256, 135, 617, 319, 321, 614, 308, 334, 230, 518, 470, 64, 339, 270, 157], 8045, 300738886]) == 7695\nassert my_solution.maxCount(*[[104, 351, 540, 301, 565, 429, 569, 598, 475, 337, 383, 496, 524, 324, 689, 167, 528, 383, 209, 166, 498, 699, 345, 102, 410, 160, 149, 587, 315, 268, 208, 427, 364, 4, 553, 663, 453, 8, 358, 194, 415, 653, 274, 249, 552, 34, 193, 58, 178, 295, 621, 90, 249, 593, 624, 76, 373, 568, 657, 600, 452, 607, 97, 310, 442, 430, 257, 607, 690, 371, 205, 160, 39, 350, 406, 375, 172, 482, 578, 195, 256, 376, 637, 661, 510, 544, 253, 487, 603, 308, 138, 224, 446, 273, 277, 488, 431, 553, 481, 535, 272, 697, 228, 605, 123, 607, 559, 554, 450, 104, 22, 285, 580, 328, 646, 128, 658, 167, 695, 174, 273, 551, 173, 700, 116, 600, 85, 24, 568, 219, 279, 55, 572, 528, 655, 347, 519, 606, 453, 380, 435, 688, 74, 663, 553, 371, 293, 326, 395, 696, 32, 321, 422, 496, 392, 114, 555, 310, 669, 222, 211, 457, 364, 298, 550, 324, 269, 649, 287, 425, 578, 82, 276, 594, 601, 535, 336, 292, 596, 698, 517, 589, 202, 85, 41, 222, 333, 463, 686, 555, 40, 398, 637, 232, 121, 325, 67, 680, 528, 199, 186, 116, 78, 354, 672, 88, 340, 218, 198, 44, 193, 156, 508, 402, 123, 419, 140, 630, 104, 231, 279, 336, 107, 111, 8, 88, 508, 230, 650, 701, 680, 386, 528, 550, 657, 499, 16, 360, 519, 596, 206, 650, 36, 536, 383, 344, 194, 313, 579, 359, 467, 194, 151, 615, 593, 362, 105, 152, 691, 248, 621, 297, 278, 333, 411, 4, 491, 144, 552, 610, 428, 226, 230, 243, 263, 416, 345, 322, 160, 120, 40, 13, 95, 12, 444, 671, 270, 27, 612, 450, 47, 1, 92, 437, 255, 87, 425, 504, 594, 579, 344, 452, 479, 328, 468, 574, 682, 351, 256, 70, 47, 542, 69, 423, 177, 28, 625, 515, 660, 377, 387, 53, 486, 476, 92, 302, 654, 420, 257, 495, 162, 539, 512, 421, 296, 284, 664, 253, 376, 596, 139, 557, 518, 460, 310, 27, 637, 375, 435, 438, 483], 77, 512050749]) == 51\nassert my_solution.maxCount(*[[812, 748, 455, 510, 326, 370, 409, 703, 401, 296, 166, 686, 73, 532, 475, 165, 589, 110, 414, 162, 425, 277, 778, 842, 528, 216, 838, 38, 444, 697, 49, 172, 637, 744, 784, 480, 218, 342, 514, 493, 385, 549, 394, 288, 499, 285, 245, 369, 48, 826, 583, 609, 7, 898, 66, 390, 81, 114, 226, 723, 837, 416, 177, 80, 352, 708, 814, 711, 448, 434, 761, 782, 470, 365, 681, 264, 615, 541, 438, 521, 456, 458, 695, 608, 330, 238, 866, 642, 353, 557, 108, 125, 806, 215, 727, 757, 313, 11, 482, 887, 798, 90, 432, 529, 849, 303, 175, 37, 556, 196, 466, 23, 811, 700, 813, 758, 1, 411, 696, 717, 16, 747, 452, 450, 77, 674, 547, 95, 539, 121, 658, 173, 746, 702, 612, 606, 854, 348, 661, 531, 698, 567, 368, 124, 687, 13, 354, 39, 624, 704, 882, 722, 199, 513, 640, 607, 194, 291, 821, 764, 341, 185, 233, 740, 195, 684, 244, 875, 631, 357, 792, 633, 231, 823, 664, 749, 610, 388, 904, 133, 469, 107, 873, 588, 707, 332, 25, 691, 871, 305, 33, 52, 570, 148, 656, 573, 815, 347, 685, 793, 62, 51, 693, 361, 188, 336, 40, 122, 406, 240, 404, 726, 542, 350, 266, 339, 525, 801, 471, 257, 349, 645, 213, 620, 618, 140, 263, 771, 442, 836, 246, 130, 862, 267, 132, 109, 592, 191, 159, 492, 560, 300, 262, 209, 169, 417, 189, 334, 270, 276, 451, 554, 886, 562, 509, 79, 310, 709, 859, 461, 36, 672, 268, 712, 905, 102, 78, 204, 496, 791, 104, 657, 682, 337, 611, 808, 293, 4, 530, 164, 797, 534, 533, 317, 464, 511, 380, 22, 116, 254, 830, 768, 765, 364, 259, 183, 568, 234, 228, 193, 396, 894, 180, 273, 2, 5, 88, 308, 430, 360, 271, 841, 229, 580, 561, 431, 663, 729, 870, 688, 713, 161, 74, 225, 142, 572, 860, 643, 803, 280, 619, 594, 399, 86, 787, 34, 785, 477, 374, 20, 487, 181, 627, 512, 780, 731, 445, 897, 834, 314, 418, 76, 616, 70, 12, 340, 151, 331, 412, 176, 96, 585, 617, 65, 322, 805, 804, 468, 454, 802, 868, 230, 767, 855, 888, 501, 555, 255, 31, 224, 667, 58, 29, 311, 197, 602, 408, 221, 595, 719, 774, 675, 641, 460, 644, 153, 752, 179, 865, 467, 318, 488, 375, 111, 219, 328, 575, 772, 45, 710, 621, 120, 538, 678, 422, 333, 536, 47, 287, 154, 320, 835, 41, 590, 32, 395, 650, 828, 443, 93, 692, 433, 203, 558, 879, 202, 630, 441, 628, 734, 825, 220, 182, 574, 437, 569, 850, 158, 474, 278, 893, 524, 295], 1029, 1253]) == 34\nassert my_solution.maxCount(*[[43, 272, 161, 404, 343, 614, 250, 739, 57, 800, 302, 869, 831, 827, 202, 746, 626, 673, 259, 827, 600, 532, 768, 266, 409, 67, 473, 845, 874, 854, 803, 571, 546, 421, 681, 623, 107, 561, 536, 318, 602, 839, 693, 633, 13, 632, 295, 564, 670, 804, 813, 681, 734, 663, 18, 739, 3, 230, 723, 772, 97, 424, 592, 634, 778, 175, 586, 247, 309, 274, 889, 615, 301, 717, 681, 624, 382, 611, 384, 611, 162, 324, 726, 779, 369, 142, 712, 128, 117, 867, 144, 498, 408, 634, 196, 452, 559, 137, 565, 295, 804, 6, 72, 81, 466, 834, 476, 4, 219, 718, 175, 351, 640, 32, 759, 656, 600, 92, 639, 644, 737, 482, 568, 710, 371, 614, 807, 201, 634, 544, 205, 399, 661, 664, 58, 419, 489, 106, 163, 297, 701, 784, 598, 902, 628, 702, 871, 462, 686, 620, 47, 404, 58, 684, 436, 907, 651, 240, 803, 371, 766, 175, 374, 813, 684, 634, 514, 244, 458, 385, 556, 857, 296, 486, 233, 127, 3, 301, 52, 379, 318, 246, 876, 244, 876, 354, 55, 444, 453, 380, 608, 488, 297, 614, 815, 291, 25, 299, 168, 630, 157, 600, 183, 578, 97, 92, 126, 203, 387, 575, 271, 731, 489, 734, 312, 281, 171, 776, 838, 523, 23, 865, 174, 226, 192, 557, 94, 869, 611, 798, 207, 836, 134, 103, 829, 207, 615, 601, 845, 398, 41, 533, 296, 333, 473, 95, 609, 591, 876, 685, 7, 387, 878, 117, 374, 304, 15, 359, 184, 60, 476, 186, 567, 843, 109, 282, 885, 235, 3, 837, 141, 319, 395, 89, 162, 830, 894, 738, 99, 1, 376, 836, 716, 454, 873, 699, 430, 575, 77, 79, 338, 540, 723, 89, 861, 13, 519, 574, 315, 720, 430, 831, 527, 816, 181, 716, 224, 115, 48, 505, 157, 831, 604, 553, 641, 252, 251, 32, 258, 553, 693, 620, 58, 767, 207, 339, 600, 813, 713, 124, 530, 825, 631, 481, 590, 88, 779, 311, 501, 734, 106, 893, 495, 875, 763, 742, 828, 709, 365, 454, 613, 332, 515, 889, 132, 625, 811, 172, 366, 842, 599, 114, 375, 725, 750, 526, 610, 462, 161, 535, 25, 819, 673, 692, 403, 389, 334, 823, 454, 65, 40, 91, 433, 763, 401, 82, 878, 98, 271, 697, 339, 186, 371, 644, 604, 581, 619, 31, 575, 127, 492, 590, 46, 807, 856, 155, 779, 288, 797, 829, 120, 298, 722, 454, 550, 222, 249, 156, 18, 370, 782, 644, 715, 211, 761, 430, 151, 567, 565, 228, 753, 422, 142, 613, 469, 280, 303, 54, 661, 480, 568, 589, 299, 558, 444, 892, 861, 251, 259, 383, 735, 895, 357, 781], 2794, 891214307]) == 2443\nassert my_solution.maxCount(*[[1474, 239, 389, 366, 989, 1289, 1583, 1421, 687, 158, 932, 367, 4, 498, 926, 504, 274, 438, 1411, 870, 879, 544, 656, 850, 955, 230, 353, 1657, 1598, 1182, 684, 1459, 1195, 285, 483, 1091, 1654, 924, 429, 1669, 1492, 930, 1418, 1565, 1429, 263, 1451, 726, 969, 944, 361, 883, 354, 90, 538, 1264, 1060, 1197, 589, 1269, 976, 1651, 812, 562, 321, 1170, 569, 77, 1498, 1019, 1171, 229, 1278, 733, 416, 287, 686, 823, 1514, 66, 1035, 941, 182, 72, 540, 34, 1178, 566, 1095, 826, 207, 1022, 133, 626, 1107, 55, 198, 695, 1537, 1131, 911, 1025, 1196, 964, 1164, 334, 306, 1323, 1570, 1244, 789, 1275, 738, 214, 1329, 1040, 61, 1632, 456, 171, 1428, 1199, 307, 1191, 1457, 979, 746, 1559, 953, 327, 442, 335, 413, 1063, 910, 1074, 1294, 800, 199, 100, 1016, 1440, 339, 233, 501, 784, 387, 1322, 947, 876, 332, 467, 1296, 218, 375, 1397, 405, 720, 673, 1213, 1341, 86, 1475, 928, 854, 283, 881, 844, 903, 1085, 815, 706, 853, 1031, 873, 165, 1058, 1018, 245, 169, 919, 545, 68, 935, 867, 409, 669, 104, 803, 1566, 314, 1515, 205, 443, 134, 957, 1655, 1641, 1441, 1377, 744, 277, 588, 19, 412, 1314, 662, 1417, 1614, 1477, 216, 1579, 958, 1030, 965, 308, 770, 1206, 1455, 1473, 9, 1163, 582, 1042, 301, 449, 1036, 788, 627, 729, 1099, 916, 85, 918, 468, 635, 1255, 847, 1208, 1460, 246, 1276, 1300, 1159, 621, 888, 115, 1249, 914, 1502, 871, 139, 1354, 1005, 69, 486, 1154, 475, 1521, 782, 1260, 356, 1100, 1078, 176, 658, 1553, 1072, 848, 360, 683, 1437, 164, 260, 811, 765, 95, 647, 1588, 209, 570, 672, 1326, 345, 869, 664, 1263, 725, 1070, 1369, 1117, 1517, 455, 715, 457, 272, 1424, 226, 605, 559, 805, 1083, 1034, 730, 896, 1549, 1649, 264, 615, 1463, 648, 1628, 1087, 974, 649, 962, 160, 406, 1303, 836, 995, 1210, 1050, 1419, 1415, 1204, 1350, 1624, 548, 162, 364, 749, 1591, 934, 739, 1073, 1121, 289, 1646, 822, 244, 337, 148, 1599, 973, 494, 1311, 152, 596, 142, 188, 440, 1507, 269, 806, 1597, 1265, 875, 988, 140, 882, 292, 1242, 1293, 15, 892, 874, 1538, 795, 1088, 488, 960, 1548, 1399, 1601, 830, 1190, 755, 1223, 1186, 105, 689, 446, 1576, 708, 1364, 1033, 753, 97, 818, 347, 82, 404, 313, 453, 1408, 563, 190, 304, 1262, 943, 1123, 518, 1004, 234, 505, 516, 963, 1094, 1533, 638, 791, 998, 1067, 611, 1240, 71, 1333, 210, 1557, 997, 439, 533, 863, 1506, 773, 116, 62, 1481, 478, 655, 1608, 485, 295, 1315, 838, 203, 925, 106, 670, 992, 659, 1633, 379, 125, 1219, 1286, 1287, 580, 1647, 644, 1021, 1349, 1003, 967, 395, 479, 297, 680, 1272, 1258, 1068, 942, 1642, 1024, 267, 1443, 909, 328, 1409, 543, 690, 1542, 837, 1643, 178, 1051, 1396, 1580, 1125, 1002, 1187, 801, 1089, 752, 174, 1177, 143, 1513, 278, 1023, 275, 392, 1351, 121, 900, 933, 1518, 1610, 187, 1052, 1143, 89, 1217, 206, 427, 369, 981, 217, 766, 424, 451, 528, 243, 1348, 1613, 1464, 1007, 1545, 678, 76, 541, 471, 1148, 902, 1243, 460, 1525, 1000, 425, 208, 1279, 29, 628, 1500, 1032, 435, 1162, 530, 1015, 1009, 1198, 1461, 391, 1423, 1527, 1550, 1180, 865, 1184, 717, 820, 64, 1406, 372, 341, 1319, 575, 940, 102, 537, 781, 286, 156, 574, 294, 107, 1225, 637, 567, 52, 780, 804, 952, 1640, 634, 1547, 532, 231, 1469, 1246, 1118, 1098, 448, 653, 889, 1603, 351, 757, 718, 642, 65, 1491, 96, 1064, 1487, 1558, 529, 1653, 1482, 324, 929, 606, 242, 573, 101, 112, 1066, 625, 1555, 1427, 948, 774, 1490, 1609, 1422, 810, 291, 693, 1627, 472, 1358, 400, 1345, 1173, 316, 1535, 474, 1038, 1606, 737, 785, 745, 1511, 1065, 1433, 722, 872, 1232, 459, 1167, 1147, 1560, 325, 702, 1384, 748, 1523, 895, 1110, 1371, 236, 1363, 1194, 698, 1, 768, 1472, 1619, 1526, 685, 868, 1478, 1626, 60, 110, 716, 1268, 390, 1372, 1238, 1413, 549, 584, 1142, 179, 1248, 1214, 476, 1256, 1008, 1168, 359, 330, 694, 931, 618, 1193, 122, 817, 30, 1667, 591, 1288, 1343, 147, 1192, 502, 241, 1664, 660, 450, 1600, 821, 572, 1308, 630, 303, 1467, 252, 1621, 14, 949, 1120, 1516, 1339, 991, 1228, 1386, 88, 1672, 576, 223, 721, 368, 1298, 999, 489, 1090, 535, 211, 80, 1102, 447, 846, 839, 346, 904, 511, 1084, 1586, 124, 917, 1582, 491, 1468, 786, 1592, 342, 39, 1230, 279, 28, 1446, 743, 767, 1101, 114, 302, 793, 1639, 1092, 99, 808, 1045, 280, 554, 1662, 138, 1226, 487, 700, 996, 1006, 1281, 1114, 764, 849, 215, 1237, 1494, 1105, 676, 23, 154, 47, 1330, 922, 257, 1373, 546, 365, 1615, 613, 763, 856, 709, 524, 1540, 645, 1505, 454, 1233, 1325, 1551, 1245, 671, 1205, 796, 1499, 350, 1401, 1160, 127, 1041, 123, 1438, 250, 1554, 651, 507, 411, 469, 542, 1014, 237, 758, 1053, 1485, 1328, 742, 381, 1462, 797, 802, 312], 7716, 1060]) == 38\nassert my_solution.maxCount(*[[1516, 561, 494, 894, 1285, 1196, 1311, 783, 906, 964, 617, 350, 779, 876, 184, 345, 145, 524, 337, 1486, 1050, 1155, 851, 1561, 1162, 1599, 1567, 1356, 1064, 1286, 154, 194, 501, 756, 272, 1153, 812, 1597, 156, 511, 325, 1553, 987, 1303, 800, 13, 1510, 1517, 350, 1672, 105, 350, 1606, 589, 516, 1401, 1351, 760, 26, 1632, 389, 1181, 445, 457, 955, 344, 877, 1223, 1038, 1398, 1605, 85, 1002, 959, 661, 442, 823, 386, 1403, 13, 1207, 843, 309, 294, 188, 792, 1100, 1328, 987, 1441, 1365, 996, 423, 1261, 438, 1128, 1171, 607, 217, 1269, 403, 326, 735, 942, 1080, 802, 1206, 1402, 869, 1276, 514, 89, 1300, 1234, 1048, 750, 1412, 374, 405, 691, 1530, 956, 571, 1009, 315, 1064, 287, 309, 430, 362, 1245, 1453, 917, 938, 229, 1581, 562, 952, 1531, 1662, 160, 1431, 1673, 1616, 1438, 872, 1487, 1110, 1390, 1661, 747, 201, 979, 1571, 1656, 1605, 208, 137, 1319, 542, 268, 1150, 1390, 1111, 627, 1183, 84, 1106, 443, 1568, 1503, 1306, 719, 986, 37, 784, 60, 118, 1248, 412, 245, 1584, 265, 362, 671, 797, 18, 749, 1124, 651, 1480, 1295, 732, 488, 1431, 1536, 1615, 201, 977, 1258, 1569, 611, 517, 381, 1050, 679, 1466, 1303, 143, 1301, 1435, 73, 518, 105, 1259, 485, 413, 25, 1214, 706, 799, 847, 327, 399, 1200, 1360, 896, 51, 1115, 159, 943, 1241, 244, 874, 1604, 1403, 771, 794, 1044, 1118, 1112, 1387, 1573, 911, 1164, 37, 682, 1218, 1456, 205, 637, 816, 612, 644, 25, 122, 968, 1295, 589, 708, 960, 1160, 723, 1156, 863, 829, 400, 1521, 31, 272, 1080, 1645, 1470, 170, 767, 985, 254, 759, 375, 1575, 980, 512, 1357, 620, 507, 1034, 1265, 1526, 1594, 210, 1168, 209, 1281, 703, 1603, 334, 1477, 415, 783, 331, 1012, 1298, 1320, 1416, 1422, 461, 847, 260, 680, 1291, 806, 1434, 148, 101, 901, 1223, 552, 1227, 1598, 1208, 130, 910, 742, 831, 786, 83, 730, 1120, 874, 390, 1299, 682, 540, 19, 894, 1300, 758, 79, 65, 1198, 1316, 337, 750, 941, 306, 512, 830, 1210, 336, 989, 1190, 280, 1592, 1539, 18, 1637, 755, 1421, 599, 244, 492, 1215, 929, 680, 274, 136, 1203, 1432, 1627, 1064, 1639, 178, 1368, 1221, 818, 1522, 353, 1595, 610, 1183, 316, 333, 1633, 761, 1288, 712, 818, 661, 671, 606, 1405, 1288, 521, 375, 1523, 378, 1538, 1529, 1330, 7, 222, 91, 961, 433, 637, 351, 467, 647, 153, 1639, 1405, 92, 1345, 293, 676, 376, 305, 298, 1331, 1518, 513, 1484, 576, 492, 243, 69, 6, 1403, 406, 782, 1380, 106, 1426, 1050, 131, 509, 158, 1513, 476, 766, 896, 216, 451, 230, 1271, 73, 1027, 826, 1593, 1261, 357, 338, 1035, 724, 1144, 1669, 1302, 1669, 1202, 529, 276, 1190, 1014, 909, 1503, 1117, 1543, 269, 969, 1629, 1181, 362, 1264, 558, 103, 840, 1338, 148, 1597, 1162, 1425, 351, 253, 583, 795, 1382, 1665, 981, 427, 730, 279, 93, 1355, 723, 1375, 1497, 1143, 1381, 1105, 939, 1626, 1392, 1604, 814, 1167, 1641, 992, 1205, 428, 1435, 1175, 1395, 42, 886, 441, 516, 1482, 1152, 1264, 850, 809, 36, 440, 114, 1193, 625, 631, 206, 681, 284, 1522, 962, 1528, 1599, 1517, 118, 1248, 639, 1109, 580, 861, 324, 1275, 1108, 1185, 1245, 113, 499, 895, 459, 52, 1071, 637, 730, 187, 507, 1018, 1024, 121, 391, 448, 1404, 791, 216, 1122, 1257, 34, 4, 507, 1232, 1502, 1175, 60, 931, 914, 905, 704, 1591, 870, 492, 643, 468, 1436, 34, 501, 1302, 373, 676, 1232, 45, 19, 767, 1348, 311, 1126, 806, 1198, 939, 1027, 629, 747, 1177, 1428, 1030, 36, 271, 259, 477, 121, 755, 411, 339, 385, 1488, 277, 442, 627, 162, 349, 1431, 1395, 91, 1069, 158, 175, 1634, 720, 504, 1454, 1268, 920, 487, 233, 349, 325, 1529, 1133, 1477, 1070, 1378, 1237, 1498, 1513, 279, 896, 853, 282, 1580, 205, 756, 1172, 1598, 1506, 1668, 103, 13, 463, 66, 697, 735, 1535, 522, 313, 82, 680, 84, 775, 1215, 190, 1261, 488, 1594, 112, 323, 613, 1007, 146, 1022, 686, 580, 1274, 1107, 776, 1439, 1222, 1622, 179, 16, 383, 872, 228, 843, 1395, 590, 1047, 952, 1170, 551, 737, 971, 567, 1015, 1260, 1181, 970, 156, 557, 1281, 1473, 538, 450, 296, 1602, 844, 55, 1594, 1015, 1092, 752, 616, 1072, 106, 731, 495, 515, 961, 1498, 1578, 178, 1393, 951, 1178, 357, 435, 885, 499, 1642, 904, 668, 1611, 116, 95, 871, 1124, 254, 1135, 244, 1268, 908, 1509, 1589, 112, 149, 581, 355, 301, 723, 335, 1409, 1569, 1291, 573, 1120, 1234, 1525, 1035, 1105, 155, 1551, 1450, 1459, 882, 1315, 215, 995, 1371, 1380, 287, 997, 631, 425, 1563, 600, 1467, 113, 800, 351, 1008, 658, 1254, 658, 235, 514, 18, 626, 444, 70, 134, 685, 1356, 919, 1622, 1240, 247, 1257, 1204, 963, 459, 803, 1186, 693, 50, 1197, 508, 436, 48, 1432, 783, 706, 1317, 1381, 128, 223, 315, 639, 118, 1236, 765, 1259, 1504, 1202, 820, 170, 866, 551, 1256, 838], 2472, 603420949]) == 1806\nassert my_solution.maxCount(*[[1468, 690, 617, 437, 151, 679, 555, 1430, 445, 1607, 1168, 58, 1535, 825, 395, 943, 1284, 816, 1071, 315, 1597, 815, 984, 944, 897, 447, 683, 1134, 1079, 292, 1136, 715, 685, 753, 1385, 108, 307, 1057, 302, 780, 725, 823, 375, 895, 392, 1442, 525, 485, 1306, 428, 160, 1458, 36, 1264, 696, 818, 878, 1573, 752, 244, 117, 1241, 1440, 104, 1562, 318, 454, 740, 969, 290, 438, 1379, 1387, 1065, 410, 1551, 762, 578, 1163, 201, 1275, 1467, 757, 1464, 1239, 803, 713, 626, 747, 233, 1278, 957, 1526, 1469, 20, 227, 902, 935, 390, 777, 1642, 414, 914, 529, 304, 868, 910, 929, 450, 228, 1328, 70, 127, 90, 1062, 1049, 510, 1293, 558, 956, 456, 1360, 378, 1623, 1336, 997, 866, 1611, 791, 339, 1104, 547, 128, 1413, 1285, 1497, 258, 1018, 161, 1572, 875, 981, 1030, 283, 774, 1489, 1682, 624, 355, 465, 607, 1150, 1388, 1273, 1017, 772, 418, 1550, 323, 1257, 370, 689, 1146, 1634, 812, 604, 462, 1077, 1427, 1258, 265, 1558, 1395, 446, 1472, 1008, 1226, 970, 313, 314, 1359, 796, 1598, 1471, 286, 1357, 1680, 917, 405, 1063, 1004, 648, 785, 361, 988, 585, 150, 693, 573, 1658, 664, 60, 870, 495, 1340, 482, 942, 1191, 985, 1243, 1318, 91, 1281, 844, 620, 980, 836, 8, 49, 274, 1368, 116, 865, 1308, 469, 668, 1202, 599, 1656, 1024, 1415, 799, 771, 1109, 1223, 517, 565, 430, 279, 135, 516, 587, 1674, 770, 1547, 1300, 221, 346, 496, 1240, 1488, 386, 347, 271, 1279, 1412, 1422, 1494, 1310, 767, 294, 1298, 686, 670, 513, 333, 1630, 421, 319, 926, 182, 1463, 709, 1544, 1446, 194, 1182, 1374, 904, 1311, 32, 1207, 1644, 705, 843, 6, 1673, 1372, 1075, 986, 758, 1228, 1174, 1114, 1392, 1425, 1564, 15, 630, 1252, 1287, 368, 542, 1434, 1217, 1219, 1052, 765, 1164, 1122, 1432, 971, 337, 1280, 1476, 775, 1358, 536, 661, 560, 551, 311, 1626, 180, 1429, 695, 287, 1070, 584, 471, 1633, 248, 1361, 26, 623, 380, 1481, 330, 759, 798, 1184, 1162, 1236, 1543, 263, 964, 1158, 1012, 1269, 1003, 18, 119, 534, 977, 1613, 853, 618, 1319, 1443, 122, 1060, 1083, 10, 778, 1491, 1511, 967, 1230, 923, 407, 1483, 595, 817, 1670, 1151, 1394, 1087, 214, 44, 1681, 1297, 1402, 795, 927, 1455, 1177, 1524, 1586, 644, 1337, 467, 1576, 539, 52, 1375, 1294, 394, 431, 152, 737, 750, 281, 298, 158, 133, 1303, 1500, 1007, 276, 880, 1214, 1145, 1180, 179, 828, 484, 1647, 1101, 1396, 954, 537, 1272, 1355, 225, 1465, 591, 1645, 521, 1679, 494, 1330, 351, 1617, 1091, 393, 84, 105, 1453, 22, 611, 1559, 266, 1021, 353, 1516, 1220, 1133, 1365, 1054, 385, 720, 348, 1663, 185, 919, 186, 191, 1580, 1192, 1548, 892, 176, 25, 1321, 1107, 697, 1144, 1638, 1199, 1428, 921, 792, 1045, 1408, 1100, 1518, 1307, 1405, 612, 1664, 738, 781, 1404, 358, 162, 1056, 1651, 736, 994, 582, 261, 387, 183, 739, 303, 676, 232, 729, 996, 384, 1588, 449, 17, 65, 436, 655, 656, 678, 1616, 1451, 1246, 706, 871, 716, 1614, 1000, 979, 391, 851, 1010, 72, 958, 486, 1502, 982, 532, 1067, 148, 131, 100, 544, 877, 1643, 354, 1378, 1342, 493, 1585, 915, 269, 1416, 250, 321, 1612, 717, 1400, 1493, 1042, 847, 89, 592, 383, 1234, 1218, 1554, 172, 882, 328, 209, 178, 1449, 600, 82, 790, 864, 1437, 1457, 557, 12, 1265, 1250, 946, 1267, 130, 616, 841, 316, 247, 461, 1454, 1059, 1166, 474, 1157, 960, 562, 400, 826, 707, 1225, 830, 850, 229, 1604, 295, 1106, 208, 256, 1561, 813, 654, 388, 1332, 1011, 1462, 535, 434, 1529, 955, 784, 645, 1313, 4, 1574, 663, 631, 972, 643, 563, 838, 417, 741, 237, 1055, 215, 1584, 842, 1507, 788, 1622, 723, 987, 806, 1433, 508, 464, 476, 1073, 1477, 589, 1655, 413, 746, 300, 1143, 856, 721, 356, 1155, 588, 546, 246, 918, 114, 1589, 527, 1590, 949, 193, 285, 312, 499, 641, 1563, 1382, 1602, 1110, 867, 703, 687, 1560, 763, 364, 574, 1040, 1620, 522, 1460, 455, 640, 1130, 783, 609, 54, 1324, 1147, 59, 156, 1193, 579, 1423, 601, 1201, 1046, 452, 711, 137, 1051, 1304, 597, 1259, 1061, 1621, 350, 787, 1386, 1251, 30, 76, 712, 1625, 506, 324, 702, 241, 53, 999, 224, 1605, 1480, 789, 196, 132, 175, 653, 724, 199, 169, 1390, 1020, 1556, 1537, 657, 745, 1212, 1520, 651, 1376, 1487, 543, 835, 704, 1452, 342, 908, 782, 1232, 500, 548, 1094, 1053, 586, 1501, 299, 1102, 155, 520, 398, 1154, 107, 31, 1640, 1253, 786, 1499, 773, 603, 1575, 742, 139, 1648, 1383, 28, 1276, 857, 41, 1013, 1023, 1568, 637, 1266, 1203, 688, 1466, 379, 1095, 933, 1019, 367, 833, 1606, 1533, 1183, 282, 170, 681, 1363, 939, 1176, 515, 1474, 147, 125, 329, 1002, 13, 968, 1553, 827, 74, 671, 397, 426, 1076, 280, 523, 27, 429, 1198, 167, 1513, 1050, 1282, 422, 415, 920, 492, 1111, 480, 1009, 776, 14, 1411, 1631, 338, 1505, 748, 991, 291, 1175, 530], 5279, 275588926]) == 4438\nassert my_solution.maxCount(*[[1410, 91, 226, 1098, 1182, 1554, 1247, 1064, 1540, 1087, 922, 1221, 1431, 572, 705, 379, 1184, 1560, 1540, 1170, 754, 524, 790, 1288, 1126, 885, 192, 955, 1008, 1434, 68, 1597, 1002, 1400, 1279, 1111, 139, 1425, 257, 285, 1323, 974, 1019, 760, 1450, 976, 1228, 255, 70, 1483, 1148, 863, 1573, 1372, 1066, 536, 695, 729, 108, 84, 1668, 1342, 354, 362, 1400, 364, 662, 1517, 1121, 70, 261, 708, 148, 477, 1543, 282, 67, 813, 1145, 215, 620, 405, 1632, 101, 1316, 1083, 970, 1636, 382, 79, 192, 863, 1078, 1206, 1301, 59, 515, 429, 834, 781, 200, 276, 1135, 1599, 1129, 974, 370, 1585, 857, 1474, 1278, 1161, 1527, 867, 504, 731, 1218, 1377, 1299, 208, 934, 59, 910, 916, 655, 964, 477, 988, 1059, 895, 1629, 625, 583, 414, 340, 22, 917, 541, 1514, 600, 1167, 1169, 522, 792, 968, 1131, 1205, 1200, 319, 1607, 840, 1538, 1482, 409, 962, 1364, 52, 75, 1647, 620, 1201, 1582, 502, 1144, 267, 737, 1547, 1325, 555, 1047, 664, 1027, 1201, 171, 167, 1501, 1625, 334, 793, 1079, 1635, 410, 656, 165, 45, 1533, 1279, 1058, 1337, 1398, 780, 1307, 320, 1345, 838, 1027, 1352, 618, 1497, 354, 303, 1664, 408, 566, 556, 178, 882, 1079, 216, 1653, 979, 138, 1555, 1514, 1271, 98, 530, 456, 1401, 342, 735, 590, 742, 1226, 207, 1275, 603, 342, 505, 1516, 804, 704, 1517, 1659, 190, 1, 1270, 29, 1404, 455, 205, 1283, 1490, 56, 410, 192, 184, 629, 1280, 1490, 1145, 834, 1286, 232, 208, 1153, 513, 424, 900, 727, 391, 133, 1577, 1635, 1674, 958, 908, 124, 1641, 1527, 1081, 1548, 879, 755, 1609, 1319, 1404, 415, 345, 535, 1329, 554, 598, 1173, 573, 465, 760, 1406, 120, 1255, 474, 1293, 395, 728, 914, 891, 114, 936, 442, 1479, 1097, 837, 1068, 1422, 694, 301, 724, 1671, 1635, 259, 1201, 481, 152, 1323, 1070, 1342, 269, 694, 509, 681, 445, 1379, 837, 277, 1435, 951, 469, 389, 1204, 1237, 1004, 979, 1305, 1558, 642, 889, 719, 1620, 544, 486, 158, 1409, 1431, 1022, 1598, 219, 1519, 1186, 536, 603, 702, 444, 70, 635, 653, 1564, 1285, 1646, 1614, 68, 137, 281, 741, 533, 987, 1023, 1278, 338, 230, 1666, 525, 254, 1223, 1231, 1037, 809, 326, 703, 374, 1436, 506, 72, 736, 307, 511, 641, 285, 1191, 475, 808, 1318, 1437, 474, 35, 714, 1216, 1051, 378, 463, 577, 551, 1305, 162, 821, 1317, 1177, 536, 1319, 1008, 579, 790, 1428, 1566, 490, 1088, 1026, 502, 873, 1109, 60, 355, 1257, 771, 12, 849, 1665, 358, 675, 1597, 146, 306, 1297, 548, 1301, 531, 666, 1548, 1158, 965, 206, 883, 1668, 273, 340, 396, 1083, 1228, 247, 1169, 377, 448, 88, 587, 1682, 367, 827, 520, 1086, 612, 646, 1664, 951, 131, 306, 1671, 1526, 1355, 744, 857, 686, 108, 1518, 250, 1105, 1357, 1443, 777, 912, 1610, 1528, 327, 50, 680, 928, 794, 1673, 88, 891, 86, 188, 81, 645, 1414, 1187, 459, 56, 550, 31, 1053, 641, 1613, 757, 1545, 998, 333, 1074, 672, 300, 1547, 885, 1681, 140, 851, 488, 1166, 336, 405, 899, 324, 440, 138, 1354, 875, 68, 1477, 193, 1619, 688, 1039, 923, 642, 911, 1586, 135, 475, 1123, 204, 908, 622, 1490, 1176, 359, 317, 1593, 167, 1443, 1622, 1011, 895, 845, 967, 1183, 680, 810, 1081, 627, 525, 1616, 868, 1532, 744, 764, 526, 1683, 643, 381, 488, 428, 1409, 1099, 1643, 1276, 747, 473, 962, 1001, 1644, 841, 817, 868, 1583, 998, 1259, 1188, 1518, 7, 1327, 162, 1642, 1396, 92, 1017, 405, 241, 1248, 1295, 344, 1436, 1320, 1507, 401, 308, 1544, 1338, 1551, 1512, 648, 1584, 678, 239, 258, 211, 1352, 163, 338, 332, 1558, 898, 206, 643, 1259, 122, 1058, 468, 1325, 1047, 493, 377, 339, 1529, 1091, 360, 1286, 63, 1111, 455, 1277, 690, 998, 1053, 366, 1417, 1244, 1520, 1594, 590, 465, 716, 504, 1176, 1496, 501, 426, 1003, 1622, 476, 770, 454, 1209, 1355, 1148, 615, 1061, 1517, 1147, 408, 1193, 646, 109, 380, 1566, 1395, 798, 125, 1107, 175, 476, 35, 1444, 681, 672, 682, 875, 1342, 1304, 880, 681, 686, 614, 1217, 548, 235, 1054, 734, 718, 1506, 1385, 1600, 7, 20, 133, 594, 1234, 1507, 1542, 1619, 387, 1392, 1666, 1117, 282, 523, 1085, 287, 1148, 971, 247, 195, 1368, 969, 1383, 1509, 1514, 902, 1396, 1441, 1172, 666, 152, 1004, 667, 621, 257, 733, 38, 1465, 846, 1676, 652, 1335, 1089, 219, 544, 380, 1172, 405, 694, 490, 1649, 136, 1007, 95, 167, 1510, 1356, 147, 472, 522, 406, 615, 1050, 461, 1264, 211, 1229, 683, 1402, 77, 567, 1575, 1114, 149, 878, 1558, 694, 1263, 1394, 1611, 1333, 1311, 198, 1476, 1269, 1416, 569, 550, 478, 144, 388, 1437, 935, 459, 1477, 582, 367, 877, 398, 834, 123, 254, 349, 1242, 342, 1207, 1547, 1465, 188, 1187, 816, 1540, 480, 1550, 501, 800, 1625, 568, 514, 1472, 1136, 772, 1253, 147, 939, 622, 255, 32, 1472, 5, 1133, 167, 221, 933, 1351, 1268, 1574, 214, 1421, 1331, 1642, 1098, 1302, 1163], 6608, 146437394]) == 5941\nassert my_solution.maxCount(*[[320, 304, 115, 281, 1339, 1503, 1673, 191, 371, 389, 1344, 911, 227, 1269, 188, 1687, 908, 890, 755, 334, 1283, 1258, 977, 774, 1029, 857, 663, 127, 967, 1440, 120, 831, 798, 433, 20, 945, 850, 1345, 1425, 1372, 483, 1359, 408, 226, 357, 1535, 856, 1398, 403, 522, 1509, 36, 792, 470, 1331, 1265, 1287, 962, 1357, 909, 269, 424, 1167, 468, 198, 382, 1516, 280, 667, 1358, 1178, 60, 98, 1712, 1689, 1600, 62, 953, 551, 392, 1112, 1267, 355, 420, 741, 1608, 954, 1588, 1520, 1080, 103, 1255, 1573, 1693, 544, 790, 399, 1128, 528, 1243, 1191, 618, 21, 1507, 24, 866, 916, 421, 1338, 185, 1059, 1102, 1085, 100, 1193, 579, 1454, 370, 162, 648, 1465, 140, 1134, 175, 1361, 260, 913, 585, 1300, 926, 882, 1692, 1460, 372, 637, 1562, 318, 887, 283, 1356, 1194, 333, 1117, 1218, 493, 1168, 524, 864, 1586, 567, 305, 412, 446, 1426, 1422, 1179, 1702, 1697, 753, 635, 1594, 1230, 89, 1306, 192, 1278, 366, 1521, 1026, 1171, 1456, 879, 959, 1672, 321, 781, 706, 1631, 268, 1635, 1217, 1488, 259, 1067, 393, 837, 1560, 1421, 1017, 673, 1508, 886, 426, 337, 323, 427, 422, 932, 616, 1523, 531, 1391, 1640, 845, 1543, 636, 1527, 1532, 1090, 14, 915, 1140, 553, 1199, 452, 1575, 555, 43, 609, 1554, 109, 1645, 1609, 1006, 799, 1455, 219, 1061, 1065, 56, 682, 416, 1281, 1176, 984, 1568, 1227, 306, 443, 1066, 1084, 1259, 1021, 1094, 5, 1580, 1504, 213, 41, 460, 247, 775, 614, 11, 341, 61, 873, 299, 1485, 1058, 829, 587, 898, 872, 291, 367, 249, 1461, 70, 1224, 1473, 878, 1376, 156, 27, 1131, 847, 1012, 787, 1192, 1113, 462, 116, 184, 1261, 995, 824, 45, 1246, 699, 186, 786, 611, 526, 360, 1262, 387, 1393, 1643, 1353, 2, 548, 183, 1328, 657, 490, 670, 743, 1185, 581, 1129, 1116, 1566, 214, 1220, 1389, 1536, 925, 1498, 331, 1321, 571, 796, 1164, 1522, 1088, 533, 497, 1617, 978, 445, 938, 1581, 1466, 451, 1695, 80, 439, 638, 1305, 1500, 1699, 876, 599, 1680, 1247, 1053, 1370, 860, 106, 1083, 1196, 477, 695, 509, 665, 960, 1232, 652, 776, 608, 621, 1438, 617, 1122, 1624, 1430, 1627, 434, 646, 797, 1519, 738, 1049, 1674, 1679, 600, 623, 1431, 1027, 986, 1072, 292, 1381, 347, 66, 901, 1040, 968, 1289, 381, 1584, 1340, 1055, 1175, 364, 68, 973, 1415, 696, 376, 1451, 989, 1124, 1698, 1182, 243, 595, 751, 818, 1161, 95, 933, 224, 459, 125, 1174, 1157, 756, 1501, 411, 1234, 1655, 998, 1019, 992, 46, 880, 474, 1347, 1354, 160, 1685, 1630, 1505, 1311, 272, 1228, 233, 1475, 1642, 924, 1188, 119, 502, 1497, 1014, 1133, 723, 1181, 114, 1264, 714, 500, 1544, 112, 1183, 1449, 352, 1069, 1569, 1382, 1020, 645, 1453, 454, 823, 1263, 523, 58, 812, 993, 842, 1481, 1279, 991, 942, 1385, 294, 486, 921, 1688, 71, 1480, 1097, 990, 42, 1242, 1545, 349, 30, 1591, 179, 1518, 52, 235, 822, 889, 328, 999, 8, 215, 687, 918, 1169, 1316, 1681, 760, 1325, 1469, 578, 1550, 1634, 1204, 1301, 961, 1016, 335, 712, 1367, 859, 1045, 37, 23, 313, 819, 205, 851, 1511, 161, 329, 1155, 1043, 134, 809, 1318, 1308, 1092, 1628, 1557, 1644, 79, 110, 345, 862, 237, 971, 1335, 1009, 1420, 597, 1213, 521, 562, 251, 1641, 1395, 1682, 1214, 83, 124, 1215, 368, 29, 414, 1156, 1446, 1479, 514, 296, 782, 1173, 1075, 492, 1063, 1474, 1282, 867, 1303, 662, 166, 770, 1000, 505, 1417, 1309, 123, 750, 1337, 1079, 569, 1406, 1700, 982, 1041, 1529, 931, 327, 34, 1115, 316, 858, 267, 319, 300, 572, 1121, 1515, 1548, 164, 619, 1057, 1254, 409, 1716, 1106, 713, 545, 330, 538, 1656, 1296, 718, 947, 997, 361, 1257, 703, 1317, 152, 835, 75, 1034, 1087, 1603, 605, 401, 163, 1703, 33, 588, 1028, 444, 369, 1659, 875, 1229, 1374, 1590, 1407, 1060, 1074, 817, 1401, 613, 1056, 473, 81, 1696, 1033, 1658, 293, 1253, 1615, 893, 1510, 516, 512, 633, 928, 966, 332, 208, 1540, 814, 1145, 732, 351, 496, 668, 806, 1621, 240, 295, 169, 664, 69, 1412, 1606, 1433, 417, 165, 1272, 232, 1369, 1070, 1030, 1323, 1525, 461, 1147, 1670, 1032, 203, 821, 1678, 568, 138, 4, 1038, 1365, 1375, 431, 1236, 1714, 263, 458, 1432, 432, 1648, 647, 1314, 1666, 22, 582, 1383, 199, 1118, 936, 170, 1268, 981, 189, 1411, 659, 1491, 1711, 705, 1036, 811, 1533, 996, 1429, 1284, 717, 1216, 150, 136, 958, 1572, 574, 946, 1150, 350, 1252, 900, 525, 543, 402, 1483, 1015, 885, 671, 1636, 1154, 1098, 1646, 407, 1341, 241, 1111, 1593, 577, 1428, 290, 904, 952, 97, 1276, 49, 591, 563, 1101, 722, 317, 540, 1159, 685, 1620, 1163, 841, 693, 839, 788, 378, 282, 789, 1551, 1616, 1684, 87, 491, 1332, 390, 702, 536, 530, 679, 1471, 220, 16, 761, 88, 1565, 1315, 359, 1710, 1002, 31, 810, 1008, 200, 238, 1614, 1713, 1363, 1260, 239, 479, 194, 615, 286, 807, 276, 1445, 222, 988, 1293, 719, 1482, 7, 539, 1219, 1441, 612, 1078, 1360, 1048, 948, 1237, 658, 1310, 1184, 1512, 737, 325, 728, 1277], 465, 508292145]) == 239\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2640", "questionFrontendId": "2554", "questionTitle": "Maximum Number of Integers to Choose From a Range I", "stats": { "totalAccepted": "5.1K", "totalSubmission": "8.8K", "totalAcceptedRaw": 5051, "totalSubmissionRaw": 8817, "acRate": "57.3%" } }
LeetCode/2673
# Maximize Win From Two Segments There are some prizes on the **X-axis**. You are given an integer array `prizePositions` that is **sorted in non-decreasing order**, where `prizePositions[i]` is the position of the `ith` prize. There could be different prizes at the same position on the line. You are also given an integer `k`. You are allowed to select two segments with integer endpoints. The length of each segment must be `k`. You will collect all prizes whose position falls within at least one of the two selected segments (including the endpoints of the segments). The two selected segments may intersect. * For example if `k = 2`, you can choose segments `[1, 3]` and `[2, 4]`, and you will win any prize i that satisfies `1 <= prizePositions[i] <= 3` or `2 <= prizePositions[i] <= 4`. Return *the **maximum** number of prizes you can win if you choose the two segments optimally*.   **Example 1:** ``` **Input:** prizePositions = [1,1,2,2,3,3,5], k = 2 **Output:** 7 **Explanation:** In this example, you can win all 7 prizes by selecting two segments [1, 3] and [3, 5]. ``` **Example 2:** ``` **Input:** prizePositions = [1,2,3,4], k = 0 **Output:** 2 **Explanation:** For this example, **one choice** for the segments is [3, 3] and [4, 4], and you will be able to get 2 prizes. ```   **Constraints:** * `1 <= prizePositions.length <= 105` * `1 <= prizePositions[i] <= 109` * `0 <= k <= 109` * `prizePositions` is sorted in non-decreasing order.   .spoilerbutton {display:block; border:dashed; padding: 0px 0px; margin:10px 0px; font-size:150%; font-weight: bold; color:#000000; background-color:cyan; outline:0; } .spoiler {overflow:hidden;} .spoiler > div {-webkit-transition: all 0s ease;-moz-transition: margin 0s ease;-o-transition: all 0s ease;transition: margin 0s ease;} .spoilerbutton[value="Show Message"] + .spoiler > div {margin-top:-500%;} .spoilerbutton[value="Hide Message"] + .spoiler {padding:5px;} Please make sure your answer follows the type signature below: ```python3 class Solution: def maximizeWin(self, prizePositions: List[int], k: int) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.maximizeWin(*[[1, 1, 2, 2, 3, 3, 5], 2]) == 7\nassert my_solution.maximizeWin(*[[1, 2, 3, 4], 0]) == 2\nassert my_solution.maximizeWin(*[[1, 2, 3, 4, 5], 1]) == 4\nassert my_solution.maximizeWin(*[[2616, 2618, 2620, 2621, 2626, 2635, 2657, 2662, 2662, 2669, 2671, 2693, 2702, 2713, 2714, 2718, 2730, 2731, 2750, 2756, 2772, 2773, 2775, 2785, 2795, 2805, 2811, 2813, 2816, 2823, 2824, 2824, 2826, 2830, 2833, 2857, 2885, 2898, 2910, 2919, 2928, 2941, 2942, 2944, 2965, 2967, 2970, 2973, 2974, 2975, 2977, 3002, 3007, 3012, 3042, 3049, 3078, 3084, 3089, 3090, 3094, 3097, 3114, 3124, 3125, 3125, 3144, 3147, 3148, 3174, 3197, 3255, 3262, 3288, 3291, 3316, 3320, 3322, 3331, 3342, 3378, 3412, 3412, 3416, 3420, 3427, 3428, 3446, 3452, 3472, 3479, 3483, 3488, 3500, 3516, 3522, 3531, 3532, 3540, 3540, 3544, 3557, 3570, 3580, 3592, 3597, 3597, 3601, 3615, 3631, 3640, 3645, 3673, 3677, 3681, 3683, 3685, 3718, 3738, 3746, 3758, 3769, 3797, 3802, 3815, 3832, 3839, 3851, 3864, 3888, 3889, 3901, 3902, 3910, 3913, 3933, 3940, 3961, 3974, 3988, 4003, 4013, 4019, 4023, 4026, 4047, 4060, 4065, 4072, 4073, 4082, 4084, 4109, 4132, 4139, 4143, 4145, 4146, 4155], 6641]) == 159\nassert my_solution.maximizeWin(*[[3937, 3938, 3939, 3951, 3951, 3959, 3975, 3988, 3993, 4010, 4031, 4033, 4036, 4038, 4039, 4041, 4047, 4058, 4059, 4064, 4072, 4081, 4084, 4084, 4089, 4094, 4098, 4112, 4114, 4116, 4123, 4123, 4127, 4130, 4135, 4143, 4149, 4152, 4163, 4164, 4176, 4178, 4180, 4198, 4216, 4224, 4233, 4240, 4253, 4259, 4273, 4286, 4305, 4322, 4335, 4350, 4364, 4378, 4396, 4397, 4398, 4404, 4415, 4421, 4430, 4469, 4476, 4490, 4492, 4497, 4504, 4519, 4519, 4525, 4526, 4530, 4530, 4540, 4550, 4554, 4563, 4571, 4571, 4595, 4595, 4606, 4639, 4639, 4660, 4663, 4676, 4678, 4680, 4695, 4697, 4709, 4709, 4711, 4724, 4751, 4781, 4786, 4786, 4794, 4797, 4801, 4807, 4808, 4817, 4822, 4824, 4825, 4840, 4851, 4887, 4889, 4891, 4910, 4917, 4927, 4931, 4932, 4951, 4959, 4964, 4993, 4997, 5003, 5003, 5006, 5006, 5022, 5029, 5035, 5043, 5045, 5045, 5046, 5059, 5060, 5079, 5084, 5105, 5109, 5109, 5112, 5120, 5126, 5130, 5142, 5143, 5151, 5152, 5154, 5156, 5168, 5189, 5213, 5214, 5223, 5226, 5235, 5247, 5259, 5272, 5289, 5303, 5309, 5317, 5322, 5344, 5347, 5352, 5374, 5379, 5380, 5383, 5385, 5391, 5418, 5425, 5429, 5432, 5479, 5486, 5490, 5502, 5502, 5505, 5506, 5509, 5515, 5518, 5519, 5521, 5526, 5528, 5533, 5536, 5536, 5538, 5555, 5556, 5557, 5557, 5566, 5571, 5580, 5585, 5596, 5604, 5619, 5634, 5649, 5668, 5694, 5696, 5699, 5701, 5704, 5709, 5732, 5745, 5745, 5746, 5749, 5762, 5766, 5766, 5770, 5773, 5796, 5810, 5817, 5823, 5838, 5843, 5846, 5860, 5869, 5872, 5877, 5880, 5896, 5899, 5902, 5905, 5910, 5913, 5913, 5915, 5923], 220]) == 74\nassert my_solution.maximizeWin(*[[415288, 416336, 416780, 417164, 419922, 420866, 421399, 421501, 423010, 423524, 423709, 423948, 425094, 425754, 426119, 426709, 426735, 426765, 427996, 428353, 429030, 429288, 429866, 430018, 432194, 432463, 432595, 433785, 436041, 438907, 439684, 440741, 443014, 443041, 443714, 444384, 444816, 445584, 446750, 447461, 448391, 448908, 449019, 449040, 449058, 451322, 451575, 451725, 452221, 452292, 452832, 453051, 453542, 454620, 457091, 459311, 459844, 460931, 462022, 462375, 462687, 464670, 465424, 465930, 467740, 468158, 469906, 470861, 471421, 472771, 472930, 473042, 473383, 473751, 476165, 476779, 478436, 479490, 481215, 481781, 482147, 484372, 485161, 488039, 488728, 489591, 490259, 492542, 492866, 495823, 496729, 498602, 501398, 501560, 502157, 502458, 502486, 503315, 503679, 504090, 505532, 506787, 506858, 506873, 507416, 507708, 507735, 508035, 509557, 510743, 511784, 512680, 512985, 513468, 514010, 514230, 514905, 515129, 515415, 515959, 516080, 519872, 523531, 523844, 524656, 525478, 525674, 525938, 526351, 526410, 526657, 526700, 526975, 527299, 527501, 527684, 527941, 529840, 530232, 530454, 531248, 532176, 532228, 532976, 534579, 534720, 535615, 536452, 537848, 538315, 538390, 539558, 539711, 542729, 543041, 544991, 545040, 545385, 545692, 545713, 546174, 546631, 547431, 547866, 549373, 549463, 549799, 551368, 551554, 552213, 553636, 554369, 555124, 556077, 558142, 558149, 558588, 559580, 560429, 561470, 564174, 565686, 566368, 566820, 567304, 568791, 568981, 570008, 570073, 571549, 571952, 572272, 573747, 579507, 581030, 581348, 582148, 583708, 585240, 586386, 587014, 587196, 587916, 588043, 588794, 589803, 592156, 594703, 594739, 595673, 598887, 598967, 599759, 600214, 601251, 601509, 603597, 604002, 604662, 605317, 605851, 605888, 607114, 608043, 608746, 610284, 612061, 615398, 615959, 616251, 616568, 618018, 618297, 618882, 622423, 624707, 624769, 626565, 627656, 627717, 628485, 629337, 629954, 631681, 633092, 633667, 634093, 635001, 635704, 636342, 638816, 639012, 640721, 640757, 641568, 642249, 643159, 643660, 645912, 646279, 647791, 648050, 648719, 648762, 649006, 651763, 652282, 653361, 653733, 654377, 656288, 657280, 659153, 659527, 662296, 662573, 665248, 668896, 669184, 669589, 670676, 671884, 672214, 672552, 674550, 675950, 678704, 679612, 681171, 681467, 681883, 682258, 682696, 682875, 685080, 685380, 685578, 686223, 687383, 687902, 690306, 690701, 691816, 691941, 692039, 692119, 692318, 693286, 696521, 697180, 699595, 699718, 699751], 481169]) == 313\nassert my_solution.maximizeWin(*[[42, 53, 114, 116, 134, 181, 225, 271, 287, 292, 330, 363, 368, 371, 402, 429, 431, 432, 443, 479, 484, 493, 499, 500, 560, 579, 594, 597, 607, 607, 706, 728, 734, 750, 751, 768, 774, 791, 798, 813, 822, 836, 839, 857, 860, 861, 865, 888, 926, 939, 942, 950, 954, 986, 1010, 1012, 1019, 1043, 1045, 1056, 1066, 1084, 1155, 1159, 1192, 1210, 1244, 1258, 1264, 1284, 1291, 1295, 1311, 1316, 1320, 1324, 1361, 1380, 1406, 1408, 1424, 1433, 1442, 1449, 1464, 1468, 1472, 1476, 1487, 1502, 1554, 1581, 1618, 1619, 1629, 1682, 1701, 1704, 1705, 1742, 1751, 1768, 1778, 1783, 1803, 1809, 1811, 1822, 1829, 1832, 1846, 1872, 1878, 1891, 2021, 2032, 2049, 2101, 2166, 2181, 2198, 2202, 2225, 2235, 2237, 2262, 2262, 2266, 2274, 2294, 2357, 2361, 2386, 2389, 2397, 2413, 2443, 2455, 2470, 2528, 2546, 2560, 2595, 2609, 2626, 2652, 2724, 2758, 2765, 2788, 2800, 2843, 2847, 2876, 2878, 2882, 2884, 2902, 2908, 2947, 2947, 2952, 2975, 2983, 2991, 3010, 3020, 3029, 3040, 3062, 3063, 3088, 3118, 3122, 3151, 3157, 3193, 3198, 3226, 3247, 3263, 3270, 3292, 3320, 3326, 3326, 3329, 3330, 3358, 3382, 3402, 3412, 3418, 3438, 3462, 3469, 3470, 3486, 3541, 3580, 3627, 3632, 3639, 3676, 3679, 3680, 3681, 3726, 3728, 3728, 3733, 3754, 3758, 3773, 3776, 3783, 3826, 3903, 3912, 3956, 3977, 4006, 4015, 4015, 4018, 4021, 4051, 4070, 4075, 4104, 4138, 4147, 4158, 4188, 4189, 4190, 4220, 4222, 4222, 4242, 4285, 4287, 4300, 4324, 4354, 4358, 4387, 4434, 4449, 4450, 4459, 4464, 4494, 4534, 4538, 4553, 4554, 4627, 4632, 4637, 4644, 4686, 4688, 4772, 4786, 4798, 4859, 4893, 4899, 4954, 4990, 5023, 5056, 5089, 5093, 5102, 5118, 5121, 5154, 5156, 5259, 5266, 5268, 5272, 5272, 5280, 5288, 5324, 5374, 5416, 5420, 5439, 5483, 5510, 5512, 5557, 5567, 5586, 5623, 5632, 5642, 5665, 5670, 5682, 5683, 5699, 5715, 5747, 5766, 5771, 5773, 5845, 5865, 5884, 5886, 5927, 5953, 5963, 6033, 6046, 6072, 6073, 6101, 6125, 6125, 6131, 6150, 6152, 6155, 6160, 6165, 6169, 6169, 6180, 6246, 6321, 6328, 6330, 6331, 6346, 6367, 6424, 6461, 6475, 6477, 6481, 6509, 6566, 6566, 6598, 6620, 6654, 6684, 6697, 6732, 6732, 6752, 6757, 6765, 6767, 6799, 6805, 6830, 6877, 6886, 6938, 6938, 6941, 6978, 7002, 7003, 7102, 7132, 7136, 7155, 7176, 7188, 7198, 7200, 7230, 7266, 7284, 7313, 7322, 7322, 7345, 7362, 7387, 7388, 7400, 7404, 7447, 7450, 7462, 7467, 7480, 7493, 7497, 7516, 7560, 7584, 7590, 7600, 7646, 7652, 7652, 7664, 7669, 7688, 7697, 7709, 7720, 7725, 7783, 7807, 7811, 7812, 7843, 7843, 7845, 7859, 7876, 7884, 7900, 7901, 7911, 7920, 7927, 7968, 7974, 7987, 8000, 8007, 8027, 8054, 8092, 8093, 8105, 8114, 8217, 8217, 8226, 8227, 8235, 8303, 8313, 8315, 8341, 8348], 8550]) == 449\nassert my_solution.maximizeWin(*[[305, 305, 305, 305, 305, 306, 306, 306, 306, 306, 306, 307, 307, 307, 307, 308, 308, 309, 309, 309, 309, 310, 310, 310, 310, 311, 311, 311, 311, 311, 312, 312, 312, 312, 312, 312, 312, 312, 312, 313, 313, 314, 314, 314, 314, 314, 315, 315, 315, 315, 316, 316, 316, 316, 317, 317, 317, 317, 317, 318, 318, 319, 319, 319, 319, 320, 321, 321, 321, 321, 321, 321, 322, 322, 322, 322, 322, 323, 323, 323, 323, 323, 323, 324, 324, 324, 324, 325, 325, 325, 325, 325, 326, 326, 327, 327, 327, 329, 329, 329, 329, 329, 330, 330, 330, 330, 330, 330, 331, 331, 331, 331, 331, 331, 332, 332, 332, 332, 332, 333, 333, 333, 334, 334, 335, 335, 335, 335, 336, 336, 336, 336, 336, 336, 336, 336, 336, 337, 337, 337, 337, 338, 338, 338, 338, 338, 338, 338, 339, 339, 339, 339, 340, 340, 340, 340, 340, 340, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 342, 342, 342, 342, 342, 342, 342, 343, 343, 344, 344, 344, 345, 345, 345, 347, 347, 347, 347, 347, 348, 348, 348, 348, 348, 349, 349, 349, 349, 349, 350, 350, 350, 350, 350, 351, 352, 352, 352, 352, 353, 353, 353, 353, 353, 353, 354, 354, 354, 354, 354, 354, 355, 355, 355, 355, 355, 356, 356, 356, 356, 357, 357, 357, 357, 358, 358, 358, 359, 359, 359, 359, 359, 360, 360, 361, 361, 361, 362, 362, 362, 362, 362, 363, 363, 363, 363, 364, 364, 364, 364, 365, 365, 366, 366, 367, 367, 367, 367, 367, 367, 367, 367, 367, 368, 368, 368, 368, 368, 368, 368, 368, 369, 369, 369, 370, 370, 370, 370, 370, 370, 370, 370, 371, 371, 371, 371, 371, 372, 372, 372, 372, 373, 374, 374, 374, 375, 376, 376, 377, 377, 377, 377, 377, 377, 377, 378, 378, 378, 379, 379, 379, 379, 379, 379, 380, 381, 382, 382, 382, 382, 382, 383, 383, 384, 384, 385, 385, 385, 386, 386, 386, 387, 387, 387, 387, 388, 388, 388, 388, 389, 389, 389, 389, 389, 389, 389, 390, 391, 391, 391, 392, 392, 392, 393, 393, 393, 393, 393, 393, 394, 394, 394, 394, 394, 395, 395, 395, 395, 395, 395, 395, 395, 396, 396, 396, 396, 396, 396, 397, 397, 398, 398, 398, 398, 398, 398, 399, 399, 399, 400, 400, 400, 400, 401, 401, 401, 402, 402, 402, 402, 402, 402, 402, 403, 403, 403, 403, 404, 404, 404, 404, 404, 404, 405, 405, 405, 405, 405, 405, 406, 406, 406, 406, 406, 406, 406, 406, 407, 407, 407, 407, 407, 407, 408, 408, 408, 409, 409, 409, 409, 409, 409, 410, 410, 410, 410, 410, 410, 411, 411, 411, 411, 412, 412, 413, 413, 413, 413, 413, 414, 414, 414, 414, 415, 415, 415, 415, 416, 416, 416, 417, 417, 417, 418, 418, 418, 418, 418, 418, 419, 419, 419, 419, 419, 419, 419, 419, 419, 420, 420, 420, 420, 420, 420, 422, 422, 422, 422, 422, 423, 424, 424, 424, 424, 424, 424, 425, 425, 425, 425, 425, 425, 426, 426, 427, 428, 428, 428, 428, 428, 428, 428, 429, 429, 429, 429, 430, 430, 430, 430, 431, 431, 432, 432, 432, 432, 432, 432, 433, 433, 433, 433], 324]) == 553\nassert my_solution.maximizeWin(*[[81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94], 82]) == 896\nassert my_solution.maximizeWin(*[[41680, 41688, 41709, 41716, 41742, 41744, 41753, 41778, 41783, 41791, 41796, 41833, 41840, 41867, 41874, 41888, 41897, 41904, 41977, 41982, 42008, 42022, 42039, 42042, 42046, 42088, 42128, 42138, 42148, 42150, 42194, 42244, 42263, 42280, 42288, 42301, 42330, 42384, 42385, 42389, 42390, 42415, 42427, 42459, 42480, 42486, 42551, 42577, 42588, 42591, 42610, 42611, 42637, 42639, 42653, 42672, 42689, 42702, 42756, 42764, 42792, 42796, 42800, 42841, 42858, 42862, 42871, 42914, 42915, 42921, 42932, 42956, 43070, 43157, 43192, 43198, 43251, 43265, 43358, 43384, 43394, 43403, 43414, 43442, 43453, 43465, 43484, 43505, 43546, 43595, 43623, 43637, 43647, 43717, 43734, 43744, 43754, 43756, 43855, 43864, 43896, 43994, 43995, 44017, 44039, 44055, 44082, 44098, 44121, 44159, 44167, 44219, 44243, 44286, 44290, 44340, 44351, 44396, 44456, 44464, 44530, 44530, 44646, 44664, 44668, 44676, 44710, 44715, 44719, 44721, 44729, 44734, 44793, 44803, 44822, 44842, 44843, 44860, 44890, 44891, 44943, 44959, 44973, 44992, 45008, 45028, 45059, 45060, 45074, 45081, 45082, 45095, 45099, 45101, 45105, 45107, 45117, 45121, 45132, 45145, 45146, 45151, 45191, 45239, 45256, 45266, 45270, 45300, 45330, 45337, 45374, 45396, 45413, 45437, 45437, 45467, 45470, 45481, 45490, 45497, 45508, 45667, 45680, 45691, 45721, 45727, 45732, 45805, 45814, 45832, 45840, 45861, 45861, 45864, 45878, 45883, 45895, 45897, 45932, 45969, 46007, 46029, 46081, 46086, 46120, 46125, 46156, 46169, 46180, 46184, 46256, 46308, 46315, 46317, 46322, 46344, 46363, 46366, 46378, 46414, 46419, 46426, 46429, 46504, 46505, 46506, 46508, 46513, 46533, 46565, 46575, 46576, 46598, 46599, 46654, 46717, 46719, 46728, 46736, 46756, 46758, 46767, 46788, 46811, 46835, 46845, 46864, 46916, 46975, 47013, 47062, 47063, 47069, 47087, 47090, 47093, 47111, 47119, 47127, 47132, 47156, 47188, 47209, 47213, 47275, 47279, 47317, 47343, 47355, 47368, 47392, 47392, 47415, 47434, 47442, 47484, 47531, 47575, 47575, 47577, 47631, 47635, 47669, 47710, 47716, 47730, 47732, 47770, 47833, 47843, 47857, 47926, 47941, 47947, 47962, 47963, 47976, 48005, 48016, 48081, 48090, 48100, 48111, 48175, 48176, 48189, 48201, 48201, 48267, 48404, 48490, 48519, 48530, 48624, 48667, 48736, 48805, 48844, 48885, 48893, 48906, 48927, 48929, 48941, 48984, 48990, 49045, 49057, 49070, 49144, 49222, 49274, 49276, 49286, 49301, 49318, 49337, 49340, 49377, 49407, 49413, 49417, 49419, 49436, 49478, 49492, 49535, 49566, 49646, 49711, 49744, 49747, 49788, 49795, 49824, 49829, 49873, 49922, 49947, 49989, 50005, 50022, 50036, 50093, 50148, 50161, 50178, 50192, 50194, 50208, 50218, 50231, 50238, 50254, 50261, 50278, 50291, 50304, 50307, 50363, 50365, 50367, 50398, 50418, 50456, 50467, 50469, 50474, 50501, 50538, 50556, 50568, 50573, 50577, 50640, 50652, 50685, 50693, 50700, 50706, 50725, 50746, 50766, 50768, 50781, 50834, 50850, 50850, 50881, 50890, 51006, 51020, 51026, 51031, 51046, 51051, 51074, 51082, 51106, 51122, 51138, 51143, 51190, 51206, 51218, 51243, 51338, 51343, 51356, 51370, 51371, 51418, 51440, 51462, 51479, 51487, 51488, 51496, 51549, 51607, 51642, 51672, 51687, 51688, 51700, 51705, 51771, 51771, 51782, 51824, 51837, 51850, 51860, 51867, 51892, 51908, 51918, 51985, 52001, 52005, 52030, 52051, 52064, 52132, 52161, 52207, 52217, 52240, 52309, 52332, 52363, 52368, 52421, 52484, 52553, 52571, 52594, 52675, 52687, 52719, 52724, 52799, 52808, 52987, 53000, 53010, 53111, 53133, 53135, 53153, 53164, 53185, 53229, 53263, 53269, 53283, 53286, 53297, 53310, 53315, 53372, 53377, 53380, 53402, 53438, 53443, 53506, 53509, 53546, 53599, 53612, 53644, 53693, 53718, 53721, 53735, 53746, 53787, 53827, 53896, 53911, 53922, 53939, 53961, 53972, 53989, 54033, 54041, 54047, 54072, 54077, 54089, 54106, 54112, 54133, 54185, 54197, 54201, 54209, 54224, 54254, 54309, 54342, 54348, 54364, 54369, 54369, 54397, 54419, 54430, 54467, 54545, 54559, 54617, 54623, 54724, 54735, 54736, 54780, 54781, 54785, 54792, 54793, 54830, 54882, 54896, 54972, 55007, 55020, 55034, 55090, 55092, 55148, 55200, 55202, 55219, 55221, 55222, 55274, 55276, 55287, 55316, 55324, 55343, 55379, 55390, 55394, 55434, 55435, 55443, 55464, 55549, 55553, 55556, 55586, 55620, 55622, 55639, 55643, 55676, 55676, 55683, 55748, 55778, 55812, 55815, 55957, 55958, 55986, 55996, 56013, 56016, 56025, 56054, 56074, 56076, 56087, 56120, 56122, 56129, 56148, 56150, 56160, 56207, 56209, 56284, 56342, 56369, 56438, 56466, 56477, 56493, 56509, 56521, 56542, 56557, 56579, 56605, 56637, 56640, 56694, 56705, 56731, 56745, 56747, 56771, 56783, 56797, 56811, 56841, 56864, 56904, 56921, 56944, 56967, 56995, 57046, 57072, 57107, 57112, 57113, 57115, 57148, 57215, 57235, 57236, 57258, 57272, 57277, 57280, 57282, 57285, 57302, 57309, 57331, 57334, 57370, 57377, 57440, 57442, 57443, 57538, 57589, 57609, 57611, 57621, 57623, 57655, 57681, 57690, 57703, 57730, 57758, 57769, 57788, 57830, 57831, 57847, 57863, 57872, 57880, 57885, 57896, 57921, 58005, 58008, 58011, 58040, 58061, 58086, 58100, 58138, 58185, 58225, 58228, 58241, 58260, 58275, 58330, 58338, 58388, 58390, 58410, 58441, 58484, 58490, 58575, 58621, 58627, 58670, 58716, 58724, 58728, 58742, 58743, 58745, 58771, 58813, 58830, 58838, 58848, 58852, 58862, 58930, 58934, 59009, 59053, 59053, 59079, 59098, 59112, 59129, 59148, 59207, 59208, 59227, 59257, 59457, 59468, 59498, 59506, 59517, 59517, 59552, 59554, 59556, 59600, 59600, 59645, 59681, 59685, 59686, 59740, 59761, 59774, 59799, 59802, 59833, 59876, 59905, 59962, 59972, 60022, 60027, 60036, 60075, 60083, 60105, 60144, 60160, 60171, 60173, 60194, 60220, 60264, 60273, 60280, 60299, 60302, 60336, 60342, 60361, 60366, 60377, 60524, 60532, 60567, 60568, 60574, 60575, 60609, 60610, 60618, 60626, 60629, 60641, 60666, 60680, 60693, 60693, 60728, 60731, 60734, 60794, 60804, 60866, 60881, 60907, 60922, 60954, 60955, 60987, 61074, 61075, 61089, 61101, 61101, 61147, 61215, 61225, 61280, 61300, 61328, 61351, 61358, 61389, 61406, 61410, 61417, 61431, 61446, 61448, 61461, 61471, 61490, 61498, 61510, 61512, 61550, 61551, 61569, 61579, 61620, 61647, 61684, 61731, 61754, 61764, 61811, 61818, 61878, 61880, 61881, 61901, 61950, 61983, 62012, 62017, 62024, 62025, 62081, 62139, 62148, 62204, 62212, 62250, 62251, 62272, 62297, 62334, 62336, 62337, 62363, 62375, 62382, 62403, 62412, 62425, 62450, 62461, 62473, 62503, 62530, 62539, 62555, 62566, 62568, 62580, 62586, 62590, 62599, 62645, 62659, 62665, 62686, 62729, 62750, 62760, 62768, 62772, 62796, 62838, 62890, 62904, 62935, 62964, 63019, 63021, 63021, 63069, 63086, 63099, 63099, 63107, 63154], 904]) == 111\nassert my_solution.maximizeWin(*[[375344743, 375811382, 376205354, 376583225, 377326584, 377528242, 377556486, 377561264, 377747991, 377749793, 377838108, 377905270, 378225612, 378389478, 378638215, 379501835, 379550808, 380108794, 380146950, 380691791, 381393652, 382408980, 382670758, 383132819, 384531606, 384601605, 384619910, 384848369, 385221568, 385231233, 385753380, 385949112, 386833113, 387371507, 387648433, 387669754, 387712024, 387960080, 388599148, 388931923, 389889842, 390466891, 390628019, 390915526, 391471142, 391481330, 391883528, 392131052, 392170820, 392873875, 392948257, 393200244, 393217847, 393227344, 393548051, 393564034, 394717709, 396648759, 397290396, 397473501, 398172233, 398431650, 398509186, 398829475, 398890185, 399201278, 399598370, 400335640, 400886541, 401423147, 401596279, 402068593, 402900993, 403027769, 403515881, 404956177, 405354937, 406036459, 406682171, 406818231, 407126246, 407374429, 408011409, 408535761, 408642304, 408894488, 409787453, 409807299, 410313373, 410614153, 410808004, 412195139, 412641197, 413922900, 414109622, 414287986, 414382334, 414693905, 414876837, 414976334, 415371268, 415716409, 416429736, 417258167, 417426100, 417635786, 418804503, 419050297, 419773033, 419878382, 420064412, 420497879, 421027960, 421424811, 422087830, 422107655, 423025413, 423083263, 423112230, 423298825, 423787582, 423961843, 424292689, 424939243, 425056934, 426223721, 426295609, 426567665, 426787636, 426941716, 427947471, 428503139, 428511729, 428520675, 428605077, 428794088, 429514626, 429804206, 430098631, 430158655, 430187406, 431583883, 431785301, 431926967, 432049526, 432306436, 432312542, 432313473, 432578851, 432655672, 432730640, 432869346, 432891421, 433292749, 433420800, 433969706, 434257007, 434430199, 435164434, 435602256, 435627677, 435930182, 436132585, 436349199, 437135467, 437454940, 437774216, 438159481, 438169635, 438664688, 439265721, 439715813, 440271155, 441010442, 441166897, 441192055, 441526923, 441602630, 442143100, 442983517, 443071496, 443328899, 444772683, 444879199, 445810350, 445917622, 445978681, 446227097, 446309463, 446647098, 446660098, 446962967, 446983709, 447278253, 447387622, 447975621, 448104047, 448134985, 449126767, 449355419, 450508025, 450608498, 450820492, 451893936, 452096442, 452687744, 453609510, 453829020, 454334559, 454382390, 454694452, 454779520, 455125333, 455286585, 456080969, 456618332, 456657407, 456706375, 457622753, 457948197, 458337647, 458510749, 458953193, 459062696, 459084205, 459219347, 459311702, 459548662, 459549465, 459825411, 460486502, 460809812, 461672674, 461736577, 462144905, 462163457, 462705146, 462799115, 462978062, 463075675, 463405864, 464150809, 464381247, 464468421, 464610198, 465077145, 465264285, 465490378, 465892133, 466142165, 466383208, 466589265, 466623751, 466642223, 466849580, 467392187, 467473187, 467737515, 467770346, 468391734, 468396254, 468597025, 468706659, 469545260, 469548802, 470531856, 470542741, 471253163, 471465840, 471737215, 471830132, 471986170, 472111291, 472895883, 473190408, 473759623, 473819369, 474476756, 474721682, 475025035, 476043766, 476571257, 476949002, 477983505, 477995897, 478330583, 478443218, 478544130, 478654201, 479212071, 479478225, 479514198, 479651156, 479722039, 479850621, 479962461, 480240876, 480739017, 480849313, 481243652, 481535682, 482141304, 482672032, 483057639, 483090707, 483303439, 483522540, 483863060, 484020556, 484447303, 484555767, 484891807, 484930678, 485791276, 486086663, 486481282, 487117636, 487339158, 488195829, 488425064, 488614205, 488865762, 489011683, 489415853, 489698506, 490623722, 491078678, 491155152, 491486345, 491578202, 491838937, 492031953, 492970749, 493351260, 493457725, 494074574, 494269621, 494789844, 494946902, 495248135, 495386431, 495957495, 496763514, 497038953, 497294685, 498395649, 498621425, 499151628, 499908505, 500235558, 500249429, 501009330, 501968415, 502462284, 502705458, 502850996, 502975948, 502996862, 503229333, 503305824, 503476011, 503694479, 504502392, 504572661, 505026750, 505598419, 505860413, 505947985, 506033217, 506379896, 506814214, 507063145, 507229613, 507484911, 507509670, 508076993, 508356875, 508391331, 508545177, 508904924, 509051708, 509426866, 510149081, 510550051, 511307779, 511617039, 512319546, 512559298, 512588607, 512705920, 512911566, 513030763, 513065181, 513341070, 513845222, 513935530, 513974837, 515145391, 515431408, 515532844, 515556141, 516178966, 516923647, 517363175, 517610088, 517753193, 518129924, 518251104, 519053349, 519178507, 519586386, 519631377, 519815449, 520861973, 521061436, 521390965, 521845209, 522627131, 523923949, 524275138, 524313650, 524706243, 524800064, 525328862, 525525500, 525705965, 526221370, 526791616, 526847612, 526915034, 527578210, 528211713, 528265211, 528372502, 528880170, 528938383, 529446502, 529528273, 530317143, 530415876, 531202886, 532006161, 532162179, 532308455, 532612053, 533497184, 533741102, 534317878, 534529892, 535452515, 535494236, 535833656, 536481616, 537282762, 537606885, 537653689, 537672732, 537672816, 537822499, 537835973, 538592250, 538987852, 541700470, 541925452, 542048479, 542316513, 543350704, 543721539, 543784778, 544022143, 544328076, 544580127, 545419317, 545652938, 546444569, 546605041, 547495534, 547508819, 548398765, 548453243, 548471005, 549074107, 549115921, 549565220, 549609045, 549691959, 550521237, 551256123, 551765796, 551836039, 552190804, 552208151, 552555907, 552577264, 552631110, 552772714, 553645105, 554255016, 554439844, 554517304, 554991642, 555126826, 555177263, 555776402, 555936697, 555995953, 556063912, 556209379, 557827557, 559259489, 559337656, 559518477, 562653900, 562722644, 566137440, 566334015, 566479511, 566545447, 567244640, 567805121, 567862874, 567866338, 567962873, 568000243, 568254541, 568520531, 568582931, 568781617, 569284645, 570023442, 570864078, 571430710, 571700363, 572288554, 572958785, 573342488, 574241106, 574396274, 575692079, 575759636, 575934276, 576030593, 576099190, 576381414, 576597305, 576735021, 577128503, 577549056, 578198224, 578604209, 578879551, 579297101, 579327915, 579328534, 579436584, 579690565, 580161662, 580465749, 580555114, 580607032, 580869317, 581015151, 581054006, 581740778, 582049879, 582707046, 582791911, 582932696, 583849788, 583888998, 583930305, 583950123, 584953605, 585065301, 585210530, 585211547, 585636106, 585685042, 585695842, 585979096, 586410456, 586544943, 586854190, 587389470, 588902969, 589110813, 589172115, 589442181, 589491893, 589627942, 589717284, 590226577, 591062097, 591498207, 591515537, 591961646, 592014281, 592148740, 592286436, 592310300, 593246141, 593256206, 593380442, 593463818, 594781426, 594824070, 594831879, 594931949, 595368996, 596616057, 596716001, 596766017, 597704640, 598207133, 598404617, 599014207, 600293385, 600893195, 601355588, 601401383, 601870213, 602179061, 602386885, 603285355, 603673352, 603814135, 603889490, 604160860, 604312475, 604457867, 604587468, 605534418, 606022456, 606182373, 606483037, 606543133, 606620572, 606680214, 606754278, 606861176, 607638574, 607970824, 608629492, 609078120, 609518013, 609543374, 609721759, 609815688, 610025373, 610341639, 610601058, 610915945, 611205241, 611398319, 611424055, 611560824, 612067602, 612361884, 613177111, 613268532, 613316638, 613360679, 613481599, 613540965, 613576196, 613662913, 614781590, 615234975, 615772253, 615839466, 616519630, 616566216, 617672222, 618287514, 618331620, 619228897, 619790029, 620639284, 621011016, 621204960, 621554920, 621656884, 621713132, 621746466, 622014189, 622077255, 622105397, 623545203, 623741987, 623986256, 624053130, 624056468, 624617896, 624919921, 625587862, 625995770, 626489644, 626949220, 627095975, 627223355, 627599604, 628221303, 628449345, 628533427, 628616044, 628676847, 628723633, 629309297, 629995345, 630602404, 630718176, 631094359, 631165472, 631482602, 631865374, 631908049, 632337805, 632384667, 632562050, 632937752, 632944941, 633949052, 634216296, 634312014, 634497021, 635035374, 635334368, 635437514, 635844654, 636487908, 636509466, 636544329, 636635063, 636733046, 637404075, 637485348, 637761723, 638353788, 639557577, 640338772, 641132684, 641179240, 641291929, 641581172, 641929244, 642104635, 642242207, 642719168, 642733046, 643020637, 643287367, 643306171, 643511443, 645013995, 645601298, 646723775, 647025401, 647091716, 647549737, 647602032, 647745368, 648195732, 648239529, 648291198, 648492767, 648628349, 648938617, 649232505, 649542291, 649920714, 649992363, 650066607, 651391427, 651852353, 652217492, 653360977, 653363896, 654667280, 654812987, 654875840, 655303201, 655716834, 655833352, 655875258, 656629940, 656687292, 656691516, 656768575, 657118644, 657519771, 657755248, 658727856, 659290820, 659683824, 659947222, 661023468, 661799735, 663011594, 663361297, 664668990, 665107775, 665157395, 665204395, 665268199, 666226327, 666566906, 667469150, 667561265, 667845206, 668204698, 668925972, 669141092, 669951127, 670017909, 670482257, 670623785, 670636197, 671570168, 671684871, 671930196, 672671805, 673027659, 673119830, 673162196, 673234493, 673316493, 673329275, 673432596, 673544316, 673738935, 673939103, 674061518, 674757718, 675159973, 675220679, 675436537, 675513175, 676290230, 676353888, 676975711, 677248545, 677651077, 678210480, 678281195, 678469486, 679350651, 679440193, 679712384, 679794445, 679995747, 680027679, 680126827, 680258571, 680483943, 681092177, 681460555, 681500685, 681928438, 681934149, 682058541, 682084906, 682184253, 682263189, 682756635, 682918460, 682970775, 683411383, 684438392, 684512200, 684796193, 684907127, 684991420, 685024043, 685151132, 685357964, 685466175, 685542727, 685628248, 686199513, 686393669, 686667810, 687151730, 687573563, 687767688, 688315254, 689097050, 689669555, 690075664, 690195821, 690883841, 691044829, 691387338, 691410157, 692029721, 692208321, 692475807, 692525097, 692622968, 692642614, 693725449, 694012046, 694105886, 695248149, 695422111, 696120578, 696517217, 696797852, 697455884, 697929593, 698208231, 698291130, 698325785, 698897587, 699124433, 699140763, 699203146, 699590753, 700210933, 700632895, 700746471, 700768506, 700773482, 701435056, 701490549, 702167169, 702408048, 702594727, 702601892, 702930476, 703149836, 703770797, 704035508, 704301769, 705318460, 705367634, 705374889, 705680362, 705779949, 705865549, 706062106, 706785041, 707085704, 708318577, 708630436, 708698070, 709363760, 709656921, 709718208, 710177558, 710180281, 710680888, 710947453, 710955794, 711047125, 711199046, 712103764, 712297542, 712441530, 712448521, 712968765, 712998917, 713385290, 713585051, 713820360, 714237341, 714320431, 714663700, 715239638, 715492814, 715681817, 715757996, 716457187, 716492672, 716509274, 716745700, 716907444, 717911595, 718326366, 718725158, 719711744, 719773658, 720200365, 720304182, 721080555, 721375707, 721672298, 721816769, 722352866, 722525382, 723569379, 724190317, 724282107, 724312445, 726082999, 726386683, 726953107, 727096456, 727613551, 729390276, 729396314, 729937239, 730636535, 730798866, 731192263, 731286811, 731762769, 732023214, 732425138, 732652337, 732937629, 733192730, 733417087, 733988673, 734667968, 735186603, 735732733, 735904246, 735946124, 736819009, 737076557, 737378851, 737809387, 738332574, 739197874, 740379255, 741213342, 741230007, 741419762, 741680130, 741792699, 742324623, 743638624, 743719025, 743817400, 745334876, 745341428, 745538266, 745539016, 745736581, 746260981, 746359496, 746689829, 747153988, 747834409, 748492938, 748897793, 749073992, 749865861, 751189892, 751287234, 751810001, 751920224, 752330766, 752497265, 752697708, 753138045, 753518988, 754270893, 754703161], 172]) == 3\nassert my_solution.maximizeWin(*[[5626, 5627, 5630, 5631, 5633, 5634, 5638, 5639, 5639, 5643, 5651, 5653, 5653, 5653, 5653, 5656, 5657, 5657, 5661, 5673, 5674, 5679, 5685, 5690, 5692, 5694, 5695, 5699, 5700, 5705, 5705, 5711, 5711, 5713, 5714, 5715, 5716, 5717, 5717, 5717, 5720, 5720, 5721, 5724, 5725, 5728, 5729, 5731, 5731, 5731, 5732, 5736, 5738, 5739, 5740, 5742, 5742, 5743, 5747, 5752, 5752, 5759, 5764, 5766, 5767, 5769, 5771, 5773, 5776, 5777, 5779, 5781, 5784, 5788, 5790, 5796, 5799, 5803, 5805, 5806, 5809, 5810, 5815, 5820, 5822, 5822, 5827, 5829, 5832, 5833, 5834, 5839, 5839, 5845, 5846, 5847, 5849, 5850, 5851, 5852, 5855, 5859, 5864, 5865, 5869, 5869, 5875, 5879, 5884, 5885, 5891, 5894, 5895, 5895, 5896, 5896, 5897, 5897, 5900, 5905, 5911, 5913, 5916, 5917, 5921, 5922, 5924, 5926, 5932, 5934, 5935, 5945, 5946, 5951, 5953, 5955, 5956, 5956, 5957, 5958, 5958, 5967, 5967, 5967, 5968, 5969, 5973, 5975, 5976, 5980, 5980, 5982, 5987, 5989, 5994, 5996, 5998, 6002, 6003, 6005, 6014, 6019, 6023, 6027, 6030, 6035, 6036, 6039, 6039, 6043, 6043, 6051, 6051, 6051, 6053, 6054, 6055, 6061, 6064, 6066, 6066, 6068, 6068, 6069, 6072, 6072, 6075, 6075, 6075, 6075, 6077, 6077, 6078, 6079, 6080, 6086, 6088, 6092, 6094, 6095, 6096, 6102, 6109, 6110, 6110, 6111, 6111, 6111, 6116, 6116, 6117, 6122, 6127, 6131, 6133, 6136, 6136, 6137, 6142, 6142, 6142, 6146, 6147, 6148, 6149, 6154, 6154, 6163, 6172, 6175, 6176, 6182, 6183, 6185, 6186, 6190, 6193, 6194, 6201, 6202, 6203, 6208, 6209, 6219, 6220, 6221, 6222, 6224, 6225, 6225, 6225, 6227, 6227, 6230, 6235, 6240, 6243, 6244, 6245, 6246, 6247, 6251, 6254, 6255, 6256, 6260, 6261, 6264, 6265, 6266, 6266, 6267, 6268, 6269, 6270, 6271, 6273, 6279, 6280, 6281, 6282, 6286, 6287, 6287, 6287, 6288, 6289, 6289, 6290, 6291, 6292, 6298, 6300, 6303, 6305, 6313, 6316, 6317, 6318, 6320, 6322, 6328, 6331, 6331, 6334, 6334, 6336, 6336, 6337, 6340, 6347, 6347, 6352, 6355, 6355, 6357, 6361, 6361, 6363, 6366, 6371, 6373, 6374, 6375, 6377, 6380, 6385, 6395, 6395, 6401, 6407, 6413, 6416, 6418, 6419, 6419, 6419, 6420, 6430, 6433, 6435, 6437, 6440, 6440, 6445, 6446, 6449, 6450, 6452, 6452, 6452, 6454, 6455, 6456, 6458, 6462, 6465, 6467, 6469, 6477, 6478, 6483, 6492, 6493, 6494, 6495, 6496, 6497, 6497, 6497, 6498, 6499, 6501, 6503, 6507, 6509, 6510, 6510, 6511, 6511, 6513, 6515, 6518, 6518, 6519, 6519, 6524, 6525, 6526, 6527, 6529, 6535, 6536, 6536, 6543, 6546, 6548, 6552, 6553, 6554, 6555, 6560, 6564, 6565, 6566, 6572, 6574, 6579, 6580, 6583, 6586, 6591, 6599, 6599, 6600, 6605, 6610, 6614, 6614, 6616, 6628, 6630, 6633, 6640, 6641, 6644, 6646, 6646, 6650, 6651, 6652, 6653, 6654, 6655, 6659, 6659, 6660, 6663, 6663, 6664, 6665, 6668, 6671, 6671, 6673, 6673, 6674, 6681, 6685, 6686, 6686, 6690, 6693, 6696, 6697, 6699, 6701, 6703, 6704, 6707, 6708, 6708, 6711, 6714, 6715, 6717, 6718, 6724, 6726, 6727, 6728, 6732, 6743, 6743, 6743, 6744, 6746, 6747, 6752, 6752, 6753, 6754, 6754, 6754, 6758, 6760, 6760, 6764, 6765, 6782, 6783, 6791, 6792, 6794, 6796, 6796, 6803, 6804, 6804, 6808, 6815, 6817, 6819, 6819, 6822, 6822, 6826, 6827, 6835, 6837, 6837, 6837, 6837, 6840, 6841, 6844, 6847, 6850, 6850, 6852, 6852, 6852, 6855, 6856, 6860, 6860, 6861, 6861, 6868, 6868, 6870, 6872, 6874, 6876, 6878, 6879, 6880, 6882, 6886, 6889, 6890, 6892, 6897, 6897, 6898, 6900, 6900, 6903, 6903, 6905, 6905, 6905, 6907, 6912, 6917, 6917, 6917, 6923, 6924, 6924, 6927, 6931, 6935, 6935, 6941, 6943, 6944, 6945, 6946, 6953, 6958, 6959, 6966, 6967, 6968, 6970, 6974, 6978, 6981, 6982, 6983, 6987, 6987, 6987, 6988, 6989, 6989, 6992, 6992, 6993, 6993, 6998, 7000, 7000, 7002, 7003, 7008, 7009, 7010, 7012, 7014, 7016, 7018, 7019, 7022, 7023, 7026, 7026, 7027, 7032, 7037, 7037, 7041, 7042, 7045, 7053, 7053, 7054, 7055, 7057, 7060, 7061, 7061, 7064, 7066, 7069, 7070, 7072, 7072, 7079, 7081, 7097, 7098, 7099, 7106, 7106, 7106, 7110, 7110, 7112, 7112, 7117, 7120, 7120, 7122, 7126, 7129, 7134, 7137, 7146, 7147, 7149, 7160, 7160, 7160, 7162, 7165, 7165, 7172, 7176, 7176, 7177, 7177, 7178, 7179, 7187, 7189, 7190, 7191, 7197, 7197, 7197, 7201, 7206, 7208, 7214, 7217, 7218, 7222, 7225, 7229, 7230, 7234, 7235, 7236, 7236, 7242, 7245, 7246, 7252, 7254, 7256, 7257, 7257, 7258, 7263, 7264, 7265, 7271, 7277, 7282, 7285, 7288, 7292, 7294, 7295, 7296, 7300, 7301, 7304, 7304, 7306, 7307, 7309, 7310, 7311, 7312, 7313, 7314, 7322, 7322, 7336, 7337, 7342, 7346, 7347, 7348, 7350, 7358, 7358, 7359, 7366, 7368, 7370, 7374, 7375, 7378, 7379, 7379, 7380, 7380, 7383, 7383, 7390, 7390, 7391, 7393, 7395, 7401, 7403, 7409, 7410, 7419, 7422, 7423, 7425, 7427, 7429, 7440, 7441, 7448, 7452, 7453, 7453, 7456, 7457, 7458, 7459, 7462, 7462, 7467, 7467, 7469, 7471, 7471, 7472, 7473, 7476, 7476, 7478, 7478, 7481, 7481, 7482, 7483, 7483, 7490, 7491, 7495, 7499, 7500, 7502, 7508, 7512, 7512, 7516, 7516, 7517, 7519, 7530, 7531, 7535, 7536, 7545, 7547, 7549, 7549, 7550, 7550, 7560, 7571, 7578, 7578, 7582, 7582, 7592, 7596, 7597, 7597, 7600, 7604, 7605, 7607, 7615, 7617, 7618, 7619, 7619, 7619, 7621, 7622, 7623, 7624, 7626, 7629, 7636, 7637, 7644, 7645, 7646, 7649, 7649, 7649, 7654, 7655, 7657, 7662, 7666, 7667, 7673, 7673, 7676, 7679, 7679, 7683, 7683, 7687, 7693, 7695, 7698, 7699, 7706, 7707, 7708, 7711, 7712, 7713, 7716, 7717, 7718, 7720, 7724, 7730, 7739, 7739, 7741, 7741, 7743, 7745, 7746, 7748, 7748, 7748, 7750, 7756, 7758, 7765, 7767, 7768, 7772, 7777, 7788, 7789, 7797, 7797, 7801, 7801, 7807, 7811, 7811, 7812, 7813, 7819, 7825, 7827, 7829, 7843, 7844, 7850, 7852, 7852, 7854, 7854, 7855, 7861, 7865, 7869, 7870, 7872, 7875, 7878, 7878, 7886, 7889, 7890, 7893, 7895, 7897, 7900, 7902, 7903, 7905, 7906, 7907, 7911, 7916, 7920, 7922, 7924, 7926, 7930, 7932, 7942, 7947, 7947, 7949, 7949, 7952, 7958, 7959, 7963, 7967, 7968, 7973, 7973, 7977, 7978, 7981, 7992, 7994, 7995, 7999, 8003, 8004, 8005, 8006, 8009, 8009, 8010, 8011, 8012, 8012, 8014, 8015, 8017, 8024, 8025, 8034, 8035, 8036, 8038, 8039, 8040, 8051, 8051, 8059, 8065, 8066, 8069, 8072, 8073, 8073, 8076, 8079, 8084, 8086, 8091, 8093, 8093, 8094, 8095, 8095, 8096, 8096, 8099, 8102, 8107, 8111, 8114, 8115, 8118, 8119, 8127, 8129, 8130, 8136, 8139, 8144, 8147, 8151, 8151, 8153, 8154, 8162, 8162, 8163, 8166, 8167, 8167, 8167, 8167, 8168, 8170, 8174, 8176, 8183, 8185, 8187, 8188, 8190, 8194, 8195, 8196, 8196, 8200, 8204, 8204, 8205, 8205, 8208, 8213, 8219, 8221, 8223, 8229, 8231, 8239, 8240, 8240, 8240, 8241, 8245, 8246, 8254, 8256, 8260, 8272, 8272, 8272, 8274, 8281, 8281, 8282, 8291, 8298, 8299, 8301, 8301, 8302, 8306, 8307, 8308, 8309, 8310, 8314, 8318, 8318, 8320, 8322, 8322, 8327, 8327, 8333, 8336, 8338, 8340, 8348, 8349, 8357, 8359, 8371, 8379, 8381, 8381, 8382, 8385, 8385, 8385, 8387, 8388, 8389, 8390, 8394, 8402, 8403, 8406, 8406, 8408, 8408, 8410, 8411, 8412, 8413, 8414, 8414, 8419, 8420, 8420, 8424, 8427, 8431], 879]) == 758\nassert my_solution.maximizeWin(*[[7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9], 503]) == 1678\nassert my_solution.maximizeWin(*[[885752020, 885756956, 885807567, 885837743, 885849450, 885894531, 885929312, 885931662, 886058747, 886096971, 886098826, 886120215, 886167102, 886177838, 886232776, 886241031, 886317479, 886319136, 886373787, 886425727, 886443885, 886502351, 886528719, 886535215, 886574039, 886694251, 886762584, 886773426, 886851074, 886930648, 886994977, 887015963, 887125310, 887172809, 887179116, 887199570, 887204341, 887259587, 887365552, 887369051, 887388776, 887410802, 887430459, 887639522, 887814793, 887848113, 887885779, 887899803, 887922670, 887925062, 887927740, 887971712, 887991599, 888024510, 888243760, 888412144, 888441363, 888502940, 888584827, 888592967, 888600329, 888659678, 888669167, 888823550, 888848241, 888934798, 889004387, 889005122, 889023885, 889063783, 889099179, 889133952, 889147323, 889155008, 889226960, 889300563, 889318442, 889331082, 889367599, 889386482, 889442314, 889454347, 889559593, 889596842, 889609538, 889618399, 889717143, 889765571, 889774902, 889808753, 889831804, 889854902, 889872341, 889873977, 889953507, 890020487, 890121488, 890128004, 890214509, 890217040, 890237124, 890241467, 890354356, 890357664, 890478911, 890504023, 890519526, 890523404, 890536167, 890551394, 890687973, 890694979, 890736459, 890750311, 890751891, 890797648, 890880095, 890887592, 890935346, 890941951, 890988758, 890989303, 891038158, 891040619, 891083710, 891118452, 891148823, 891198421, 891206147, 891229171, 891256198, 891266698, 891280594, 891294330, 891396115, 891427135, 891559939, 891591606, 891677971, 891743304, 891771621, 891937736, 892053301, 892070749, 892199049, 892212910, 892232351, 892281898, 892332295, 892351921, 892424027, 892504898, 892602753, 892614793, 892643121, 892691659, 892707482, 892748391, 892778295, 892805275, 892854149, 892890917, 892941223, 892951872, 892964249, 893111214, 893114456, 893165501, 893203480, 893227798, 893336889, 893349306, 893471654, 893563639, 893603924, 893653251, 893661583, 893695841, 893909062, 893913990, 893959740, 894050390, 894065170, 894195066, 894208740, 894262982, 894263921, 894292677, 894343226, 894393267, 894413940, 894415595, 894447171, 894515583, 894558271, 894576980, 894638350, 894692046, 894710518, 894771749, 894815685, 894863384, 894934988, 894978618, 894979220, 895082052, 895100380, 895149432, 895164985, 895193712, 895324160, 895338164, 895419047, 895575054, 895627695, 895634795, 895648728, 895675173, 895693733, 895827822, 895830238, 895954063, 895981360, 895989961, 896005111, 896057976, 896131778, 896137527, 896151511, 896167880, 896202337, 896221722, 896229153, 896240871, 896246029, 896253564, 896257536, 896311684, 896334011, 896347083, 896363352, 896393975, 896435687, 896468487, 896484101, 896495175, 896504657, 896519376, 896532916, 896566321, 896624755, 896656491, 896686290, 896714973, 896752164, 896763868, 896767885, 896773908, 896779834, 896865966, 896928558, 896945836, 896951207, 897007668, 897064841, 897103899, 897110002, 897179773, 897180491, 897213842, 897239881, 897260677, 897273770, 897459365, 897500381, 897606938, 897616752, 897659799, 897682854, 897756148, 897793043, 897796327, 897881832, 897935928, 897974183, 898011569, 898043140, 898053569, 898108818, 898110700, 898118802, 898228260, 898241784, 898251713, 898287826, 898389877, 898397527, 898427016, 898508934, 898586522, 898594921, 898685371, 898700830, 898731039, 898786339, 898949398, 899049118, 899084985, 899113667, 899121589, 899126650, 899156102, 899207726, 899235729, 899252228, 899288938, 899305933, 899367011, 899385109, 899389743, 899396959, 899451940, 899526199, 899526480, 899591287, 899597678, 899649922, 899681211, 899728171, 899754770, 899824849, 899901082, 899964042, 900012605, 900050742, 900073302, 900104936, 900143586, 900155157, 900160895, 900187010, 900297482, 900412219, 900419723, 900451263, 900452095, 900459023, 900463060, 900465811, 900486904, 900513936, 900535028, 900569281, 900648948, 900720309, 900728518, 900748601, 900760827, 900941853, 900967362, 901024593, 901031803, 901104362, 901133402, 901135278, 901177644, 901238628, 901243357, 901288919, 901293431, 901316603, 901509450, 901574581, 901603032, 901639345, 901644220, 901685278, 901720934, 901724800, 901845006, 901860154, 901867797, 901881290, 901890263, 901906482, 901920157, 902055632, 902105996, 902121503, 902175964, 902196777, 902252853, 902471569, 902523984, 902613688, 902634003, 902715419, 902721607, 902743132, 902821955, 902837482, 902990701, 903012296, 903185054, 903228000, 903232003, 903338344, 903363015, 903375477, 903382988, 903458416, 903616653, 903636582, 903668376, 903765452, 903789282, 903798681, 903807623, 903834924, 903846120, 903965668, 903968547, 904012323, 904081756, 904102704, 904157836, 904161886, 904173739, 904308497, 904389536, 904393272, 904409136, 904420522, 904515995, 904535708, 904579131, 904599003, 904657608, 904694169, 904760291, 904895047, 904895693, 904897528, 904910751, 904914631, 904966138, 905079374, 905112633, 905114717, 905122699, 905155084, 905198877, 905211287, 905215241, 905302435, 905327308, 905424182, 905489190, 905606452, 905655607, 905661965, 905680995, 905729167, 905733501, 905763749, 905772227, 905900916, 905937795, 905968990, 905980241, 906019298, 906104217, 906172343, 906180788, 906257151, 906428033, 906551474, 906564007, 906647677, 906675716, 906685872, 906721234, 906756260, 906778826, 906788054, 906791057, 906845420, 906846745, 906857991, 906862864, 906880356, 906917087, 907082308, 907091069, 907116378, 907197980, 907246805, 907304616, 907325663, 907330492, 907417925, 907435781, 907451666, 907462997, 907528172, 907563885, 907621682, 907629814, 907686931, 907780713, 907806295, 907819178, 907845405, 907908815, 907963997, 908001236, 908010184, 908059395, 908114113, 908303506, 908332823, 908500229, 908528633, 908595885, 908743697, 908800311, 908804755, 908875023, 908896208, 908950841, 908955176, 908998088, 909011529, 909028916, 909029646, 909085990, 909121615, 909163088, 909175626, 909211868, 909247771, 909261964, 909322461, 909396742, 909403653, 909494232, 909531021, 909538065, 909603367, 909790410, 909821552, 909856262, 909856569, 910045065, 910177718, 910183200, 910241686, 910286100, 910325394, 910328516, 910359825, 910365627, 910382755, 910383375, 910441300, 910536852, 910568439, 910576859, 910580280, 910611777, 910634826, 910636932, 910654955, 910706955, 910709267, 910723867, 910778780, 910789721, 910827418, 910846822, 910886981, 910951879, 911125706, 911141103, 911181933, 911229901, 911271813, 911349009, 911420119, 911493270, 911494711, 911499380, 911533401, 911539361, 911550421, 911561281, 911610955, 911633467, 911726920, 911758304, 911782600, 911803087, 911885174, 911902866, 911930465, 911931497, 911945327, 911958742, 912067782, 912072503, 912304868, 912341806, 912403978, 912427565, 912469547, 912475235, 912544600, 912562406, 912624366, 912641821, 912771019, 912797291, 912809177, 912859513, 912904171, 912925478, 912959073, 913010117, 913011254, 913041719, 913062216, 913088658, 913119970, 913211625, 913338786, 913339437, 913340779, 913363592, 913499490, 913545339, 913600947, 913617578, 913618276, 913666735, 913714098, 913731401, 913769732, 913789164, 913867399, 913874572, 913875057, 913906192, 913927851, 913968866, 914066196, 914072588, 914090585, 914092433, 914141696, 914224394, 914261215, 914326063, 914337121, 914345521, 914351012, 914355151, 914355268, 914373227, 914447670, 914541341, 914570604, 914609161, 914621801, 914653725, 914689329, 914704687, 914724377, 914724615, 914797150, 914803132, 914847707, 914870063, 914879953, 914906176, 914908803, 914923649, 914975937, 915002011, 915036371, 915048077, 915157375, 915226475, 915226505, 915247188, 915276506, 915291794, 915375879, 915491292, 915705722, 915707858, 915726035, 915742359, 915758701, 915784179, 915802131, 915854514, 915912165, 915921258, 915925342, 915928196, 915932909, 915995644, 916000622, 916134602, 916172761, 916197889, 916207744, 916283249, 916364012, 916393882, 916420563, 916515544, 916593964, 916599655, 916617681, 916703027, 916929441, 916941581, 916958532, 916963243, 916982497, 916989302, 917001229, 917002511, 917015268, 917075763, 917108532, 917141920, 917154596, 917196423, 917238709, 917245924, 917275534, 917287857, 917304670, 917399069, 917498491, 917503317, 917612266, 917718640, 917783730, 917789183, 917838907, 917863423, 917902517, 917908370, 917925057, 918057565, 918168825, 918208645, 918222738, 918279297, 918319040, 918376560, 918388917, 918495081, 918532204, 918564598, 918578214, 918823248, 918853926, 918881773, 918897735, 918901473, 918932699, 918949514, 919003868, 919060418, 919077274, 919149520, 919157064, 919210036, 919295204, 919633663, 919669405, 919679624, 919724392, 919801564, 919842866, 919941113, 919980509, 920026040, 920089401, 920134226, 920143666, 920241874, 920273011, 920355813, 920402440, 920428298, 920485582, 920524750, 920642004, 920731036, 920743704, 920783584, 920830353, 920839454, 920887451, 920899647, 921013584, 921017295, 921151550, 921184422, 921313976, 921323065, 921323317, 921417645, 921496452, 921511164, 921541145, 921552665, 921577330, 921591344, 921680399, 921691335, 921738142, 921745633, 921802419, 921820715, 921910904, 921930737, 921938297, 922006063, 922008681, 922010884, 922042774, 922053273, 922113416, 922116871, 922150578, 922156302, 922233956, 922261552, 922366770, 922401895, 922420269, 922433019, 922454995, 922484134, 922597648, 922632980, 922637038, 922642878, 922649542, 922672101, 922708707, 922754099, 922867483, 922924740, 923078411, 923131023, 923159217, 923209836, 923216018, 923256689, 923256693, 923297415, 923374286, 923386158, 923448786, 923476278, 923585411, 923631661, 923641967, 923664695, 923665684, 923669094, 923691628, 923825156, 923864819, 923896181, 923920623, 923938199, 923967993, 924038915, 924074350, 924099618, 924207604, 924208362, 924211720, 924234752, 924287686, 924292391, 924381075, 924428356, 924469530, 924498593, 924520708, 924531996, 924581108, 924599480, 924622322, 924629272, 924677888, 924684365, 924688805, 924748139, 924766845, 924775355, 924854505, 924947297, 924948016, 924995209, 925029013, 925057457, 925194276, 925291215, 925378480, 925452038, 925485646, 925584551, 925589920, 925674618, 925678734, 925679768, 925724537, 925732689, 925768233, 925770116, 925836603, 925927259, 925995628, 926079388, 926096820, 926150415, 926152577, 926197922, 926322413, 926339121, 926349035, 926402146, 926421206, 926450385, 926453606, 926539950, 926598692, 926690289, 926692093, 926712647, 926767449, 926777027, 926813810, 926832178, 926898923, 926913237, 926986890, 927029335, 927047747, 927055369, 927078132, 927155621, 927185770, 927188463, 927242993, 927309566, 927326650, 927345926, 927411035, 927458654, 927551832, 927572051, 927642651, 927685554, 927703422, 927710554, 927788110, 927804687, 927814967, 927825029, 927828995, 927876009, 927886334, 927915250, 927943725, 928025555, 928029328, 928104107, 928132440, 928149213, 928271208, 928301735, 928305765, 928336990, 928339041, 928388192, 928482743, 928632124, 928790430, 928877371, 928934277, 928962181, 929054931, 929098045, 929106345, 929119486, 929196392, 929242264, 929349375, 929351001, 929363117, 929390949, 929520567, 929703031, 929789933, 929862142, 929934969, 929963778, 929965296, 929984188, 930003909, 930015112, 930020338, 930035035, 930051476, 930195616, 930258865, 930348307, 930350266, 930352952, 930361192, 930433442, 930463793, 930511211, 930514899, 930600344, 930620548, 930720157, 930755838, 930765097, 930813598, 930820920, 930878167, 930958498, 930972051, 930993148, 931047015, 931111268, 931180147, 931230825, 931247434, 931257404, 931440207, 931460631, 931618227, 931626981, 931675942, 931680416, 931815273, 931895070, 931936362, 932036360, 932046191, 932094432, 932151670, 932168081, 932220732, 932272602, 932274716, 932305706, 932342597, 932368267, 932405552, 932407488, 932477883, 932507825, 932510840, 932540870, 932628635, 932669909, 932691361, 932699651, 932723795, 932730693, 932769404, 932775157, 932811466, 932812005, 932830303, 932869948, 932876711, 932901124, 932941925, 932949494, 932969412, 932996041, 933006428, 933095902, 933117608, 933283696, 933321619, 933331527, 933382602, 933413421, 933415000, 933436793, 933438909, 933440192, 933478635, 933495550, 933557189, 933560114, 933697103, 933717600, 933813835, 933961068, 934006740, 934033001, 934158763, 934160514, 934175228, 934226266, 934241956, 934250494, 934292994, 934305281, 934381979, 934387437, 934461963, 934486453, 934488021, 934603690, 934612512, 934641297, 934738520, 934793840, 934808969, 934890917, 934894936, 934916580, 934948547, 934965186, 934993944, 934995473, 935028318, 935045283, 935099823, 935102947, 935129564, 935132707, 935142451, 935262885, 935278906, 935299274, 935509892, 935550382, 935555621, 935604759, 935605963, 935613249, 935782587, 935832403, 935890980, 935897820, 935909952, 935915084, 935917009, 935937923, 935944864, 935955811, 935967277, 936047276, 936087192, 936174945, 936182595, 936184661, 936213376, 936253233, 936351960, 936386523, 936401794, 936448165, 936571816, 936619977, 936620909, 936657523, 936695275, 936730782, 936746893, 936811348, 936842583, 936897722, 936968949, 937003834, 937042508, 937139865, 937165333, 937196860, 937202877, 937229184, 937305816, 937350156, 937352002, 937357704, 937380228, 937387766, 937510251, 937515871, 937516362, 937525015, 937695488, 937745878, 937769128, 937770387, 937773554, 937778902, 937841158, 937911558, 938003243, 938044103, 938054850, 938139682, 938289891, 938332540, 938391953, 938418407, 938418995, 938437894, 938486620, 938589012, 938602618, 938765512, 938799115, 938813642, 938832356, 938840616, 938997149, 939079588, 939083324, 939124866, 939136248, 939198411, 939339152, 939361372, 939503228, 939514809, 939578324, 939646221, 939676578, 939853918, 939873584, 939876717, 939895827, 939923423, 939993674, 940058884, 940066032, 940107816, 940135068, 940172109, 940204810, 940236224, 940238255, 940257049, 940285145, 940286551, 940301857, 940327131, 940445983, 940465854, 940512337, 940655924, 940680806, 940687232, 940726061, 940742727, 940748232, 940779768, 940830976, 940860449, 940872932, 940880710, 940894484, 940905197, 940953214, 940959336, 941007703, 941175305, 941216758, 941265705, 941286485, 941294662, 941344325, 941353855, 941384134, 941394441, 941490346, 941572568, 941574288, 941585600, 941628015, 941635027, 941643956, 941656112, 941681906, 941784890, 941990488, 942102963, 942123556, 942149778, 942158556, 942176952, 942179521, 942271873, 942390975, 942465891, 942522571, 942593291, 942680533, 942703575, 942704940, 942746852, 942806857, 942857787, 942857857, 942858752, 942974098, 942986191, 943106080, 943144330, 943220705, 943270203, 943365543, 943379867, 943385426, 943386428, 943462490, 943496550, 943559420, 943563820, 943624192, 943673519, 943692764, 943695150, 943785022, 943805619, 943825946, 943860637, 943869797, 943887743, 943986637, 943989203, 944015659, 944036506, 944054726, 944074351, 944079183, 944089340, 944099557, 944133981, 944156454, 944170523, 944176219, 944212017, 944222706, 944240053, 944283665, 944286315, 944302276, 944342900, 944357713, 944379912, 944420426, 944430250, 944432577, 944508222, 944515139, 944578579, 944578786, 944639735, 944640668, 944686802, 944690669, 944717138, 944829965, 944960010, 944966917, 944991271, 944999357, 945044694, 945096350, 945129179, 945194731, 945282221, 945291986, 945343237, 945459392, 945490078, 945491450, 945493203, 945494762, 945520429, 945551573, 945628754, 945945665, 945981448, 946024590, 946052640, 946055531, 946061184, 946119026, 946141511, 946356934, 946448995, 946495417, 946510645, 946521203, 946568646, 946598011, 946644577, 946668713, 946701117, 946754777, 946780981, 946810407, 946862628, 946930991, 946943433, 946991433, 947010598, 947039171, 947151016, 947194232, 947230519, 947270962, 947359807, 947382981, 947436700, 947441480, 947445077, 947462864, 947493349, 947602492, 947657166, 947673161, 947673427, 947682770, 947709694, 947752500, 947792870, 947830369, 947936260, 947975542, 948069883, 948124233, 948133505, 948176881, 948198842, 948219655, 948269132, 948368323, 948459722, 948498849, 948522012, 948693513, 948695883, 948711656, 948760086, 948819135, 948854283, 948927225, 949072826, 949087547, 949090126, 949233069, 949292617, 949341566, 949359158, 949384850, 949483677, 949487583, 949526375, 949594555, 949620085, 949678632, 949720117, 949757849, 949815081, 949823497, 949827185, 949924172, 950025229, 950079791, 950117677, 950172466, 950221827, 950279417, 950292900, 950350985, 950381006, 950407144, 950430357, 950435045, 950469032, 950520087, 950555015, 950571704, 950601825, 950621576, 950633352, 950637939, 950641075, 950685960, 950702923, 950725971, 950754607, 950821265, 950839051, 950896324, 951010005, 951118317, 951171533, 951176669, 951185181, 951295873, 951302471, 951348359, 951420599, 951536089, 951545762, 951695277, 951715592, 951792597, 951810601, 951870103, 952090923, 952092787, 952139512, 952180158, 952216273, 952246640, 952255167, 952256377, 952291070, 952301248, 952397984, 952410137, 952431730, 952447485, 952475447, 952531121, 952589003, 952594281, 952635531, 952812617, 952888096, 952901548, 952959007, 952974561, 953023373, 953073700, 953083170, 953149225, 953250865, 953262780, 953354386, 953363783, 953380284, 953461845, 953482771, 953483910, 953505946, 953512355, 953606199, 953631218, 953660870, 953694872, 953770909, 953853825, 953884918, 953901248, 953931176, 953991688, 953995139, 954004482, 954034039, 954118964, 954192058, 954201352, 954255045, 954267248, 954333395, 954349500, 954401042, 954427987, 954547363, 954563226, 954789043, 954966904, 954995201, 955075890, 955114752, 955198151, 955201698, 955229698, 955235232, 955244709, 955246817, 955361817, 955407246, 955415021, 955458840, 955521834, 955527767, 955537789, 955658150, 955711929, 955734125, 955740492, 955744570, 955753163, 955757085, 955838910, 955853855, 955917961, 955987474, 956010469, 956064505, 956093788, 956157813, 956177012, 956188914, 956256222, 956301288, 956312747, 956356184, 956389890, 956402330, 956436117, 956444875, 956473902, 956477025, 956489554, 956552406, 956553025, 956569845, 956591981, 956686933, 956702474, 956721097, 956848768, 956894891, 956958368, 956988505, 957056609, 957080917, 957184243, 957200421, 957288103, 957314549, 957341142, 957367145, 957566138, 957579005, 957687199, 957740004, 957749731, 957798688, 957811362, 957907851, 957967007, 958014373, 958014976, 958066229, 958316942, 958415123, 958436502, 958696420, 958737090, 958742784, 958754987, 958760031, 958881563, 958994100, 959084840, 959215315, 959275819, 959314868, 959368666, 959378579, 959409043, 959555827, 959557757, 959573975, 959583198, 959664858, 959749562, 959988321, 960001921, 960020589, 960225850, 960334010, 960348360, 960465641, 960471063, 960505261, 960528944, 960632803, 960866994, 960874069, 960904923, 960942512, 961039970, 961091361, 961165683, 961172319, 961175739, 961207714, 961247983, 961258520, 961283936, 961288224, 961305006, 961340043, 961373603, 961418322, 961425842, 961449175, 961512220, 961528501, 961571278, 961642003, 961791929, 961924219, 961947094, 961971794, 962025855, 962030691, 962045389, 962081337, 962151701, 962217316, 962219518, 962288528, 962308692, 962333208, 962358282, 962376345, 962575891, 962605715, 962609511, 962669606, 962684301, 962711521, 962719204, 962781121, 962839240, 962959870, 962962196, 962970039, 963050135, 963072525, 963107698, 963114182, 963118701, 963119937, 963192571, 963228082, 963411476, 963472006, 963545479, 963550930, 963622035, 963634123, 963694127, 963839955, 963846910, 963886316, 964000215, 964033744, 964078470, 964221848, 964347439, 964379023, 964418268, 964431040, 964450252, 964483745, 964578054, 964609036, 964633249, 964683052, 964694690, 964723250, 964792762, 964812601, 964819397, 964918156, 964922066, 964959965, 965014565, 965030949, 965049924, 965062703, 965123149, 965247998, 965367243, 965406176, 965406754, 965502564, 965600557, 965677139, 965754412, 965791994, 965870062, 965870594, 965930685, 965997872, 966016415, 966018167, 966018275, 966033585, 966067437, 966100042, 966196439, 966253098, 966279845, 966319673, 966330923, 966499750, 966519297, 966533286, 966549759, 966621885, 966681061, 966689899, 966711727, 966727879, 966740585, 966747993, 966850145, 966957103, 966999375, 967004794, 967073002, 967146720, 967151755, 967157829, 967162847, 967185444, 967193244, 967253229, 967283247, 967294547, 967301345, 967311187, 967338599, 967355941, 967386525, 967448030, 967647882, 967666320, 967674869, 967715016, 967725485, 967752825, 967779801, 967788007, 967888130, 967906066, 967915065, 967915603, 967932359, 967978727, 968089176, 968121219, 968140074, 968174117, 968186775, 968230806, 968317287, 968476397, 968477983, 968484231, 968485353, 968494994, 968519164, 968521527, 968538486, 968571755, 968585868, 968688914, 968731622, 968746117, 968750087, 968774935, 968809717, 968921134, 968933226, 968943554, 968945215, 969011385, 969063548, 969089863, 969135973, 969144615, 969268202, 969276894, 969278933], 401]) == 4\nassert my_solution.maximizeWin(*[[692, 692, 692, 692, 692, 692, 692, 692, 692, 692, 693, 693, 693, 693, 693, 693, 693, 693, 693, 693, 694, 694, 694, 694, 694, 694, 694, 694, 694, 694, 695, 695, 695, 695, 695, 695, 695, 695, 696, 696, 696, 696, 696, 696, 696, 696, 696, 696, 696, 696, 697, 697, 697, 697, 697, 697, 697, 697, 697, 697, 697, 697, 697, 698, 698, 698, 698, 698, 698, 698, 698, 698, 698, 698, 698, 698, 698, 698, 698, 698, 699, 699, 699, 700, 700, 700, 700, 700, 700, 700, 700, 700, 701, 701, 701, 701, 701, 701, 701, 701, 701, 701, 701, 701, 701, 702, 702, 702, 702, 702, 702, 702, 702, 702, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 704, 704, 704, 704, 704, 704, 704, 704, 704, 704, 704, 704, 704, 705, 705, 705, 705, 705, 705, 705, 705, 705, 705, 706, 706, 706, 706, 706, 706, 706, 706, 706, 706, 707, 707, 707, 707, 707, 707, 707, 707, 707, 707, 708, 708, 708, 708, 708, 708, 708, 708, 708, 709, 709, 709, 709, 709, 709, 709, 709, 709, 709, 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, 711, 711, 711, 711, 711, 711, 711, 711, 711, 711, 711, 711, 711, 711, 712, 712, 712, 712, 712, 712, 712, 712, 712, 712, 712, 712, 712, 713, 713, 713, 713, 713, 713, 713, 714, 714, 714, 714, 714, 714, 714, 714, 714, 714, 714, 714, 715, 715, 715, 715, 715, 715, 715, 715, 715, 716, 716, 716, 716, 716, 716, 716, 716, 717, 717, 717, 717, 717, 717, 717, 717, 717, 717, 718, 718, 718, 718, 718, 718, 718, 718, 718, 718, 718, 718, 718, 718, 718, 718, 718, 719, 719, 719, 719, 719, 719, 719, 719, 720, 720, 720, 720, 720, 720, 720, 720, 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, 722, 722, 722, 722, 722, 722, 722, 722, 722, 722, 722, 723, 723, 723, 723, 723, 723, 723, 723, 724, 724, 724, 724, 724, 724, 724, 724, 724, 724, 724, 724, 725, 725, 725, 725, 725, 726, 726, 726, 726, 726, 726, 726, 726, 726, 727, 727, 727, 727, 727, 727, 727, 727, 728, 728, 728, 728, 728, 728, 728, 728, 728, 729, 729, 729, 729, 729, 729, 729, 729, 729, 729, 729, 729, 729, 729, 729, 730, 730, 730, 730, 730, 730, 731, 731, 731, 731, 731, 731, 731, 731, 732, 732, 732, 732, 732, 733, 733, 733, 733, 733, 733, 733, 733, 733, 733, 733, 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, 735, 735, 735, 735, 735, 735, 735, 736, 736, 736, 736, 736, 736, 736, 737, 737, 737, 737, 737, 737, 737, 737, 737, 737, 738, 738, 738, 738, 738, 738, 738, 738, 738, 738, 738, 738, 739, 739, 739, 739, 739, 739, 739, 739, 740, 740, 740, 740, 740, 740, 740, 740, 740, 740, 740, 740, 741, 741, 741, 741, 741, 741, 741, 741, 742, 742, 742, 742, 742, 742, 742, 743, 743, 743, 743, 743, 743, 743, 743, 743, 743, 743, 743, 743, 743, 743, 744, 744, 744, 744, 744, 744, 744, 744, 744, 745, 745, 745, 745, 745, 745, 745, 745, 745, 745, 746, 746, 746, 746, 746, 746, 746, 746, 746, 746, 747, 747, 747, 747, 747, 747, 747, 747, 747, 747, 748, 748, 748, 748, 748, 748, 748, 748, 749, 749, 749, 749, 749, 749, 749, 749, 749, 750, 750, 750, 750, 750, 750, 750, 750, 750, 750, 750, 750, 750, 750, 750, 750, 750, 750, 750, 751, 751, 751, 751, 751, 751, 751, 751, 751, 751, 752, 752, 752, 752, 752, 752, 752, 752, 752, 752, 752, 753, 753, 753, 753, 753, 753, 753, 753, 754, 754, 754, 754, 754, 754, 754, 754, 754, 754, 754, 754, 755, 755, 755, 755, 755, 755, 755, 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, 757, 757, 757, 757, 757, 757, 758, 758, 758, 758, 758, 758, 758, 758, 758, 758, 758, 758, 758, 759, 759, 759, 759, 759, 759, 759, 759, 759, 759, 760, 760, 760, 760, 760, 760, 761, 761, 761, 761, 761, 761, 761, 761, 761, 761, 761, 761, 761, 761, 762, 762, 762, 762, 762, 762, 762, 762, 762, 762, 763, 763, 763, 764, 764, 764, 764, 764, 764, 764, 764, 764, 764, 764, 764, 765, 765, 765, 765, 765, 765, 765, 765, 765, 765, 765, 766, 766, 766, 766, 766, 766, 766, 766, 766, 766, 766, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 769, 769, 769, 769, 769, 769, 769, 769, 769, 769, 769, 769, 769, 770, 770, 770, 770, 770, 770, 770, 770, 770, 771, 771, 771, 771, 771, 771, 771, 771, 771, 771, 772, 772, 772, 772, 772, 772, 772, 772, 772, 772, 773, 773, 773, 773, 773, 773, 773, 773, 773, 773, 773, 773, 773, 774, 774, 774, 774, 774, 775, 775, 775, 775, 775, 775, 775, 775, 775, 775, 775, 776, 776, 776, 776, 776, 776, 776, 777, 777, 777, 777, 777, 777, 777, 777, 777, 777, 777, 778, 778, 778, 778, 778, 778, 778, 778, 778, 778, 778, 778, 778, 778, 778, 778, 778, 778, 778, 778, 778, 779, 779, 779, 779, 779, 779, 779, 779, 779, 779, 779, 779, 779, 780, 780, 780, 780, 780, 780, 780, 780, 780, 781, 781, 781, 781, 781, 781, 782, 782, 782, 782, 782, 782, 782, 782, 782, 782, 782, 782, 783, 783, 783, 783, 783, 783, 783, 783, 783, 783, 783, 784, 784, 784, 784, 784, 784, 784, 784, 784, 784, 784, 784, 784, 785, 785, 785, 785, 785, 785, 785, 785, 785, 785, 786, 786, 786, 786, 786, 786, 786, 786, 786, 786, 787, 787, 787, 787, 787, 787, 787, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 789, 789, 789, 790, 790, 790, 790, 790, 790, 790, 791, 791, 791, 791, 791, 791, 791, 791, 791, 791, 792, 792, 792, 792, 792, 792, 792, 792, 792, 792, 792, 793, 793, 793, 793, 793, 793, 793, 793, 793, 793, 793, 793, 793, 793, 793, 793, 793, 794, 794, 794, 794, 794, 794, 794, 794, 794, 794, 794, 794, 794, 795, 795, 795, 795, 795, 795, 795, 795, 795, 795, 795, 795, 796, 796, 796, 796, 796, 796, 796, 796, 796, 796, 796, 796, 796, 797, 797, 797, 798, 798, 798, 798, 798, 798, 798, 798, 798, 798, 799, 799, 799, 799, 799, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 801, 801, 801, 801, 801, 801, 801, 802, 802, 802, 802, 802, 802, 802, 802, 802, 802, 802, 802, 802, 802, 803, 803, 803, 803, 803, 803, 804, 804, 804, 804, 804, 804, 804, 804, 804, 805, 805, 805, 805, 805, 805, 805, 805, 806, 806, 806, 806, 806, 806, 806, 806, 806, 806, 806, 806, 806, 806, 807, 807, 807, 807, 807, 807, 807, 807, 807, 808, 808, 808, 808, 808, 809, 809, 810, 810, 810, 810, 810, 810, 810, 810, 811, 811, 811, 811, 811, 812, 812, 812, 812, 812, 812, 813, 813, 813, 813, 813, 813, 813, 813, 813, 813, 813, 813, 813, 814, 814, 814, 814, 814, 814, 814, 814, 814, 815, 815, 815, 815, 815, 815, 815, 815, 815, 815, 815, 815, 815, 815, 816, 816, 816, 816, 816, 816, 816, 816, 816, 816, 816, 816, 816, 816, 816, 816, 817, 817, 817, 817, 817, 817, 817, 817, 817, 817, 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, 819, 819, 819, 819, 819, 819, 819, 819, 819, 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, 821, 821, 821, 821, 821, 821, 821, 821, 821, 821, 821, 821, 821, 822, 822, 822, 822, 822, 822, 822, 822, 822, 822, 822, 823, 823, 823, 823, 823, 823, 823, 824, 824, 824, 824, 824, 825, 825, 825, 825, 826, 826, 826, 826, 826, 827, 827, 827, 827, 827, 827, 827, 827, 827, 827, 827, 827, 827, 827, 827, 827, 827, 828, 828, 828, 828, 828, 828, 828, 828, 828, 828, 828, 829, 829, 829, 829, 829, 829, 829, 829, 829, 829, 829, 829, 829, 829, 829, 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 832, 832, 832, 832, 832, 832, 832, 832, 832, 832, 832, 832, 832, 833, 833, 833, 833, 833, 833, 833, 833, 833, 833, 833, 833, 834, 834, 834, 834, 834, 834, 834, 834, 834, 835, 835, 835, 835, 835, 835, 835, 835, 835, 835, 835, 836, 836, 836, 836, 836, 836, 836, 836, 836, 836, 836, 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, 838, 838, 838, 838, 838, 838, 839, 839, 839, 839, 839, 839, 839, 839, 839, 840, 840, 840, 840, 840, 840, 840, 840, 840, 840, 841, 841, 841, 841, 841, 841, 841, 841, 841, 842, 842, 842, 842, 842, 842, 842, 842, 842, 842, 842, 842, 843, 843, 843, 843, 843, 843, 843, 843, 843, 843, 844, 844, 844, 844, 844, 844, 844, 844, 844, 844, 844, 844, 845, 845, 845, 845, 845, 845, 845, 845, 845, 845, 845, 845, 846, 846, 846, 846, 846, 846, 846, 846, 847, 847, 847, 847, 847, 847, 847, 847, 847, 847, 847, 847, 847, 847, 847, 847, 847, 847, 847, 847, 848, 848, 848, 848, 848, 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, 850, 850, 850, 850, 850, 850, 850, 850, 850, 850, 850, 850, 850, 850, 850, 850, 850, 850, 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, 852, 852, 852, 852, 852, 852, 852, 852, 852, 853, 853, 853, 853, 853, 853, 853, 853, 853, 853, 853, 853, 853, 853, 853, 853, 854, 854, 854, 854, 854, 854, 854, 854, 854, 854, 854, 854, 854, 854, 855, 855, 855, 855, 855, 855, 855, 855, 855, 856, 856, 856, 856, 856, 857, 857, 857, 857, 857, 857, 857, 857, 857, 857, 857, 857, 857, 858, 858, 858, 858, 858, 859, 859, 859, 859, 859, 859, 859, 859, 859, 859, 859, 859, 859, 859, 859, 860, 860, 860, 860, 860, 860, 860, 860, 861, 861, 861, 861, 861, 861, 861, 861, 862, 862, 862, 862, 862, 862, 862, 862, 862, 862, 862, 863, 863, 863, 863, 863, 863, 864, 864, 864, 864, 864, 864, 864, 865, 865, 865, 865, 865, 865, 865, 865, 865, 865, 865, 865, 866, 866, 866, 866, 866, 866, 866, 866, 866, 867, 867, 867, 867, 867, 867, 867, 868, 868, 868, 868, 868, 868, 868, 869, 869, 869, 869, 869, 870, 870, 870, 870, 870, 870, 870, 870, 870, 870, 870, 870, 870, 871, 871, 871, 871, 871, 871, 872, 872, 872, 872, 872, 872, 872, 873, 873, 873, 873, 873, 873, 873, 873, 873, 873, 873, 873, 873, 873, 874, 874, 874, 874, 874, 874, 874, 874, 874, 874, 874, 875, 875, 875, 875, 875, 875, 875, 875, 875, 875, 875, 875, 876, 876, 876, 876, 876, 877, 877, 877, 877, 877, 877, 877, 877, 877, 877, 877, 878, 878, 878, 878, 878, 878, 878, 878, 878, 879, 879, 879, 879, 879, 879, 879, 879, 879, 879, 880, 880, 880, 880, 880, 880, 880, 880, 880, 881, 881, 881, 881, 881, 881, 881, 881, 881, 881, 882, 882, 882, 882, 882, 882, 882, 882, 882, 883, 883, 883, 883, 883, 883, 883, 883, 883, 883, 883, 884, 884, 884, 884, 884, 884, 884, 884, 884, 884, 884, 884, 885, 885, 885, 885, 885, 885, 885, 885, 885, 885, 885, 886, 886, 886, 886, 886, 886, 887, 887, 887, 887, 887, 887, 887, 887, 887, 887, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 889, 889, 889, 889, 889, 889, 889, 889, 889, 889, 889, 889, 890, 890, 890, 890, 890, 890, 890, 890, 890, 891, 891, 891, 891, 891, 891, 891, 891, 891, 891, 891, 892, 892, 892, 892, 892, 892, 892, 892, 892, 892, 892, 892, 892, 893, 893, 893, 893, 893, 893, 893, 893, 893, 893, 893, 893, 894, 894, 894, 894, 894, 894, 894, 894, 894, 894, 894, 894, 894, 895, 895, 895, 895, 895, 895, 895, 895, 896, 896, 896, 896, 896, 896, 896, 896, 896, 896, 896, 896, 897, 897, 897, 897, 897, 897, 897, 897, 897], 1455]) == 2094\nassert my_solution.maximizeWin(*[[1051376, 1051414, 1052293, 1052600, 1053062, 1053212, 1054098, 1054109, 1054257, 1054288, 1054514, 1054610, 1054630, 1054956, 1055390, 1055462, 1055554, 1055578, 1055767, 1056065, 1056408, 1056706, 1057088, 1057618, 1057876, 1058039, 1058475, 1058501, 1059276, 1059854, 1060149, 1060483, 1060591, 1061379, 1061446, 1061536, 1062025, 1062389, 1062521, 1062700, 1062984, 1063020, 1063227, 1063409, 1063727, 1063727, 1064128, 1064224, 1064456, 1064920, 1065042, 1065175, 1065456, 1066212, 1066297, 1066614, 1067414, 1067503, 1067627, 1067744, 1067974, 1068182, 1068229, 1068615, 1069163, 1069219, 1069336, 1069345, 1069681, 1069840, 1070241, 1070508, 1070566, 1071304, 1071471, 1071670, 1071794, 1071941, 1072006, 1072431, 1073033, 1073109, 1073152, 1073536, 1073719, 1073781, 1073873, 1073915, 1073938, 1074395, 1074676, 1074862, 1075041, 1075182, 1075209, 1075797, 1076127, 1076876, 1076921, 1076929, 1077080, 1077131, 1077182, 1077449, 1077480, 1077889, 1077953, 1078122, 1078318, 1078382, 1078572, 1078576, 1078912, 1079179, 1079330, 1079662, 1079832, 1079886, 1079929, 1079984, 1080029, 1081060, 1081094, 1081145, 1081336, 1081357, 1081416, 1081549, 1081762, 1082088, 1082171, 1082632, 1082662, 1082998, 1083179, 1083183, 1083328, 1083458, 1083677, 1083685, 1083755, 1083759, 1084166, 1084294, 1084930, 1085331, 1085633, 1085796, 1085835, 1085953, 1086623, 1086663, 1086735, 1086939, 1087089, 1087459, 1087975, 1088029, 1088712, 1088797, 1089209, 1089545, 1089667, 1089754, 1089765, 1090152, 1090276, 1090408, 1090513, 1090705, 1091011, 1091022, 1091073, 1091309, 1091371, 1091737, 1091827, 1091990, 1092400, 1092528, 1092538, 1092612, 1092833, 1092840, 1092882, 1092961, 1093018, 1093187, 1093327, 1093577, 1093719, 1093721, 1093771, 1094508, 1094722, 1094809, 1095914, 1096087, 1096221, 1096390, 1096659, 1096997, 1097125, 1097207, 1098439, 1099159, 1099171, 1099192, 1099507, 1099753, 1099944, 1099988, 1100344, 1100715, 1101367, 1101727, 1102367, 1102372, 1102578, 1102886, 1103058, 1103070, 1103117, 1103446, 1103839, 1104013, 1104327, 1104730, 1104798, 1106120, 1106218, 1106270, 1106928, 1107849, 1107869, 1107895, 1108156, 1108256, 1108321, 1108362, 1108384, 1108804, 1108835, 1108908, 1108918, 1108919, 1109056, 1109109, 1109517, 1109563, 1109587, 1109699, 1109993, 1110051, 1110135, 1110767, 1110781, 1111411, 1111454, 1111473, 1111481, 1112079, 1112155, 1112326, 1112601, 1112643, 1112736, 1113029, 1113069, 1113163, 1113363, 1113580, 1113743, 1114003, 1114055, 1114076, 1114129, 1114208, 1114220, 1115333, 1116509, 1116524, 1116967, 1117046, 1117237, 1117466, 1117635, 1117977, 1118077, 1118279, 1118369, 1118495, 1118497, 1118645, 1118883, 1118891, 1119185, 1119353, 1119557, 1120106, 1120256, 1120757, 1120808, 1120917, 1120935, 1121167, 1121658, 1122111, 1122696, 1122795, 1122979, 1123794, 1123934, 1124109, 1124141, 1124642, 1124942, 1125298, 1125338, 1125436, 1126068, 1126319, 1126890, 1126939, 1127194, 1127354, 1127483, 1127497, 1127506, 1127774, 1128039, 1128072, 1128211, 1128476, 1128693, 1128712, 1128939, 1128968, 1129493, 1129599, 1129830, 1130120, 1130289, 1131301, 1131499, 1131542, 1131714, 1131951, 1132024, 1132042, 1132393, 1132808, 1133004, 1133024, 1133091, 1133395, 1133905, 1134102, 1134195, 1134197, 1134298, 1134421, 1134525, 1134633, 1135159, 1135294, 1136376, 1136600, 1136684, 1136885, 1137093, 1137158, 1137406, 1137452, 1138090, 1138218, 1138260, 1138739, 1139035, 1139132, 1139193, 1139255, 1139385, 1139506, 1139851, 1139920, 1140039, 1140160, 1140238, 1140276, 1140611, 1140810, 1140956, 1141198, 1141654, 1141821, 1142499, 1142521, 1142550, 1142851, 1143182, 1143354, 1143727, 1143798, 1144011, 1144233, 1144244, 1144266, 1144392, 1144464, 1144499, 1144552, 1144904, 1145033, 1145286, 1145502, 1145770, 1146190, 1146402, 1146815, 1146883, 1147143, 1147342, 1147342, 1147815, 1148053, 1148756, 1148794, 1149095, 1149163, 1149291, 1149485, 1149717, 1150308, 1150862, 1151029, 1152665, 1152826, 1153232, 1153269, 1153312, 1153913, 1154182, 1154245, 1154627, 1155951, 1156019, 1156483, 1156550, 1156792, 1157674, 1157805, 1157839, 1157925, 1158216, 1158840, 1159090, 1159588, 1159892, 1159969, 1160389, 1160642, 1160964, 1161377, 1161490, 1161581, 1161582, 1161655, 1161771, 1161872, 1162194, 1162434, 1162537, 1163006, 1163129, 1163146, 1163281, 1163672, 1164281, 1164466, 1164606, 1165384, 1165474, 1165643, 1165659, 1165874, 1166013, 1166119, 1166290, 1166302, 1166372, 1166391, 1166426, 1166710, 1167241, 1167459, 1167834, 1167839, 1168895, 1168943, 1169150, 1169376, 1169469, 1169965, 1170034, 1170475, 1170571, 1171414, 1171849, 1172009, 1172239, 1172345, 1172742, 1173155, 1173254, 1173320, 1173552, 1173872, 1173997, 1174597, 1174672, 1174891, 1175043, 1175344, 1175458, 1175611, 1175853, 1176086, 1176206, 1176313, 1176765, 1177167, 1177201, 1177267, 1177412, 1177576, 1177736, 1177916, 1178056, 1178284, 1179053, 1179173, 1179422, 1179577, 1180041, 1180328, 1180428, 1181041, 1181327, 1181887, 1181993, 1182103, 1182281, 1182337, 1182543, 1183037, 1184101, 1184370, 1185640, 1186191, 1186554, 1186662, 1186683, 1186896, 1187044, 1187072, 1187625, 1187984, 1188157, 1188604, 1188624, 1188797, 1188871, 1189314, 1189391, 1189401, 1189498, 1189808, 1190216, 1190266, 1190390, 1190840, 1190864, 1190984, 1191255, 1191689, 1191915, 1192375, 1192618, 1192754, 1192873, 1193098, 1193235, 1193292, 1194659, 1194791, 1195009, 1195178, 1195249, 1195661, 1196061, 1196225, 1196401, 1196653, 1196680, 1196804, 1196947, 1198789, 1199110, 1199141, 1199239, 1199247, 1200423, 1200758, 1200770, 1201014, 1201068, 1201211, 1201236, 1201360, 1201485, 1201551, 1202042, 1202087, 1202239, 1203031, 1203219, 1203520, 1203575, 1204590, 1204638, 1204796, 1205472, 1205791, 1205839, 1206369, 1206521, 1206659, 1206760, 1206908, 1207242, 1207307, 1207462, 1207849, 1208436, 1208492, 1209067, 1209146, 1209735, 1209917, 1210142, 1210295, 1210411, 1210530, 1211039, 1211191, 1211512, 1211574, 1211671, 1212644, 1212731, 1212976, 1213053, 1213288, 1213426, 1213433, 1213785, 1213991, 1214127, 1214378, 1214842, 1214863, 1215742, 1215808, 1215859, 1216057, 1216552, 1216933, 1216976, 1217237, 1217329, 1217420, 1217646, 1217791, 1218094, 1218096, 1218302, 1218361, 1218372, 1218914, 1218925, 1219193, 1219568, 1219863, 1219874, 1219992, 1220102, 1220656, 1220805, 1220861, 1220949, 1220974, 1221001, 1221005, 1221032, 1221183, 1222354, 1222395, 1223141, 1223603, 1223676, 1223689, 1224478, 1224517, 1224546, 1224555, 1224837, 1225097, 1225178, 1225472, 1225617, 1225666, 1225753, 1226204, 1226339, 1226737, 1226756, 1227072, 1227532, 1227845, 1227926, 1228635, 1228901, 1229110, 1229122, 1229821, 1230089, 1230511, 1230901, 1231440, 1231795, 1231797, 1231911, 1232612, 1232761, 1232767, 1233117, 1233129, 1233135, 1233143, 1234334, 1234361, 1234749, 1235053, 1235578, 1236074, 1236926, 1237046, 1237091, 1237156, 1237312, 1237459, 1237772, 1237823, 1237837, 1237869, 1238227, 1238705, 1238761, 1238860, 1239045, 1239619, 1239692, 1239768, 1239924, 1239967, 1240019, 1240119, 1240478, 1240702, 1240799, 1240846, 1241099, 1241129, 1241570, 1241903, 1241924, 1242502, 1242546, 1242554, 1242968, 1242987, 1243218, 1243539, 1243568, 1243989, 1244139, 1244711, 1244782, 1245017, 1245061, 1245315, 1245408, 1245568, 1245724, 1246168, 1246266, 1246538, 1246747, 1246847, 1246938, 1247060, 1247200, 1247206, 1247253, 1247663, 1247881, 1248915, 1248940, 1249000, 1249121, 1249257, 1249439, 1249641, 1249984, 1250277, 1250406, 1250615, 1250716, 1250756, 1251095, 1251164, 1251403, 1251575, 1251762, 1252505, 1252742, 1252767, 1252782, 1252846, 1252883, 1252936, 1253044, 1253223, 1253279, 1253368, 1253747, 1253760, 1253843, 1254343, 1254353, 1254591, 1254703, 1254952, 1255279, 1255303, 1255537, 1255995, 1256664, 1256730, 1256754, 1257081, 1257191, 1257196, 1257228, 1257324, 1257408, 1257563, 1257644, 1258431, 1258471, 1258652, 1258686, 1258862, 1259348, 1259469, 1259548, 1259599, 1259825, 1259833, 1259994, 1260251, 1260426, 1260553, 1260570, 1260609, 1260809, 1260972, 1261237, 1261652, 1261853, 1262025, 1262376, 1262465, 1262494, 1262841, 1263200, 1263231, 1263239, 1263515, 1263593, 1263854, 1264258, 1264319, 1264486, 1264517, 1264824, 1265182, 1265247, 1265683, 1265899, 1266226, 1266292, 1266327, 1266410, 1266977, 1267302, 1268001, 1268295, 1268945, 1269118, 1269502, 1269963, 1270365, 1270488, 1270572, 1271173, 1271452, 1271534, 1271684, 1272047, 1272506, 1272556, 1272691, 1272721, 1272754, 1272984, 1273270, 1273920, 1274075, 1274189, 1274328, 1274337, 1275040, 1275322, 1275522, 1275610, 1275646, 1275903, 1276026, 1276173, 1276377, 1277068, 1277482, 1278062, 1278082, 1278331, 1278463, 1278580, 1278625, 1279188, 1279674, 1279747, 1279884, 1281058, 1281058, 1281218, 1281313, 1281474, 1281484, 1281821, 1282266, 1282330, 1282685, 1282923, 1282967, 1283219, 1283287, 1284711, 1284808, 1285687, 1286398, 1286684, 1287116, 1287327, 1287676, 1287970, 1288246, 1288713, 1289664, 1289666, 1290055, 1290150, 1290285, 1290567, 1291199, 1291367, 1291474, 1291535, 1291639, 1291746, 1291786, 1291948, 1292136, 1292172, 1292208, 1292396, 1292459, 1292504, 1292573, 1293068, 1293421, 1293495, 1293554, 1293860, 1293901, 1294289, 1295216, 1295303, 1295727, 1295815, 1296264, 1296532, 1297035, 1297697, 1297851, 1297892, 1298292, 1298547, 1298924, 1298993, 1299081, 1299162, 1299413, 1299894, 1300196, 1300695, 1300864, 1300952, 1301012, 1301178, 1301179, 1301729, 1301864, 1301901, 1302789, 1303014, 1303402, 1303614, 1303703, 1303834, 1303941, 1304457, 1304546, 1305460, 1305526, 1305788, 1305924, 1306559, 1306585, 1306707, 1306745, 1306772, 1307314, 1307499, 1307563, 1307644, 1307872, 1308038, 1308630, 1308779, 1308830, 1308837, 1308887, 1308932, 1309094, 1309156, 1309547, 1309646, 1309665, 1309862, 1310137, 1310175, 1310398, 1310559, 1310900, 1311001, 1311178, 1311217, 1311723, 1311788, 1311793, 1311887, 1312032, 1312062, 1312082, 1312148, 1312208, 1312287, 1312410, 1312758, 1313051, 1313057, 1313147, 1313454, 1313468, 1314603, 1314697, 1314845, 1314872, 1314926, 1315735, 1315886, 1315911, 1315983, 1316203, 1316275, 1316363, 1316941, 1317869, 1318123, 1318215, 1318368, 1318718, 1318733, 1318767, 1318838, 1319012, 1319436, 1319524, 1319644, 1319766, 1320300, 1320685, 1320822, 1320866, 1321120, 1321316, 1321389, 1321829, 1322285, 1322365, 1322472, 1322504, 1322775, 1322872, 1322964, 1323023, 1323264, 1323706, 1324188, 1324781, 1324874, 1325453, 1325561, 1325633, 1325757, 1326079, 1326085, 1326172, 1326258, 1326381, 1326497, 1326679, 1326969, 1327091, 1327555, 1327681, 1327833, 1328017, 1328159, 1328210, 1328289, 1328372, 1328379, 1328738, 1328827, 1329039, 1329519, 1330007, 1330072, 1330257, 1330260, 1330701, 1330937, 1331234, 1331366, 1332610, 1333018, 1333153, 1333617, 1333822, 1333922, 1333960, 1334473, 1334579, 1334620, 1334713, 1334745, 1335188, 1335731, 1336277, 1336651, 1336758, 1336782, 1337603, 1337722, 1337758, 1338223, 1338704, 1338845, 1338858, 1339092, 1339360, 1339485, 1339760, 1339996, 1340058, 1340547, 1341601, 1341656, 1341815, 1342568, 1342605, 1342696, 1342786, 1342913, 1343432, 1343621, 1343732, 1343782, 1344417, 1344864, 1345089, 1345396, 1345910, 1346192, 1346218, 1346624, 1346930, 1347208, 1347350, 1347486, 1348270, 1348963, 1349055, 1349144, 1349491, 1349588, 1349642, 1349696, 1349739, 1349883, 1349966, 1350011, 1350592, 1350642, 1350808, 1350824, 1350919, 1351327, 1351982, 1352011, 1352141, 1352566, 1352712, 1352866, 1353038, 1353062, 1353075, 1353638, 1353813, 1354128, 1354293, 1354337, 1354574, 1354598, 1354614, 1354775, 1354999, 1355115, 1355248, 1355285, 1355320, 1355574, 1356901, 1356904, 1357147, 1357198, 1357601, 1357683, 1357717, 1357843, 1357884, 1358068, 1358118, 1358277, 1358391, 1358513, 1359271, 1359751, 1359754, 1360390, 1360519, 1360544, 1360692, 1360714, 1360866, 1361136, 1361357, 1361631, 1362038, 1362378, 1362428, 1362459, 1362707, 1363270, 1363339, 1363440, 1363495, 1363579, 1363623, 1363739, 1363883, 1364429, 1364651, 1365067, 1365358, 1365456, 1365770, 1365812, 1365883, 1366060, 1366295, 1366553, 1366869, 1366983, 1366983, 1367047, 1367334, 1367366, 1367851, 1367957, 1367993, 1368028, 1368176, 1368182, 1368306, 1368500, 1368737, 1368933, 1369098, 1369746, 1369814, 1369947, 1370717, 1370765, 1370781, 1371058, 1371079, 1371086, 1371163, 1371315, 1371341, 1372336, 1372424, 1372435, 1372632, 1372842, 1372934, 1373057, 1373336, 1374228, 1374325, 1374594, 1374855, 1375287, 1375436, 1375565, 1375702, 1375778, 1375931, 1376141, 1376627, 1376855, 1376891, 1377011, 1377515, 1377718, 1377957, 1378045, 1378127, 1378145, 1378289, 1378448, 1379116, 1379184, 1379323, 1379638, 1379713, 1379719, 1380122, 1380307, 1380328, 1380404, 1380642, 1380917, 1380985, 1381730, 1381869, 1381964, 1382101, 1382186, 1382438, 1382510, 1383035, 1383095, 1383336, 1383459, 1383592, 1384840, 1385753, 1386020, 1386352, 1386790, 1386943, 1387145, 1387152, 1387241, 1388441, 1388581, 1388734, 1389080, 1389189, 1389543, 1389849, 1389871, 1390152, 1390193, 1390989, 1391066, 1391139, 1391145, 1391475, 1391580, 1391779, 1392062, 1392165, 1392519, 1393274, 1393361, 1393433, 1393448, 1393802, 1394444, 1394487, 1394634, 1394667, 1395104, 1395152, 1395434, 1395675, 1395839, 1395967, 1396353, 1396936, 1396966, 1397029, 1397081, 1397477, 1397498, 1397620, 1397785, 1398019, 1399133, 1399672, 1400009, 1400049, 1401107, 1401199, 1401289, 1401570, 1401880, 1402113, 1402191, 1402275, 1402440, 1402516, 1402545, 1402650, 1402836, 1402845, 1403089, 1403461, 1403514, 1403648, 1403686, 1403876, 1404062, 1404130, 1404365, 1404486, 1404855, 1405023, 1405690, 1405954, 1405986, 1406021, 1406482, 1406816, 1406851, 1407312, 1407804, 1408543, 1409082, 1409851, 1410258, 1410682, 1411026, 1411063, 1411162, 1411552, 1412580, 1412649, 1412990, 1413115, 1413177, 1413517, 1413564, 1413760, 1413837, 1413965, 1414219, 1414284, 1414477, 1414596, 1414775, 1414926, 1415171, 1415775, 1415878, 1416038, 1416115, 1416168, 1416628, 1416662, 1416738, 1416801, 1417202, 1417211, 1417270, 1417539, 1417546, 1417750, 1417810, 1417926, 1418241, 1418564, 1418802, 1418863, 1418943, 1418965, 1419035, 1419100, 1419228, 1419242, 1419268, 1419268, 1419615, 1420047, 1420130, 1420215, 1421478, 1421691, 1421966, 1422500, 1422647, 1423083, 1423443, 1423770, 1424030, 1424494, 1424728, 1424815, 1425082, 1425573, 1425801, 1426574, 1426605, 1426945, 1427336, 1427604, 1427669, 1427829, 1428323, 1428610, 1428864, 1428876, 1429160, 1429178, 1429441, 1429501, 1429656, 1429863, 1429912, 1429976, 1430221, 1430461, 1430648, 1430676, 1430737, 1431205, 1431337, 1431381, 1431628, 1431739, 1432271, 1433236, 1433542, 1433601, 1433654, 1433699, 1433706, 1433824, 1434042, 1434665, 1434724, 1435372, 1435550, 1436101, 1436106, 1436274, 1436312, 1436354, 1437228, 1437456, 1437637, 1437667, 1437669, 1437680, 1437681, 1437682, 1437871, 1437949, 1438003, 1438472, 1438960, 1439068, 1439554, 1439709, 1440134, 1440203, 1440355, 1440401, 1440515, 1440733, 1440743, 1440925, 1441095, 1441927, 1442186, 1442191, 1442193, 1442599, 1442805, 1442900, 1442931, 1442960, 1443112, 1443742, 1443768, 1443888, 1444087, 1444346, 1445208, 1445529, 1445541, 1445553, 1445750, 1446008, 1446362, 1446856, 1447253, 1447944, 1448526, 1448675, 1449056, 1449189, 1449262, 1449287, 1449329, 1449438, 1449504, 1449742, 1449770, 1449901, 1450187, 1450275, 1450544, 1450720, 1450732, 1450791, 1451760, 1451841, 1452553, 1453223, 1453407, 1454838, 1455115, 1455263, 1455431, 1455772, 1455936, 1456215, 1456508, 1456559, 1457290, 1457610, 1457641, 1457956, 1458057, 1458410, 1458787, 1458954, 1459355, 1459398, 1459468, 1459526, 1459686, 1460121, 1460329, 1460596, 1460619, 1460666, 1461124, 1461432, 1461435, 1461509, 1461641, 1461929, 1462450, 1462471, 1462624, 1462641, 1462701, 1462740, 1462898, 1462992, 1463189, 1463434, 1463772, 1463914, 1464240, 1464283, 1464348, 1464355, 1464692, 1464866, 1464876, 1464912, 1465729, 1465840, 1466023, 1466035, 1466384, 1467018, 1467168, 1467176, 1467316, 1467318, 1467665, 1467939, 1468331, 1468474, 1468562, 1468615, 1468810, 1468963, 1469098, 1469290, 1469531, 1469547, 1469883, 1470093, 1470364, 1470377, 1470417, 1470425, 1470438, 1470443, 1470523, 1470975, 1471728, 1471842, 1472094, 1472101, 1472238, 1472474, 1472593, 1472604, 1472617, 1472894, 1473255, 1473266, 1473280, 1473305, 1473499, 1474027, 1474093, 1474119, 1474732, 1474896, 1475005, 1475244, 1475379, 1475757, 1476081, 1476364, 1476431, 1476436, 1476500, 1476524, 1476592, 1476820, 1477033, 1477321, 1477332, 1477564, 1478151, 1478248, 1478546, 1478547, 1478887, 1479061, 1479338, 1479546, 1480168, 1480683, 1481065, 1481101, 1481208, 1481219, 1481314, 1481768, 1481777, 1481814, 1482304, 1482455, 1482947, 1482989, 1483064, 1483478, 1484141, 1484463, 1484522, 1484944, 1485475, 1485621, 1485627, 1485809, 1485817, 1485889, 1486199, 1486330, 1486393, 1486534, 1486581, 1486842, 1486854, 1487155, 1487250, 1487620, 1487691, 1487732, 1488108, 1488186, 1488358, 1488525, 1488828, 1489310, 1489317, 1489405, 1489491, 1490014, 1490073, 1490371, 1490376, 1490924, 1491304, 1491448, 1492012, 1492091, 1492248, 1492260, 1492371, 1492464, 1492741, 1492779, 1492911, 1493011, 1493062, 1493424, 1493827, 1493850, 1494122, 1494617, 1494794, 1495344, 1495471, 1495513, 1495984, 1497009, 1497036, 1497637, 1497694, 1497704, 1497778, 1497922, 1498125, 1498281, 1498408, 1498483, 1498534, 1498838, 1499021, 1499372, 1499376, 1499410, 1499847, 1500687, 1500900, 1500931, 1501657, 1501738, 1501956, 1502102, 1502269, 1502568, 1502705, 1503470, 1503508, 1503570, 1503847, 1504597, 1504605, 1504635, 1504807, 1504825, 1505308, 1505458, 1505772, 1505904, 1506260, 1506570, 1506902, 1507063, 1507127, 1507163, 1507256, 1507334, 1507413, 1507598, 1508022, 1508045, 1508302, 1509093, 1509256, 1509365, 1510410, 1510418, 1511032, 1511114, 1511154, 1511409, 1511821, 1512030, 1512254, 1512503, 1512568, 1513096, 1513127, 1513164, 1513558, 1513567, 1514129, 1514508, 1514711, 1514881, 1515302, 1515385, 1516001, 1516121, 1516232, 1516372, 1516700, 1517372, 1517374, 1517570, 1517695, 1518473, 1518858, 1518876, 1518997, 1519352, 1519504, 1520030, 1520104, 1520165, 1520512, 1521244, 1521652, 1521670, 1521674, 1521861, 1522051, 1522122, 1522126, 1522671, 1522814, 1522825, 1523137, 1523880, 1523894, 1524019, 1524024, 1524762, 1525007, 1525164, 1525304, 1525317, 1525471, 1525788, 1526017, 1526188, 1526466, 1526740, 1527130, 1527176, 1527886, 1528136, 1528249, 1528328, 1528372, 1528455, 1528833, 1529130, 1529218, 1529814, 1530306, 1530394, 1530398, 1530869, 1531376, 1531933, 1532139, 1532362, 1532476, 1532591, 1532625, 1533259, 1533327, 1533460, 1533556, 1533598, 1533928, 1534224, 1534488, 1534505, 1534602, 1534807, 1534939, 1534991, 1535066, 1535326, 1535517, 1535670, 1535809, 1535813, 1536406, 1536555, 1537155, 1537312, 1537376, 1537504, 1537770, 1538088, 1538108, 1538147, 1538273, 1538283, 1538411, 1538594, 1538604, 1539196, 1539801, 1539814, 1539905, 1539916, 1540248, 1540420, 1540477, 1540576, 1540809, 1541113, 1541184, 1541463, 1541473, 1541540, 1541542, 1541601, 1541842, 1542092, 1542235, 1542722, 1543347, 1543653, 1543730, 1543827, 1544065, 1544099, 1544912, 1545145, 1545191, 1545380, 1546132, 1546682, 1546724, 1546759, 1546973, 1547146, 1547622, 1547879, 1548044, 1549263, 1549307, 1550180, 1550290, 1550295, 1550369, 1550449, 1550506, 1550624, 1550817, 1550920, 1550964, 1551249, 1551378, 1551629, 1551874, 1552326, 1552601, 1552974, 1553288, 1553502, 1553861, 1553974, 1554637, 1554648, 1554999, 1555434, 1555606, 1555638, 1555780, 1556083, 1556378, 1556392, 1556441, 1556536, 1556718, 1557079, 1557172, 1557250, 1558124, 1558248, 1558274, 1558291, 1558335, 1558371, 1558430, 1559172, 1559184, 1559558, 1559966, 1560180, 1560587, 1560634, 1560735, 1561585, 1562317, 1562579, 1562688, 1563286, 1563429, 1563432, 1563595, 1563614, 1564043, 1564136, 1564218, 1565326, 1565405, 1565546, 1565570, 1565735, 1565874, 1565986, 1566061, 1566232, 1566271, 1567179, 1567369, 1567567, 1567581, 1567583, 1567649, 1568162, 1568216, 1568497, 1568829, 1568838, 1569124, 1569179, 1569403, 1569632, 1569678, 1569691, 1570496, 1571043, 1571144, 1571633, 1572005, 1572109, 1572311, 1572328, 1572671, 1573172, 1573375, 1573453, 1573864, 1574174, 1574222, 1574535, 1575048, 1575472, 1575488, 1575518, 1575603, 1575696, 1576323, 1576342, 1576880, 1577243, 1577255, 1577403, 1577499, 1577551, 1577560, 1578928, 1579070, 1579123, 1579373, 1579408, 1579428, 1579565, 1579718, 1580310, 1580319, 1580405, 1580856, 1580884, 1581084, 1581287, 1581506, 1582431, 1582575, 1583089, 1583567, 1583605, 1583641, 1583846, 1584554, 1585320, 1585383, 1585424, 1585952, 1585985, 1586102, 1586112, 1586514, 1586667, 1586923, 1587320, 1587433, 1587445, 1587893, 1587964, 1588346, 1588454, 1588524, 1589463, 1589483, 1589847, 1589888, 1589915, 1590262, 1590382, 1590515, 1590655, 1590872, 1590912, 1590972, 1591037, 1591418, 1591528, 1591538, 1591996, 1592200, 1592543, 1592709, 1592875, 1593135, 1593256, 1593331, 1593604, 1593782, 1593931, 1593995, 1594150, 1594629, 1594726, 1594771, 1594819, 1594888, 1594953, 1594963, 1595117, 1595189, 1595461, 1595538, 1595765, 1596413, 1596802, 1597069, 1597221, 1598008, 1598136, 1598350, 1598481, 1598640, 1598809, 1599085, 1599267, 1599388, 1599835, 1600198, 1600274, 1600277, 1600550, 1601091, 1601267, 1601268, 1601291, 1601817, 1601904, 1601955, 1602137, 1602226, 1602326, 1602841, 1603152, 1603360, 1603466, 1603484, 1603695, 1603899, 1604263, 1604345, 1604374, 1604709], 655]) == 20\nassert my_solution.maximizeWin(*[[781574104, 781585918, 781586427, 781607305, 781697607, 781741079, 781742265, 781745787, 781760186, 781828455, 781854971, 781871730, 781908989, 782078557, 782098848, 782102640, 782102687, 782207039, 782214340, 782284871, 782293674, 782313692, 782333204, 782421578, 782423174, 782463564, 782573772, 782586667, 782628953, 782657307, 782715661, 782766910, 782786305, 782820350, 782829344, 782946494, 783030188, 783054067, 783150041, 783201308, 783214820, 783222920, 783276872, 783383676, 783414336, 783425671, 783452705, 783459950, 783511244, 783522867, 783563395, 783600961, 783643342, 783661914, 783681312, 783720966, 783790324, 783898474, 783927827, 783937125, 783974146, 783980015, 784027670, 784036379, 784059233, 784080840, 784084793, 784133517, 784165714, 784194506, 784287695, 784370531, 784377025, 784395646, 784399931, 784410113, 784412415, 784423672, 784482059, 784505208, 784517911, 784556177, 784585827, 784634204, 784658855, 784660821, 784684120, 784751395, 784784947, 784832970, 784857232, 784877728, 784881364, 784900790, 784917187, 784938835, 784955876, 784985843, 784998666, 785199250, 785203928, 785255193, 785273832, 785351874, 785363872, 785363876, 785405785, 785586436, 785719587, 785723685, 785746482, 785781794, 785783325, 785785077, 785837663, 785852043, 785929648, 785949235, 785965502, 786057783, 786108457, 786108678, 786138172, 786158645, 786174481, 786189757, 786190932, 786244441, 786251419, 786266989, 786298115, 786304082, 786335998, 786402337, 786436987, 786464537, 786550367, 786603604, 786690331, 786714076, 786722133, 786922888, 786925937, 786928025, 786945336, 787052308, 787134603, 787169783, 787224423, 787229552, 787246785, 787257358, 787321040, 787350952, 787366420, 787454908, 787456808, 787525946, 787531018, 787555212, 787736296, 787789618, 787803811, 787828723, 787887476, 787900526, 787905931, 787910617, 787951801, 787954168, 787995531, 787996824, 788042603, 788055443, 788069676, 788089994, 788188665, 788197220, 788203987, 788220622, 788262969, 788299350, 788300298, 788383654, 788487283, 788531472, 788552688, 788617031, 788648826, 788652387, 788665485, 788677725, 788708071, 788711980, 788754171, 788803403, 788816909, 788884516, 788976834, 789052540, 789074188, 789080514, 789119516, 789139302, 789241640, 789258889, 789265441, 789281733, 789282900, 789422712, 789455544, 789468867, 789493466, 789504200, 789540389, 789585962, 789589391, 789605601, 789645676, 789696163, 789705442, 789737499, 789821421, 789838699, 789855046, 789898618, 789945874, 789956511, 789995973, 789996735, 790006567, 790025543, 790131415, 790159360, 790163727, 790239388, 790255720, 790442423, 790483647, 790484664, 790504412, 790546804, 790550057, 790566856, 790572939, 790646054, 790655582, 790657219, 790660457, 790739176, 790741680, 790746461, 790753245, 790763635, 790764458, 790777647, 790778677, 790972065, 791044089, 791068920, 791095383, 791110085, 791132345, 791133158, 791155944, 791232012, 791256442, 791276552, 791294044, 791313863, 791393200, 791435325, 791465423, 791494337, 791509815, 791564374, 791566595, 791647518, 791718950, 791750717, 791769154, 791769633, 791773998, 791782203, 791793772, 791825390, 791872864, 791874082, 791934527, 791980765, 791995328, 792025597, 792038617, 792051755, 792069099, 792082987, 792092593, 792104417, 792141505, 792158531, 792167568, 792180281, 792198319, 792208060, 792248533, 792253591, 792266966, 792267898, 792269813, 792300784, 792338118, 792363653, 792363801, 792398228, 792454428, 792548368, 792567104, 792587815, 792594392, 792684873, 792689709, 792729712, 792731954, 792764283, 792801879, 792851777, 792883704, 792894714, 792950146, 793009735, 793123445, 793132651, 793159805, 793197865, 793228763, 793238282, 793243674, 793267960, 793287479, 793308936, 793374057, 793404202, 793415455, 793506537, 793537341, 793592257, 793626297, 793628387, 793703602, 793711644, 793762243, 793902788, 793908554, 793933212, 794003012, 794018082, 794035896, 794112355, 794141876, 794144822, 794177672, 794248772, 794264878, 794307634, 794312215, 794328873, 794338015, 794395198, 794487732, 794501856, 794537046, 794661717, 794674325, 794727907, 794760715, 794783080, 794796485, 794796866, 794802500, 794818122, 794860651, 794868333, 794874618, 794895585, 795092685, 795111616, 795118350, 795174530, 795195863, 795235292, 795265122, 795271156, 795284135, 795389300, 795454494, 795483808, 795577927, 795611399, 795622232, 795638633, 795650568, 795654939, 795700845, 795701018, 795716387, 795723656, 795739201, 795765891, 795808938, 795985920, 795990042, 796078054, 796172951, 796196356, 796229778, 796252516, 796253254, 796256871, 796277048, 796304478, 796330917, 796387646, 796391484, 796391753, 796446098, 796477955, 796500051, 796552883, 796632305, 796659034, 796727074, 796794112, 796845286, 796861738, 796885476, 796898002, 796922096, 796994050, 797016418, 797043244, 797067974, 797072154, 797085908, 797086191, 797145988, 797175698, 797179343, 797223925, 797244469, 797309618, 797321314, 797389515, 797405767, 797410566, 797456719, 797463081, 797493111, 797520607, 797654233, 797770978, 797779468, 797822108, 797842662, 797867407, 797883301, 798037966, 798076742, 798138064, 798144452, 798205390, 798344630, 798362690, 798371397, 798376337, 798384005, 798388523, 798392620, 798418837, 798600000, 798620491, 798627133, 798645706, 798654047, 798687485, 798719250, 798764362, 798826713, 798832846, 798897737, 798909236, 798911360, 798913965, 798916878, 798922180, 798961615, 798997728, 799016352, 799080664, 799180867, 799210023, 799226154, 799247856, 799307179, 799354588, 799416310, 799516275, 799523679, 799603072, 799650686, 799674245, 799711679, 799714029, 799785708, 799794629, 799795109, 799813984, 799848842, 799878673, 799880707, 799934660, 800010844, 800014965, 800028099, 800044441, 800159324, 800205097, 800238959, 800251237, 800360677, 800389353, 800398078, 800403847, 800484043, 800528581, 800535809, 800589087, 800618746, 800646287, 800648945, 800662679, 800706895, 800791027, 800807864, 800811451, 800819591, 800887683, 800901563, 800911963, 800924053, 800952914, 800959653, 800961269, 800966437, 801011909, 801062652, 801082929, 801092456, 801144019, 801146879, 801196182, 801234181, 801253722, 801269904, 801292912, 801315519, 801322243, 801341454, 801350126, 801353398, 801394840, 801443826, 801461770, 801491001, 801492469, 801497668, 801586464, 801590775, 801632055, 801639181, 801675165, 801734444, 801789164, 801789770, 801813326, 801832801, 801834808, 801872226, 801890143, 801904953, 801935859, 801960421, 802036519, 802044398, 802059327, 802066356, 802084122, 802117036, 802207110, 802299819, 802320963, 802329190, 802379925, 802387237, 802396171, 802408222, 802418599, 802432638, 802486035, 802498742, 802523168, 802599350, 802617409, 802620551, 802637043, 802659543, 802659970, 802670766, 802728332, 802729956, 802733110, 802760349, 802774607, 802784132, 802832005, 802841584, 802888602, 802893048, 802910545, 802925752, 802943790, 802965298, 802972667, 802999938, 803071741, 803115917, 803141672, 803196648, 803216147, 803240889, 803259448, 803388254, 803391553, 803454954, 803470993, 803551739, 803684289, 803726676, 803731979, 803733368, 803746489, 803751202, 803772874, 803784796, 803792788, 803799290, 803857886, 803905496, 803913411, 803946229, 804063152, 804083695, 804158678, 804164140, 804193835, 804203996, 804272270, 804285248, 804353284, 804436106, 804452975, 804458532, 804470419, 804506998, 804554494, 804613344, 804641909, 804642527, 804719576, 804761620, 804783147, 804790299, 804827996, 804829556, 804838295, 804885774, 804891115, 804943429, 804990183, 804991442, 805003591, 805083316, 805083853, 805104506, 805137212, 805277972, 805290205, 805304570, 805372087, 805394907, 805413944, 805522742, 805585126, 805606010, 805613420, 805638644, 805640963, 805642698, 805659777, 805713390, 805754970, 805819478, 805861689, 805865245, 805918390, 806019907, 806087753, 806146361, 806181862, 806204364, 806244279, 806269486, 806275997, 806280858, 806302978, 806304604, 806329029, 806348773, 806376737, 806385753, 806421449, 806426718, 806495604, 806511175, 806532412, 806541445, 806570772, 806627364, 806640382, 806657682, 806661280, 806681443, 806740099, 806960897, 806972550, 807014162, 807159840, 807200536, 807224367, 807231040, 807282244, 807439756, 807518850, 807566657, 807579371, 807605362, 807671325, 807716250, 807800145, 807814802, 807830467, 807841276, 807940921, 807965397, 807966716, 807971346, 808023752, 808027086, 808040496, 808091334, 808098191, 808128767, 808159047, 808311942, 808357346, 808415577, 808485601, 808507534, 808513978, 808521262, 808534081, 808542024, 808552050, 808589971, 808598635, 808620351, 808656911, 808701509, 808765988, 808867165, 808922794, 808988000, 809012989, 809031842, 809034708, 809069665, 809087146, 809099305, 809122684, 809159694, 809179604, 809226873, 809234312, 809290278, 809309161, 809368425, 809419939, 809428550, 809490088, 809498372, 809575071, 809580174, 809583566, 809605612, 809622207, 809708592, 809744199, 809756716, 809782008, 809815801, 809879012, 809892228, 809901458, 809914871, 809936228, 809983957, 809991285, 810033161, 810039992, 810089440, 810105312, 810142477, 810145367, 810175177, 810191254, 810212742, 810256736, 810269783, 810272606, 810311322, 810313945, 810321694, 810349677, 810402126, 810411722, 810477198, 810484323, 810558584, 810592317, 810612942, 810641709, 810750077, 810768086, 810770063, 810776698, 810789295, 810790893, 810808497, 810892468, 810916926, 810949655, 811052741, 811058061, 811151347, 811172996, 811184539, 811239214, 811279239, 811293635, 811317456, 811320690, 811332285, 811333664, 811352142, 811401612, 811439105, 811462800, 811466563, 811476075, 811476586, 811478945, 811542788, 811595328, 811660388, 811709214, 811751203, 811758612, 811770419, 811784323, 811800916, 811923310, 811937633, 811945459, 811979408, 811991146, 812004581, 812033206, 812069153, 812079727, 812092070, 812102071, 812164843, 812189975, 812214348, 812221441, 812244217, 812295598, 812337884, 812388777, 812439934, 812455883, 812456548, 812485960, 812494633, 812516225, 812517484, 812539926, 812583635, 812628688, 812635192, 812689520, 812692411, 812693913, 812730977, 812736469, 812739367, 812762492, 812774846, 812791705, 812809919, 812814065, 812816778, 812936002, 812947744, 812951753, 813005012, 813016725, 813074859, 813130780, 813153118, 813165685, 813197381, 813255433, 813270302, 813293661, 813299150, 813337546, 813494121, 813495640, 813527418, 813547617, 813571449, 813629528, 813633976, 813638796, 813657471, 813697917, 813768941, 813790078, 813839214, 813866390, 813888259, 814045339, 814070356, 814114573, 814139108, 814179373, 814246673, 814270404, 814285020, 814287604, 814327898, 814438631, 814448439, 814451731, 814498902, 814555750, 814569247, 814591049, 814593474, 814700390, 814741447, 814763459, 814769853, 814779436, 814786299, 814801088, 814903176, 814912313, 815011002, 815070271, 815075897, 815108600, 815198781, 815228282, 815267255, 815282321, 815306637, 815349973, 815371024, 815396343, 815516798, 815524898, 815538493, 815551725, 815590483, 815590665, 815602009, 815641735, 815644536, 815663351, 815665623, 815674725, 815718022, 815723771, 815731375, 815736257, 815784322, 815794321, 815836099, 815890837, 815924845, 815953060, 815960060, 815987387, 815994225, 816039087, 816100428, 816207591, 816264732, 816277755, 816279820, 816283084, 816431505, 816450288, 816485288, 816495992, 816519353, 816576462, 816590782, 816598284, 816704557, 816807869, 816877448, 816928779, 816989370, 816993046, 817007404, 817029673, 817050573, 817086908, 817088891, 817112362, 817122459, 817133706, 817135026, 817279564, 817309680, 817382411, 817388795, 817390150, 817394199, 817440477, 817485948, 817523716, 817538917, 817556216, 817557901, 817580715, 817588348, 817589150, 817698310, 817719044, 817732683, 817859148, 817944384, 817972311, 818013761, 818024854, 818036886, 818071542, 818138459, 818200748, 818255971, 818294651, 818304981, 818314571, 818314602, 818348430, 818446443, 818548224, 818568163, 818633205, 818699342, 818768732, 818856427, 818870951, 818931201, 818933839, 818947576, 818971654, 818993337, 819009803, 819066333, 819089062, 819104054, 819131762, 819158717, 819170100, 819176497, 819233327, 819268299, 819275245, 819320295, 819370410, 819392906, 819411008, 819448870, 819490788, 819543947, 819570575, 819578458, 819586213, 819598334, 819607217, 819670790, 819672835, 819756603, 819772671, 819806923, 819820068, 819857360, 819875013, 819923935, 820043618, 820043725, 820065965, 820075140, 820077181, 820088267, 820090610, 820106922, 820108368, 820149735, 820156879, 820161670, 820168345, 820180064, 820215919, 820306449, 820358289, 820362023, 820370680, 820390855, 820451523, 820496688, 820500151, 820567882, 820579322, 820614381, 820672318, 820743603, 820787564, 820787641, 821000385, 821011218, 821101658, 821159072, 821218615, 821223189, 821243185, 821255589, 821296031, 821376616, 821382974, 821402406, 821406740, 821452702, 821472101, 821475585, 821507448, 821574946, 821605147, 821608940, 821629828, 821654335, 821760061, 821775279, 821889300, 821898309, 821980476, 821988741, 822023820, 822058780, 822078088, 822082678, 822082991, 822112366, 822131398, 822218072, 822242230, 822339269, 822339563, 822343649, 822360409, 822393757, 822396624, 822437918, 822465259, 822491457, 822510890, 822549825, 822585892, 822747589, 822749424, 822770805, 822851444, 822851977, 822875143, 822882586, 822920711, 822937373, 822956277, 822997377, 823008288, 823038433, 823059308, 823062724, 823160207, 823168520, 823176195, 823178193, 823194725, 823200848, 823240115, 823266791, 823310434, 823347672, 823381728, 823476189, 823550306, 823576357, 823588785, 823605601, 823639914, 823640924, 823663838, 823699250, 823709226, 823715688, 823720115, 823849350, 823866541, 823914053, 824018737, 824027986, 824057853, 824080019, 824087556, 824166924, 824252629, 824262679, 824278204, 824337944, 824351363, 824403845, 824412530, 824420201, 824498351, 824525473, 824555260, 824579016, 824651089, 824663359, 824665474, 824703677, 824749011, 824758769, 824771713, 824774410, 824844501, 824881267, 824886737, 824887511, 824909594, 824913823, 824975527, 824979080, 824988871, 825022595, 825092241, 825108830, 825123260, 825148476, 825195002, 825238179, 825325539, 825361340, 825365366, 825368928, 825407252, 825459879, 825499610, 825508488, 825533983, 825577604, 825664869, 825681186, 825696455, 825708387, 825748859, 825751056, 825755926, 825832261, 825857786, 825887524, 825908749, 825912824, 825944461, 825949297, 826084079, 826117925, 826229063, 826266738, 826277132, 826371630, 826390828, 826393770, 826409490, 826419876, 826451638, 826567107, 826570076, 826598287, 826639658, 826646493, 826668487, 826689065, 826704450, 826736263, 826741863, 826777323, 826785940, 826796051, 826804556, 826856786, 826870694, 826875900, 827004266, 827028866, 827056226, 827127714, 827158609, 827176157, 827256137, 827259306, 827284233, 827400382, 827444721, 827445495, 827585754, 827641416, 827792766, 827803093, 827840977, 827849417, 827858807, 827905051, 828030524, 828054866, 828062387, 828126453, 828200974, 828220113, 828221137, 828287258, 828303597, 828326681, 828329628, 828338549, 828365470, 828367139, 828376038, 828426590, 828467036, 828476492, 828477975, 828509709, 828598241, 828616308, 828669510, 828697249, 828747060, 828751590, 828796079, 828834000, 828835853, 828856316, 828881207, 828909833, 828930111, 828955291, 828997212, 829029120, 829069109, 829091177, 829101015, 829116734, 829124930, 829183134, 829186759, 829280830, 829450566, 829455664, 829477231, 829523761, 829599728, 829613768, 829706986, 829708673, 829712728, 829736785, 829750624, 829772190, 829806817, 829850094, 829886087, 829893256, 829925360, 829936884, 829983478, 830018587, 830023282, 830115036, 830196987, 830201959, 830287593, 830324092, 830370271, 830384094, 830428021, 830482153, 830495882, 830496310, 830509288, 830525054, 830532816, 830565732, 830586212, 830629793, 830636488, 830657479, 830663470, 830681401, 830729388, 830739646, 830775315, 830806990, 830849482, 830869391, 830938250, 830996253, 831064648, 831077242, 831095414, 831140051, 831141536, 831145089, 831196924, 831230725, 831270966, 831294848, 831474969, 831483178, 831488179, 831494695, 831503906, 831584768, 831600440, 831609072, 831692526, 831710436, 831719595, 831736197, 831769288, 831814459, 831842785, 831946826, 831976997, 831981942, 831996400, 832077645, 832146906, 832147393, 832181719, 832209070, 832215683, 832222240, 832268305, 832272397, 832382572, 832390395, 832422093, 832450482, 832451223, 832487838, 832504913, 832549339, 832681229, 832699017, 832721270, 832738471, 832800255, 832802744, 832816281, 832845352, 832845849, 832870415, 832917203, 832932435, 832976359, 833094105, 833187281, 833193414, 833194370, 833197835, 833210590, 833212402, 833252444, 833258161, 833258370, 833292097, 833336848, 833392557, 833394202, 833471198, 833476700, 833493790, 833567900, 833568015, 833605192, 833641793, 833651329, 833732629, 833777369, 833831300, 833843063, 833946490, 833963731, 833980395, 834007852, 834029587, 834036100, 834042931, 834093323, 834116860, 834132152, 834137123, 834176221, 834192717, 834233184, 834261306, 834264621, 834277493, 834391392, 834421870, 834423606, 834426377, 834433061, 834451037, 834519819, 834566641, 834656929, 834687689, 834693879, 834716806, 834724248, 834742177, 834797215, 834821999, 834879338, 834886902, 834892697, 834931490, 834968243, 834994524, 835001843, 835004911, 835037411, 835052430, 835146669, 835178897, 835182053, 835187466, 835199899, 835223517, 835276366, 835326333, 835401518, 835402094, 835432097, 835461910, 835487373, 835488043, 835504412, 835535282, 835654141, 835679808, 835681644, 835703846, 835739279, 835749947, 835752451, 835760856, 835824639, 835914514, 835948741, 835978782, 835982882, 836000260, 836081487, 836100592, 836105452, 836105633, 836170816, 836187243, 836245863, 836247644, 836249285, 836259287, 836265680, 836343805, 836443858, 836573963, 836668455, 836693359, 836724097, 836738744, 836782418, 836866858, 836879905, 836935258, 836981708, 836989893, 837021177, 837064278, 837081805, 837120523, 837123514, 837173373, 837224994, 837279085, 837285824, 837355410, 837462182, 837492033, 837527537, 837531557, 837560423, 837593852, 837623118, 837732296, 837757273, 837760325, 837760651, 837785744, 837789948, 837795117, 837800364, 837810215, 837847665, 837854320, 837859975, 837911360, 837980569, 838066063, 838069303, 838081681, 838147510, 838169263, 838190736, 838198681, 838212281, 838252169, 838325339, 838335738, 838364874, 838389126, 838420028, 838431581, 838448681, 838461674, 838491063, 838640717, 838697376, 838743400, 838782240, 838809626, 838814698, 838834885, 838837666, 838856662, 838940456, 838960372, 838987734, 839042144, 839103069, 839155387, 839159171, 839196727, 839213806, 839285330, 839316964, 839341069, 839377853, 839403251, 839405469, 839427088, 839443974, 839445425, 839524194, 839574501, 839660631, 839663657, 839708828, 839722603, 839753775, 839770335, 839773869, 839827072, 839855954, 839933551, 839946776, 839950208, 839953001, 840005212, 840027496, 840034219, 840044679, 840048862, 840058524, 840111213, 840125863, 840155728, 840214494, 840292315, 840317042, 840336087, 840362136, 840459775, 840469450, 840535190, 840542395, 840565874, 840578327, 840678508, 840734849, 840752139, 840809241, 840869342, 840881516, 840882577, 840960169, 841006668, 841089244, 841152986, 841215590, 841251159, 841260028, 841279115, 841310065, 841323174, 841354275, 841373803, 841384886, 841403505, 841497957, 841549948, 841555353, 841555401, 841595970, 841631960, 841645514, 841696581, 841752034, 841832077, 841840895, 841857638, 841864260, 841930972, 842011511, 842035921, 842056733, 842066969, 842069588, 842078328, 842109449, 842120545, 842152297, 842159970, 842193203, 842322215, 842390005, 842417000, 842431300, 842458913, 842484611, 842504497, 842586189, 842604450, 842682148, 842688274, 842688320, 842728837, 842733137, 842737422, 842752305, 842753447, 842790699, 842812639, 842813787, 842818213, 842925311, 842984798, 842993801, 843016503, 843032714, 843033164, 843074705, 843084447, 843086105, 843202433, 843204523, 843212853, 843215732, 843274263, 843281819, 843340584, 843380843, 843450130, 843459560, 843494696, 843561425, 843572222, 843604517, 843686500, 843710097, 843752757, 843795554, 843834482, 843835329, 843855093, 843874262, 843877426, 843886028, 843891885, 843898323, 843972381, 843974204, 844002153, 844071571, 844149357, 844249907, 844262584, 844307894, 844367003, 844384809, 844386548, 844492093, 844497944, 844511143, 844548770, 844598311, 844607340, 844609343, 844673134, 844684615, 844790353, 844796887, 844797184, 844824590, 844885749, 844886242, 845009188, 845023824, 845066067, 845158923, 845189654, 845232329, 845234188, 845235154, 845265936, 845275116, 845285879, 845344294, 845368908, 845378915, 845458262, 845471710, 845484285, 845491410, 845520578, 845534582, 845539109, 845571618, 845572803, 845579849, 845589926, 845596620, 845608904, 845612727, 845613317, 845621646, 845664712, 845691359, 845701396, 845791817, 845794863, 845827584, 845862922, 845884490, 845893947, 845902662, 845991498, 846004131, 846090380, 846114532, 846126457, 846127249, 846171465, 846212604, 846300660, 846399424, 846409854, 846423563, 846432577, 846476091, 846485795, 846497487, 846530792, 846551985, 846584060, 846683575, 846695089, 846744277, 846748854, 846770981, 846867639, 846913568, 846933767, 846964235, 846980403, 847029995, 847084590, 847118390, 847140428, 847145131, 847176269, 847198931, 847201257, 847268898, 847374824, 847420490, 847443126, 847444159, 847448926, 847498099, 847529766, 847622436, 847649006, 847672656, 847801555, 847888427, 847923019, 847928585, 847938161, 847957808, 848035990, 848092719, 848114785, 848133640, 848215541, 848240891, 848246400, 848274878, 848325286, 848366729, 848390725, 848451093, 848451870, 848455125, 848485920, 848496496, 848530719, 848597909, 848631994, 848679909, 848724658, 848778038, 848781748, 848813024, 848818892, 848870840, 848951552, 848990435, 849001806, 849040607, 849049534, 849063217, 849099085, 849107635, 849111839, 849112551, 849156769, 849179460, 849246889, 849247722, 849248010, 849266226, 849297770, 849315435, 849332975, 849335419, 849401766, 849423441, 849424557, 849467433, 849479034, 849495670, 849499351, 849569788, 849573717, 849587367, 849625759, 849692504, 849714334, 849729672, 849748305, 849752432, 849756169, 849759791, 849778894, 849797498, 849812725, 849839559, 849858404, 849892338, 849917550, 849922931, 849934464, 849971085, 849983137, 850013758, 850064893, 850318417, 850361311, 850374387, 850499667, 850560103, 850571512, 850572913, 850588465, 850608065, 850624467, 850658994, 850685861, 850711485, 850736717, 850762884, 850774640, 850783061, 850823700, 850892848, 850904496, 851003058, 851105715, 851156452, 851156907, 851166901, 851289830, 851311183, 851329974, 851354035, 851361153, 851403246, 851419249, 851491177, 851502001, 851509767, 851519168, 851566087, 851668916, 851691778, 851766765, 851772161, 851801209, 851862935, 851882553, 851883696, 851898233, 851934993, 851951984, 851976319, 852007395, 852046338, 852064012, 852075229, 852104177, 852124620, 852151302, 852155829, 852159971, 852174294, 852198141, 852220190, 852229676, 852232982, 852290328, 852304447, 852325165, 852337154, 852362214, 852401370, 852483962, 852497137, 852524844, 852548667, 852571963, 852605983, 852690503, 852744931, 852750986, 852778299, 852808785, 852837308, 852886784, 852916217, 852939051, 852978578, 852987550, 853002655, 853016050, 853078456, 853137056, 853197223, 853300525, 853313059, 853321076, 853355982, 853446210, 853494170, 853494308, 853529117, 853564774, 853573658, 853607610, 853624398, 853705660, 853721043, 853756343, 853797971, 853811365, 853857547, 853907679, 853926894, 853930454, 853954165, 853957309, 853992876, 854027509, 854046445, 854057197, 854069116, 854084777, 854155200, 854155289, 854204481, 854225082, 854298485, 854360924, 854414629, 854442217, 854464729, 854477793, 854509763, 854536765, 854588879, 854606190, 854613802, 854652574, 854666407, 854677707, 854712575, 854718983, 854740031, 854746999, 854779246, 854824765, 854854124, 854865377, 854887000, 854896031, 854932515, 854960984, 854965384, 854982397, 855030858, 855082150, 855089066, 855116919, 855126378, 855170518, 855209587, 855369286, 855404532, 855410615, 855416634, 855458888, 855488127, 855685199, 855695609, 855765097, 855779905, 855784554, 855796009, 855851567, 855869630, 855912205, 855966106, 856054205, 856060034, 856103929, 856121640, 856144070, 856155677, 856189531, 856236222, 856243054, 856291850, 856292246, 856312865, 856326457, 856345558, 856347332, 856485538, 856513790, 856516842, 856555120, 856571841, 856745556, 856749910, 856834322, 856876689, 856879495, 856887208, 856959201, 856995782, 856996775, 857071170, 857091492, 857101530, 857127150, 857208236, 857211100, 857230548, 857258912, 857300669, 857342234, 857344998, 857350580, 857392142, 857436388, 857492425, 857600366, 857649625, 857684159, 857684246, 857794911, 857806912, 857808493, 857819064, 857916408, 857962468, 857971959, 857973874, 858016157, 858037364, 858077003, 858134644, 858150753, 858155583, 858233482, 858250235, 858314241, 858342205, 858407315, 858468586, 858512018, 858513000, 858632738, 858656421, 858662044, 858663380, 858683592, 858719988, 858780291, 858787352, 858797355, 858797509, 858808908, 858894740, 858898281, 858913501, 858914594, 858972611, 859023911, 859067155, 859143891, 859245680, 859257803, 859345378, 859346593, 859347860, 859354609, 859359677, 859395117, 859453126, 859490328, 859529568, 859549142, 859561522, 859583151, 859583896, 859597792, 859656612, 859703929, 859705596, 859721292, 859783908, 859791923, 859861226, 859876894, 859905880, 859908764, 859942110, 859946396, 860020759, 860040551, 860075100, 860123168, 860170614, 860184092, 860192999, 860222729, 860225931, 860270763, 860311847, 860323953, 860370859, 860407350, 860450084, 860454937, 860509360, 860546069, 860602243, 860602408, 860881734, 860881989, 860892822, 860906713, 860919789, 860928172, 860964890, 861033584, 861124484, 861167195, 861170946, 861209872, 861245873, 861273328, 861295629, 861299085, 861312177, 861334968, 861335555, 861338524, 861353778, 861385193, 861409631, 861409839, 861428112, 861464821, 861467551, 861470704, 861490126, 861505704, 861512831, 861547501, 861554466, 861570925, 861615939, 861620812, 861678530, 861775169, 861798611, 861833148, 861844752, 861849132, 861886214, 861935041, 861965698, 861986080, 862095077, 862142662, 862149682, 862150270, 862154645, 862158944, 862234305, 862235546, 862264278, 862279020, 862316021, 862394722, 862540863, 862568246, 862614864, 862633410, 862716411, 862726837, 862798854, 862806354, 862808120, 862822950, 862828161, 862915462, 862925714, 862951633, 862959491, 862982471, 862984922, 863034459, 863175254, 863194829, 863225402, 863229562, 863267069, 863277042, 863372185, 863393707, 863457527, 863481030, 863495163, 863632023, 863657124, 863669387, 863730001, 863752541, 863798811, 863809863, 863848901, 863921053, 863936011, 863938920, 863940491, 864034597, 864041948, 864042741, 864177566, 864212544, 864215535, 864257569, 864270617, 864306292, 864318688, 864323001, 864379086, 864389693, 864406022, 864471922, 864521009, 864630317, 864636575, 864672096, 864723051, 864723926, 864750186, 864751393, 864805642, 864809554, 864815252, 864854617, 864901303, 864939008, 864956609, 864970265, 865041179, 865071369, 865076065, 865096944, 865112188, 865128298, 865142904, 865169427, 865230158, 865236597, 865247260, 865251605, 865335931, 865352595, 865368976, 865416486, 865448094, 865479888, 865501704, 865502539, 865513622, 865589213, 865630774, 865662131, 865678135, 865678381, 865691220, 865703381, 865712922, 865909955, 865921770, 865960003, 866039886, 866055545, 866144537, 866203129, 866245434, 866288169, 866333264, 866436732, 866438861, 866466166, 866501778, 866525639, 866594912, 866642265, 866692077, 866705801, 866745317, 866766633, 866870867, 866890796, 866896497, 866990506, 867081725, 867104130, 867165695, 867170311, 867179841, 867204904, 867234696, 867243510, 867329463, 867334577, 867380995, 867386803, 867485830, 867486396, 867488381, 867488824, 867494713, 867534725, 867548607, 867569336, 867589877, 867592920, 867640028, 867640775, 867656109, 867685808, 867737280, 867770468, 867795285, 868003898, 868036088, 868065396, 868065824, 868074817, 868082764, 868091327, 868098391, 868107983, 868167704, 868179583, 868206176, 868237580, 868283949, 868322256, 868335040, 868337707, 868357845, 868430631, 868435471, 868443709, 868464118, 868471312, 868473702, 868496318, 868501998, 868512754, 868517983, 868592266, 868625168, 868693186, 868698958, 868712781, 868733240, 868811735, 868863098, 868888149, 868891169, 868902360, 868946436, 868959966, 869046030, 869064375, 869114716, 869114965, 869130815, 869290984, 869298215, 869307874, 869308877, 869333403, 869345781, 869348077, 869381042, 869448646, 869471675, 869473058, 869476189, 869499439, 869527599, 869532871, 869559277, 869580248, 869584105, 869596145, 869608379, 869608586, 869658035, 869680729, 869711087, 869831178, 869880769, 869883011, 869976473, 870041589, 870043393, 870125776, 870138640, 870156732, 870221181, 870250482, 870269176, 870295212, 870297081, 870308765, 870310379, 870389308, 870400775, 870430661, 870485379, 870500657, 870609972, 870622141, 870654134, 870693906, 870739275, 870765887, 870783031, 870804887, 870877395, 870982412, 870994137, 871072207, 871072748, 871105921, 871112979, 871126093, 871179960, 871231456, 871263164, 871466744, 871476517, 871514691, 871556595, 871558570, 871623007, 871642733, 871663604, 871696224, 871703058, 871766289, 871807458, 871857631, 871898378, 871989094, 872049577, 872056388, 872057484, 872103032, 872129649, 872189881, 872210991, 872243867, 872264833, 872315554, 872348990, 872463074, 872531361, 872536766, 872571646, 872576834, 872643453, 872686924, 872765501, 872824239, 872896564, 873025028, 873031523, 873042683, 873049273, 873249363, 873257176, 873257717, 873271961, 873278948, 873294509, 873317211, 873325027, 873371889, 873382356, 873385044, 873441655, 873449574, 873463089, 873466992, 873530186, 873532174, 873653427, 873653727, 873678854, 873681548, 873685085, 873687440, 873720478, 873756251, 873769182, 873774992, 873787455, 873796093, 873914625, 873951576, 873957923, 873990174, 873991067, 874048397, 874053790, 874120409, 874153828, 874213059, 874235884, 874245030, 874272436, 874329512, 874336085, 874397810, 874486828, 874505493, 874508510, 874603712, 874614095, 874688349, 874731120, 874779997, 874784270, 874784271, 874818749, 874828589, 874888930, 874951700, 874964982, 875022028, 875087741, 875145663, 875169006, 875185981, 875238415, 875277423, 875332355, 875336920, 875345012, 875362595, 875394666, 875400678, 875404389, 875464109], 730]) == 4\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2673", "questionFrontendId": "2555", "questionTitle": "Maximize Win From Two Segments", "stats": { "totalAccepted": "3.6K", "totalSubmission": "8.7K", "totalAcceptedRaw": 3586, "totalSubmissionRaw": 8664, "acRate": "41.4%" } }
LeetCode/2679
# Count Distinct Numbers on Board You are given a positive integer `n`, that is initially placed on a board. Every day, for `109` days, you perform the following procedure: * For each number `x` present on the board, find all numbers `1 <= i <= n` such that `x % i == 1`. * Then, place those numbers on the board. Return *the number of **distinct** integers present on the board after* `109` *days have elapsed*. **Note:** * Once a number is placed on the board, it will remain on it until the end. * `%` stands for the modulo operation. For example, `14 % 3` is `2`.   **Example 1:** ``` **Input:** n = 5 **Output:** 4 **Explanation:** Initially, 5 is present on the board. The next day, 2 and 4 will be added since 5 % 2 == 1 and 5 % 4 == 1. After that day, 3 will be added to the board because 4 % 3 == 1. At the end of a billion days, the distinct numbers on the board will be 2, 3, 4, and 5. ``` **Example 2:** ``` **Input:** n = 3 **Output:** 2 **Explanation:** Since 3 % 2 == 1, 2 will be added to the board. After a billion days, the only two distinct numbers on the board are 2 and 3. ```   **Constraints:** * `1 <= n <= 100` Please make sure your answer follows the type signature below: ```python3 class Solution: def distinctIntegers(self, n: int) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.distinctIntegers(*[5]) == 4\nassert my_solution.distinctIntegers(*[3]) == 2\nassert my_solution.distinctIntegers(*[1]) == 1\nassert my_solution.distinctIntegers(*[2]) == 1\nassert my_solution.distinctIntegers(*[4]) == 3\nassert my_solution.distinctIntegers(*[6]) == 5\nassert my_solution.distinctIntegers(*[7]) == 6\nassert my_solution.distinctIntegers(*[8]) == 7\nassert my_solution.distinctIntegers(*[9]) == 8\nassert my_solution.distinctIntegers(*[10]) == 9\nassert my_solution.distinctIntegers(*[11]) == 10\nassert my_solution.distinctIntegers(*[12]) == 11\nassert my_solution.distinctIntegers(*[13]) == 12\nassert my_solution.distinctIntegers(*[14]) == 13\nassert my_solution.distinctIntegers(*[15]) == 14\nassert my_solution.distinctIntegers(*[16]) == 15\nassert my_solution.distinctIntegers(*[17]) == 16\nassert my_solution.distinctIntegers(*[18]) == 17\nassert my_solution.distinctIntegers(*[19]) == 18\nassert my_solution.distinctIntegers(*[20]) == 19\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2679", "questionFrontendId": "2549", "questionTitle": "Count Distinct Numbers on Board", "stats": { "totalAccepted": "8.2K", "totalSubmission": "12.9K", "totalAcceptedRaw": 8160, "totalSubmissionRaw": 12868, "acRate": "63.4%" } }
LeetCode/2681
# Put Marbles in Bags You have `k` bags. You are given a **0-indexed** integer array `weights` where `weights[i]` is the weight of the `ith` marble. You are also given the integer `k.` Divide the marbles into the `k` bags according to the following rules: * No bag is empty. * If the `ith` marble and `jth` marble are in a bag, then all marbles with an index between the `ith` and `jth` indices should also be in that same bag. * If a bag consists of all the marbles with an index from `i` to `j` inclusively, then the cost of the bag is `weights[i] + weights[j]`. The **score** after distributing the marbles is the sum of the costs of all the `k` bags. Return *the **difference** between the **maximum** and **minimum** scores among marble distributions*.   **Example 1:** ``` **Input:** weights = [1,3,5,1], k = 2 **Output:** 4 **Explanation:** The distribution [1],[3,5,1] results in the minimal score of (1+1) + (3+1) = 6. The distribution [1,3],[5,1], results in the maximal score of (1+3) + (5+1) = 10. Thus, we return their difference 10 - 6 = 4. ``` **Example 2:** ``` **Input:** weights = [1, 3], k = 2 **Output:** 0 **Explanation:** The only distribution possible is [1],[3]. Since both the maximal and minimal score are the same, we return 0. ```   **Constraints:** * `1 <= k <= weights.length <= 105` * `1 <= weights[i] <= 109` Please make sure your answer follows the type signature below: ```python3 class Solution: def putMarbles(self, weights: List[int], k: int) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.putMarbles(*[[1, 3, 5, 1], 2]) == 4\nassert my_solution.putMarbles(*[[1, 3], 2]) == 0\nassert my_solution.putMarbles(*[[1, 4, 2, 5, 2], 3]) == 3\nassert my_solution.putMarbles(*[[54, 6, 34, 66, 63, 52, 39, 62, 46, 75, 28, 65, 18, 37, 18, 13, 33, 69, 19, 40, 13, 10, 43, 61, 72], 4]) == 289\nassert my_solution.putMarbles(*[[56, 41, 27, 71, 62, 57, 67, 34, 8, 71, 2, 12, 52, 1, 64, 43, 32, 42, 9, 25, 73, 29, 31], 5]) == 342\nassert my_solution.putMarbles(*[[58, 12, 11, 41, 66, 63, 14, 39, 71, 38, 16, 71, 43, 70, 27, 71, 37, 57, 12, 50, 41, 74, 31, 38, 24, 25, 24, 5, 34, 61, 9, 12, 17, 20, 5], 6]) == 454\nassert my_solution.putMarbles(*[[51, 68, 36, 67, 31, 28, 54, 75, 36, 58, 64, 46, 11, 42, 15, 63, 43, 25, 32, 3, 35, 15, 29, 48, 22, 43, 55, 8, 13, 19, 29, 6, 74, 69, 10], 2]) == 122\nassert my_solution.putMarbles(*[[25, 74, 16, 51, 12, 48, 15, 5], 1]) == 0\nassert my_solution.putMarbles(*[[24, 16, 62, 27, 8, 3, 70, 55, 13, 34, 9, 29, 10], 11]) == 168\nassert my_solution.putMarbles(*[[45, 56, 24, 8, 65, 60, 6, 13, 51, 26, 34, 46, 61, 73, 22, 27, 8, 21, 21, 44], 17]) == 286\nassert my_solution.putMarbles(*[[16, 57, 23, 2, 61, 53, 73, 66, 40, 46, 50, 33, 20, 72, 2, 59, 11], 11]) == 328\nassert my_solution.putMarbles(*[[70, 36, 18], 1]) == 0\nassert my_solution.putMarbles(*[[46, 37, 46, 17, 40, 50, 54, 11, 1, 25, 43, 21, 31, 29, 58, 49, 73, 54, 5, 52, 73, 54, 6, 22, 58, 9, 34, 21, 58, 68, 63], 30]) == 119\nassert my_solution.putMarbles(*[[1, 5, 64, 42, 40, 60, 7, 54, 25, 71, 11, 17, 2, 52, 54, 41, 1, 28, 2, 1, 68, 13, 25, 16, 26, 39, 36, 24, 13, 61, 51, 11, 3, 36, 58, 15], 17]) == 850\nassert my_solution.putMarbles(*[[67, 45, 15, 20, 36, 3, 6, 6, 27], 5]) == 178\nassert my_solution.putMarbles(*[[41, 47, 73, 6, 64, 59, 56, 48, 69, 23, 27, 49, 38, 2, 18, 20, 35, 43, 44, 48, 12, 44, 5, 6, 35, 21, 20, 75, 38, 47, 51, 71, 17, 38, 15, 62], 16]) == 846\nassert my_solution.putMarbles(*[[40, 23, 67, 10], 3]) == 27\nassert my_solution.putMarbles(*[[43, 39, 54, 14, 13, 72, 62, 61, 44, 44, 16, 62, 15, 64, 55, 5, 39, 43, 20, 22, 73, 49, 12, 9, 11, 26], 24]) == 216\nassert my_solution.putMarbles(*[[8, 50, 2, 13, 51, 72, 67, 38, 58, 63, 75, 28, 55, 11, 48], 4]) == 275\nassert my_solution.putMarbles(*[[75, 22, 56, 25, 46, 15, 9, 4, 68, 58, 26, 16, 64, 51, 33, 27, 6], 7]) == 354\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2681", "questionFrontendId": "2551", "questionTitle": "Put Marbles in Bags", "stats": { "totalAccepted": "4.2K", "totalSubmission": "7.5K", "totalAcceptedRaw": 4199, "totalSubmissionRaw": 7548, "acRate": "55.6%" } }
LeetCode/2682
# Count Increasing Quadruplets Given a **0-indexed** integer array `nums` of size `n` containing all numbers from `1` to `n`, return *the number of increasing quadruplets*. A quadruplet `(i, j, k, l)` is increasing if: * `0 <= i < j < k < l < n`, and * `nums[i] < nums[k] < nums[j] < nums[l]`.   **Example 1:** ``` **Input:** nums = [1,3,2,4,5] **Output:** 2 **Explanation:** - When i = 0, j = 1, k = 2, and l = 3, nums[i] < nums[k] < nums[j] < nums[l]. - When i = 0, j = 1, k = 2, and l = 4, nums[i] < nums[k] < nums[j] < nums[l]. There are no other quadruplets, so we return 2. ``` **Example 2:** ``` **Input:** nums = [1,2,3,4] **Output:** 0 **Explanation:** There exists only one quadruplet with i = 0, j = 1, k = 2, l = 3, but since nums[j] < nums[k], we return 0. ```   **Constraints:** * `4 <= nums.length <= 4000` * `1 <= nums[i] <= nums.length` * All the integers of `nums` are **unique**. `nums` is a permutation. Please make sure your answer follows the type signature below: ```python3 class Solution: def countQuadruplets(self, nums: List[int]) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.countQuadruplets(*[[1, 3, 2, 4, 5]]) == 2\nassert my_solution.countQuadruplets(*[[1, 2, 3, 4]]) == 0\nassert my_solution.countQuadruplets(*[[2, 5, 3, 1, 4]]) == 0\nassert my_solution.countQuadruplets(*[[1, 3, 5, 2, 4]]) == 1\nassert my_solution.countQuadruplets(*[[2, 4, 1, 3]]) == 0\nassert my_solution.countQuadruplets(*[[3, 9, 5, 4, 8, 2, 1, 10, 7, 6]]) == 7\nassert my_solution.countQuadruplets(*[[1, 7, 6, 5, 8, 3, 2, 4]]) == 4\nassert my_solution.countQuadruplets(*[[9, 8, 5, 4, 2, 1, 6, 3, 7, 10]]) == 4\nassert my_solution.countQuadruplets(*[[5, 2, 4, 1, 3]]) == 0\nassert my_solution.countQuadruplets(*[[5, 3, 2, 4, 1]]) == 0\nassert my_solution.countQuadruplets(*[[7, 2, 8, 9, 6, 4, 5, 1, 3]]) == 0\nassert my_solution.countQuadruplets(*[[4, 2, 6, 3, 5, 7, 1, 8, 10, 9]]) == 12\nassert my_solution.countQuadruplets(*[[3, 4, 6, 1, 7, 2, 8, 5, 9]]) == 11\nassert my_solution.countQuadruplets(*[[9, 5, 3, 10, 6, 2, 4, 8, 7, 1]]) == 2\nassert my_solution.countQuadruplets(*[[7, 4, 8, 9, 1, 3, 6, 2, 5]]) == 1\nassert my_solution.countQuadruplets(*[[6, 1, 3, 9, 10, 7, 4, 8, 5, 2]]) == 2\nassert my_solution.countQuadruplets(*[[1, 4, 2, 5, 3]]) == 1\nassert my_solution.countQuadruplets(*[[3, 6, 4, 5, 8, 1, 7, 2]]) == 4\nassert my_solution.countQuadruplets(*[[8, 7, 3, 4, 1, 6, 9, 5, 2]]) == 0\nassert my_solution.countQuadruplets(*[[3, 5, 1, 4, 2, 6]]) == 2\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2682", "questionFrontendId": "2552", "questionTitle": "Count Increasing Quadruplets", "stats": { "totalAccepted": "4.3K", "totalSubmission": "10.9K", "totalAcceptedRaw": 4350, "totalSubmissionRaw": 10863, "acRate": "40.0%" } }
LeetCode/2630
# Alternating Digit Sum You are given a positive integer `n`. Each digit of `n` has a sign according to the following rules: * The **most significant digit** is assigned a **positive** sign. * Each other digit has an opposite sign to its adjacent digits. Return *the sum of all digits with their corresponding sign*.   **Example 1:** ``` **Input:** n = 521 **Output:** 4 **Explanation:** (+5) + (-2) + (+1) = 4. ``` **Example 2:** ``` **Input:** n = 111 **Output:** 1 **Explanation:** (+1) + (-1) + (+1) = 1. ``` **Example 3:** ``` **Input:** n = 886996 **Output:** 0 **Explanation:** (+8) + (-8) + (+6) + (-9) + (+9) + (-6) = 0. ```   **Constraints:** * `1 <= n <= 109`   .spoilerbutton {display:block; border:dashed; padding: 0px 0px; margin:10px 0px; font-size:150%; font-weight: bold; color:#000000; background-color:cyan; outline:0; } .spoiler {overflow:hidden;} .spoiler > div {-webkit-transition: all 0s ease;-moz-transition: margin 0s ease;-o-transition: all 0s ease;transition: margin 0s ease;} .spoilerbutton[value="Show Message"] + .spoiler > div {margin-top:-500%;} .spoilerbutton[value="Hide Message"] + .spoiler {padding:5px;} Please make sure your answer follows the type signature below: ```python3 class Solution: def alternateDigitSum(self, n: int) -> int: ```
{ "code": "\nfrom typing import *\n\n#<INSERT>\n\nmy_solution = Solution()\n\nassert my_solution.alternateDigitSum(*[521]) == 4\nassert my_solution.alternateDigitSum(*[111]) == 1\nassert my_solution.alternateDigitSum(*[886996]) == 0\nassert my_solution.alternateDigitSum(*[4]) == 4\nassert my_solution.alternateDigitSum(*[2]) == 2\nassert my_solution.alternateDigitSum(*[7]) == 7\nassert my_solution.alternateDigitSum(*[8]) == 8\nassert my_solution.alternateDigitSum(*[10]) == 1\nassert my_solution.alternateDigitSum(*[1]) == 1\nassert my_solution.alternateDigitSum(*[5]) == 5\nassert my_solution.alternateDigitSum(*[72]) == 5\nassert my_solution.alternateDigitSum(*[64]) == 2\nassert my_solution.alternateDigitSum(*[25]) == -3\nassert my_solution.alternateDigitSum(*[56]) == -1\nassert my_solution.alternateDigitSum(*[18]) == -7\nassert my_solution.alternateDigitSum(*[81]) == 7\nassert my_solution.alternateDigitSum(*[26]) == -4\nassert my_solution.alternateDigitSum(*[40]) == 4\nassert my_solution.alternateDigitSum(*[58]) == -3\nassert my_solution.alternateDigitSum(*[97]) == 2\n" }
{ "programming_language": "python", "execution_language": "python", "questionId": "2630", "questionFrontendId": "2544", "questionTitle": "Alternating Digit Sum", "stats": { "totalAccepted": "33.5K", "totalSubmission": "42.2K", "totalAcceptedRaw": 33487, "totalSubmissionRaw": 42171, "acRate": "79.4%" } }