minimum-operations-to-maximize-last-elements-in-arrays

Minimum Operations to Maximize Last Elements in Arrays

Prompt:
"""
You are given two 0-indexed integer arrays, nums1 and nums2, both having length n.
You are allowed to perform a series of operations (possibly none).
In an operation, you select an index i in the range [0, n - 1] and swap the values of nums1[i] and nums2[i].
Your task is to find the minimum number of operations required to satisfy the following conditions:

nums1[n - 1] is equal to the maximum value among all elements of nums1, i.e., nums1[n - 1] = max(nums1[0], nums1[1], ..., nums1[n - 1]).
nums2[n - 1] is equal to the maximum value among all elements of nums2, i.e., nums2[n - 1] = max(nums2[0], nums2[1], ..., nums2[n - 1]).

Return an integer denoting the minimum number of operations needed to meet both conditions, or -1 if it is impossible to satisfy both conditions.

Example 1:

Input: nums1 = [1,2,7], nums2 = [4,5,3]
Output: 1
Explanation: In this example, an operation can be performed using index i = 2.
When nums1[2] and nums2[2] are swapped, nums1 becomes [1,2,3] and nums2 becomes [4,5,7].
Both conditions are now satisfied.
It can be shown that the minimum number of operations needed to be performed is 1.
So, the answer is 1.

Example 2:

Input: nums1 = [2,3,4,5,9], nums2 = [8,8,4,4,4]
Output: 2
Explanation: In this example, the following operations can be performed:
First operation using index i = 4.
When nums1[4] and nums2[4] are swapped, nums1 becomes [2,3,4,5,4], and nums2 becomes [8,8,4,4,9].
Another operation using index i = 3.
When nums1[3] and nums2[3] are swapped, nums1 becomes [2,3,4,4,4], and nums2 becomes [8,8,4,5,9].
Both conditions are now satisfied.
It can be shown that the minimum number of operations needed to be performed is 2.
So, the answer is 2.

Example 3:

Input: nums1 = [1,5,4], nums2 = [2,5,3]
Output: -1
Explanation: In this example, it is not possible to satisfy both conditions.
So, the answer is -1.

Constraints:

1 <= n == nums1.length == nums2.length <= 1000
1 <= nums1[i] <= 109
1 <= nums2[i] <= 109
"""
class Solution:
    def minOperations(self, nums1: List[int], nums2: List[int]) -> int:

You are given two 0-indexed integer arrays, nums1 and nums2, both having length n.
You are allowed to perform a series of operations (possibly none).
In an operation, you select an index i in the range [0, n - 1] and swap the values of nums1[i] and nums2[i].
Your task is to find the minimum number of operations required to satisfy the following conditions:

nums1[n - 1] is equal to the maximum value among all elements of nums1, i.e., nums1[n - 1] = max(nums1[0], nums1[1], ..., nums1[n - 1]).
nums2[n - 1] is equal to the maximum value among all elements of nums2, i.e., nums2[n - 1] = max(nums2[0], nums2[1], ..., nums2[n - 1]).

Return an integer denoting the minimum number of operations needed to meet both conditions, or -1 if it is impossible to satisfy both conditions.

Example 1:

Input: nums1 = [1,2,7], nums2 = [4,5,3]
Output: 1
Explanation: In this example, an operation can be performed using index i = 2.
When nums1[2] and nums2[2] are swapped, nums1 becomes [1,2,3] and nums2 becomes [4,5,7].
Both conditions are now satisfied.
It can be shown that the minimum number of operations needed to be performed is 1.
So, the answer is 1.

Example 2:

Input: nums1 = [2,3,4,5,9], nums2 = [8,8,4,4,4]
Output: 2
Explanation: In this example, the following operations can be performed:
First operation using index i = 4.
When nums1[4] and nums2[4] are swapped, nums1 becomes [2,3,4,5,4], and nums2 becomes [8,8,4,4,9].
Another operation using index i = 3.
When nums1[3] and nums2[3] are swapped, nums1 becomes [2,3,4,4,4], and nums2 becomes [8,8,4,5,9].
Both conditions are now satisfied.
It can be shown that the minimum number of operations needed to be performed is 2.
So, the answer is 2.

Example 3:

Input: nums1 = [1,5,4], nums2 = [2,5,3]
Output: -1
Explanation: In this example, it is not possible to satisfy both conditions.
So, the answer is -1.

Constraints:

1 <= n == nums1.length == nums2.length <= 1000
1 <= nums1[i] <= 109
1 <= nums2[i] <= 109

Please complete the code below to solve above prblem:
```python
class Solution:
    def minOperations(self, nums1: List[int], nums2: List[int]) -> int:

```

my_solution = Solution()

test_input = { "nums1": [1,2,7], "nums2": [4,5,3] }
assert my_solution.minOperations(**test_input) == 1

test_input = { "nums1": [2,3,4,5,9], "nums2": [8,8,4,4,4] }
assert my_solution.minOperations(**test_input) == 2

test_input = { "nums1": [1,5,4], "nums2": [2,5,3] }
assert my_solution.minOperations(**test_input) == -1

test_input = { "nums1": [1], "nums2": [1] }
assert my_solution.minOperations(**test_input) == 0

test_input = { "nums1": [1,2], "nums2": [2,1] }
assert my_solution.minOperations(**test_input) == 1

test_input = { "nums1": [1,1,10], "nums2": [1,5,1] }
assert my_solution.minOperations(**test_input) == 1

test_input = { "nums1": [1,4,16], "nums2": [16,16,16] }
assert my_solution.minOperations(**test_input) == 0

test_input = { "nums1": [1,5,15], "nums2": [1,1,1] }
assert my_solution.minOperations(**test_input) == 0

test_input = { "nums1": [2,5,7], "nums2": [2,2,2] }
assert my_solution.minOperations(**test_input) == 0

test_input = { "nums1": [8,9,10], "nums2": [10,9,9] }
assert my_solution.minOperations(**test_input) == 1

test_input = { "nums1": [9,14,14], "nums2": [14,11,14] }
assert my_solution.minOperations(**test_input) == 0

test_input = { "nums1": [16,16,16], "nums2": [6,7,16] }
assert my_solution.minOperations(**test_input) == 0

test_input = { "nums1": [19,7,19], "nums2": [5,19,19] }
assert my_solution.minOperations(**test_input) == 0

test_input = { "nums1": [1,1,8,9], "nums2": [1,7,1,1] }
assert my_solution.minOperations(**test_input) == 1

test_input = { "nums1": [1,5,9,9], "nums2": [9,9,8,9] }
assert my_solution.minOperations(**test_input) == 0

test_input = { "nums1": [1,7,7,7], "nums2": [7,3,3,7] }
assert my_solution.minOperations(**test_input) == 0

test_input = { "nums1": [10,18,12,12], "nums2": [19,6,5,12] }
assert my_solution.minOperations(**test_input) == -1

test_input = { "nums1": [12,9,11,12], "nums2": [3,9,9,9] }
assert my_solution.minOperations(**test_input) == 0

test_input = { "nums1": [15,54,22,54], "nums2": [54,19,54,54] }
assert my_solution.minOperations(**test_input) == 0

test_input = { "nums1": [20,20,20,20], "nums2": [5,8,19,20] }
assert my_solution.minOperations(**test_input) == 0

test_input = { "nums1": [1,3,4,6,7], "nums2": [1,1,1,1,1] }
assert my_solution.minOperations(**test_input) == 0

test_input = { "nums1": [1,11,17,1,18], "nums2": [1,1,1,18,1] }
assert my_solution.minOperations(**test_input) == 1

test_input = { "nums1": [3,3,3,14,14], "nums2": [3,3,4,3,3] }
assert my_solution.minOperations(**test_input) == 1

test_input = { "nums1": [4,4,8,4,17], "nums2": [4,8,4,14,4] }
assert my_solution.minOperations(**test_input) == 2

test_input = { "nums1": [4,12,11,11,12], "nums2": [12,6,12,12,12] }
assert my_solution.minOperations(**test_input) == 0

test_input = { "nums1": [6,21,87,63,87], "nums2": [87,87,23,63,63] }
assert my_solution.minOperations(**test_input) == 2

test_input = { "nums1": [10,6,6,6,10], "nums2": [6,6,10,10,6] }
assert my_solution.minOperations(**test_input) == 2

test_input = { "nums1": [16,12,15,15,16], "nums2": [8,16,16,15,15] }
assert my_solution.minOperations(**test_input) == 2

test_input = { "nums1": [17,3,6,6,17], "nums2": [3,17,6,14,6] }
assert my_solution.minOperations(**test_input) == 2

test_input = { "nums1": [19,13,18,18,19], "nums2": [5,13,13,13,13] }
assert my_solution.minOperations(**test_input) == 0

test_input = { "nums1": [20,20,53,20,68], "nums2": [20,28,20,61,20] }
assert my_solution.minOperations(**test_input) == 2

test_input = { "nums1": [6,6,2,4,4,6], "nums2": [1,1,6,4,4,4] }
assert my_solution.minOperations(**test_input) == 1

test_input = { "nums1": [8,6,6,6,7,8], "nums2": [5,8,8,8,7,7] }
assert my_solution.minOperations(**test_input) == 2

test_input = { "nums1": [15,1,15,6,12,15], "nums2": [1,15,2,15,15,15] }
assert my_solution.minOperations(**test_input) == 0

test_input = { "nums1": [17,13,19,9,6,14], "nums2": [17,14,15,1,19,19] }
assert my_solution.minOperations(**test_input) == -1

test_input = { "nums1": [20,8,10,12,17,20], "nums2": [7,20,20,20,20,20] }
assert my_solution.minOperations(**test_input) == 0

test_input = { "nums1": [20,18,15,11,17,20], "nums2": [7,15,13,7,20,12] }
assert my_solution.minOperations(**test_input) == -1

test_input = { "nums1": [20,20,20,20,19,20], "nums2": [3,6,7,15,20,20] }
assert my_solution.minOperations(**test_input) == 0

test_input = { "nums1": [28,43,79,32,40,3], "nums2": [95,25,74,16,82,56] }
assert my_solution.minOperations(**test_input) == -1

test_input = { "nums1": [29,81,58,99,41,36], "nums2": [15,34,47,57,31,95] }
assert my_solution.minOperations(**test_input) == -1

test_input = { "nums1": [1,1,4,1,7,1,15], "nums2": [1,1,1,4,1,9,1] }
assert my_solution.minOperations(**test_input) == 2

test_input = { "nums1": [1,4,4,4,7,4,9], "nums2": [9,9,4,6,4,9,4] }
assert my_solution.minOperations(**test_input) == 2

test_input = { "nums1": [2,88,17,88,68,68,88], "nums2": [88,16,88,68,68,68,68] }
assert my_solution.minOperations(**test_input) == 2

test_input = { "nums1": [3,3,5,3,3,3,18], "nums2": [3,4,3,11,13,14,3] }
assert my_solution.minOperations(**test_input) == 2

test_input = { "nums1": [3,41,98,71,71,71,98], "nums2": [98,98,49,71,85,94,71] }
assert my_solution.minOperations(**test_input) == 2

test_input = { "nums1": [5,5,27,53,5,59,65], "nums2": [5,16,5,5,58,5,5] }
assert my_solution.minOperations(**test_input) == 2

test_input = { "nums1": [5,6,11,11,13,11,14], "nums2": [14,14,11,11,11,14,11] }
assert my_solution.minOperations(**test_input) == 2

test_input = { "nums1": [6,5,1,10,8,4,5], "nums2": [3,8,8,3,6,1,4] }
assert my_solution.minOperations(**test_input) == -1

test_input = { "nums1": [14,3,4,4,4,4,14], "nums2": [2,14,4,4,5,12,4] }
assert my_solution.minOperations(**test_input) == 2

test_input = { "nums1": [14,28,68,68,65,67,68], "nums2": [68,68,49,64,68,67,67] }
assert my_solution.minOperations(**test_input) == 3

test_input = { "nums1": [19,19,8,9,10,13,19], "nums2": [1,5,19,19,19,13,13] }
assert my_solution.minOperations(**test_input) == 3

test_input = { "nums1": [20,6,20,20,20,20,20], "nums2": [3,20,7,9,13,14,20] }
assert my_solution.minOperations(**test_input) == 0

test_input = { "nums1": [85,85,62,85,78,84,85], "nums2": [5,37,85,76,85,85,85] }
assert my_solution.minOperations(**test_input) == 0

test_input = { "nums1": [1,2,2,2,2,2,2,10], "nums2": [10,2,2,2,7,8,9,2] }
assert my_solution.minOperations(**test_input) == 1

test_input = { "nums1": [1,9,3,3,4,9,9,9], "nums2": [9,2,9,9,9,6,8,9] }
assert my_solution.minOperations(**test_input) == 0

test_input = { "nums1": [3,3,4,3,3,3,3,8], "nums2": [3,3,3,5,7,7,8,3] }
assert my_solution.minOperations(**test_input) == 2

test_input = { "nums1": [4,8,11,19,16,16,19,19], "nums2": [19,19,19,13,16,16,16,16] }
assert my_solution.minOperations(**test_input) == 3

test_input = { "nums1": [8,20,4,9,9,4,4,20], "nums2": [9,14,10,1,1,20,16,15] }
assert my_solution.minOperations(**test_input) == 2

test_input = { "nums1": [9,9,1,2,2,6,8,9], "nums2": [1,1,9,2,2,2,2,2] }
assert my_solution.minOperations(**test_input) == 1

test_input = { "nums1": [10,4,10,9,10,10,10,10], "nums2": [4,10,9,9,9,9,9,9] }
assert my_solution.minOperations(**test_input) == 1

test_input = { "nums1": [13,95,19,56,59,95,95,95], "nums2": [95,14,95,95,95,83,88,95] }
assert my_solution.minOperations(**test_input) == 0

test_input = { "nums1": [19,7,19,8,9,15,9,19], "nums2": [7,19,7,19,9,9,18,9] }
assert my_solution.minOperations(**test_input) == 3

test_input = { "nums1": [19,19,3,3,15,16,3,19], "nums2": [2,2,3,7,3,3,17,3] }
assert my_solution.minOperations(**test_input) == 2

test_input = { "nums1": [1,8,8,5,8,8,8,7,8], "nums2": [8,2,4,8,5,6,6,8,8] }
assert my_solution.minOperations(**test_input) == 0

test_input = { "nums1": [1,10,10,5,10,8,10,10,10], "nums2": [10,2,4,10,7,8,8,8,8] }
assert my_solution.minOperations(**test_input) == 2

test_input = { "nums1": [2,7,7,7,7,7,7,17,18], "nums2": [18,7,10,11,13,15,17,7,7] }
assert my_solution.minOperations(**test_input) == 2

test_input = { "nums1": [3,13,22,24,13,13,13,81,91], "nums2": [91,13,13,13,45,59,71,13,13] }
assert my_solution.minOperations(**test_input) == 4

test_input = { "nums1": [4,4,9,4,16,4,17,4,18], "nums2": [4,8,4,14,4,16,4,18,4] }
assert my_solution.minOperations(**test_input) == 4

test_input = { "nums1": [6,9,65,13,65,65,28,28,65], "nums2": [65,65,13,65,24,27,28,34,28] }
assert my_solution.minOperations(**test_input) == 4

test_input = { "nums1": [8,3,5,6,6,3,3,3,8], "nums2": [1,3,3,3,3,7,7,8,3] }
assert my_solution.minOperations(**test_input) == 3

test_input = { "nums1": [10,1,10,10,10,9,9,9,10], "nums2": [1,10,5,6,8,9,9,10,9] }
assert my_solution.minOperations(**test_input) == 2

test_input = { "nums1": [15,15,3,5,15,15,9,13,15], "nums2": [1,2,15,15,6,8,9,9,9] }
assert my_solution.minOperations(**test_input) == 2

test_input = { "nums1": [16,3,3,7,3,11,3,3,16], "nums2": [2,3,6,3,10,3,15,16,3] }
assert my_solution.minOperations(**test_input) == 4

test_input = { "nums1": [16,3,16,7,16,16,10,10,16], "nums2": [2,16,4,16,9,10,10,13,10] }
assert my_solution.minOperations(**test_input) == 3

test_input = { "nums1": [80,80,18,39,39,62,39,39,80], "nums2": [2,10,80,39,42,39,66,66,39] }
assert my_solution.minOperations(**test_input) == 4

test_input = { "nums1": [1,1,1,1,1,1,1,7,1,9], "nums2": [9,1,3,3,3,5,5,1,9,1] }
assert my_solution.minOperations(**test_input) == 2

test_input = { "nums1": [1,2,2,2,2,5,8,2,2,9], "nums2": [9,2,2,2,4,2,2,9,9,2] }
assert my_solution.minOperations(**test_input) == 3

test_input = { "nums1": [1,2,18,18,10,18,18,17,18,18], "nums2": [18,18,5,5,18,13,14,18,18,18] }
assert my_solution.minOperations(**test_input) == 0

test_input = { "nums1": [1,3,1,1,1,1,16,16,1,19], "nums2": [1,1,7,7,9,12,1,1,18,1] }
assert my_solution.minOperations(**test_input) == 4

test_input = { "nums1": [1,9,3,9,4,5,7,8,8,9], "nums2": [9,1,9,3,9,9,7,7,7,7] }
assert my_solution.minOperations(**test_input) == 4

test_input = { "nums1": [2,2,2,2,10,11,2,2,2,20], "nums2": [2,3,9,9,2,2,12,14,19,2] }
assert my_solution.minOperations(**test_input) == 3

test_input = { "nums1": [3,15,6,7,7,10,7,7,15,15], "nums2": [15,6,15,7,9,7,12,13,7,7] }
assert my_solution.minOperations(**test_input) == 4

test_input = { "nums1": [5,20,20,8,8,12,20,19,20,20], "nums2": [20,6,7,20,20,20,15,20,20,20] }
assert my_solution.minOperations(**test_input) == 0

test_input = { "nums1": [8,8,8,8,8,8,8,8,6,8], "nums2": [1,2,3,4,4,5,5,5,8,8] }
assert my_solution.minOperations(**test_input) == 0

test_input = { "nums1": [9,3,3,3,3,6,7,7,3,9], "nums2": [3,3,4,5,5,3,3,3,7,3] }
assert my_solution.minOperations(**test_input) == 4

test_input = { "nums1": [9,8,6,2,1,10,9,7,9,4], "nums2": [6,2,8,2,5,3,6,5,6,10] }
assert my_solution.minOperations(**test_input) == -1

test_input = { "nums1": [10,2,2,2,3,2,2,2,2,10], "nums2": [1,10,2,2,2,6,6,8,10,2] }
assert my_solution.minOperations(**test_input) == 3

test_input = { "nums1": [12,19,10,4,17,12,18,6,7,7], "nums2": [20,5,15,7,10,8,2,16,14,1] }
assert my_solution.minOperations(**test_input) == -1

test_input = { "nums1": [17,31,31,34,31,42,31,65,31,89], "nums2": [89,31,32,31,37,31,45,31,84,31] }
assert my_solution.minOperations(**test_input) == 4

test_input = { "nums1": [19,7,7,19,9,19,19,19,17,19], "nums2": [6,19,19,8,19,10,10,16,19,19] }
assert my_solution.minOperations(**test_input) == 0

test_input = { "nums1": [20,20,7,20,8,11,11,11,11,20], "nums2": [5,6,20,7,20,11,15,18,20,11] }
assert my_solution.minOperations(**test_input) == 4

test_input = { "nums1": [90,7,90,13,90,33,33,83,33,90], "nums2": [6,90,13,90,22,33,62,33,86,33] }
assert my_solution.minOperations(**test_input) == 4

test_input = { "nums1": [1,1,1,1,1,10,1,15,16,17,20], "nums2": [1,2,2,9,10,1,14,1,1,1,1] }
assert my_solution.minOperations(**test_input) == 5

test_input = { "nums1": [1,1,1,1,3,1,1,6,1,1,8], "nums2": [1,1,1,3,1,3,5,1,6,7,1] }
assert my_solution.minOperations(**test_input) == 3

test_input = { "nums1": [1,2,2,6,2,2,2,2,2,2,10], "nums2": [10,2,4,2,6,6,7,8,9,9,2] }
assert my_solution.minOperations(**test_input) == 2

test_input = { "nums1": [1,2,3,20,8,8,19,19,19,20,20], "nums2": [20,20,20,5,20,20,20,19,19,19,19] }
assert my_solution.minOperations(**test_input) == 3

test_input = { "nums1": [1,2,4,9,5,9,9,6,7,6,9], "nums2": [9,9,9,4,9,5,5,6,6,7,6] }
assert my_solution.minOperations(**test_input) == 5

test_input = { "nums1": [1,7,7,7,7,7,13,16,7,19,19], "nums2": [19,7,10,11,11,12,7,7,16,7,7] }
assert my_solution.minOperations(**test_input) == 4

test_input = { "nums1": [1,10,4,10,10,10,6,10,7,9,10], "nums2": [10,3,10,5,5,6,10,7,10,9,9] }
assert my_solution.minOperations(**test_input) == 4

test_input = { "nums1": [1,20,20,7,20,20,13,17,17,19,20], "nums2": [20,2,4,20,7,7,20,20,17,17,17] }
assert my_solution.minOperations(**test_input) == 4


maximum-strong-pair-xor-ii

Maximum Strong Pair XOR II

Prompt:
"""
You are given a 0-indexed integer array nums. A pair of integers x and y is called a strong pair if it satisfies the condition:

|x - y| <= min(x, y)

You need to select two integers from nums such that they form a strong pair and their bitwise XOR is the maximum among all strong pairs in the array.
Return the maximum XOR value out of all possible strong pairs in the array nums.
Note that you can pick the same integer twice to form a pair.

Example 1:

Input: nums = [1,2,3,4,5]
Output: 7
Explanation: There are 11 strong pairs in the array nums: (1, 1), (1, 2), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (3, 5), (4, 4), (4, 5) and (5, 5).
The maximum XOR possible from these pairs is 3 XOR 4 = 7.

Example 2:

Input: nums = [10,100]
Output: 0
Explanation: There are 2 strong pairs in the array nums: (10, 10) and (100, 100).
The maximum XOR possible from these pairs is 10 XOR 10 = 0 since the pair (100, 100) also gives 100 XOR 100 = 0.

Example 3:

Input: nums = [500,520,2500,3000]
Output: 1020
Explanation: There are 6 strong pairs in the array nums: (500, 500), (500, 520), (520, 520), (2500, 2500), (2500, 3000) and (3000, 3000).
The maximum XOR possible from these pairs is 500 XOR 520 = 1020 since the only other non-zero XOR value is 2500 XOR 3000 = 636.

Constraints:

1 <= nums.length <= 5 * 104
1 <= nums[i] <= 220 - 1
"""
class Solution:
    def maximumStrongPairXor(self, nums: List[int]) -> int:

You are given a 0-indexed integer array nums. A pair of integers x and y is called a strong pair if it satisfies the condition:

|x - y| <= min(x, y)

You need to select two integers from nums such that they form a strong pair and their bitwise XOR is the maximum among all strong pairs in the array.
Return the maximum XOR value out of all possible strong pairs in the array nums.
Note that you can pick the same integer twice to form a pair.

Example 1:

Input: nums = [1,2,3,4,5]
Output: 7
Explanation: There are 11 strong pairs in the array nums: (1, 1), (1, 2), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (3, 5), (4, 4), (4, 5) and (5, 5).
The maximum XOR possible from these pairs is 3 XOR 4 = 7.

Example 2:

Input: nums = [10,100]
Output: 0
Explanation: There are 2 strong pairs in the array nums: (10, 10) and (100, 100).
The maximum XOR possible from these pairs is 10 XOR 10 = 0 since the pair (100, 100) also gives 100 XOR 100 = 0.

Example 3:

Input: nums = [500,520,2500,3000]
Output: 1020
Explanation: There are 6 strong pairs in the array nums: (500, 500), (500, 520), (520, 520), (2500, 2500), (2500, 3000) and (3000, 3000).
The maximum XOR possible from these pairs is 500 XOR 520 = 1020 since the only other non-zero XOR value is 2500 XOR 3000 = 636.

Constraints:

1 <= nums.length <= 5 * 104
1 <= nums[i] <= 220 - 1

Please complete the code below to solve above prblem:
```python
class Solution:
    def maximumStrongPairXor(self, nums: List[int]) -> int:

```

my_solution = Solution()

test_input = { "nums": [1,2,3,4,5] }
assert my_solution.maximumStrongPairXor(**test_input) == 7

test_input = { "nums": [10,100] }
assert my_solution.maximumStrongPairXor(**test_input) == 0

test_input = { "nums": [500,520,2500,3000] }
assert my_solution.maximumStrongPairXor(**test_input) == 1020

test_input = { "nums": [1] }
assert my_solution.maximumStrongPairXor(**test_input) == 0

test_input = { "nums": [2,3] }
assert my_solution.maximumStrongPairXor(**test_input) == 1

test_input = { "nums": [3,4] }
assert my_solution.maximumStrongPairXor(**test_input) == 7

test_input = { "nums": [4,5] }
assert my_solution.maximumStrongPairXor(**test_input) == 1

test_input = { "nums": [5,6] }
assert my_solution.maximumStrongPairXor(**test_input) == 3

test_input = { "nums": [1,1,1] }
assert my_solution.maximumStrongPairXor(**test_input) == 0

test_input = { "nums": [1,1,2] }
assert my_solution.maximumStrongPairXor(**test_input) == 3

test_input = { "nums": [1,1,3] }
assert my_solution.maximumStrongPairXor(**test_input) == 0

test_input = { "nums": [1,1,4] }
assert my_solution.maximumStrongPairXor(**test_input) == 0

test_input = { "nums": [1,1,5] }
assert my_solution.maximumStrongPairXor(**test_input) == 0

test_input = { "nums": [1,2,1] }
assert my_solution.maximumStrongPairXor(**test_input) == 3

test_input = { "nums": [1,2,2] }
assert my_solution.maximumStrongPairXor(**test_input) == 3

test_input = { "nums": [1,2,3] }
assert my_solution.maximumStrongPairXor(**test_input) == 3

test_input = { "nums": [1,2,4] }
assert my_solution.maximumStrongPairXor(**test_input) == 6

test_input = { "nums": [1,2,5] }
assert my_solution.maximumStrongPairXor(**test_input) == 3

test_input = { "nums": [1,3,1] }
assert my_solution.maximumStrongPairXor(**test_input) == 0

test_input = { "nums": [1,3,2] }
assert my_solution.maximumStrongPairXor(**test_input) == 3

test_input = { "nums": [1,3,3] }
assert my_solution.maximumStrongPairXor(**test_input) == 0

test_input = { "nums": [1,3,4] }
assert my_solution.maximumStrongPairXor(**test_input) == 7

test_input = { "nums": [1,3,5] }
assert my_solution.maximumStrongPairXor(**test_input) == 6

test_input = { "nums": [1,4,1] }
assert my_solution.maximumStrongPairXor(**test_input) == 0

test_input = { "nums": [1,4,2] }
assert my_solution.maximumStrongPairXor(**test_input) == 6

test_input = { "nums": [1,4,3] }
assert my_solution.maximumStrongPairXor(**test_input) == 7

test_input = { "nums": [1,4,4] }
assert my_solution.maximumStrongPairXor(**test_input) == 0

test_input = { "nums": [1,4,5] }
assert my_solution.maximumStrongPairXor(**test_input) == 1

test_input = { "nums": [1,5,1] }
assert my_solution.maximumStrongPairXor(**test_input) == 0

test_input = { "nums": [1,5,2] }
assert my_solution.maximumStrongPairXor(**test_input) == 3

test_input = { "nums": [1,5,3] }
assert my_solution.maximumStrongPairXor(**test_input) == 6

test_input = { "nums": [1,5,4] }
assert my_solution.maximumStrongPairXor(**test_input) == 1

test_input = { "nums": [1,5,5] }
assert my_solution.maximumStrongPairXor(**test_input) == 0

test_input = { "nums": [2,1,1] }
assert my_solution.maximumStrongPairXor(**test_input) == 3

test_input = { "nums": [2,1,2] }
assert my_solution.maximumStrongPairXor(**test_input) == 3

test_input = { "nums": [2,1,3] }
assert my_solution.maximumStrongPairXor(**test_input) == 3

test_input = { "nums": [2,1,4] }
assert my_solution.maximumStrongPairXor(**test_input) == 6

test_input = { "nums": [2,1,5] }
assert my_solution.maximumStrongPairXor(**test_input) == 3

test_input = { "nums": [2,2,1] }
assert my_solution.maximumStrongPairXor(**test_input) == 3

test_input = { "nums": [2,2,2] }
assert my_solution.maximumStrongPairXor(**test_input) == 0

test_input = { "nums": [2,2,3] }
assert my_solution.maximumStrongPairXor(**test_input) == 1

test_input = { "nums": [2,2,4] }
assert my_solution.maximumStrongPairXor(**test_input) == 6

test_input = { "nums": [2,2,5] }
assert my_solution.maximumStrongPairXor(**test_input) == 0

test_input = { "nums": [2,3,1] }
assert my_solution.maximumStrongPairXor(**test_input) == 3

test_input = { "nums": [2,3,2] }
assert my_solution.maximumStrongPairXor(**test_input) == 1

test_input = { "nums": [2,3,3] }
assert my_solution.maximumStrongPairXor(**test_input) == 1

test_input = { "nums": [2,3,4] }
assert my_solution.maximumStrongPairXor(**test_input) == 7

test_input = { "nums": [2,3,5] }
assert my_solution.maximumStrongPairXor(**test_input) == 6

test_input = { "nums": [2,4,1] }
assert my_solution.maximumStrongPairXor(**test_input) == 6

test_input = { "nums": [2,4,2] }
assert my_solution.maximumStrongPairXor(**test_input) == 6

test_input = { "nums": [2,4,3] }
assert my_solution.maximumStrongPairXor(**test_input) == 7

test_input = { "nums": [2,4,4] }
assert my_solution.maximumStrongPairXor(**test_input) == 6

test_input = { "nums": [2,4,5] }
assert my_solution.maximumStrongPairXor(**test_input) == 6

test_input = { "nums": [2,5,1] }
assert my_solution.maximumStrongPairXor(**test_input) == 3

test_input = { "nums": [2,5,2] }
assert my_solution.maximumStrongPairXor(**test_input) == 0

test_input = { "nums": [2,5,3] }
assert my_solution.maximumStrongPairXor(**test_input) == 6

test_input = { "nums": [2,5,4] }
assert my_solution.maximumStrongPairXor(**test_input) == 6

test_input = { "nums": [2,5,5] }
assert my_solution.maximumStrongPairXor(**test_input) == 0

test_input = { "nums": [3,1,1] }
assert my_solution.maximumStrongPairXor(**test_input) == 0

test_input = { "nums": [3,1,2] }
assert my_solution.maximumStrongPairXor(**test_input) == 3

test_input = { "nums": [3,1,3] }
assert my_solution.maximumStrongPairXor(**test_input) == 0

test_input = { "nums": [3,1,4] }
assert my_solution.maximumStrongPairXor(**test_input) == 7

test_input = { "nums": [3,1,5] }
assert my_solution.maximumStrongPairXor(**test_input) == 6

test_input = { "nums": [3,2,1] }
assert my_solution.maximumStrongPairXor(**test_input) == 3

test_input = { "nums": [3,2,2] }
assert my_solution.maximumStrongPairXor(**test_input) == 1

test_input = { "nums": [3,2,3] }
assert my_solution.maximumStrongPairXor(**test_input) == 1

test_input = { "nums": [3,2,4] }
assert my_solution.maximumStrongPairXor(**test_input) == 7

test_input = { "nums": [3,2,5] }
assert my_solution.maximumStrongPairXor(**test_input) == 6

test_input = { "nums": [3,3,1] }
assert my_solution.maximumStrongPairXor(**test_input) == 0

test_input = { "nums": [3,3,2] }
assert my_solution.maximumStrongPairXor(**test_input) == 1

test_input = { "nums": [3,3,3] }
assert my_solution.maximumStrongPairXor(**test_input) == 0

test_input = { "nums": [3,3,4] }
assert my_solution.maximumStrongPairXor(**test_input) == 7

test_input = { "nums": [3,3,5] }
assert my_solution.maximumStrongPairXor(**test_input) == 6

test_input = { "nums": [3,4,1] }
assert my_solution.maximumStrongPairXor(**test_input) == 7

test_input = { "nums": [3,4,2] }
assert my_solution.maximumStrongPairXor(**test_input) == 7

test_input = { "nums": [3,4,3] }
assert my_solution.maximumStrongPairXor(**test_input) == 7

test_input = { "nums": [3,4,4] }
assert my_solution.maximumStrongPairXor(**test_input) == 7

test_input = { "nums": [3,4,5] }
assert my_solution.maximumStrongPairXor(**test_input) == 7

test_input = { "nums": [3,5,1] }
assert my_solution.maximumStrongPairXor(**test_input) == 6

test_input = { "nums": [3,5,2] }
assert my_solution.maximumStrongPairXor(**test_input) == 6

test_input = { "nums": [3,5,3] }
assert my_solution.maximumStrongPairXor(**test_input) == 6

test_input = { "nums": [3,5,4] }
assert my_solution.maximumStrongPairXor(**test_input) == 7

test_input = { "nums": [3,5,5] }
assert my_solution.maximumStrongPairXor(**test_input) == 6

test_input = { "nums": [4,1,1] }
assert my_solution.maximumStrongPairXor(**test_input) == 0

test_input = { "nums": [4,1,2] }
assert my_solution.maximumStrongPairXor(**test_input) == 6

test_input = { "nums": [4,1,3] }
assert my_solution.maximumStrongPairXor(**test_input) == 7

test_input = { "nums": [4,1,4] }
assert my_solution.maximumStrongPairXor(**test_input) == 0

test_input = { "nums": [4,1,5] }
assert my_solution.maximumStrongPairXor(**test_input) == 1

test_input = { "nums": [4,2,1] }
assert my_solution.maximumStrongPairXor(**test_input) == 6

test_input = { "nums": [4,2,2] }
assert my_solution.maximumStrongPairXor(**test_input) == 6

test_input = { "nums": [4,2,3] }
assert my_solution.maximumStrongPairXor(**test_input) == 7

test_input = { "nums": [4,2,4] }
assert my_solution.maximumStrongPairXor(**test_input) == 6

test_input = { "nums": [4,2,5] }
assert my_solution.maximumStrongPairXor(**test_input) == 6

test_input = { "nums": [4,3,1] }
assert my_solution.maximumStrongPairXor(**test_input) == 7

test_input = { "nums": [4,3,2] }
assert my_solution.maximumStrongPairXor(**test_input) == 7

test_input = { "nums": [4,3,3] }
assert my_solution.maximumStrongPairXor(**test_input) == 7

test_input = { "nums": [4,3,4] }
assert my_solution.maximumStrongPairXor(**test_input) == 7

test_input = { "nums": [4,3,5] }
assert my_solution.maximumStrongPairXor(**test_input) == 7

test_input = { "nums": [4,4,1] }
assert my_solution.maximumStrongPairXor(**test_input) == 0

test_input = { "nums": [4,4,2] }
assert my_solution.maximumStrongPairXor(**test_input) == 6


distribute-candies-among-children-i

Distribute Candies Among Children I

Prompt:
"""
You are given two positive integers n and limit.

Return the total number of ways to distribute n candies among 3 children such that no child gets more than limit candies.

Example 1:

Input: n = 5, limit = 2
Output: 3
Explanation: There are 3 ways to distribute 5 candies such that no child gets more than 2 candies: (1, 2, 2), (2, 1, 2) and (2, 2, 1).

Example 2:

Input: n = 3, limit = 3
Output: 10
Explanation: There are 10 ways to distribute 3 candies such that no child gets more than 3 candies: (0, 0, 3), (0, 1, 2), (0, 2, 1), (0, 3, 0), (1, 0, 2), (1, 1, 1), (1, 2, 0), (2, 0, 1), (2, 1, 0) and (3, 0, 0).

Constraints:

 * 1 <= n <= 50
 * 1 <= limit <= 50
"""
class Solution:
    def distributeCandies(self, n: int, limit: int) -> int:

You are given two positive integers n and limit.

Return the total number of ways to distribute n candies among 3 children such that no child gets more than limit candies.

Example 1:

Input: n = 5, limit = 2
Output: 3
Explanation: There are 3 ways to distribute 5 candies such that no child gets more than 2 candies: (1, 2, 2), (2, 1, 2) and (2, 2, 1).

Example 2:

Input: n = 3, limit = 3
Output: 10
Explanation: There are 10 ways to distribute 3 candies such that no child gets more than 3 candies: (0, 0, 3), (0, 1, 2), (0, 2, 1), (0, 3, 0), (1, 0, 2), (1, 1, 1), (1, 2, 0), (2, 0, 1), (2, 1, 0) and (3, 0, 0).

Constraints:

 * 1 <= n <= 50
 * 1 <= limit <= 50

Please complete the code below to solve above prblem:
```python
class Solution:
    def distributeCandies(self, n: int, limit: int) -> int:

```

my_solution = Solution()

test_input = { "n": 5, "limit": 2 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 3, "limit": 3 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 1, "limit": 1 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 2 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 3 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 4 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 5 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 6 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 7 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 8 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 9 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 10 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 11 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 12 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 13 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 14 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 15 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 16 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 17 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 18 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 19 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 20 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 21 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 22 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 23 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 24 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 25 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 2, "limit": 1 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 2, "limit": 2 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 3 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 4 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 5 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 6 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 7 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 8 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 9 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 10 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 11 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 12 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 13 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 14 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 15 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 16 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 17 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 18 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 19 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 20 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 21 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 22 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 23 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 24 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 25 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 3, "limit": 1 }
assert my_solution.distributeCandies(**test_input) == 1

test_input = { "n": 3, "limit": 2 }
assert my_solution.distributeCandies(**test_input) == 7

test_input = { "n": 3, "limit": 4 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 5 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 6 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 7 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 8 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 9 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 10 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 11 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 12 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 13 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 14 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 15 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 16 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 17 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 18 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 19 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 20 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 21 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 22 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 23 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 24 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 25 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 4, "limit": 1 }
assert my_solution.distributeCandies(**test_input) == 0

test_input = { "n": 4, "limit": 2 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 4, "limit": 3 }
assert my_solution.distributeCandies(**test_input) == 12

test_input = { "n": 4, "limit": 4 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 5 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 6 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 7 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 8 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 9 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 10 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 11 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 12 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 13 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 14 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 15 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 16 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 17 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 18 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 19 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 20 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 21 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 22 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 23 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 24 }
assert my_solution.distributeCandies(**test_input) == 15


distribute-candies-among-children-ii

Distribute Candies Among Children II

Prompt:
"""
You are given two positive integers n and limit.

Return the total number of ways to distribute n candies among 3 children such that no child gets more than limit candies.

Example 1:

Input: n = 5, limit = 2
Output: 3
Explanation: There are 3 ways to distribute 5 candies such that no child gets more than 2 candies: (1, 2, 2), (2, 1, 2) and (2, 2, 1).

Example 2:

Input: n = 3, limit = 3
Output: 10
Explanation: There are 10 ways to distribute 3 candies such that no child gets more than 3 candies: (0, 0, 3), (0, 1, 2), (0, 2, 1), (0, 3, 0), (1, 0, 2), (1, 1, 1), (1, 2, 0), (2, 0, 1), (2, 1, 0) and (3, 0, 0).

Constraints:

 * 1 <= n <= 106
 * 1 <= limit <= 106
"""
class Solution:
    def distributeCandies(self, n: int, limit: int) -> int:

You are given two positive integers n and limit.

Return the total number of ways to distribute n candies among 3 children such that no child gets more than limit candies.

Example 1:

Input: n = 5, limit = 2
Output: 3
Explanation: There are 3 ways to distribute 5 candies such that no child gets more than 2 candies: (1, 2, 2), (2, 1, 2) and (2, 2, 1).

Example 2:

Input: n = 3, limit = 3
Output: 10
Explanation: There are 10 ways to distribute 3 candies such that no child gets more than 3 candies: (0, 0, 3), (0, 1, 2), (0, 2, 1), (0, 3, 0), (1, 0, 2), (1, 1, 1), (1, 2, 0), (2, 0, 1), (2, 1, 0) and (3, 0, 0).

Constraints:

 * 1 <= n <= 106
 * 1 <= limit <= 106

Please complete the code below to solve above prblem:
```python
class Solution:
    def distributeCandies(self, n: int, limit: int) -> int:

```

my_solution = Solution()

test_input = { "n": 5, "limit": 2 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 3, "limit": 3 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 1, "limit": 1 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 2 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 3 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 4 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 5 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 6 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 7 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 8 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 9 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 10 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 11 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 12 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 13 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 14 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 15 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 16 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 17 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 18 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 19 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 1, "limit": 20 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 2, "limit": 1 }
assert my_solution.distributeCandies(**test_input) == 3

test_input = { "n": 2, "limit": 2 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 3 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 4 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 5 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 6 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 7 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 8 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 9 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 10 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 11 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 12 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 13 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 14 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 15 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 16 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 17 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 18 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 19 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 2, "limit": 20 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 3, "limit": 1 }
assert my_solution.distributeCandies(**test_input) == 1

test_input = { "n": 3, "limit": 2 }
assert my_solution.distributeCandies(**test_input) == 7

test_input = { "n": 3, "limit": 4 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 5 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 6 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 7 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 8 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 9 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 10 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 11 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 12 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 13 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 14 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 15 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 16 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 17 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 18 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 19 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 3, "limit": 20 }
assert my_solution.distributeCandies(**test_input) == 10

test_input = { "n": 4, "limit": 1 }
assert my_solution.distributeCandies(**test_input) == 0

test_input = { "n": 4, "limit": 2 }
assert my_solution.distributeCandies(**test_input) == 6

test_input = { "n": 4, "limit": 3 }
assert my_solution.distributeCandies(**test_input) == 12

test_input = { "n": 4, "limit": 4 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 5 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 6 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 7 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 8 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 9 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 10 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 11 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 12 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 13 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 14 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 15 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 16 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 17 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 18 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 19 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 4, "limit": 20 }
assert my_solution.distributeCandies(**test_input) == 15

test_input = { "n": 5, "limit": 1 }
assert my_solution.distributeCandies(**test_input) == 0

test_input = { "n": 5, "limit": 3 }
assert my_solution.distributeCandies(**test_input) == 12

test_input = { "n": 5, "limit": 4 }
assert my_solution.distributeCandies(**test_input) == 18

test_input = { "n": 5, "limit": 5 }
assert my_solution.distributeCandies(**test_input) == 21

test_input = { "n": 5, "limit": 6 }
assert my_solution.distributeCandies(**test_input) == 21

test_input = { "n": 5, "limit": 7 }
assert my_solution.distributeCandies(**test_input) == 21

test_input = { "n": 5, "limit": 8 }
assert my_solution.distributeCandies(**test_input) == 21

test_input = { "n": 5, "limit": 9 }
assert my_solution.distributeCandies(**test_input) == 21

test_input = { "n": 5, "limit": 10 }
assert my_solution.distributeCandies(**test_input) == 21

test_input = { "n": 5, "limit": 11 }
assert my_solution.distributeCandies(**test_input) == 21

test_input = { "n": 5, "limit": 12 }
assert my_solution.distributeCandies(**test_input) == 21

test_input = { "n": 5, "limit": 13 }
assert my_solution.distributeCandies(**test_input) == 21

test_input = { "n": 5, "limit": 14 }
assert my_solution.distributeCandies(**test_input) == 21

test_input = { "n": 5, "limit": 15 }
assert my_solution.distributeCandies(**test_input) == 21

test_input = { "n": 5, "limit": 16 }
assert my_solution.distributeCandies(**test_input) == 21

test_input = { "n": 5, "limit": 17 }
assert my_solution.distributeCandies(**test_input) == 21

test_input = { "n": 5, "limit": 18 }
assert my_solution.distributeCandies(**test_input) == 21

test_input = { "n": 5, "limit": 19 }
assert my_solution.distributeCandies(**test_input) == 21

test_input = { "n": 5, "limit": 20 }
assert my_solution.distributeCandies(**test_input) == 21


number-of-strings-which-can-be-rearranged-to-contain-substring

Number of Strings Which Can Be Rearranged to Contain Substring

Prompt:
"""
You are given an integer n.

A string s is called good if it contains only lowercase English characters and it is possible to rearrange the characters of s such that the new string contains "leet" as a substring.

For example:

 * The string "lteer" is good because we can rearrange it to form "leetr" .
 * "letl" is not good because we cannot rearrange it to contain "leet" as a substring.

Return the total number of good strings of length n.

Since the answer may be large, return it modulo 109 + 7.

A substring is a contiguous sequence of characters within a string.

Example 1:

Input: n = 4
Output: 12
Explanation: The 12 strings which can be rearranged to have "leet" as a substring are: "eelt", "eetl", "elet", "elte", "etel", "etle", "leet", "lete", "ltee", "teel", "tele", and "tlee".

Example 2:

Input: n = 10
Output: 83943898
Explanation: The number of strings with length 10 which can be rearranged to have "leet" as a substring is 526083947580. Hence the answer is 526083947580 % (109 + 7) = 83943898.

Constraints:

 * 1 <= n <= 105
"""
class Solution:
    def stringCount(self, n: int) -> int:

You are given an integer n.

A string s is called good if it contains only lowercase English characters and it is possible to rearrange the characters of s such that the new string contains "leet" as a substring.

For example:

 * The string "lteer" is good because we can rearrange it to form "leetr" .
 * "letl" is not good because we cannot rearrange it to contain "leet" as a substring.

Return the total number of good strings of length n.

Since the answer may be large, return it modulo 109 + 7.

A substring is a contiguous sequence of characters within a string.

Example 1:

Input: n = 4
Output: 12
Explanation: The 12 strings which can be rearranged to have "leet" as a substring are: "eelt", "eetl", "elet", "elte", "etel", "etle", "leet", "lete", "ltee", "teel", "tele", and "tlee".

Example 2:

Input: n = 10
Output: 83943898
Explanation: The number of strings with length 10 which can be rearranged to have "leet" as a substring is 526083947580. Hence the answer is 526083947580 % (109 + 7) = 83943898.

Constraints:

 * 1 <= n <= 105

Please complete the code below to solve above prblem:
```python
class Solution:
    def stringCount(self, n: int) -> int:

```

my_solution = Solution()

test_input = { "n": 4 }
assert my_solution.stringCount(**test_input) == 12

test_input = { "n": 10 }
assert my_solution.stringCount(**test_input) == 83943898

test_input = { "n": 1 }
assert my_solution.stringCount(**test_input) == 0

test_input = { "n": 2 }
assert my_solution.stringCount(**test_input) == 0

test_input = { "n": 3 }
assert my_solution.stringCount(**test_input) == 0

test_input = { "n": 5 }
assert my_solution.stringCount(**test_input) == 1460

test_input = { "n": 6 }
assert my_solution.stringCount(**test_input) == 106620

test_input = { "n": 7 }
assert my_solution.stringCount(**test_input) == 6058192

test_input = { "n": 8 }
assert my_solution.stringCount(**test_input) == 295164156

test_input = { "n": 9 }
assert my_solution.stringCount(**test_input) == 947613240

test_input = { "n": 11 }
assert my_solution.stringCount(**test_input) == 795234177

test_input = { "n": 12 }
assert my_solution.stringCount(**test_input) == 55396773

test_input = { "n": 13 }
assert my_solution.stringCount(**test_input) == 968092561

test_input = { "n": 14 }
assert my_solution.stringCount(**test_input) == 715599898

test_input = { "n": 15 }
assert my_solution.stringCount(**test_input) == 430509685

test_input = { "n": 16 }
assert my_solution.stringCount(**test_input) == 462719236

test_input = { "n": 17 }
assert my_solution.stringCount(**test_input) == 155543310

test_input = { "n": 18 }
assert my_solution.stringCount(**test_input) == 159683962

test_input = { "n": 19 }
assert my_solution.stringCount(**test_input) == 808507313

test_input = { "n": 20 }
assert my_solution.stringCount(**test_input) == 291395991

test_input = { "n": 21 }
assert my_solution.stringCount(**test_input) == 461951930

test_input = { "n": 22 }
assert my_solution.stringCount(**test_input) == 871561520

test_input = { "n": 23 }
assert my_solution.stringCount(**test_input) == 993268925

test_input = { "n": 24 }
assert my_solution.stringCount(**test_input) == 871982505

test_input = { "n": 25 }
assert my_solution.stringCount(**test_input) == 935610434

test_input = { "n": 26 }
assert my_solution.stringCount(**test_input) == 867518559

test_input = { "n": 27 }
assert my_solution.stringCount(**test_input) == 3067523

test_input = { "n": 28 }
assert my_solution.stringCount(**test_input) == 716801469

test_input = { "n": 29 }
assert my_solution.stringCount(**test_input) == 452206104

test_input = { "n": 30 }
assert my_solution.stringCount(**test_input) == 52805056

test_input = { "n": 31 }
assert my_solution.stringCount(**test_input) == 61992724

test_input = { "n": 32 }
assert my_solution.stringCount(**test_input) == 76928250

test_input = { "n": 33 }
assert my_solution.stringCount(**test_input) == 257967635

test_input = { "n": 34 }
assert my_solution.stringCount(**test_input) == 549347744

test_input = { "n": 35 }
assert my_solution.stringCount(**test_input) == 290653839

test_input = { "n": 36 }
assert my_solution.stringCount(**test_input) == 123906995

test_input = { "n": 37 }
assert my_solution.stringCount(**test_input) == 41253530

test_input = { "n": 38 }
assert my_solution.stringCount(**test_input) == 828924891

test_input = { "n": 39 }
assert my_solution.stringCount(**test_input) == 60893212

test_input = { "n": 40 }
assert my_solution.stringCount(**test_input) == 618599272

test_input = { "n": 41 }
assert my_solution.stringCount(**test_input) == 840600409

test_input = { "n": 42 }
assert my_solution.stringCount(**test_input) == 995406621

test_input = { "n": 43 }
assert my_solution.stringCount(**test_input) == 991833054

test_input = { "n": 44 }
assert my_solution.stringCount(**test_input) == 403185520

test_input = { "n": 45 }
assert my_solution.stringCount(**test_input) == 904195428

test_input = { "n": 46 }
assert my_solution.stringCount(**test_input) == 643609894

test_input = { "n": 47 }
assert my_solution.stringCount(**test_input) == 177947842

test_input = { "n": 48 }
assert my_solution.stringCount(**test_input) == 826753905

test_input = { "n": 49 }
assert my_solution.stringCount(**test_input) == 855443295

test_input = { "n": 50 }
assert my_solution.stringCount(**test_input) == 232825199

test_input = { "n": 51 }
assert my_solution.stringCount(**test_input) == 227116084

test_input = { "n": 52 }
assert my_solution.stringCount(**test_input) == 417264566

test_input = { "n": 53 }
assert my_solution.stringCount(**test_input) == 468973861

test_input = { "n": 54 }
assert my_solution.stringCount(**test_input) == 999145386

test_input = { "n": 55 }
assert my_solution.stringCount(**test_input) == 721276317

test_input = { "n": 56 }
assert my_solution.stringCount(**test_input) == 385673910

test_input = { "n": 57 }
assert my_solution.stringCount(**test_input) == 7891114

test_input = { "n": 58 }
assert my_solution.stringCount(**test_input) == 85081065

test_input = { "n": 59 }
assert my_solution.stringCount(**test_input) == 194677227

test_input = { "n": 60 }
assert my_solution.stringCount(**test_input) == 759126147

test_input = { "n": 61 }
assert my_solution.stringCount(**test_input) == 273111337

test_input = { "n": 62 }
assert my_solution.stringCount(**test_input) == 166598301

test_input = { "n": 63 }
assert my_solution.stringCount(**test_input) == 955460796

test_input = { "n": 64 }
assert my_solution.stringCount(**test_input) == 685704195

test_input = { "n": 65 }
assert my_solution.stringCount(**test_input) == 821093882

test_input = { "n": 66 }
assert my_solution.stringCount(**test_input) == 172674695

test_input = { "n": 67 }
assert my_solution.stringCount(**test_input) == 464621746

test_input = { "n": 68 }
assert my_solution.stringCount(**test_input) == 432202634

test_input = { "n": 69 }
assert my_solution.stringCount(**test_input) == 465445347

test_input = { "n": 70 }
assert my_solution.stringCount(**test_input) == 654273613

test_input = { "n": 71 }
assert my_solution.stringCount(**test_input) == 366864502

test_input = { "n": 72 }
assert my_solution.stringCount(**test_input) == 124689502

test_input = { "n": 73 }
assert my_solution.stringCount(**test_input) == 419691288

test_input = { "n": 74 }
assert my_solution.stringCount(**test_input) == 987033948

test_input = { "n": 75 }
assert my_solution.stringCount(**test_input) == 842828500

test_input = { "n": 76 }
assert my_solution.stringCount(**test_input) == 409614634

test_input = { "n": 77 }
assert my_solution.stringCount(**test_input) == 73844796

test_input = { "n": 78 }
assert my_solution.stringCount(**test_input) == 584672527

test_input = { "n": 79 }
assert my_solution.stringCount(**test_input) == 113476429

test_input = { "n": 80 }
assert my_solution.stringCount(**test_input) == 974106352

test_input = { "n": 81 }
assert my_solution.stringCount(**test_input) == 646239862

test_input = { "n": 82 }
assert my_solution.stringCount(**test_input) == 420253116

test_input = { "n": 83 }
assert my_solution.stringCount(**test_input) == 817573615

test_input = { "n": 84 }
assert my_solution.stringCount(**test_input) == 471199144

test_input = { "n": 85 }
assert my_solution.stringCount(**test_input) == 567239979

test_input = { "n": 86 }
assert my_solution.stringCount(**test_input) == 221534816

test_input = { "n": 87 }
assert my_solution.stringCount(**test_input) == 707218848

test_input = { "n": 88 }
assert my_solution.stringCount(**test_input) == 687360104

test_input = { "n": 89 }
assert my_solution.stringCount(**test_input) == 551986596

test_input = { "n": 90 }
assert my_solution.stringCount(**test_input) == 122933939

test_input = { "n": 91 }
assert my_solution.stringCount(**test_input) == 427294641

test_input = { "n": 92 }
assert my_solution.stringCount(**test_input) == 14022454

test_input = { "n": 93 }
assert my_solution.stringCount(**test_input) == 568729284

test_input = { "n": 94 }
assert my_solution.stringCount(**test_input) == 653568519

test_input = { "n": 95 }
assert my_solution.stringCount(**test_input) == 15509440

test_input = { "n": 96 }
assert my_solution.stringCount(**test_input) == 991824044

test_input = { "n": 97 }
assert my_solution.stringCount(**test_input) == 690441338

test_input = { "n": 98 }
assert my_solution.stringCount(**test_input) == 600462833

test_input = { "n": 99 }
assert my_solution.stringCount(**test_input) == 880019356

test_input = { "n": 100 }
assert my_solution.stringCount(**test_input) == 86731066


maximum-spending-after-buying-items

Maximum Spending After Buying Items

Prompt:
"""
You are given a 0-indexed m * n integer matrix values, representing the values of m * n different items in m different shops. Each shop has n items where the jth item in the ith shop has a value of values[i][j]. Additionally, the items in the ith shop are sorted in non-increasing order of value. That is, values[i][j] >= values[i][j + 1] for all 0 <= j < n - 1.

On each day, you would like to buy a single item from one of the shops. Specifically, On the dth day you can:

 * Pick any shop i.
 * Buy the rightmost available item j for the price of values[i][j] * d. That is, find the greatest index j such that item j was never bought before, and buy it for the price of values[i][j] * d.

Note that all items are pairwise different. For example, if you have bought item 0 from shop 1, you can still buy item 0 from any other shop.

Return the maximum amount of money that can be spent on buying all m * n products.

Example 1:

Input: values = [[8,5,2],[6,4,1],[9,7,3]]
Output: 285
Explanation: On the first day, we buy product 2 from shop 1 for a price of values[1][2] * 1 = 1.
On the second day, we buy product 2 from shop 0 for a price of values[0][2] * 2 = 4.
On the third day, we buy product 2 from shop 2 for a price of values[2][2] * 3 = 9.
On the fourth day, we buy product 1 from shop 1 for a price of values[1][1] * 4 = 16.
On the fifth day, we buy product 1 from shop 0 for a price of values[0][1] * 5 = 25.
On the sixth day, we buy product 0 from shop 1 for a price of values[1][0] * 6 = 36.
On the seventh day, we buy product 1 from shop 2 for a price of values[2][1] * 7 = 49.
On the eighth day, we buy product 0 from shop 0 for a price of values[0][0] * 8 = 64.
On the ninth day, we buy product 0 from shop 2 for a price of values[2][0] * 9 = 81.
Hence, our total spending is equal to 285.
It can be shown that 285 is the maximum amount of money that can be spent buying all m * n products.

Example 2:

Input: values = [[10,8,6,4,2],[9,7,5,3,2]]
Output: 386
Explanation: On the first day, we buy product 4 from shop 0 for a price of values[0][4] * 1 = 2.
On the second day, we buy product 4 from shop 1 for a price of values[1][4] * 2 = 4.
On the third day, we buy product 3 from shop 1 for a price of values[1][3] * 3 = 9.
On the fourth day, we buy product 3 from shop 0 for a price of values[0][3] * 4 = 16.
On the fifth day, we buy product 2 from shop 1 for a price of values[1][2] * 5 = 25.
On the sixth day, we buy product 2 from shop 0 for a price of values[0][2] * 6 = 36.
On the seventh day, we buy product 1 from shop 1 for a price of values[1][1] * 7 = 49.
On the eighth day, we buy product 1 from shop 0 for a price of values[0][1] * 8 = 64
On the ninth day, we buy product 0 from shop 1 for a price of values[1][0] * 9 = 81.
On the tenth day, we buy product 0 from shop 0 for a price of values[0][0] * 10 = 100.
Hence, our total spending is equal to 386.
It can be shown that 386 is the maximum amount of money that can be spent buying all m * n products.

Constraints:

 * 1 <= m == values.length <= 10
 * 1 <= n == values[i].length <= 104
 * 1 <= values[i][j] <= 106
 * values[i] are sorted in non-increasing order.
"""
class Solution:
    def maxSpending(self, values: List[List[int]]) -> int:

You are given a 0-indexed m * n integer matrix values, representing the values of m * n different items in m different shops. Each shop has n items where the jth item in the ith shop has a value of values[i][j]. Additionally, the items in the ith shop are sorted in non-increasing order of value. That is, values[i][j] >= values[i][j + 1] for all 0 <= j < n - 1.

On each day, you would like to buy a single item from one of the shops. Specifically, On the dth day you can:

 * Pick any shop i.
 * Buy the rightmost available item j for the price of values[i][j] * d. That is, find the greatest index j such that item j was never bought before, and buy it for the price of values[i][j] * d.

Note that all items are pairwise different. For example, if you have bought item 0 from shop 1, you can still buy item 0 from any other shop.

Return the maximum amount of money that can be spent on buying all m * n products.

Example 1:

Input: values = [[8,5,2],[6,4,1],[9,7,3]]
Output: 285
Explanation: On the first day, we buy product 2 from shop 1 for a price of values[1][2] * 1 = 1.
On the second day, we buy product 2 from shop 0 for a price of values[0][2] * 2 = 4.
On the third day, we buy product 2 from shop 2 for a price of values[2][2] * 3 = 9.
On the fourth day, we buy product 1 from shop 1 for a price of values[1][1] * 4 = 16.
On the fifth day, we buy product 1 from shop 0 for a price of values[0][1] * 5 = 25.
On the sixth day, we buy product 0 from shop 1 for a price of values[1][0] * 6 = 36.
On the seventh day, we buy product 1 from shop 2 for a price of values[2][1] * 7 = 49.
On the eighth day, we buy product 0 from shop 0 for a price of values[0][0] * 8 = 64.
On the ninth day, we buy product 0 from shop 2 for a price of values[2][0] * 9 = 81.
Hence, our total spending is equal to 285.
It can be shown that 285 is the maximum amount of money that can be spent buying all m * n products.

Example 2:

Input: values = [[10,8,6,4,2],[9,7,5,3,2]]
Output: 386
Explanation: On the first day, we buy product 4 from shop 0 for a price of values[0][4] * 1 = 2.
On the second day, we buy product 4 from shop 1 for a price of values[1][4] * 2 = 4.
On the third day, we buy product 3 from shop 1 for a price of values[1][3] * 3 = 9.
On the fourth day, we buy product 3 from shop 0 for a price of values[0][3] * 4 = 16.
On the fifth day, we buy product 2 from shop 1 for a price of values[1][2] * 5 = 25.
On the sixth day, we buy product 2 from shop 0 for a price of values[0][2] * 6 = 36.
On the seventh day, we buy product 1 from shop 1 for a price of values[1][1] * 7 = 49.
On the eighth day, we buy product 1 from shop 0 for a price of values[0][1] * 8 = 64
On the ninth day, we buy product 0 from shop 1 for a price of values[1][0] * 9 = 81.
On the tenth day, we buy product 0 from shop 0 for a price of values[0][0] * 10 = 100.
Hence, our total spending is equal to 386.
It can be shown that 386 is the maximum amount of money that can be spent buying all m * n products.

Constraints:

 * 1 <= m == values.length <= 10
 * 1 <= n == values[i].length <= 104
 * 1 <= values[i][j] <= 106
 * values[i] are sorted in non-increasing order.

Please complete the code below to solve above prblem:
```python
class Solution:
    def maxSpending(self, values: List[List[int]]) -> int:

```

my_solution = Solution()

test_input = { "values": [[8,5,2],[6,4,1],[9,7,3]] }
assert my_solution.maxSpending(**test_input) == 285

test_input = { "values": [[10,8,6,4,2],[9,7,5,3,2]] }
assert my_solution.maxSpending(**test_input) == 386

test_input = { "values": [[1000000]] }
assert my_solution.maxSpending(**test_input) == 1000000

test_input = { "values": [[1]] }
assert my_solution.maxSpending(**test_input) == 1

test_input = { "values": [[1],[2]] }
assert my_solution.maxSpending(**test_input) == 5

test_input = { "values": [[2],[1]] }
assert my_solution.maxSpending(**test_input) == 5

test_input = { "values": [[1],[1]] }
assert my_solution.maxSpending(**test_input) == 3

test_input = { "values": [[5,2]] }
assert my_solution.maxSpending(**test_input) == 12

test_input = { "values": [[5,5]] }
assert my_solution.maxSpending(**test_input) == 15

test_input = { "values": [[7,5]] }
assert my_solution.maxSpending(**test_input) == 19

test_input = { "values": [[3,2,1]] }
assert my_solution.maxSpending(**test_input) == 14

test_input = { "values": [[2,2,1]] }
assert my_solution.maxSpending(**test_input) == 11

test_input = { "values": [[3,3,2]] }
assert my_solution.maxSpending(**test_input) == 17

test_input = { "values": [[3],[2],[1]] }
assert my_solution.maxSpending(**test_input) == 14

test_input = { "values": [[2],[10],[1]] }
assert my_solution.maxSpending(**test_input) == 35

test_input = { "values": [[1000000,1000000,1000000]] }
assert my_solution.maxSpending(**test_input) == 6000000

test_input = { "values": [[1000000,1000000,1000000,1000000]] }
assert my_solution.maxSpending(**test_input) == 10000000

test_input = { "values": [[1000000],[1000000],[1000000],[1000000]] }
assert my_solution.maxSpending(**test_input) == 10000000

test_input = { "values": [[1000000,1000000],[1000000,1000000]] }
assert my_solution.maxSpending(**test_input) == 10000000

test_input = { "values": [[2,1],[4,3]] }
assert my_solution.maxSpending(**test_input) == 30

test_input = { "values": [[3,1],[4,2]] }
assert my_solution.maxSpending(**test_input) == 30

test_input = { "values": [[4,1],[3,2]] }
assert my_solution.maxSpending(**test_input) == 30

test_input = { "values": [[15,13,13,12,12,12,12,11,11,11,11,9,9,8,7,5,5,5,1]] }
assert my_solution.maxSpending(**test_input) == 2162

test_input = { "values": [[13,13,11,7,2,1],[13,10,10,6,3,3]] }
assert my_solution.maxSpending(**test_input) == 776

test_input = { "values": [[12,6],[13,5],[13,3],[6,6],[15,6],[5,4],[6,1]] }
assert my_solution.maxSpending(**test_input) == 971

test_input = { "values": [[15,15,14,14,14,10,10,9,9,8,8,8,7,7,7,4]] }
assert my_solution.maxSpending(**test_input) == 1585

test_input = { "values": [[11,10],[10,1],[14,6],[13,5],[7,3],[10,10],[10,5]] }
assert my_solution.maxSpending(**test_input) == 1061

test_input = { "values": [[15,13,12,7,6,4,1]] }
assert my_solution.maxSpending(**test_input) == 298

test_input = { "values": [[8,2],[4,1],[10,4]] }
assert my_solution.maxSpending(**test_input) == 133

test_input = { "values": [[10,4],[13,2],[7,5],[15,11]] }
assert my_solution.maxSpending(**test_input) == 380

test_input = { "values": [[13,10,10,9,8,5,5,2,1,1]] }
assert my_solution.maxSpending(**test_input) == 465

test_input = { "values": [[15,14,8,7,5,5,1]] }
assert my_solution.maxSpending(**test_input) == 283

test_input = { "values": [[15,15,14,14,14,14,13,11,10,10,10,9,7,7,6,6,4,4,2,1]] }
assert my_solution.maxSpending(**test_input) == 2449

test_input = { "values": [[15,14,11,10,10,6,2],[13,8,8,6,6,3,2]] }
assert my_solution.maxSpending(**test_input) == 1084

test_input = { "values": [[15,15,14,13,13,12,11,9,9,9,8,6,5,5,4,3,2,1,1]] }
assert my_solution.maxSpending(**test_input) == 2030

test_input = { "values": [[15,10,7],[14,2,2],[14,13,12],[13,13,10]] }
assert my_solution.maxSpending(**test_input) == 975

test_input = { "values": [[10,9,3,3],[11,8,7,2],[14,14,13,1],[14,14,11,4],[13,11,9,5]] }
assert my_solution.maxSpending(**test_input) == 2338

test_input = { "values": [[11,7,5,2],[15,5,5,3]] }
assert my_solution.maxSpending(**test_input) == 307

test_input = { "values": [[15,10,10,9,8,7,4,2,2]] }
assert my_solution.maxSpending(**test_input) == 425

test_input = { "values": [[15,13,12,12,10,5,4,3,1]] }
assert my_solution.maxSpending(**test_input) == 484

test_input = { "values": [[12,12,12,11,10,10,7,7,6,5,5,3,2,1]] }
assert my_solution.maxSpending(**test_input) == 979

test_input = { "values": [[15,13,13,13,12,12,11,11,10,9,9,9,8,6,6,4,4,3,2,1]] }
assert my_solution.maxSpending(**test_input) == 2253

test_input = { "values": [[14,11],[11,8],[10,4],[4,3],[9,6],[8,4],[7,7],[10,4],[14,4]] }
assert my_solution.maxSpending(**test_input) == 1621

test_input = { "values": [[14,13,13,11,11,8,8,7,6,4,3,2,1]] }
assert my_solution.maxSpending(**test_input) == 912

test_input = { "values": [[15,14,14,10,10,9,9,7,7,7,7,7,6,6,6,4,4,3,3]] }
assert my_solution.maxSpending(**test_input) == 1823

test_input = { "values": [[14,13,11,10,10,1,1],[15,12,8,6,6,5,5]] }
assert my_solution.maxSpending(**test_input) == 1120

test_input = { "values": [[15,14,13,12,11,10,10,10,9,7,6,6,4,3,3,3,2,2,1]] }
assert my_solution.maxSpending(**test_input) == 1860

test_input = { "values": [[12,6,5,4,2]] }
assert my_solution.maxSpending(**test_input) == 109

test_input = { "values": [[15,15,14,13,12,12,12,11,10,10,9,9,9,8,7,6,3,2]] }
assert my_solution.maxSpending(**test_input) == 2006

test_input = { "values": [[15,14,12,11,10,10,7,6,2,1]] }
assert my_solution.maxSpending(**test_input) == 610

test_input = { "values": [[15,13,12,11,8,6,5]] }
assert my_solution.maxSpending(**test_input) == 328

test_input = { "values": [[15,15,12,10,9,7,7,6,6,5,4,2,1]] }
assert my_solution.maxSpending(**test_input) == 896

test_input = { "values": [[15,15,12,12,10,10,9,7,6,4,4,4,1]] }
assert my_solution.maxSpending(**test_input) == 969

test_input = { "values": [[15,14,14,13,8,7,7,4,3,3,2,1]] }
assert my_solution.maxSpending(**test_input) == 792

test_input = { "values": [[15,15,14,14,14,13,10,8,6,6,5,5,3,3,2,2,1]] }
assert my_solution.maxSpending(**test_input) == 1634

test_input = { "values": [[14,12,11,10,10,8,7,7,5,5,3,3,3]] }
assert my_solution.maxSpending(**test_input) == 855

test_input = { "values": [[14,14,9,9,4,4,1],[12,12,9,8,7,6,3]] }
assert my_solution.maxSpending(**test_input) == 1060

test_input = { "values": [[15,15,15,13,12,12,10,9,9,9,9,7,6,4,4,4,1]] }
assert my_solution.maxSpending(**test_input) == 1727

test_input = { "values": [[9,4],[13,4],[13,9],[6,5],[8,2],[13,1]] }
assert my_solution.maxSpending(**test_input) == 732

test_input = { "values": [[14,9,9,9,8,7,5],[15,14,10,8,5,3,1]] }
assert my_solution.maxSpending(**test_input) == 1094

test_input = { "values": [[15,15,14,13,10,3,1]] }
assert my_solution.maxSpending(**test_input) == 354

test_input = { "values": [[13,12],[13,12],[11,8],[14,3]] }
assert my_solution.maxSpending(**test_input) == 441

test_input = { "values": [[13,12,11,10,7,5,5,1]] }
assert my_solution.maxSpending(**test_input) == 358

test_input = { "values": [[15,10,9,8,8,7,7,5,4,3,1]] }
assert my_solution.maxSpending(**test_input) == 582

test_input = { "values": [[10,10,6,4,1],[14,13,13,11,9],[14,11,7,4,3]] }
assert my_solution.maxSpending(**test_input) == 1302

test_input = { "values": [[15,14,12,12,11,11,10,9,9,8,8,6,6,4,2,2,1]] }
assert my_solution.maxSpending(**test_input) == 1596

test_input = { "values": [[12,5,4,3,3,2,1,1],[13,11,9,9,6,4,3,1]] }
assert my_solution.maxSpending(**test_input) == 1019

test_input = { "values": [[15,15,13,11,10,10,7,1,1]] }
assert my_solution.maxSpending(**test_input) == 526

test_input = { "values": [[14,12,10,4,3,1],[12,12,8,7,6,2],[15,13,8,5,4,1]] }
assert my_solution.maxSpending(**test_input) == 1719

test_input = { "values": [[13,8,8,8,5,4,3],[15,13,9,8,7,3,2]] }
assert my_solution.maxSpending(**test_input) == 1006

test_input = { "values": [[13,13,12,12,9]] }
assert my_solution.maxSpending(**test_input) == 186

test_input = { "values": [[10,3],[11,9],[10,5],[8,7],[6,1]] }
assert my_solution.maxSpending(**test_input) == 472

test_input = { "values": [[15,15,12,12,11,10,9,8,2,2,1,1,1]] }
assert my_solution.maxSpending(**test_input) == 941

test_input = { "values": [[14,14,13,13,11,11,10,10,10,9,8,8,7,7,6,6,5,4,3]] }
assert my_solution.maxSpending(**test_input) == 2023

test_input = { "values": [[11,10,9,7,6,5,3,1],[14,14,10,9,7,4,4,3]] }
assert my_solution.maxSpending(**test_input) == 1270

test_input = { "values": [[6,2],[10,2],[13,5],[8,7],[10,3],[13,2],[13,6]] }
assert my_solution.maxSpending(**test_input) == 972

test_input = { "values": [[15,15,15,14,13,12,6,5,5,4]] }
assert my_solution.maxSpending(**test_input) == 694

test_input = { "values": [[11,9],[8,1],[2,1],[15,13],[12,4],[14,5],[13,4]] }
assert my_solution.maxSpending(**test_input) == 1113

test_input = { "values": [[15,14,14,13,12,11,10,10,5,4,2]] }
assert my_solution.maxSpending(**test_input) == 800

test_input = { "values": [[13,12,12,6,5,5,4,2,2,2,1]] }
assert my_solution.maxSpending(**test_input) == 523

test_input = { "values": [[13,8],[15,1],[9,1],[13,1]] }
assert my_solution.maxSpending(**test_input) == 372

test_input = { "values": [[12,8,4,1],[14,8,8,3]] }
assert my_solution.maxSpending(**test_input) == 335

test_input = { "values": [[15,14,14,13,13,13,12,12,9,9,8,7,6,5,5,5,4,3,1]] }
assert my_solution.maxSpending(**test_input) == 2113

test_input = { "values": [[13,9,8,2,1],[9,4,3,2,1],[10,8,6,3,1]] }
assert my_solution.maxSpending(**test_input) == 877

test_input = { "values": [[8,6],[13,1],[12,8],[8,7]] }
assert my_solution.maxSpending(**test_input) == 342

test_input = { "values": [[9,7],[15,15],[9,8],[6,1],[11,4]] }
assert my_solution.maxSpending(**test_input) == 585

test_input = { "values": [[14,9,9,8,6,4,2]] }
assert my_solution.maxSpending(**test_input) == 257

test_input = { "values": [[15,13,11,11,10,9,5,5,4,4,4,4,3,2]] }
assert my_solution.maxSpending(**test_input) == 968

test_input = { "values": [[13,7,7,4],[8,8,6,6]] }
assert my_solution.maxSpending(**test_input) == 305

test_input = { "values": [[15,13,12,10,10,10,9,9,9,8,7,6,6,5,4,4,2,1,1]] }
assert my_solution.maxSpending(**test_input) == 1805

test_input = { "values": [[13,13,1],[11,5,4],[14,5,1],[15,5,2],[10,1,1],[15,12,1]] }
assert my_solution.maxSpending(**test_input) == 1714

test_input = { "values": [[15,15,14,14,11,10,10,8,8,8,3,1,1]] }
assert my_solution.maxSpending(**test_input) == 1050

test_input = { "values": [[3,3],[15,10],[14,9]] }
assert my_solution.maxSpending(**test_input) == 236

test_input = { "values": [[14,13,11,10,9,7,2]] }
assert my_solution.maxSpending(**test_input) == 314

test_input = { "values": [[11,7],[5,3],[11,6],[6,1],[15,13]] }
assert my_solution.maxSpending(**test_input) == 550

test_input = { "values": [[14,13,13,12,12,12,11,11,9,8,8,6,5,5,5,5,3,3,2]] }
assert my_solution.maxSpending(**test_input) == 1962

test_input = { "values": [[14,14,13,13,13,12,12,11,10,9,9,8,8,7,3,2,2]] }
assert my_solution.maxSpending(**test_input) == 1750

test_input = { "values": [[15,8],[12,2],[15,10],[9,3],[5,4],[14,2],[7,6]] }
assert my_solution.maxSpending(**test_input) == 1091

test_input = { "values": [[15,9,7,3,3],[7,6,4,3,2],[15,9,8,4,4],[15,10,9,7,4]] }
assert my_solution.maxSpending(**test_input) == 1952

test_input = { "values": [[12,12,10,8,8,8,8,6,2,2,1]] }
assert my_solution.maxSpending(**test_input) == 585


find-champion-i

Find Champion I

Prompt:
"""
There are n teams numbered from 0 to n - 1 in a tournament.

Given a 0-indexed 2D boolean matrix grid of size n * n. For all i, j that 0 <= i, j <= n - 1 and i != j team i is stronger than team j if grid[i][j] == 1, otherwise, team j is stronger than team i.

Team a will be the champion of the tournament if there is no team b that is stronger than team a.

Return the team that will be the champion of the tournament.

Example 1:

Input: grid = [[0,1],[0,0]]
Output: 0
Explanation: There are two teams in this tournament.
grid[0][1] == 1 means that team 0 is stronger than team 1. So team 0 will be the champion.

Example 2:

Input: grid = [[0,0,1],[1,0,1],[0,0,0]]
Output: 1
Explanation: There are three teams in this tournament.
grid[1][0] == 1 means that team 1 is stronger than team 0.
grid[1][2] == 1 means that team 1 is stronger than team 2.
So team 1 will be the champion.

Constraints:

 * n == grid.length
 * n == grid[i].length
 * 2 <= n <= 100
 * grid[i][j] is either 0 or 1.
 * For all i grid[i][i] is 0.
 * For all i, j that i != j, grid[i][j] != grid[j][i].
 * The input is generated such that if team a is stronger than team b and team b is stronger than team c, then team a is stronger than team c.
"""
class Solution:
    def findChampion(self, grid: List[List[int]]) -> int:

There are n teams numbered from 0 to n - 1 in a tournament.

Given a 0-indexed 2D boolean matrix grid of size n * n. For all i, j that 0 <= i, j <= n - 1 and i != j team i is stronger than team j if grid[i][j] == 1, otherwise, team j is stronger than team i.

Team a will be the champion of the tournament if there is no team b that is stronger than team a.

Return the team that will be the champion of the tournament.

Example 1:

Input: grid = [[0,1],[0,0]]
Output: 0
Explanation: There are two teams in this tournament.
grid[0][1] == 1 means that team 0 is stronger than team 1. So team 0 will be the champion.

Example 2:

Input: grid = [[0,0,1],[1,0,1],[0,0,0]]
Output: 1
Explanation: There are three teams in this tournament.
grid[1][0] == 1 means that team 1 is stronger than team 0.
grid[1][2] == 1 means that team 1 is stronger than team 2.
So team 1 will be the champion.

Constraints:

 * n == grid.length
 * n == grid[i].length
 * 2 <= n <= 100
 * grid[i][j] is either 0 or 1.
 * For all i grid[i][i] is 0.
 * For all i, j that i != j, grid[i][j] != grid[j][i].
 * The input is generated such that if team a is stronger than team b and team b is stronger than team c, then team a is stronger than team c.

Please complete the code below to solve above prblem:
```python
class Solution:
    def findChampion(self, grid: List[List[int]]) -> int:

```

my_solution = Solution()

test_input = { "grid": [[0,1],[0,0]] }
assert my_solution.findChampion(**test_input) == 0

test_input = { "grid": [[0,0,1],[1,0,1],[0,0,0]] }
assert my_solution.findChampion(**test_input) == 1

test_input = { "grid": [[0,0],[1,0]] }
assert my_solution.findChampion(**test_input) == 1

test_input = { "grid": [[0,0,0],[1,0,0],[1,1,0]] }
assert my_solution.findChampion(**test_input) == 2

test_input = { "grid": [[0,0,0],[1,0,1],[1,0,0]] }
assert my_solution.findChampion(**test_input) == 1

test_input = { "grid": [[0,1,0],[0,0,0],[1,1,0]] }
assert my_solution.findChampion(**test_input) == 2

test_input = { "grid": [[0,1,1],[0,0,0],[0,1,0]] }
assert my_solution.findChampion(**test_input) == 0

test_input = { "grid": [[0,1,1],[0,0,1],[0,0,0]] }
assert my_solution.findChampion(**test_input) == 0

test_input = { "grid": [[0,0,0,0],[1,0,0,0],[1,1,0,0],[1,1,1,0]] }
assert my_solution.findChampion(**test_input) == 3

test_input = { "grid": [[0,0,0,0],[1,0,0,0],[1,1,0,1],[1,1,0,0]] }
assert my_solution.findChampion(**test_input) == 2

test_input = { "grid": [[0,0,0,0],[1,0,0,1],[1,1,0,1],[1,0,0,0]] }
assert my_solution.findChampion(**test_input) == 2

test_input = { "grid": [[0,0,0,0],[1,0,1,0],[1,0,0,0],[1,1,1,0]] }
assert my_solution.findChampion(**test_input) == 3

test_input = { "grid": [[0,0,0,0],[1,0,1,1],[1,0,0,0],[1,0,1,0]] }
assert my_solution.findChampion(**test_input) == 1

test_input = { "grid": [[0,0,0,0],[1,0,1,1],[1,0,0,1],[1,0,0,0]] }
assert my_solution.findChampion(**test_input) == 1

test_input = { "grid": [[0,0,0,1],[1,0,0,1],[1,1,0,1],[0,0,0,0]] }
assert my_solution.findChampion(**test_input) == 2

test_input = { "grid": [[0,0,0,1],[1,0,1,1],[1,0,0,1],[0,0,0,0]] }
assert my_solution.findChampion(**test_input) == 1

test_input = { "grid": [[0,0,1,0],[1,0,1,0],[0,0,0,0],[1,1,1,0]] }
assert my_solution.findChampion(**test_input) == 3

test_input = { "grid": [[0,0,1,0],[1,0,1,1],[0,0,0,0],[1,0,1,0]] }
assert my_solution.findChampion(**test_input) == 1

test_input = { "grid": [[0,0,1,1],[1,0,1,1],[0,0,0,0],[0,0,1,0]] }
assert my_solution.findChampion(**test_input) == 1

test_input = { "grid": [[0,0,1,1],[1,0,1,1],[0,0,0,1],[0,0,0,0]] }
assert my_solution.findChampion(**test_input) == 1

test_input = { "grid": [[0,1,0,0],[0,0,0,0],[1,1,0,0],[1,1,1,0]] }
assert my_solution.findChampion(**test_input) == 3

test_input = { "grid": [[0,1,0,0],[0,0,0,0],[1,1,0,1],[1,1,0,0]] }
assert my_solution.findChampion(**test_input) == 2

test_input = { "grid": [[0,1,0,1],[0,0,0,0],[1,1,0,1],[0,1,0,0]] }
assert my_solution.findChampion(**test_input) == 2

test_input = { "grid": [[0,1,0,1],[0,0,0,1],[1,1,0,1],[0,0,0,0]] }
assert my_solution.findChampion(**test_input) == 2

test_input = { "grid": [[0,1,1,0],[0,0,0,0],[0,1,0,0],[1,1,1,0]] }
assert my_solution.findChampion(**test_input) == 3

test_input = { "grid": [[0,1,1,0],[0,0,1,0],[0,0,0,0],[1,1,1,0]] }
assert my_solution.findChampion(**test_input) == 3

test_input = { "grid": [[0,1,1,1],[0,0,0,0],[0,1,0,0],[0,1,1,0]] }
assert my_solution.findChampion(**test_input) == 0

test_input = { "grid": [[0,1,1,1],[0,0,0,0],[0,1,0,1],[0,1,0,0]] }
assert my_solution.findChampion(**test_input) == 0

test_input = { "grid": [[0,1,1,1],[0,0,0,1],[0,1,0,1],[0,0,0,0]] }
assert my_solution.findChampion(**test_input) == 0

test_input = { "grid": [[0,1,1,1],[0,0,1,0],[0,0,0,0],[0,1,1,0]] }
assert my_solution.findChampion(**test_input) == 0

test_input = { "grid": [[0,1,1,1],[0,0,1,1],[0,0,0,0],[0,0,1,0]] }
assert my_solution.findChampion(**test_input) == 0

test_input = { "grid": [[0,1,1,1],[0,0,1,1],[0,0,0,1],[0,0,0,0]] }
assert my_solution.findChampion(**test_input) == 0

test_input = { "grid": [[0,0,0,0,0],[1,0,0,0,0],[1,1,0,0,0],[1,1,1,0,1],[1,1,1,0,0]] }
assert my_solution.findChampion(**test_input) == 3

test_input = { "grid": [[0,0,0,0,0],[1,0,0,0,0],[1,1,0,1,0],[1,1,0,0,0],[1,1,1,1,0]] }
assert my_solution.findChampion(**test_input) == 4

test_input = { "grid": [[0,0,0,0,0],[1,0,0,0,0],[1,1,0,1,1],[1,1,0,0,0],[1,1,0,1,0]] }
assert my_solution.findChampion(**test_input) == 2

test_input = { "grid": [[0,0,0,0,0],[1,0,0,0,0],[1,1,0,1,1],[1,1,0,0,1],[1,1,0,0,0]] }
assert my_solution.findChampion(**test_input) == 2

test_input = { "grid": [[0,0,0,0,0],[1,0,0,0,1],[1,1,0,0,1],[1,1,1,0,1],[1,0,0,0,0]] }
assert my_solution.findChampion(**test_input) == 3

test_input = { "grid": [[0,0,0,0,0],[1,0,0,0,1],[1,1,0,1,1],[1,1,0,0,1],[1,0,0,0,0]] }
assert my_solution.findChampion(**test_input) == 2

test_input = { "grid": [[0,0,0,0,0],[1,0,0,1,0],[1,1,0,1,0],[1,0,0,0,0],[1,1,1,1,0]] }
assert my_solution.findChampion(**test_input) == 4

test_input = { "grid": [[0,0,0,0,0],[1,0,0,1,0],[1,1,0,1,1],[1,0,0,0,0],[1,1,0,1,0]] }
assert my_solution.findChampion(**test_input) == 2

test_input = { "grid": [[0,0,0,0,0],[1,0,0,1,1],[1,1,0,1,1],[1,0,0,0,1],[1,0,0,0,0]] }
assert my_solution.findChampion(**test_input) == 2

test_input = { "grid": [[0,0,0,0,0],[1,0,1,0,1],[1,0,0,0,0],[1,1,1,0,1],[1,0,1,0,0]] }
assert my_solution.findChampion(**test_input) == 3

test_input = { "grid": [[0,0,0,0,0],[1,0,1,1,0],[1,0,0,0,0],[1,0,1,0,0],[1,1,1,1,0]] }
assert my_solution.findChampion(**test_input) == 4

test_input = { "grid": [[0,0,0,0,0],[1,0,1,1,0],[1,0,0,1,0],[1,0,0,0,0],[1,1,1,1,0]] }
assert my_solution.findChampion(**test_input) == 4

test_input = { "grid": [[0,0,0,0,0],[1,0,1,1,1],[1,0,0,0,0],[1,0,1,0,1],[1,0,1,0,0]] }
assert my_solution.findChampion(**test_input) == 1

test_input = { "grid": [[0,0,0,0,0],[1,0,1,1,1],[1,0,0,0,1],[1,0,1,0,1],[1,0,0,0,0]] }
assert my_solution.findChampion(**test_input) == 1

test_input = { "grid": [[0,0,0,0,0],[1,0,1,1,1],[1,0,0,1,1],[1,0,0,0,1],[1,0,0,0,0]] }
assert my_solution.findChampion(**test_input) == 1

test_input = { "grid": [[0,0,0,0,1],[1,0,0,0,1],[1,1,0,0,1],[1,1,1,0,1],[0,0,0,0,0]] }
assert my_solution.findChampion(**test_input) == 3

test_input = { "grid": [[0,0,0,0,1],[1,0,0,0,1],[1,1,0,1,1],[1,1,0,0,1],[0,0,0,0,0]] }
assert my_solution.findChampion(**test_input) == 2

test_input = { "grid": [[0,0,0,0,1],[1,0,0,1,1],[1,1,0,1,1],[1,0,0,0,1],[0,0,0,0,0]] }
assert my_solution.findChampion(**test_input) == 2

test_input = { "grid": [[0,0,0,0,1],[1,0,1,1,1],[1,0,0,0,1],[1,0,1,0,1],[0,0,0,0,0]] }
assert my_solution.findChampion(**test_input) == 1

test_input = { "grid": [[0,0,0,1,0],[1,0,0,1,0],[1,1,0,1,0],[0,0,0,0,0],[1,1,1,1,0]] }
assert my_solution.findChampion(**test_input) == 4

test_input = { "grid": [[0,0,0,1,0],[1,0,0,1,0],[1,1,0,1,1],[0,0,0,0,0],[1,1,0,1,0]] }
assert my_solution.findChampion(**test_input) == 2

test_input = { "grid": [[0,0,0,1,0],[1,0,0,1,1],[1,1,0,1,1],[0,0,0,0,0],[1,0,0,1,0]] }
assert my_solution.findChampion(**test_input) == 2

test_input = { "grid": [[0,0,0,1,0],[1,0,1,1,0],[1,0,0,1,0],[0,0,0,0,0],[1,1,1,1,0]] }
assert my_solution.findChampion(**test_input) == 4

test_input = { "grid": [[0,0,0,1,0],[1,0,1,1,1],[1,0,0,1,0],[0,0,0,0,0],[1,0,1,1,0]] }
assert my_solution.findChampion(**test_input) == 1

test_input = { "grid": [[0,0,0,1,0],[1,0,1,1,1],[1,0,0,1,1],[0,0,0,0,0],[1,0,0,1,0]] }
assert my_solution.findChampion(**test_input) == 1

test_input = { "grid": [[0,0,0,1,1],[1,0,0,1,1],[1,1,0,1,1],[0,0,0,0,0],[0,0,0,1,0]] }
assert my_solution.findChampion(**test_input) == 2

test_input = { "grid": [[0,0,0,1,1],[1,0,0,1,1],[1,1,0,1,1],[0,0,0,0,1],[0,0,0,0,0]] }
assert my_solution.findChampion(**test_input) == 2

test_input = { "grid": [[0,0,0,1,1],[1,0,1,1,1],[1,0,0,1,1],[0,0,0,0,0],[0,0,0,1,0]] }
assert my_solution.findChampion(**test_input) == 1

test_input = { "grid": [[0,0,0,1,1],[1,0,1,1,1],[1,0,0,1,1],[0,0,0,0,1],[0,0,0,0,0]] }
assert my_solution.findChampion(**test_input) == 1

test_input = { "grid": [[0,0,1,0,0],[1,0,1,0,0],[0,0,0,0,0],[1,1,1,0,0],[1,1,1,1,0]] }
assert my_solution.findChampion(**test_input) == 4

test_input = { "grid": [[0,0,1,0,0],[1,0,1,1,0],[0,0,0,0,0],[1,0,1,0,0],[1,1,1,1,0]] }
assert my_solution.findChampion(**test_input) == 4

test_input = { "grid": [[0,0,1,0,0],[1,0,1,1,1],[0,0,0,0,0],[1,0,1,0,1],[1,0,1,0,0]] }
assert my_solution.findChampion(**test_input) == 1

test_input = { "grid": [[0,0,1,0,1],[1,0,1,0,1],[0,0,0,0,1],[1,1,1,0,1],[0,0,0,0,0]] }
assert my_solution.findChampion(**test_input) == 3

test_input = { "grid": [[0,0,1,1,0],[1,0,1,1,0],[0,0,0,1,0],[0,0,0,0,0],[1,1,1,1,0]] }
assert my_solution.findChampion(**test_input) == 4

test_input = { "grid": [[0,0,1,1,0],[1,0,1,1,1],[0,0,0,0,0],[0,0,1,0,0],[1,0,1,1,0]] }
assert my_solution.findChampion(**test_input) == 1

test_input = { "grid": [[0,0,1,1,1],[1,0,1,1,1],[0,0,0,1,0],[0,0,0,0,0],[0,0,1,1,0]] }
assert my_solution.findChampion(**test_input) == 1

test_input = { "grid": [[0,0,1,1,1],[1,0,1,1,1],[0,0,0,1,1],[0,0,0,0,1],[0,0,0,0,0]] }
assert my_solution.findChampion(**test_input) == 1

test_input = { "grid": [[0,1,0,0,0],[0,0,0,0,0],[1,1,0,0,0],[1,1,1,0,1],[1,1,1,0,0]] }
assert my_solution.findChampion(**test_input) == 3

test_input = { "grid": [[0,1,0,0,0],[0,0,0,0,0],[1,1,0,1,1],[1,1,0,0,0],[1,1,0,1,0]] }
assert my_solution.findChampion(**test_input) == 2

test_input = { "grid": [[0,1,0,0,1],[0,0,0,0,0],[1,1,0,0,1],[1,1,1,0,1],[0,1,0,0,0]] }
assert my_solution.findChampion(**test_input) == 3

test_input = { "grid": [[0,1,0,0,1],[0,0,0,0,0],[1,1,0,1,1],[1,1,0,0,1],[0,1,0,0,0]] }
assert my_solution.findChampion(**test_input) == 2

test_input = { "grid": [[0,1,0,1,0],[0,0,0,0,0],[1,1,0,1,0],[0,1,0,0,0],[1,1,1,1,0]] }
assert my_solution.findChampion(**test_input) == 4

test_input = { "grid": [[0,1,0,1,0],[0,0,0,0,0],[1,1,0,1,1],[0,1,0,0,0],[1,1,0,1,0]] }
assert my_solution.findChampion(**test_input) == 2

test_input = { "grid": [[0,1,0,1,0],[0,0,0,1,0],[1,1,0,1,0],[0,0,0,0,0],[1,1,1,1,0]] }
assert my_solution.findChampion(**test_input) == 4

test_input = { "grid": [[0,1,0,1,0],[0,0,0,1,0],[1,1,0,1,1],[0,0,0,0,0],[1,1,0,1,0]] }
assert my_solution.findChampion(**test_input) == 2

test_input = { "grid": [[0,1,0,1,1],[0,0,0,0,0],[1,1,0,1,1],[0,1,0,0,1],[0,1,0,0,0]] }
assert my_solution.findChampion(**test_input) == 2

test_input = { "grid": [[0,1,0,1,1],[0,0,0,1,1],[1,1,0,1,1],[0,0,0,0,0],[0,0,0,1,0]] }
assert my_solution.findChampion(**test_input) == 2

test_input = { "grid": [[0,1,1,0,0],[0,0,0,0,0],[0,1,0,0,0],[1,1,1,0,0],[1,1,1,1,0]] }
assert my_solution.findChampion(**test_input) == 4

test_input = { "grid": [[0,1,1,0,0],[0,0,1,0,0],[0,0,0,0,0],[1,1,1,0,1],[1,1,1,0,0]] }
assert my_solution.findChampion(**test_input) == 3

test_input = { "grid": [[0,1,1,0,1],[0,0,0,0,0],[0,1,0,0,1],[1,1,1,0,1],[0,1,0,0,0]] }
assert my_solution.findChampion(**test_input) == 3

test_input = { "grid": [[0,1,1,0,1],[0,0,0,0,1],[0,1,0,0,1],[1,1,1,0,1],[0,0,0,0,0]] }
assert my_solution.findChampion(**test_input) == 3

test_input = { "grid": [[0,1,1,0,1],[0,0,1,0,0],[0,0,0,0,0],[1,1,1,0,1],[0,1,1,0,0]] }
assert my_solution.findChampion(**test_input) == 3

test_input = { "grid": [[0,1,1,0,1],[0,0,1,0,1],[0,0,0,0,0],[1,1,1,0,1],[0,0,1,0,0]] }
assert my_solution.findChampion(**test_input) == 3

test_input = { "grid": [[0,1,1,0,1],[0,0,1,0,1],[0,0,0,0,1],[1,1,1,0,1],[0,0,0,0,0]] }
assert my_solution.findChampion(**test_input) == 3

test_input = { "grid": [[0,1,1,1,0],[0,0,0,1,0],[0,1,0,1,0],[0,0,0,0,0],[1,1,1,1,0]] }
assert my_solution.findChampion(**test_input) == 4

test_input = { "grid": [[0,1,1,1,0],[0,0,1,0,0],[0,0,0,0,0],[0,1,1,0,0],[1,1,1,1,0]] }
assert my_solution.findChampion(**test_input) == 4

test_input = { "grid": [[0,1,1,1,0],[0,0,1,1,0],[0,0,0,0,0],[0,0,1,0,0],[1,1,1,1,0]] }
assert my_solution.findChampion(**test_input) == 4

test_input = { "grid": [[0,1,1,1,1],[0,0,0,0,0],[0,1,0,0,0],[0,1,1,0,0],[0,1,1,1,0]] }
assert my_solution.findChampion(**test_input) == 0

test_input = { "grid": [[0,1,1,1,1],[0,0,0,0,0],[0,1,0,0,0],[0,1,1,0,1],[0,1,1,0,0]] }
assert my_solution.findChampion(**test_input) == 0

test_input = { "grid": [[0,1,1,1,1],[0,0,0,0,0],[0,1,0,0,1],[0,1,1,0,1],[0,1,0,0,0]] }
assert my_solution.findChampion(**test_input) == 0

test_input = { "grid": [[0,1,1,1,1],[0,0,0,0,0],[0,1,0,1,0],[0,1,0,0,0],[0,1,1,1,0]] }
assert my_solution.findChampion(**test_input) == 0

test_input = { "grid": [[0,1,1,1,1],[0,0,0,0,0],[0,1,0,1,1],[0,1,0,0,0],[0,1,0,1,0]] }
assert my_solution.findChampion(**test_input) == 0

test_input = { "grid": [[0,1,1,1,1],[0,0,0,0,0],[0,1,0,1,1],[0,1,0,0,1],[0,1,0,0,0]] }
assert my_solution.findChampion(**test_input) == 0

test_input = { "grid": [[0,1,1,1,1],[0,0,0,0,1],[0,1,0,0,1],[0,1,1,0,1],[0,0,0,0,0]] }
assert my_solution.findChampion(**test_input) == 0

test_input = { "grid": [[0,1,1,1,1],[0,0,1,0,0],[0,0,0,0,0],[0,1,1,0,0],[0,1,1,1,0]] }
assert my_solution.findChampion(**test_input) == 0

test_input = { "grid": [[0,1,1,1,1],[0,0,1,0,0],[0,0,0,0,0],[0,1,1,0,1],[0,1,1,0,0]] }
assert my_solution.findChampion(**test_input) == 0

test_input = { "grid": [[0,1,1,1,1],[0,0,1,0,1],[0,0,0,0,1],[0,1,1,0,1],[0,0,0,0,0]] }
assert my_solution.findChampion(**test_input) == 0

test_input = { "grid": [[0,1,1,1,1],[0,0,1,1,0],[0,0,0,0,0],[0,0,1,0,0],[0,1,1,1,0]] }
assert my_solution.findChampion(**test_input) == 0