beautiful-towers-ii

Beautiful Towers II

Prompt:
"""
You are given a 0-indexed array maxHeights of n integers.

You are tasked with building n towers in the coordinate line. The ith tower is built at coordinate i and has a height of heights[i].

A configuration of towers is beautiful if the following conditions hold:

 1. 1 <= heights[i] <= maxHeights[i]
 2. heights is a mountain array.

Array heights is a mountain if there exists an index i such that:

 * For all 0 < j <= i, heights[j - 1] <= heights[j]
 * For all i <= k < n - 1, heights[k + 1] <= heights[k]

Return the maximum possible sum of heights of a beautiful configuration of towers.

Example 1:

Input: maxHeights = [5,3,4,1,1]
Output: 13
Explanation: One beautiful configuration with a maximum sum is heights = [5,3,3,1,1]. This configuration is beautiful since:
- 1 <= heights[i] <= maxHeights[i]
- heights is a mountain of peak i = 0.
It can be shown that there exists no other beautiful configuration with a sum of heights greater than 13.

Example 2:

Input: maxHeights = [6,5,3,9,2,7]
Output: 22
Explanation: One beautiful configuration with a maximum sum is heights = [3,3,3,9,2,2]. This configuration is beautiful since:
- 1 <= heights[i] <= maxHeights[i]
- heights is a mountain of peak i = 3.
It can be shown that there exists no other beautiful configuration with a sum of heights greater than 22.

Example 3:

Input: maxHeights = [3,2,5,5,2,3]
Output: 18
Explanation: One beautiful configuration with a maximum sum is heights = [2,2,5,5,2,2]. This configuration is beautiful since:
- 1 <= heights[i] <= maxHeights[i]
- heights is a mountain of peak i = 2.
Note that, for this configuration, i = 3 can also be considered a peak.
It can be shown that there exists no other beautiful configuration with a sum of heights greater than 18.

Constraints:

 * 1 <= n == maxHeights <= 105
 * 1 <= maxHeights[i] <= 109
"""
class Solution:
    def maximumSumOfHeights(self, maxHeights: List[int]) -> int:

You are given a 0-indexed array maxHeights of n integers.

You are tasked with building n towers in the coordinate line. The ith tower is built at coordinate i and has a height of heights[i].

A configuration of towers is beautiful if the following conditions hold:

 1. 1 <= heights[i] <= maxHeights[i]
 2. heights is a mountain array.

Array heights is a mountain if there exists an index i such that:

 * For all 0 < j <= i, heights[j - 1] <= heights[j]
 * For all i <= k < n - 1, heights[k + 1] <= heights[k]

Return the maximum possible sum of heights of a beautiful configuration of towers.

Example 1:

Input: maxHeights = [5,3,4,1,1]
Output: 13
Explanation: One beautiful configuration with a maximum sum is heights = [5,3,3,1,1]. This configuration is beautiful since:
- 1 <= heights[i] <= maxHeights[i]
- heights is a mountain of peak i = 0.
It can be shown that there exists no other beautiful configuration with a sum of heights greater than 13.

Example 2:

Input: maxHeights = [6,5,3,9,2,7]
Output: 22
Explanation: One beautiful configuration with a maximum sum is heights = [3,3,3,9,2,2]. This configuration is beautiful since:
- 1 <= heights[i] <= maxHeights[i]
- heights is a mountain of peak i = 3.
It can be shown that there exists no other beautiful configuration with a sum of heights greater than 22.

Example 3:

Input: maxHeights = [3,2,5,5,2,3]
Output: 18
Explanation: One beautiful configuration with a maximum sum is heights = [2,2,5,5,2,2]. This configuration is beautiful since:
- 1 <= heights[i] <= maxHeights[i]
- heights is a mountain of peak i = 2.
Note that, for this configuration, i = 3 can also be considered a peak.
It can be shown that there exists no other beautiful configuration with a sum of heights greater than 18.

Constraints:

 * 1 <= n == maxHeights <= 105
 * 1 <= maxHeights[i] <= 109

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

```

my_solution = Solution()

test_input = { "maxHeights": [5,3,4,1,1] }
assert my_solution.maximumSumOfHeights(**test_input) == 13

test_input = { "maxHeights": [6,5,3,9,2,7] }
assert my_solution.maximumSumOfHeights(**test_input) == 22

test_input = { "maxHeights": [3,2,5,5,2,3] }
assert my_solution.maximumSumOfHeights(**test_input) == 18

test_input = { "maxHeights": [1000000000] }
assert my_solution.maximumSumOfHeights(**test_input) == 1000000000

test_input = { "maxHeights": [1] }
assert my_solution.maximumSumOfHeights(**test_input) == 1

test_input = { "maxHeights": [352939501] }
assert my_solution.maximumSumOfHeights(**test_input) == 352939501

test_input = { "maxHeights": [1,1000000000] }
assert my_solution.maximumSumOfHeights(**test_input) == 1000000001

test_input = { "maxHeights": [1000000000,1000000000] }
assert my_solution.maximumSumOfHeights(**test_input) == 2000000000

test_input = { "maxHeights": [999999999,1000000000] }
assert my_solution.maximumSumOfHeights(**test_input) == 1999999999

test_input = { "maxHeights": [1000000000,999999999] }
assert my_solution.maximumSumOfHeights(**test_input) == 1999999999

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

test_input = { "maxHeights": [26,30,30] }
assert my_solution.maximumSumOfHeights(**test_input) == 86

test_input = { "maxHeights": [1000000000,1000000000,1000000000] }
assert my_solution.maximumSumOfHeights(**test_input) == 3000000000

test_input = { "maxHeights": [999999999,1000000000,999999999] }
assert my_solution.maximumSumOfHeights(**test_input) == 2999999998

test_input = { "maxHeights": [1000000000,999999999,999999998] }
assert my_solution.maximumSumOfHeights(**test_input) == 2999999997

test_input = { "maxHeights": [999999998,999999999,1000000000] }
assert my_solution.maximumSumOfHeights(**test_input) == 2999999997

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

test_input = { "maxHeights": [1,1,5,6,2,2,3] }
assert my_solution.maximumSumOfHeights(**test_input) == 19

test_input = { "maxHeights": [3,5,3,5,1,5,4,4,4] }
assert my_solution.maximumSumOfHeights(**test_input) == 22

test_input = { "maxHeights": [4,2,4,2,1,5,4,6] }
assert my_solution.maximumSumOfHeights(**test_input) == 19

test_input = { "maxHeights": [5,3,2,4,6,5] }
assert my_solution.maximumSumOfHeights(**test_input) == 21

test_input = { "maxHeights": [6,5,2,1,5,4,4,2] }
assert my_solution.maximumSumOfHeights(**test_input) == 19

test_input = { "maxHeights": [4,3,2,4,6,3] }
assert my_solution.maximumSumOfHeights(**test_input) == 19

test_input = { "maxHeights": [2,6,5] }
assert my_solution.maximumSumOfHeights(**test_input) == 13

test_input = { "maxHeights": [6,5,3,4,6,1,2,3,2,5] }
assert my_solution.maximumSumOfHeights(**test_input) == 25

test_input = { "maxHeights": [2,1,6,2,3] }
assert my_solution.maximumSumOfHeights(**test_input) == 12

test_input = { "maxHeights": [6,5,1,5,4,3,4,2,5] }
assert my_solution.maximumSumOfHeights(**test_input) == 22

test_input = { "maxHeights": [1,1,6,4,2,2,6] }
assert my_solution.maximumSumOfHeights(**test_input) == 18

test_input = { "maxHeights": [2,2,2,5,6,1,4,3] }
assert my_solution.maximumSumOfHeights(**test_input) == 20

test_input = { "maxHeights": [3,1,5,3,6,5,1] }
assert my_solution.maximumSumOfHeights(**test_input) == 20

test_input = { "maxHeights": [1,4,6,1,4,6,1] }
assert my_solution.maximumSumOfHeights(**test_input) == 15

test_input = { "maxHeights": [4,4,2,3,3,2,2] }
assert my_solution.maximumSumOfHeights(**test_input) == 18

test_input = { "maxHeights": [4,4,1,6,2,1,2] }
assert my_solution.maximumSumOfHeights(**test_input) == 13

test_input = { "maxHeights": [6,3,3,5,4,1,5,2,4,1] }
assert my_solution.maximumSumOfHeights(**test_input) == 23

test_input = { "maxHeights": [3,2,4] }
assert my_solution.maximumSumOfHeights(**test_input) == 8

test_input = { "maxHeights": [3,1,4,3,2,3] }
assert my_solution.maximumSumOfHeights(**test_input) == 13

test_input = { "maxHeights": [3,1,4,5,4,4,6,4] }
assert my_solution.maximumSumOfHeights(**test_input) == 28

test_input = { "maxHeights": [1,2,5,5,5,6,5,6,3] }
assert my_solution.maximumSumOfHeights(**test_input) == 37

test_input = { "maxHeights": [6,1,1,6,5] }
assert my_solution.maximumSumOfHeights(**test_input) == 14

test_input = { "maxHeights": [1,6,6,6,2,6,6] }
assert my_solution.maximumSumOfHeights(**test_input) == 25

test_input = { "maxHeights": [4,1,4,5] }
assert my_solution.maximumSumOfHeights(**test_input) == 11

test_input = { "maxHeights": [1,5,6] }
assert my_solution.maximumSumOfHeights(**test_input) == 12

test_input = { "maxHeights": [1,4,4,5,6,6,2,4,1] }
assert my_solution.maximumSumOfHeights(**test_input) == 31

test_input = { "maxHeights": [2,6,6,4,6,1,6,2,1,6] }
assert my_solution.maximumSumOfHeights(**test_input) == 27

test_input = { "maxHeights": [2,4,6,4,4] }
assert my_solution.maximumSumOfHeights(**test_input) == 20

test_input = { "maxHeights": [5,2,6,1,6,6,5] }
assert my_solution.maximumSumOfHeights(**test_input) == 21

test_input = { "maxHeights": [3,6,1,4,5,5,2,5,1] }
assert my_solution.maximumSumOfHeights(**test_input) == 22

test_input = { "maxHeights": [3,2,6,5,6,6,2,1] }
assert my_solution.maximumSumOfHeights(**test_input) == 29

test_input = { "maxHeights": [1,4,2,1,6,3,2,1,2,2] }
assert my_solution.maximumSumOfHeights(**test_input) == 18

test_input = { "maxHeights": [3,3,4,3,5,6,1,3] }
assert my_solution.maximumSumOfHeights(**test_input) == 25

test_input = { "maxHeights": [4,4,2,4,1,4,5,5,6] }
assert my_solution.maximumSumOfHeights(**test_input) == 25

test_input = { "maxHeights": [6,5,3] }
assert my_solution.maximumSumOfHeights(**test_input) == 14

test_input = { "maxHeights": [2,2,4] }
assert my_solution.maximumSumOfHeights(**test_input) == 8

test_input = { "maxHeights": [6,2,6,5,3,6,2,5,1,2] }
assert my_solution.maximumSumOfHeights(**test_input) == 27

test_input = { "maxHeights": [4,6,3,4,6,6] }
assert my_solution.maximumSumOfHeights(**test_input) == 25

test_input = { "maxHeights": [6,4,6,3] }
assert my_solution.maximumSumOfHeights(**test_input) == 17

test_input = { "maxHeights": [4,3,5,1,4] }
assert my_solution.maximumSumOfHeights(**test_input) == 13

test_input = { "maxHeights": [3,5,6,6,3,6,1] }
assert my_solution.maximumSumOfHeights(**test_input) == 27

test_input = { "maxHeights": [6,1,6,5,5,1,1,2] }
assert my_solution.maximumSumOfHeights(**test_input) == 21

test_input = { "maxHeights": [4,3,3,1,5,3,3,6,3,3] }
assert my_solution.maximumSumOfHeights(**test_input) == 25

test_input = { "maxHeights": [1,4,6,1,6,4] }
assert my_solution.maximumSumOfHeights(**test_input) == 14

test_input = { "maxHeights": [6,2,1,4,2] }
assert my_solution.maximumSumOfHeights(**test_input) == 11

test_input = { "maxHeights": [1,4,6,4,2,6,6,5,5,5] }
assert my_solution.maximumSumOfHeights(**test_input) == 36

test_input = { "maxHeights": [6,1,2,1,3,3,1] }
assert my_solution.maximumSumOfHeights(**test_input) == 12

test_input = { "maxHeights": [6,4,3,3,6,1] }
assert my_solution.maximumSumOfHeights(**test_input) == 20

test_input = { "maxHeights": [3,1,4,4] }
assert my_solution.maximumSumOfHeights(**test_input) == 10

test_input = { "maxHeights": [2,4,1,6,5,3,2] }
assert my_solution.maximumSumOfHeights(**test_input) == 19

test_input = { "maxHeights": [2,5,5,6] }
assert my_solution.maximumSumOfHeights(**test_input) == 18

test_input = { "maxHeights": [5,2,1,4] }
assert my_solution.maximumSumOfHeights(**test_input) == 9

test_input = { "maxHeights": [5,5,3,3,3,3,1,3,2] }
assert my_solution.maximumSumOfHeights(**test_input) == 25

test_input = { "maxHeights": [5,6,5] }
assert my_solution.maximumSumOfHeights(**test_input) == 16

test_input = { "maxHeights": [1,1,6,2,3,1] }
assert my_solution.maximumSumOfHeights(**test_input) == 13

test_input = { "maxHeights": [2,4,2,2,2,6,1,4,4] }
assert my_solution.maximumSumOfHeights(**test_input) == 19

test_input = { "maxHeights": [6,2,6] }
assert my_solution.maximumSumOfHeights(**test_input) == 10

test_input = { "maxHeights": [5,6,1] }
assert my_solution.maximumSumOfHeights(**test_input) == 12

test_input = { "maxHeights": [6,6,4,3,6,3,6,5] }
assert my_solution.maximumSumOfHeights(**test_input) == 31

test_input = { "maxHeights": [3,2,4,2,3,2,3,6,1,6] }
assert my_solution.maximumSumOfHeights(**test_input) == 23

test_input = { "maxHeights": [6,3,3,3,5] }
assert my_solution.maximumSumOfHeights(**test_input) == 18

test_input = { "maxHeights": [5,5,2,1] }
assert my_solution.maximumSumOfHeights(**test_input) == 13

test_input = { "maxHeights": [3,5,4,5,5,4] }
assert my_solution.maximumSumOfHeights(**test_input) == 25

test_input = { "maxHeights": [3,4,6,3,1,5,5,2] }
assert my_solution.maximumSumOfHeights(**test_input) == 20

test_input = { "maxHeights": [4,3,6,6,5,6] }
assert my_solution.maximumSumOfHeights(**test_input) == 28

test_input = { "maxHeights": [3,5,5,2,2,3,4,1,1,4] }
assert my_solution.maximumSumOfHeights(**test_input) == 24

test_input = { "maxHeights": [5,6,1,2,5,1] }
assert my_solution.maximumSumOfHeights(**test_input) == 15

test_input = { "maxHeights": [6,3,3,6,4,4,2,1,6,4] }
assert my_solution.maximumSumOfHeights(**test_input) == 28

test_input = { "maxHeights": [1,5,3,6] }
assert my_solution.maximumSumOfHeights(**test_input) == 13

test_input = { "maxHeights": [5,2,3,5,3,2,5,5,6] }
assert my_solution.maximumSumOfHeights(**test_input) == 28

test_input = { "maxHeights": [5,4,2,6,6] }
assert my_solution.maximumSumOfHeights(**test_input) == 18

test_input = { "maxHeights": [5,5,4,4,1,4,3,1,4,2] }
assert my_solution.maximumSumOfHeights(**test_input) == 24

test_input = { "maxHeights": [4,4,4,6,4] }
assert my_solution.maximumSumOfHeights(**test_input) == 22

test_input = { "maxHeights": [3,3,3,5] }
assert my_solution.maximumSumOfHeights(**test_input) == 14

test_input = { "maxHeights": [2,2,2] }
assert my_solution.maximumSumOfHeights(**test_input) == 6

test_input = { "maxHeights": [4,4,5] }
assert my_solution.maximumSumOfHeights(**test_input) == 13

test_input = { "maxHeights": [1,1,6,5,4,6,6,2,5] }
assert my_solution.maximumSumOfHeights(**test_input) == 30

test_input = { "maxHeights": [6,6,3,3,6] }
assert my_solution.maximumSumOfHeights(**test_input) == 21

test_input = { "maxHeights": [1,3,2,5,2,1] }
assert my_solution.maximumSumOfHeights(**test_input) == 13

test_input = { "maxHeights": [1,5,3,3,1,6] }
assert my_solution.maximumSumOfHeights(**test_input) == 14

test_input = { "maxHeights": [4,2,4,3] }
assert my_solution.maximumSumOfHeights(**test_input) == 11

test_input = { "maxHeights": [6,4,5,1,2,3,1] }
assert my_solution.maximumSumOfHeights(**test_input) == 18

test_input = { "maxHeights": [4,4,1,6,1,4] }
assert my_solution.maximumSumOfHeights(**test_input) == 12


count-valid-paths-in-a-tree

Count Valid Paths in a Tree

Prompt:
"""
There is an undirected tree with n nodes labeled from 1 to n. You are given the integer n and a 2D integer array edges of length n - 1, where edges[i] = [ui, vi] indicates that there is an edge between nodes ui and vi in the tree.

Return the number of valid paths in the tree.

A path (a, b) is valid if there exists exactly one prime number among the node labels in the path from a to b.

Note that:

 * The path (a, b) is a sequence of distinct nodes starting with node a and ending with node b such that every two adjacent nodes in the sequence share an edge in the tree.
 * Path (a, b) and path (b, a) are considered the same and counted only once.

Example 1:

[https://assets.leetcode.com/uploads/2023/08/27/example1.png]

Input: n = 5, edges = [[1,2],[1,3],[2,4],[2,5]]
Output: 4
Explanation: The pairs with exactly one prime number on the path between them are:
- (1, 2) since the path from 1 to 2 contains prime number 2.
- (1, 3) since the path from 1 to 3 contains prime number 3.
- (1, 4) since the path from 1 to 4 contains prime number 2.
- (2, 4) since the path from 2 to 4 contains prime number 2.
It can be shown that there are only 4 valid paths.

Example 2:

[https://assets.leetcode.com/uploads/2023/08/27/example2.png]

Input: n = 6, edges = [[1,2],[1,3],[2,4],[3,5],[3,6]]
Output: 6
Explanation: The pairs with exactly one prime number on the path between them are:
- (1, 2) since the path from 1 to 2 contains prime number 2.
- (1, 3) since the path from 1 to 3 contains prime number 3.
- (1, 4) since the path from 1 to 4 contains prime number 2.
- (1, 6) since the path from 1 to 6 contains prime number 3.
- (2, 4) since the path from 2 to 4 contains prime number 2.
- (3, 6) since the path from 3 to 6 contains prime number 3.
It can be shown that there are only 6 valid paths.

Constraints:

 * 1 <= n <= 105
 * edges.length == n - 1
 * edges[i].length == 2
 * 1 <= ui, vi <= n
 * The input is generated such that edges represent a valid tree.
"""
class Solution:
    def countPaths(self, n: int, edges: List[List[int]]) -> int:

There is an undirected tree with n nodes labeled from 1 to n. You are given the integer n and a 2D integer array edges of length n - 1, where edges[i] = [ui, vi] indicates that there is an edge between nodes ui and vi in the tree.

Return the number of valid paths in the tree.

A path (a, b) is valid if there exists exactly one prime number among the node labels in the path from a to b.

Note that:

 * The path (a, b) is a sequence of distinct nodes starting with node a and ending with node b such that every two adjacent nodes in the sequence share an edge in the tree.
 * Path (a, b) and path (b, a) are considered the same and counted only once.

Example 1:

[https://assets.leetcode.com/uploads/2023/08/27/example1.png]

Input: n = 5, edges = [[1,2],[1,3],[2,4],[2,5]]
Output: 4
Explanation: The pairs with exactly one prime number on the path between them are:
- (1, 2) since the path from 1 to 2 contains prime number 2.
- (1, 3) since the path from 1 to 3 contains prime number 3.
- (1, 4) since the path from 1 to 4 contains prime number 2.
- (2, 4) since the path from 2 to 4 contains prime number 2.
It can be shown that there are only 4 valid paths.

Example 2:

[https://assets.leetcode.com/uploads/2023/08/27/example2.png]

Input: n = 6, edges = [[1,2],[1,3],[2,4],[3,5],[3,6]]
Output: 6
Explanation: The pairs with exactly one prime number on the path between them are:
- (1, 2) since the path from 1 to 2 contains prime number 2.
- (1, 3) since the path from 1 to 3 contains prime number 3.
- (1, 4) since the path from 1 to 4 contains prime number 2.
- (1, 6) since the path from 1 to 6 contains prime number 3.
- (2, 4) since the path from 2 to 4 contains prime number 2.
- (3, 6) since the path from 3 to 6 contains prime number 3.
It can be shown that there are only 6 valid paths.

Constraints:

 * 1 <= n <= 105
 * edges.length == n - 1
 * edges[i].length == 2
 * 1 <= ui, vi <= n
 * The input is generated such that edges represent a valid tree.

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

```

my_solution = Solution()

test_input = { "n": 5, "edges": [[1,2],[1,3],[2,4],[2,5]] }
assert my_solution.countPaths(**test_input) == 4

test_input = { "n": 6, "edges": [[1,2],[1,3],[2,4],[3,5],[3,6]] }
assert my_solution.countPaths(**test_input) == 6

test_input = { "n": 1, "edges": [] }
assert my_solution.countPaths(**test_input) == 0

test_input = { "n": 2, "edges": [[2,1]] }
assert my_solution.countPaths(**test_input) == 1

test_input = { "n": 4, "edges": [[1,2],[4,1],[3,4]] }
assert my_solution.countPaths(**test_input) == 4

test_input = { "n": 5, "edges": [[1,3],[4,3],[2,3],[5,2]] }
assert my_solution.countPaths(**test_input) == 3

test_input = { "n": 5, "edges": [[1,5],[2,1],[4,5],[3,2]] }
assert my_solution.countPaths(**test_input) == 4

test_input = { "n": 5, "edges": [[2,3],[4,2],[1,3],[5,1]] }
assert my_solution.countPaths(**test_input) == 3

test_input = { "n": 5, "edges": [[4,1],[5,4],[2,1],[3,4]] }
assert my_solution.countPaths(**test_input) == 6

test_input = { "n": 5, "edges": [[3,5],[1,5],[4,3],[2,5]] }
assert my_solution.countPaths(**test_input) == 2

test_input = { "n": 4, "edges": [[2,1],[4,2],[3,2]] }
assert my_solution.countPaths(**test_input) == 3

test_input = { "n": 5, "edges": [[1,4],[2,4],[3,2],[5,4]] }
assert my_solution.countPaths(**test_input) == 4

test_input = { "n": 5, "edges": [[5,4],[3,4],[1,4],[2,4]] }
assert my_solution.countPaths(**test_input) == 6

test_input = { "n": 4, "edges": [[3,4],[1,3],[2,4]] }
assert my_solution.countPaths(**test_input) == 4

test_input = { "n": 10, "edges": [[10,9],[2,10],[1,10],[3,2],[6,10],[4,3],[8,6],[5,8],[7,6]] }
assert my_solution.countPaths(**test_input) == 16

test_input = { "n": 8, "edges": [[7,2],[6,2],[5,2],[1,2],[4,7],[8,1],[3,6]] }
assert my_solution.countPaths(**test_input) == 7

test_input = { "n": 5, "edges": [[3,2],[4,3],[5,4],[1,4]] }
assert my_solution.countPaths(**test_input) == 4

test_input = { "n": 9, "edges": [[7,4],[3,4],[5,4],[1,5],[6,4],[9,5],[8,7],[2,8]] }
assert my_solution.countPaths(**test_input) == 17

test_input = { "n": 9, "edges": [[1,8],[5,8],[4,8],[6,5],[3,1],[9,1],[7,4],[2,8]] }
assert my_solution.countPaths(**test_input) == 21

test_input = { "n": 10, "edges": [[2,9],[7,2],[10,9],[5,7],[4,5],[6,7],[8,2],[1,5],[3,10]] }
assert my_solution.countPaths(**test_input) == 11

test_input = { "n": 8, "edges": [[6,1],[8,1],[3,6],[4,1],[7,3],[2,8],[5,1]] }
assert my_solution.countPaths(**test_input) == 12

test_input = { "n": 10, "edges": [[9,1],[8,9],[5,9],[10,8],[7,5],[2,8],[3,8],[6,7],[4,1]] }
assert my_solution.countPaths(**test_input) == 16

test_input = { "n": 5, "edges": [[5,3],[4,5],[2,5],[1,4]] }
assert my_solution.countPaths(**test_input) == 2

test_input = { "n": 7, "edges": [[7,6],[2,6],[5,2],[3,5],[4,5],[1,6]] }
assert my_solution.countPaths(**test_input) == 5

test_input = { "n": 8, "edges": [[4,5],[8,4],[6,4],[2,5],[1,6],[3,1],[7,8]] }
assert my_solution.countPaths(**test_input) == 12

test_input = { "n": 10, "edges": [[9,6],[5,6],[10,6],[8,5],[4,8],[3,9],[1,3],[2,6],[7,1]] }
assert my_solution.countPaths(**test_input) == 22

test_input = { "n": 5, "edges": [[1,4],[2,4],[5,4],[3,4]] }
assert my_solution.countPaths(**test_input) == 6

test_input = { "n": 10, "edges": [[9,4],[7,9],[10,9],[6,7],[8,7],[2,7],[3,2],[1,9],[5,10]] }
assert my_solution.countPaths(**test_input) == 19

test_input = { "n": 7, "edges": [[4,7],[6,7],[1,7],[3,7],[2,6],[5,6]] }
assert my_solution.countPaths(**test_input) == 8

test_input = { "n": 5, "edges": [[1,4],[2,1],[5,2],[3,1]] }
assert my_solution.countPaths(**test_input) == 4

test_input = { "n": 5, "edges": [[4,5],[2,5],[1,4],[3,1]] }
assert my_solution.countPaths(**test_input) == 4

test_input = { "n": 10, "edges": [[4,3],[5,3],[1,4],[7,5],[6,3],[8,3],[9,1],[10,8],[2,10]] }
assert my_solution.countPaths(**test_input) == 19

test_input = { "n": 5, "edges": [[1,3],[4,1],[2,1],[5,1]] }
assert my_solution.countPaths(**test_input) == 6

test_input = { "n": 7, "edges": [[5,2],[3,5],[4,5],[1,2],[6,2],[7,2]] }
assert my_solution.countPaths(**test_input) == 4

test_input = { "n": 5, "edges": [[3,4],[1,4],[5,3],[2,5]] }
assert my_solution.countPaths(**test_input) == 2

test_input = { "n": 8, "edges": [[1,8],[2,1],[6,8],[3,6],[4,3],[5,8],[7,2]] }
assert my_solution.countPaths(**test_input) == 13

test_input = { "n": 9, "edges": [[2,1],[6,1],[8,2],[9,8],[4,9],[7,9],[3,1],[5,2]] }
assert my_solution.countPaths(**test_input) == 16

test_input = { "n": 5, "edges": [[4,3],[5,4],[1,5],[2,3]] }
assert my_solution.countPaths(**test_input) == 4

test_input = { "n": 8, "edges": [[2,4],[3,4],[6,4],[7,3],[8,7],[5,6],[1,5]] }
assert my_solution.countPaths(**test_input) == 10

test_input = { "n": 6, "edges": [[3,6],[1,3],[2,3],[5,2],[4,5]] }
assert my_solution.countPaths(**test_input) == 4

test_input = { "n": 10, "edges": [[7,5],[4,7],[10,5],[6,5],[8,6],[2,8],[9,4],[3,10],[1,9]] }
assert my_solution.countPaths(**test_input) == 11

test_input = { "n": 8, "edges": [[3,2],[8,3],[7,3],[6,2],[4,7],[5,6],[1,8]] }
assert my_solution.countPaths(**test_input) == 5

test_input = { "n": 8, "edges": [[2,6],[3,6],[5,2],[1,6],[7,2],[8,1],[4,1]] }
assert my_solution.countPaths(**test_input) == 8

test_input = { "n": 9, "edges": [[3,7],[6,7],[4,7],[1,6],[8,4],[9,1],[2,7],[5,2]] }
assert my_solution.countPaths(**test_input) == 11

test_input = { "n": 6, "edges": [[6,2],[5,6],[1,2],[3,2],[4,3]] }
assert my_solution.countPaths(**test_input) == 5

test_input = { "n": 6, "edges": [[6,2],[1,6],[3,1],[5,3],[4,3]] }
assert my_solution.countPaths(**test_input) == 7

test_input = { "n": 8, "edges": [[2,3],[8,3],[5,3],[6,3],[4,3],[7,8],[1,2]] }
assert my_solution.countPaths(**test_input) == 8

test_input = { "n": 7, "edges": [[4,6],[5,6],[7,6],[3,4],[2,6],[1,5]] }
assert my_solution.countPaths(**test_input) == 11

test_input = { "n": 6, "edges": [[4,2],[5,4],[1,5],[6,1],[3,1]] }
assert my_solution.countPaths(**test_input) == 8

test_input = { "n": 6, "edges": [[4,1],[6,1],[5,4],[3,5],[2,1]] }
assert my_solution.countPaths(**test_input) == 6

test_input = { "n": 7, "edges": [[6,7],[1,6],[4,6],[2,7],[3,2],[5,7]] }
assert my_solution.countPaths(**test_input) == 3

test_input = { "n": 6, "edges": [[4,3],[5,3],[6,5],[2,4],[1,5]] }
assert my_solution.countPaths(**test_input) == 5

test_input = { "n": 10, "edges": [[2,5],[3,5],[10,2],[8,3],[7,5],[4,3],[1,8],[9,5],[6,8]] }
assert my_solution.countPaths(**test_input) == 9

test_input = { "n": 8, "edges": [[2,8],[1,8],[5,2],[4,5],[6,5],[7,2],[3,5]] }
assert my_solution.countPaths(**test_input) == 5

test_input = { "n": 8, "edges": [[7,2],[6,7],[5,7],[8,6],[1,7],[3,5],[4,2]] }
assert my_solution.countPaths(**test_input) == 6

test_input = { "n": 7, "edges": [[5,7],[3,5],[2,7],[4,3],[6,3],[1,4]] }
assert my_solution.countPaths(**test_input) == 5

test_input = { "n": 7, "edges": [[2,3],[1,3],[7,3],[4,1],[6,3],[5,1]] }
assert my_solution.countPaths(**test_input) == 7

test_input = { "n": 7, "edges": [[4,2],[6,4],[1,6],[7,6],[5,2],[3,7]] }
assert my_solution.countPaths(**test_input) == 6

test_input = { "n": 6, "edges": [[3,4],[6,3],[1,4],[5,4],[2,6]] }
assert my_solution.countPaths(**test_input) == 8

test_input = { "n": 10, "edges": [[2,7],[1,2],[8,7],[4,2],[6,8],[10,7],[5,4],[9,8],[3,6]] }
assert my_solution.countPaths(**test_input) == 14

test_input = { "n": 8, "edges": [[6,2],[7,2],[5,6],[8,2],[3,6],[1,8],[4,2]] }
assert my_solution.countPaths(**test_input) == 11

test_input = { "n": 10, "edges": [[9,6],[1,9],[2,1],[8,1],[10,6],[7,6],[3,8],[4,3],[5,3]] }
assert my_solution.countPaths(**test_input) == 21

test_input = { "n": 8, "edges": [[4,6],[1,6],[7,6],[2,1],[8,7],[5,6],[3,5]] }
assert my_solution.countPaths(**test_input) == 13

test_input = { "n": 7, "edges": [[3,7],[6,7],[4,6],[1,3],[5,3],[2,3]] }
assert my_solution.countPaths(**test_input) == 3

test_input = { "n": 10, "edges": [[2,9],[3,9],[8,9],[10,3],[1,9],[4,8],[7,10],[6,1],[5,10]] }
assert my_solution.countPaths(**test_input) == 18

test_input = { "n": 8, "edges": [[5,6],[3,6],[7,5],[4,6],[8,6],[2,3],[1,3]] }
assert my_solution.countPaths(**test_input) == 10

test_input = { "n": 9, "edges": [[9,3],[4,3],[2,9],[7,3],[8,7],[1,7],[5,4],[6,2]] }
assert my_solution.countPaths(**test_input) == 10

test_input = { "n": 6, "edges": [[5,1],[2,1],[4,2],[6,5],[3,4]] }
assert my_solution.countPaths(**test_input) == 7

test_input = { "n": 7, "edges": [[3,6],[2,6],[5,6],[7,2],[1,6],[4,2]] }
assert my_solution.countPaths(**test_input) == 9

test_input = { "n": 5, "edges": [[1,5],[3,5],[4,3],[2,5]] }
assert my_solution.countPaths(**test_input) == 2

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

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

test_input = { "n": 10, "edges": [[8,10],[3,10],[1,8],[7,8],[6,10],[2,3],[5,8],[9,5],[4,6]] }
assert my_solution.countPaths(**test_input) == 21

test_input = { "n": 10, "edges": [[4,8],[6,8],[9,4],[1,6],[5,8],[2,8],[10,9],[7,6],[3,5]] }
assert my_solution.countPaths(**test_input) == 18

test_input = { "n": 9, "edges": [[4,6],[9,4],[3,6],[7,6],[1,4],[5,9],[2,7],[8,4]] }
assert my_solution.countPaths(**test_input) == 15

test_input = { "n": 7, "edges": [[7,6],[2,6],[1,7],[3,2],[5,2],[4,5]] }
assert my_solution.countPaths(**test_input) == 5

test_input = { "n": 9, "edges": [[1,8],[5,8],[3,8],[2,1],[9,2],[7,1],[6,5],[4,9]] }
assert my_solution.countPaths(**test_input) == 17

test_input = { "n": 7, "edges": [[3,5],[4,3],[6,5],[2,4],[7,3],[1,4]] }
assert my_solution.countPaths(**test_input) == 5

test_input = { "n": 10, "edges": [[5,2],[8,5],[10,5],[3,8],[4,2],[1,4],[9,10],[7,5],[6,8]] }
assert my_solution.countPaths(**test_input) == 12

test_input = { "n": 8, "edges": [[7,4],[1,4],[5,7],[6,1],[8,5],[3,8],[2,6]] }
assert my_solution.countPaths(**test_input) == 8

test_input = { "n": 10, "edges": [[8,2],[7,8],[9,2],[4,2],[6,4],[3,9],[5,4],[1,9],[10,8]] }
assert my_solution.countPaths(**test_input) == 24

test_input = { "n": 8, "edges": [[3,8],[2,8],[1,8],[6,8],[4,3],[7,6],[5,2]] }
assert my_solution.countPaths(**test_input) == 13

test_input = { "n": 9, "edges": [[5,4],[2,4],[9,5],[3,2],[7,3],[1,4],[8,2],[6,4]] }
assert my_solution.countPaths(**test_input) == 14

test_input = { "n": 10, "edges": [[10,8],[5,10],[1,10],[3,10],[7,3],[2,10],[6,8],[9,6],[4,6]] }
assert my_solution.countPaths(**test_input) == 18

test_input = { "n": 9, "edges": [[6,7],[5,7],[8,7],[9,6],[2,5],[4,5],[1,8],[3,6]] }
assert my_solution.countPaths(**test_input) == 11

test_input = { "n": 10, "edges": [[1,6],[9,1],[5,9],[10,6],[4,9],[8,9],[7,8],[2,1],[3,1]] }
assert my_solution.countPaths(**test_input) == 24

test_input = { "n": 8, "edges": [[4,5],[3,4],[6,5],[1,4],[2,3],[8,4],[7,3]] }
assert my_solution.countPaths(**test_input) == 10

test_input = { "n": 7, "edges": [[7,4],[6,4],[2,6],[5,6],[3,2],[1,5]] }
assert my_solution.countPaths(**test_input) == 9

test_input = { "n": 10, "edges": [[3,2],[5,3],[1,2],[9,5],[7,5],[6,3],[4,3],[8,6],[10,1]] }
assert my_solution.countPaths(**test_input) == 8

test_input = { "n": 8, "edges": [[2,8],[5,2],[4,2],[7,4],[3,2],[1,3],[6,3]] }
assert my_solution.countPaths(**test_input) == 7

test_input = { "n": 6, "edges": [[6,3],[2,3],[4,2],[5,2],[1,6]] }
assert my_solution.countPaths(**test_input) == 3

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

test_input = { "n": 5, "edges": [[1,2],[5,1],[4,5],[3,4]] }
assert my_solution.countPaths(**test_input) == 5

test_input = { "n": 9, "edges": [[8,3],[6,8],[2,8],[4,3],[5,4],[7,5],[9,4],[1,5]] }
assert my_solution.countPaths(**test_input) == 15

test_input = { "n": 5, "edges": [[2,1],[4,2],[5,1],[3,2]] }
assert my_solution.countPaths(**test_input) == 4

test_input = { "n": 6, "edges": [[4,2],[6,2],[3,2],[1,6],[5,2]] }
assert my_solution.countPaths(**test_input) == 5

test_input = { "n": 10, "edges": [[10,5],[3,10],[4,3],[8,3],[7,4],[1,7],[6,5],[9,1],[2,5]] }
assert my_solution.countPaths(**test_input) == 14

test_input = { "n": 9, "edges": [[4,7],[6,4],[8,4],[2,8],[5,2],[9,7],[1,6],[3,7]] }
assert my_solution.countPaths(**test_input) == 13

test_input = { "n": 10, "edges": [[7,3],[1,3],[2,3],[10,2],[4,2],[8,1],[9,4],[5,3],[6,3]] }
assert my_solution.countPaths(**test_input) == 10

test_input = { "n": 7, "edges": [[4,7],[2,7],[3,4],[1,7],[6,4],[5,4]] }
assert my_solution.countPaths(**test_input) == 9


sum-of-values-at-indices-with-k-set-bits

Sum of Values at Indices With K Set Bits

Prompt:
"""
You are given a 0-indexed integer array nums and an integer k.

Return an integer that denotes the sum of elements in nums whose corresponding indices have exactly k set bits in their binary representation.

The set bits in an integer are the 1's present when it is written in binary.

 * For example, the binary representation of 21 is 10101, which has 3 set bits.

Example 1:

Input: nums = [5,10,1,5,2], k = 1
Output: 13
Explanation: The binary representation of the indices are:
0 = 0002
1 = 0012
2 = 0102
3 = 0112
4 = 1002
Indices 1, 2, and 4 have k = 1 set bits in their binary representation.
Hence, the answer is nums[1] + nums[2] + nums[4] = 13.

Example 2:

Input: nums = [4,3,2,1], k = 2
Output: 1
Explanation: The binary representation of the indices are:
0 = 002
1 = 012
2 = 102
3 = 112
Only index 3 has k = 2 set bits in its binary representation.
Hence, the answer is nums[3] = 1.

Constraints:

 * 1 <= nums.length <= 1000
 * 1 <= nums[i] <= 105
 * 0 <= k <= 10
"""
class Solution:
    def sumIndicesWithKSetBits(self, nums: List[int], k: int) -> int:

You are given a 0-indexed integer array nums and an integer k.

Return an integer that denotes the sum of elements in nums whose corresponding indices have exactly k set bits in their binary representation.

The set bits in an integer are the 1's present when it is written in binary.

 * For example, the binary representation of 21 is 10101, which has 3 set bits.

Example 1:

Input: nums = [5,10,1,5,2], k = 1
Output: 13
Explanation: The binary representation of the indices are:
0 = 0002
1 = 0012
2 = 0102
3 = 0112
4 = 1002
Indices 1, 2, and 4 have k = 1 set bits in their binary representation.
Hence, the answer is nums[1] + nums[2] + nums[4] = 13.

Example 2:

Input: nums = [4,3,2,1], k = 2
Output: 1
Explanation: The binary representation of the indices are:
0 = 002
1 = 012
2 = 102
3 = 112
Only index 3 has k = 2 set bits in its binary representation.
Hence, the answer is nums[3] = 1.

Constraints:

 * 1 <= nums.length <= 1000
 * 1 <= nums[i] <= 105
 * 0 <= k <= 10

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

```

my_solution = Solution()

test_input = { "nums": [5,10,1,5,2], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 13

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

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

test_input = { "nums": [100000], "k": 0 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 100000

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

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

test_input = { "nums": [2,7], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 7

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

test_input = { "nums": [3,9], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 9

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

test_input = { "nums": [4,8], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 8

test_input = { "nums": [6,6], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 6

test_input = { "nums": [7,2], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 2

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

test_input = { "nums": [8,4], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 4

test_input = { "nums": [8,9], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 9

test_input = { "nums": [9,9], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 9

test_input = { "nums": [15,43], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 43

test_input = { "nums": [35,86], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 86

test_input = { "nums": [36,14], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 14

test_input = { "nums": [47,61], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 61

test_input = { "nums": [60,46], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 46

test_input = { "nums": [70,7], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 7

test_input = { "nums": [1,51,55], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 106

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

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

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

test_input = { "nums": [3,7,5], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 12

test_input = { "nums": [4,5,9], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 14

test_input = { "nums": [5,5,5], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 10

test_input = { "nums": [5,7,7], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 14

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

test_input = { "nums": [6,9,8], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 17

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

test_input = { "nums": [7,9,1], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 10

test_input = { "nums": [8,5,4], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 9

test_input = { "nums": [9,1,6], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 7

test_input = { "nums": [9,3,5], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 8

test_input = { "nums": [57,48,69], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 117

test_input = { "nums": [78,37,59], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 96

test_input = { "nums": [96,71,53], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 124

test_input = { "nums": [900,914,367], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 1281

test_input = { "nums": [1,4,9,2], "k": 2 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 2

test_input = { "nums": [1,5,9,5], "k": 2 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 5

test_input = { "nums": [1,8,5,6], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 13

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

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

test_input = { "nums": [2,5,8,1], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 13

test_input = { "nums": [2,7,3,9], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 10

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

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

test_input = { "nums": [6,3,8,8], "k": 2 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 8

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

test_input = { "nums": [7,1,9,6], "k": 2 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 6

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

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

test_input = { "nums": [7,8,6,2], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 14

test_input = { "nums": [8,3,9,8], "k": 2 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 8

test_input = { "nums": [8,7,3,2], "k": 2 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 2

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

test_input = { "nums": [9,6,8,8], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 14

test_input = { "nums": [9,7,8,9], "k": 2 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 9

test_input = { "nums": [9,40,73,19], "k": 2 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 19

test_input = { "nums": [41,51,58,2], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 109

test_input = { "nums": [44,96,36,56], "k": 2 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 56

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

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

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

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

test_input = { "nums": [4,2,8,8,2], "k": 2 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 8

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

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

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

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

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

test_input = { "nums": [7,7,9,5,8], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 24

test_input = { "nums": [7,9,1,3,2], "k": 2 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 3

test_input = { "nums": [8,5,6,9,7], "k": 2 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 9

test_input = { "nums": [8,6,9,4,4], "k": 2 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 4

test_input = { "nums": [8,8,2,9,2], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 12

test_input = { "nums": [9,3,7,9,6], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 16

test_input = { "nums": [9,5,5,5,5], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 15

test_input = { "nums": [27,73,37,82,78], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 188

test_input = { "nums": [36,28,94,49,79], "k": 2 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 49

test_input = { "nums": [48,54,75,72,77], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 206

test_input = { "nums": [574,419,838,216,442], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 1699

test_input = { "nums": [1,1,1,2,5,7], "k": 2 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 9

test_input = { "nums": [2,6,6,8,6,4], "k": 2 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 12

test_input = { "nums": [2,8,2,9,2,8], "k": 2 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 17

test_input = { "nums": [2,9,1,6,5,7], "k": 2 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 13

test_input = { "nums": [2,9,1,6,6,7], "k": 2 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 13

test_input = { "nums": [3,5,4,5,8,9], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 17

test_input = { "nums": [5,5,3,7,9,7], "k": 1 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 17

test_input = { "nums": [5,9,4,8,7,2], "k": 2 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 10

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

test_input = { "nums": [6,4,7,8,4,7], "k": 2 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 15

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

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

test_input = { "nums": [7,2,9,7,8,7], "k": 2 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 14

test_input = { "nums": [7,6,6,7,6,1], "k": 2 }
assert my_solution.sumIndicesWithKSetBits(**test_input) == 8


happy-students

Happy Students

Prompt:
"""
You are given a 0-indexed integer array nums of length n where n is the total number of students in the class. The class teacher tries to select a group of students so that all the students remain happy.

The ith student will become happy if one of these two conditions is met:

 * The student is selected and the total number of selected students is strictly greater than nums[i].
 * The student is not selected and the total number of selected students is strictly less than nums[i].

Return the number of ways to select a group of students so that everyone remains happy.

Example 1:

Input: nums = [1,1]
Output: 2
Explanation:
The two possible ways are:
The class teacher selects no student.
The class teacher selects both students to form the group.
If the class teacher selects just one student to form a group then the both students will not be happy. Therefore, there are only two possible ways.

Example 2:

Input: nums = [6,0,3,3,6,7,2,7]
Output: 3
Explanation:
The three possible ways are:
The class teacher selects the student with index = 1 to form the group.
The class teacher selects the students with index = 1, 2, 3, 6 to form the group.
The class teacher selects all the students to form the group.

Constraints:

 * 1 <= nums.length <= 105
 * 0 <= nums[i] < nums.length
"""
class Solution:
    def countWays(self, nums: List[int]) -> int:

You are given a 0-indexed integer array nums of length n where n is the total number of students in the class. The class teacher tries to select a group of students so that all the students remain happy.

The ith student will become happy if one of these two conditions is met:

 * The student is selected and the total number of selected students is strictly greater than nums[i].
 * The student is not selected and the total number of selected students is strictly less than nums[i].

Return the number of ways to select a group of students so that everyone remains happy.

Example 1:

Input: nums = [1,1]
Output: 2
Explanation:
The two possible ways are:
The class teacher selects no student.
The class teacher selects both students to form the group.
If the class teacher selects just one student to form a group then the both students will not be happy. Therefore, there are only two possible ways.

Example 2:

Input: nums = [6,0,3,3,6,7,2,7]
Output: 3
Explanation:
The three possible ways are:
The class teacher selects the student with index = 1 to form the group.
The class teacher selects the students with index = 1, 2, 3, 6 to form the group.
The class teacher selects all the students to form the group.

Constraints:

 * 1 <= nums.length <= 105
 * 0 <= nums[i] < nums.length

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

```

my_solution = Solution()

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

test_input = { "nums": [6,0,3,3,6,7,2,7] }
assert my_solution.countWays(**test_input) == 3

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

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

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

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

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

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

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

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

test_input = { "nums": [4,2,3,6,6,0,6,8,3] }
assert my_solution.countWays(**test_input) == 3

test_input = { "nums": [0,0,1,7,2,0,6,5] }
assert my_solution.countWays(**test_input) == 1

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

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

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

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

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

test_input = { "nums": [0,9,4,6,8,8,1,7,4,7] }
assert my_solution.countWays(**test_input) == 2

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

test_input = { "nums": [7,9,0,3,6,9,4,0,8,7] }
assert my_solution.countWays(**test_input) == 2

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

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

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

test_input = { "nums": [5,3,9,2,4,2,1,2,8,6] }
assert my_solution.countWays(**test_input) == 2

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

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

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

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

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

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

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

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

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

test_input = { "nums": [1,7,8,7,1,0,7,3,8] }
assert my_solution.countWays(**test_input) == 2

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

test_input = { "nums": [2,3,9,0,1,3,9,2,6,1] }
assert my_solution.countWays(**test_input) == 2


maximum-number-of-alloys

Maximum Number of Alloys

Prompt:
"""
You are the owner of a company that creates alloys using various types of metals. There are n different types of metals available, and you have access to k machines that can be used to create alloys. Each machine requires a specific amount of each metal type to create an alloy.

For the ith machine to create an alloy, it needs composition[i][j] units of metal of type j. Initially, you have stock[i] units of metal type i, and purchasing one unit of metal type i costs cost[i] coins.

Given integers n, k, budget, a 1-indexed 2D array composition, and 1-indexed arrays stock and cost, your goal is to maximize the number of alloys the company can create while staying within the budget of budget coins.

All alloys must be created with the same machine.

Return the maximum number of alloys that the company can create.

Example 1:

Input: n = 3, k = 2, budget = 15, composition = [[1,1,1],[1,1,10]], stock = [0,0,0], cost = [1,2,3]
Output: 2
Explanation: It is optimal to use the 1st machine to create alloys.
To create 2 alloys we need to buy the:
- 2 units of metal of the 1st type.
- 2 units of metal of the 2nd type.
- 2 units of metal of the 3rd type.
In total, we need 2 * 1 + 2 * 2 + 2 * 3 = 12 coins, which is smaller than or equal to budget = 15.
Notice that we have 0 units of metal of each type and we have to buy all the required units of metal.
It can be proven that we can create at most 2 alloys.

Example 2:

Input: n = 3, k = 2, budget = 15, composition = [[1,1,1],[1,1,10]], stock = [0,0,100], cost = [1,2,3]
Output: 5
Explanation: It is optimal to use the 2nd machine to create alloys.
To create 5 alloys we need to buy:
- 5 units of metal of the 1st type.
- 5 units of metal of the 2nd type.
- 0 units of metal of the 3rd type.
In total, we need 5 * 1 + 5 * 2 + 0 * 3 = 15 coins, which is smaller than or equal to budget = 15.
It can be proven that we can create at most 5 alloys.

Example 3:

Input: n = 2, k = 3, budget = 10, composition = [[2,1],[1,2],[1,1]], stock = [1,1], cost = [5,5]
Output: 2
Explanation: It is optimal to use the 3rd machine to create alloys.
To create 2 alloys we need to buy the:
- 1 unit of metal of the 1st type.
- 1 unit of metal of the 2nd type.
In total, we need 1 * 5 + 1 * 5 = 10 coins, which is smaller than or equal to budget = 10.
It can be proven that we can create at most 2 alloys.

Constraints:

 * 1 <= n, k <= 100
 * 0 <= budget <= 108
 * composition.length == k
 * composition[i].length == n
 * 1 <= composition[i][j] <= 100
 * stock.length == cost.length == n
 * 0 <= stock[i] <= 108
 * 1 <= cost[i] <= 100
"""
class Solution:
    def maxNumberOfAlloys(self, n: int, k: int, budget: int, composition: List[List[int]], stock: List[int], cost: List[int]) -> int:

You are the owner of a company that creates alloys using various types of metals. There are n different types of metals available, and you have access to k machines that can be used to create alloys. Each machine requires a specific amount of each metal type to create an alloy.

For the ith machine to create an alloy, it needs composition[i][j] units of metal of type j. Initially, you have stock[i] units of metal type i, and purchasing one unit of metal type i costs cost[i] coins.

Given integers n, k, budget, a 1-indexed 2D array composition, and 1-indexed arrays stock and cost, your goal is to maximize the number of alloys the company can create while staying within the budget of budget coins.

All alloys must be created with the same machine.

Return the maximum number of alloys that the company can create.

Example 1:

Input: n = 3, k = 2, budget = 15, composition = [[1,1,1],[1,1,10]], stock = [0,0,0], cost = [1,2,3]
Output: 2
Explanation: It is optimal to use the 1st machine to create alloys.
To create 2 alloys we need to buy the:
- 2 units of metal of the 1st type.
- 2 units of metal of the 2nd type.
- 2 units of metal of the 3rd type.
In total, we need 2 * 1 + 2 * 2 + 2 * 3 = 12 coins, which is smaller than or equal to budget = 15.
Notice that we have 0 units of metal of each type and we have to buy all the required units of metal.
It can be proven that we can create at most 2 alloys.

Example 2:

Input: n = 3, k = 2, budget = 15, composition = [[1,1,1],[1,1,10]], stock = [0,0,100], cost = [1,2,3]
Output: 5
Explanation: It is optimal to use the 2nd machine to create alloys.
To create 5 alloys we need to buy:
- 5 units of metal of the 1st type.
- 5 units of metal of the 2nd type.
- 0 units of metal of the 3rd type.
In total, we need 5 * 1 + 5 * 2 + 0 * 3 = 15 coins, which is smaller than or equal to budget = 15.
It can be proven that we can create at most 5 alloys.

Example 3:

Input: n = 2, k = 3, budget = 10, composition = [[2,1],[1,2],[1,1]], stock = [1,1], cost = [5,5]
Output: 2
Explanation: It is optimal to use the 3rd machine to create alloys.
To create 2 alloys we need to buy the:
- 1 unit of metal of the 1st type.
- 1 unit of metal of the 2nd type.
In total, we need 1 * 5 + 1 * 5 = 10 coins, which is smaller than or equal to budget = 10.
It can be proven that we can create at most 2 alloys.

Constraints:

 * 1 <= n, k <= 100
 * 0 <= budget <= 108
 * composition.length == k
 * composition[i].length == n
 * 1 <= composition[i][j] <= 100
 * stock.length == cost.length == n
 * 0 <= stock[i] <= 108
 * 1 <= cost[i] <= 100

Please complete the code below to solve above prblem:
```python
class Solution:
    def maxNumberOfAlloys(self, n: int, k: int, budget: int, composition: List[List[int]], stock: List[int], cost: List[int]) -> int:

```


maximum-element-sum-of-a-complete-subset-of-indices

Maximum Element-Sum of a Complete Subset of Indices

Prompt:
"""
You are given a 1-indexed array nums of n integers.

A set of numbers is complete if the product of every pair of its elements is a perfect square.

For a subset of the indices set {1, 2, ..., n} represented as {i1, i2, ..., ik}, we define its element-sum as: nums[i1] + nums[i2] + ... + nums[ik].

Return the maximum element-sum of a complete subset of the indices set {1, 2, ..., n}.

A perfect square is a number that can be expressed as the product of an integer by itself.

Example 1:

Input: nums = [8,7,3,5,7,2,4,9]
Output: 16
Explanation: Apart from the subsets consisting of a single index, there are two other complete subsets of indices: {1,4} and {2,8}.
The sum of the elements corresponding to indices 1 and 4 is equal to nums[1] + nums[4] = 8 + 5 = 13.
The sum of the elements corresponding to indices 2 and 8 is equal to nums[2] + nums[8] = 7 + 9 = 16.
Hence, the maximum element-sum of a complete subset of indices is 16.

Example 2:

Input: nums = [5,10,3,10,1,13,7,9,4]
Output: 19
Explanation: Apart from the subsets consisting of a single index, there are four other complete subsets of indices: {1,4}, {1,9}, {2,8}, {4,9}, and {1,4,9}.
The sum of the elements corresponding to indices 1 and 4 is equal to nums[1] + nums[4] = 5 + 10 = 15.
The sum of the elements corresponding to indices 1 and 9 is equal to nums[1] + nums[9] = 5 + 4 = 9.
The sum of the elements corresponding to indices 2 and 8 is equal to nums[2] + nums[8] = 10 + 9 = 19.
The sum of the elements corresponding to indices 4 and 9 is equal to nums[4] + nums[9] = 10 + 4 = 14.
The sum of the elements corresponding to indices 1, 4, and 9 is equal to nums[1] + nums[4] + nums[9] = 5 + 10 + 4 = 19.
Hence, the maximum element-sum of a complete subset of indices is 19.

Constraints:

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

You are given a 1-indexed array nums of n integers.

A set of numbers is complete if the product of every pair of its elements is a perfect square.

For a subset of the indices set {1, 2, ..., n} represented as {i1, i2, ..., ik}, we define its element-sum as: nums[i1] + nums[i2] + ... + nums[ik].

Return the maximum element-sum of a complete subset of the indices set {1, 2, ..., n}.

A perfect square is a number that can be expressed as the product of an integer by itself.

Example 1:

Input: nums = [8,7,3,5,7,2,4,9]
Output: 16
Explanation: Apart from the subsets consisting of a single index, there are two other complete subsets of indices: {1,4} and {2,8}.
The sum of the elements corresponding to indices 1 and 4 is equal to nums[1] + nums[4] = 8 + 5 = 13.
The sum of the elements corresponding to indices 2 and 8 is equal to nums[2] + nums[8] = 7 + 9 = 16.
Hence, the maximum element-sum of a complete subset of indices is 16.

Example 2:

Input: nums = [5,10,3,10,1,13,7,9,4]
Output: 19
Explanation: Apart from the subsets consisting of a single index, there are four other complete subsets of indices: {1,4}, {1,9}, {2,8}, {4,9}, and {1,4,9}.
The sum of the elements corresponding to indices 1 and 4 is equal to nums[1] + nums[4] = 5 + 10 = 15.
The sum of the elements corresponding to indices 1 and 9 is equal to nums[1] + nums[9] = 5 + 4 = 9.
The sum of the elements corresponding to indices 2 and 8 is equal to nums[2] + nums[8] = 10 + 9 = 19.
The sum of the elements corresponding to indices 4 and 9 is equal to nums[4] + nums[9] = 10 + 4 = 14.
The sum of the elements corresponding to indices 1, 4, and 9 is equal to nums[1] + nums[4] + nums[9] = 5 + 10 + 4 = 19.
Hence, the maximum element-sum of a complete subset of indices is 19.

Constraints:

 * 1 <= n == nums.length <= 104
 * 1 <= nums[i] <= 109

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

```

my_solution = Solution()

test_input = { "nums": [8,7,3,5,7,2,4,9] }
assert my_solution.maximumSum(**test_input) == 16

test_input = { "nums": [5,10,3,10,1,13,7,9,4] }
assert my_solution.maximumSum(**test_input) == 19

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

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

test_input = { "nums": [998244353,998244353,998244353,998244353] }
assert my_solution.maximumSum(**test_input) == 1996488706

test_input = { "nums": [1000000000,1,1,1000000000] }
assert my_solution.maximumSum(**test_input) == 2000000000

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

test_input = { "nums": [5,10,3,10,1,13,7,20,4] }
assert my_solution.maximumSum(**test_input) == 30

test_input = { "nums": [5,3,3,10,1,13,7,67,4] }
assert my_solution.maximumSum(**test_input) == 70

test_input = { "nums": [35,45,29,16,42,49,25,19,46] }
assert my_solution.maximumSum(**test_input) == 97

test_input = { "nums": [34,43,47,50,45] }
assert my_solution.maximumSum(**test_input) == 84

test_input = { "nums": [4,31,45,34,44] }
assert my_solution.maximumSum(**test_input) == 45

test_input = { "nums": [12,5,49,26] }
assert my_solution.maximumSum(**test_input) == 49

test_input = { "nums": [41] }
assert my_solution.maximumSum(**test_input) == 41

test_input = { "nums": [38,9,37,11,20,43] }
assert my_solution.maximumSum(**test_input) == 49

test_input = { "nums": [47,50,17,49,12,22] }
assert my_solution.maximumSum(**test_input) == 96

test_input = { "nums": [23,13,17,3,21,23] }
assert my_solution.maximumSum(**test_input) == 26

test_input = { "nums": [38,28] }
assert my_solution.maximumSum(**test_input) == 38

test_input = { "nums": [16,31,37,29,28,34,25,36] }
assert my_solution.maximumSum(**test_input) == 67

test_input = { "nums": [19,46,37,44,4,40,24,17,49] }
assert my_solution.maximumSum(**test_input) == 112

test_input = { "nums": [28,40,37] }
assert my_solution.maximumSum(**test_input) == 40

test_input = { "nums": [19,6,30,23,25,45,15,2,3,46] }
assert my_solution.maximumSum(**test_input) == 46

test_input = { "nums": [5,16,4,13,37,44,49,7] }
assert my_solution.maximumSum(**test_input) == 49

test_input = { "nums": [40,8,19,26] }
assert my_solution.maximumSum(**test_input) == 66

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

test_input = { "nums": [1,5,35,20,32,18,6,49,34,15] }
assert my_solution.maximumSum(**test_input) == 55

test_input = { "nums": [25,31,4,20,45] }
assert my_solution.maximumSum(**test_input) == 45

test_input = { "nums": [32,3,25,15,37,37,21,24,8,33] }
assert my_solution.maximumSum(**test_input) == 55

test_input = { "nums": [13] }
assert my_solution.maximumSum(**test_input) == 13

test_input = { "nums": [41,25,20,28,40,22,37,43,6,32] }
assert my_solution.maximumSum(**test_input) == 75

test_input = { "nums": [23,9,7,24,30,34,10,47] }
assert my_solution.maximumSum(**test_input) == 56

test_input = { "nums": [11,31,1,34,8,20,15,20,49] }
assert my_solution.maximumSum(**test_input) == 94

test_input = { "nums": [41,21,4,15,25,38,26,7,6] }
assert my_solution.maximumSum(**test_input) == 62

test_input = { "nums": [46,31,28,34,12,40,11,31,8,25] }
assert my_solution.maximumSum(**test_input) == 88

test_input = { "nums": [50] }
assert my_solution.maximumSum(**test_input) == 50

test_input = { "nums": [41,43,17,35] }
assert my_solution.maximumSum(**test_input) == 76

test_input = { "nums": [20,6] }
assert my_solution.maximumSum(**test_input) == 20

test_input = { "nums": [43,18,10,19,20,9,49] }
assert my_solution.maximumSum(**test_input) == 62

test_input = { "nums": [3,39,29,5,6,36,38,26,14,10] }
assert my_solution.maximumSum(**test_input) == 65

test_input = { "nums": [47,2,48,16,10,3,45,20,39] }
assert my_solution.maximumSum(**test_input) == 102

test_input = { "nums": [11,47,27,17,7] }
assert my_solution.maximumSum(**test_input) == 47

test_input = { "nums": [48,17,41,23,40,9,3,26,44,34] }
assert my_solution.maximumSum(**test_input) == 115

test_input = { "nums": [47,2,42,10,15,44,35,50] }
assert my_solution.maximumSum(**test_input) == 57

test_input = { "nums": [45,48,50,24,23,14,2,33] }
assert my_solution.maximumSum(**test_input) == 81

test_input = { "nums": [7,39,27,39,43,42,31,37,15] }
assert my_solution.maximumSum(**test_input) == 76

test_input = { "nums": [10,36,23,31] }
assert my_solution.maximumSum(**test_input) == 41

test_input = { "nums": [27,27,13,37] }
assert my_solution.maximumSum(**test_input) == 64

test_input = { "nums": [34,17,26,13] }
assert my_solution.maximumSum(**test_input) == 47

test_input = { "nums": [9,42] }
assert my_solution.maximumSum(**test_input) == 42

test_input = { "nums": [23,42,4,28,30,36,30,39] }
assert my_solution.maximumSum(**test_input) == 81

test_input = { "nums": [10,28,28,21,25,14,38] }
assert my_solution.maximumSum(**test_input) == 38

test_input = { "nums": [40,34,26,9,23,15,23,27,49] }
assert my_solution.maximumSum(**test_input) == 98

test_input = { "nums": [27,42,40,2,1] }
assert my_solution.maximumSum(**test_input) == 42

test_input = { "nums": [48,19,21,21,32,20,50,41,49,30] }
assert my_solution.maximumSum(**test_input) == 118

test_input = { "nums": [10,13,6,39,9] }
assert my_solution.maximumSum(**test_input) == 49

test_input = { "nums": [50,37,24,4,10,43,35] }
assert my_solution.maximumSum(**test_input) == 54

test_input = { "nums": [39,24] }
assert my_solution.maximumSum(**test_input) == 39

test_input = { "nums": [21] }
assert my_solution.maximumSum(**test_input) == 21

test_input = { "nums": [20,15] }
assert my_solution.maximumSum(**test_input) == 20

test_input = { "nums": [23,27,42,3,33,36,43,32,27,48,40,22,5,36,48] }
assert my_solution.maximumSum(**test_input) == 64

test_input = { "nums": [39,46,12,14,25,37,24,44,6,38,4] }
assert my_solution.maximumSum(**test_input) == 90

test_input = { "nums": [36,5,23,17,32,47,23,41,18,44,21,4,22,6,21] }
assert my_solution.maximumSum(**test_input) == 71

test_input = { "nums": [46,26,37,17,15,26,45,45,17,42,16,14,36,40] }
assert my_solution.maximumSum(**test_input) == 80

test_input = { "nums": [46,40,16,48,24,1,13,15,6,5,12,15,4] }
assert my_solution.maximumSum(**test_input) == 100

test_input = { "nums": [11,27,28,26,4,22,10,49,4,23,30,6,5] }
assert my_solution.maximumSum(**test_input) == 76

test_input = { "nums": [37,17,17,18,10,28,47,38,43,20,10] }
assert my_solution.maximumSum(**test_input) == 98

test_input = { "nums": [12,17,9,30,38,20,28,36,34,15,4,15,48] }
assert my_solution.maximumSum(**test_input) == 76

test_input = { "nums": [28,32,22,9,33,26,10,15,15,37,33,48,2,14,35] }
assert my_solution.maximumSum(**test_input) == 70

test_input = { "nums": [35,28,45,34,49,45,38,15,36,33,15,16] }
assert my_solution.maximumSum(**test_input) == 105

test_input = { "nums": [50,18,24,30,6,49,3,20,22,19,25,35,30,33] }
assert my_solution.maximumSum(**test_input) == 102

test_input = { "nums": [10,19,37,1,31,6,2,37,10,1,36,48,7,40] }
assert my_solution.maximumSum(**test_input) == 85

test_input = { "nums": [45,49,32,44,12,39,8,7,3,48,37,27,41,20,18] }
assert my_solution.maximumSum(**test_input) == 92

test_input = { "nums": [40,9,16,40,9,28,29,36,4,17,29] }
assert my_solution.maximumSum(**test_input) == 84

test_input = { "nums": [21,32,24,39,2,13,37,33,50,43,9,43,14] }
assert my_solution.maximumSum(**test_input) == 110

test_input = { "nums": [36,25,21,29,42,40,16,41,22,24,45,7,33] }
assert my_solution.maximumSum(**test_input) == 87

test_input = { "nums": [32,33,7,45,23,13,45,4,15,12] }
assert my_solution.maximumSum(**test_input) == 92

test_input = { "nums": [10,7,1,15,12,22,34,3,36,44,10,12] }
assert my_solution.maximumSum(**test_input) == 61

test_input = { "nums": [26,4,44,3,37,50,27,22,48,14,12,3,39,31] }
assert my_solution.maximumSum(**test_input) == 77

test_input = { "nums": [47,48,8,24,1,17,32,13,19,25,15,30,12] }
assert my_solution.maximumSum(**test_input) == 90

test_input = { "nums": [31,18,11,28,7,34,32,38,47,44,1,13,46] }
assert my_solution.maximumSum(**test_input) == 106

test_input = { "nums": [47,12,35,10,37,36,44,38,19,31,28,21,3,34] }
assert my_solution.maximumSum(**test_input) == 76

test_input = { "nums": [19,47,46,5,7,42,35,3,39,2,1,31] }
assert my_solution.maximumSum(**test_input) == 77

test_input = { "nums": [15,50,14,27,37,44,11,38,23,39,27,36,22] }
assert my_solution.maximumSum(**test_input) == 88

test_input = { "nums": [31,31,18,24,9,27,33,10,23,38,44,4,17,11,14] }
assert my_solution.maximumSum(**test_input) == 78

test_input = { "nums": [38,27,13,20,36,23,6,7,37,20,49,31,25,12] }
assert my_solution.maximumSum(**test_input) == 95

test_input = { "nums": [6,21,11,15,17,47,50,14,24,18,38,19,48,43] }
assert my_solution.maximumSum(**test_input) == 50

test_input = { "nums": [31,4,1,5,50,46,14,17,13,14,17,39,46,18] }
assert my_solution.maximumSum(**test_input) == 50

test_input = { "nums": [39,13,6,45,44,14,44,37,24,20,21,47,6,6,5] }
assert my_solution.maximumSum(**test_input) == 108

test_input = { "nums": [17,16,48,41,7,39,50,29,2,33] }
assert my_solution.maximumSum(**test_input) == 60

test_input = { "nums": [3,8,19,47,29,4,16,31,11,30] }
assert my_solution.maximumSum(**test_input) == 61

test_input = { "nums": [20,1,46,36,35,32,49,14,48,25,17,50,22] }
assert my_solution.maximumSum(**test_input) == 104

test_input = { "nums": [49,20,12,42,33,21,29,30,35,4,5,50] }
assert my_solution.maximumSum(**test_input) == 126

test_input = { "nums": [36,1,8,14,39,2,31,23,10,46,42] }
assert my_solution.maximumSum(**test_input) == 60

test_input = { "nums": [33,29,23,4,48,31,31,26,11,39] }
assert my_solution.maximumSum(**test_input) == 55

test_input = { "nums": [33,36,31,21,2,41,14,36,6,1,22,13,34] }
assert my_solution.maximumSum(**test_input) == 72

test_input = { "nums": [35,32,43,20,4,13,6,19,36,20] }
assert my_solution.maximumSum(**test_input) == 91

test_input = { "nums": [16,41,16,41,11,39,40,7,24,28,13] }
assert my_solution.maximumSum(**test_input) == 81

test_input = { "nums": [32,24,29,24,29,45,10,37,22,35,37,28,15] }
assert my_solution.maximumSum(**test_input) == 78

test_input = { "nums": [45,8,19,1,33,2,32,40,16,33,44,27] }
assert my_solution.maximumSum(**test_input) == 62

test_input = { "nums": [3,42,14,18,1,20,19,7,37,3,2,3,48] }
assert my_solution.maximumSum(**test_input) == 58


minimum-right-shifts-to-sort-the-array

Minimum Right Shifts to Sort the Array

Prompt:
"""
You are given a 0-indexed array nums of length n containing distinct positive integers. Return the minimum number of right shifts required to sort nums and -1 if this is not possible.

A right shift is defined as shifting the element at index i to index (i + 1) % n, for all indices.

Example 1:

Input: nums = [3,4,5,1,2]
Output: 2
Explanation:
After the first right shift, nums = [2,3,4,5,1].
After the second right shift, nums = [1,2,3,4,5].
Now nums is sorted; therefore the answer is 2.

Example 2:

Input: nums = [1,3,5]
Output: 0
Explanation: nums is already sorted therefore, the answer is 0.

Example 3:

Input: nums = [2,1,4]
Output: -1
Explanation: It's impossible to sort the array using right shifts.

Constraints:

 * 1 <= nums.length <= 100
 * 1 <= nums[i] <= 100
 * nums contains distinct integers.
"""
class Solution:
    def minimumRightShifts(self, nums: List[int]) -> int:

You are given a 0-indexed array nums of length n containing distinct positive integers. Return the minimum number of right shifts required to sort nums and -1 if this is not possible.

A right shift is defined as shifting the element at index i to index (i + 1) % n, for all indices.

Example 1:

Input: nums = [3,4,5,1,2]
Output: 2
Explanation:
After the first right shift, nums = [2,3,4,5,1].
After the second right shift, nums = [1,2,3,4,5].
Now nums is sorted; therefore the answer is 2.

Example 2:

Input: nums = [1,3,5]
Output: 0
Explanation: nums is already sorted therefore, the answer is 0.

Example 3:

Input: nums = [2,1,4]
Output: -1
Explanation: It's impossible to sort the array using right shifts.

Constraints:

 * 1 <= nums.length <= 100
 * 1 <= nums[i] <= 100
 * nums contains distinct integers.

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

```

my_solution = Solution()

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

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

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

test_input = { "nums": [31,72,79,25] }
assert my_solution.minimumRightShifts(**test_input) == 1

test_input = { "nums": [27,33,42,58,81,8,9,17] }
assert my_solution.minimumRightShifts(**test_input) == 3

test_input = { "nums": [72,13,21,35,52] }
assert my_solution.minimumRightShifts(**test_input) == 4

test_input = { "nums": [65,73,77,1] }
assert my_solution.minimumRightShifts(**test_input) == 1

test_input = { "nums": [100,8,14,68,80,84] }
assert my_solution.minimumRightShifts(**test_input) == 5

test_input = { "nums": [53,60,64,69,98,40] }
assert my_solution.minimumRightShifts(**test_input) == 1

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

test_input = { "nums": [78,12,18,21,23,36,64,70] }
assert my_solution.minimumRightShifts(**test_input) == 7

test_input = { "nums": [25,26,53,91,92,99,10,24] }
assert my_solution.minimumRightShifts(**test_input) == 2

test_input = { "nums": [63,51,65,87,6,17,32,14,42,46] }
assert my_solution.minimumRightShifts(**test_input) == -1

test_input = { "nums": [43,46,75,76,85,96,9,19,25] }
assert my_solution.minimumRightShifts(**test_input) == 3

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

test_input = { "nums": [35,72,76,82,96,97,24,26] }
assert my_solution.minimumRightShifts(**test_input) == 2

test_input = { "nums": [82,30,94,55,76,51,3,89,52,96] }
assert my_solution.minimumRightShifts(**test_input) == -1

test_input = { "nums": [57,59,88,97,6,27,41,46,52] }
assert my_solution.minimumRightShifts(**test_input) == 5

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

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

test_input = { "nums": [24,46,55,61,71,78,1,4] }
assert my_solution.minimumRightShifts(**test_input) == 2

test_input = { "nums": [83,2,21,42,73,77,80] }
assert my_solution.minimumRightShifts(**test_input) == 6

test_input = { "nums": [83,94,14,43,50,62,63] }
assert my_solution.minimumRightShifts(**test_input) == 5

test_input = { "nums": [38,46,66,77,7,15,17,35] }
assert my_solution.minimumRightShifts(**test_input) == 4

test_input = { "nums": [35,68,82,90,9,18,29,34] }
assert my_solution.minimumRightShifts(**test_input) == 4

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

test_input = { "nums": [71,73,88,12,49,55,59,70] }
assert my_solution.minimumRightShifts(**test_input) == 5

test_input = { "nums": [54,65,75,81,24,37] }
assert my_solution.minimumRightShifts(**test_input) == 2

test_input = { "nums": [57,67,73,78,79,2,45,48,51] }
assert my_solution.minimumRightShifts(**test_input) == 4

test_input = { "nums": [36,62,65,85,95,9,21] }
assert my_solution.minimumRightShifts(**test_input) == 2

test_input = { "nums": [68,12] }
assert my_solution.minimumRightShifts(**test_input) == 1

test_input = { "nums": [34,9,86,20,67,94,65,82,40,79] }
assert my_solution.minimumRightShifts(**test_input) == -1

test_input = { "nums": [92,84,37,19,16,85,20,79,25,89] }
assert my_solution.minimumRightShifts(**test_input) == -1

test_input = { "nums": [3,16,38,44,67,79,84] }
assert my_solution.minimumRightShifts(**test_input) == 0

test_input = { "nums": [14,24,58,69,71,94,13] }
assert my_solution.minimumRightShifts(**test_input) == 1

test_input = { "nums": [100,18] }
assert my_solution.minimumRightShifts(**test_input) == 1

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

test_input = { "nums": [94,30,53,56,67,72,82] }
assert my_solution.minimumRightShifts(**test_input) == 6

test_input = { "nums": [92,14,65,80,85] }
assert my_solution.minimumRightShifts(**test_input) == 4

test_input = { "nums": [43,53,81,87,93,19,31,39] }
assert my_solution.minimumRightShifts(**test_input) == 3

test_input = { "nums": [80,38] }
assert my_solution.minimumRightShifts(**test_input) == 1

test_input = { "nums": [52,72,78,83,85,99,20] }
assert my_solution.minimumRightShifts(**test_input) == 1

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

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

test_input = { "nums": [55,56,63,91,3,46] }
assert my_solution.minimumRightShifts(**test_input) == 2

test_input = { "nums": [58,10,31,37,41] }
assert my_solution.minimumRightShifts(**test_input) == 4

test_input = { "nums": [17,33,53,58,78] }
assert my_solution.minimumRightShifts(**test_input) == 0

test_input = { "nums": [82,44] }
assert my_solution.minimumRightShifts(**test_input) == 1

test_input = { "nums": [89,96,35,48,57,71] }
assert my_solution.minimumRightShifts(**test_input) == 4

test_input = { "nums": [43,69,4,29,37] }
assert my_solution.minimumRightShifts(**test_input) == 3

test_input = { "nums": [65,88] }
assert my_solution.minimumRightShifts(**test_input) == 0

test_input = { "nums": [42,44,59,76,86] }
assert my_solution.minimumRightShifts(**test_input) == 0

test_input = { "nums": [29,56,78,96,1,10,27] }
assert my_solution.minimumRightShifts(**test_input) == 3

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

test_input = { "nums": [4,33,17,3,8,91,28,13,72,42] }
assert my_solution.minimumRightShifts(**test_input) == -1

test_input = { "nums": [5,35,53,56] }
assert my_solution.minimumRightShifts(**test_input) == 0

test_input = { "nums": [65,67,70,27,41,50,52,57,60] }
assert my_solution.minimumRightShifts(**test_input) == 6

test_input = { "nums": [94,32,45,62] }
assert my_solution.minimumRightShifts(**test_input) == 3

test_input = { "nums": [23,25,34,47,61,65,6,21] }
assert my_solution.minimumRightShifts(**test_input) == 2

test_input = { "nums": [99,11,12,21,22,55,62,83] }
assert my_solution.minimumRightShifts(**test_input) == 7

test_input = { "nums": [92,13,33,58,61,85] }
assert my_solution.minimumRightShifts(**test_input) == 5

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

test_input = { "nums": [12,27,30,36] }
assert my_solution.minimumRightShifts(**test_input) == 0

test_input = { "nums": [33,44,57,16,22,26,30] }
assert my_solution.minimumRightShifts(**test_input) == 4

test_input = { "nums": [67,24] }
assert my_solution.minimumRightShifts(**test_input) == 1

test_input = { "nums": [12,44,83,87] }
assert my_solution.minimumRightShifts(**test_input) == 0

test_input = { "nums": [19,52,3,8,12] }
assert my_solution.minimumRightShifts(**test_input) == 3

test_input = { "nums": [82,86,88,6,35,47,52,58,62] }
assert my_solution.minimumRightShifts(**test_input) == 6

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

test_input = { "nums": [60,11] }
assert my_solution.minimumRightShifts(**test_input) == 1

test_input = { "nums": [69,60] }
assert my_solution.minimumRightShifts(**test_input) == 1

test_input = { "nums": [22,28,36,16,82,77,41,85,44,97] }
assert my_solution.minimumRightShifts(**test_input) == -1

test_input = { "nums": [63,94,2,14] }
assert my_solution.minimumRightShifts(**test_input) == 2

test_input = { "nums": [41,45,74,84,90,93,100,18,31] }
assert my_solution.minimumRightShifts(**test_input) == 2

test_input = { "nums": [21,38,57,64,12] }
assert my_solution.minimumRightShifts(**test_input) == 1

test_input = { "nums": [99,2,9,17,33,58,59,72] }
assert my_solution.minimumRightShifts(**test_input) == 7

test_input = { "nums": [36,89,90,98,11,14,23] }
assert my_solution.minimumRightShifts(**test_input) == 3

test_input = { "nums": [84,90,5,57,78] }
assert my_solution.minimumRightShifts(**test_input) == 3

test_input = { "nums": [48,73,76,30] }
assert my_solution.minimumRightShifts(**test_input) == 1

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

test_input = { "nums": [21,84,35,65,12,74,30,95,46,23] }
assert my_solution.minimumRightShifts(**test_input) == -1

test_input = { "nums": [64,76,46,53,54] }
assert my_solution.minimumRightShifts(**test_input) == 3

test_input = { "nums": [77,84,89,47,52,74] }
assert my_solution.minimumRightShifts(**test_input) == 3

test_input = { "nums": [12,29,31,52,88,89,10] }
assert my_solution.minimumRightShifts(**test_input) == 1

test_input = { "nums": [20,25,28,41,57,89] }
assert my_solution.minimumRightShifts(**test_input) == 0

test_input = { "nums": [1,28,51,59] }
assert my_solution.minimumRightShifts(**test_input) == 0

test_input = { "nums": [59,76,2,26,49,78,36,70,64,24] }
assert my_solution.minimumRightShifts(**test_input) == -1

test_input = { "nums": [35,43,49,63,21] }
assert my_solution.minimumRightShifts(**test_input) == 1

test_input = { "nums": [1,35,38,47,54,56,58,74] }
assert my_solution.minimumRightShifts(**test_input) == 0

test_input = { "nums": [49,94,97] }
assert my_solution.minimumRightShifts(**test_input) == 0

test_input = { "nums": [32,30] }
assert my_solution.minimumRightShifts(**test_input) == 1

test_input = { "nums": [37,36] }
assert my_solution.minimumRightShifts(**test_input) == 1

test_input = { "nums": [31,41,65,14] }
assert my_solution.minimumRightShifts(**test_input) == 1

test_input = { "nums": [45,57,73,77,17,30,42,43] }
assert my_solution.minimumRightShifts(**test_input) == 4

test_input = { "nums": [17,65,11] }
assert my_solution.minimumRightShifts(**test_input) == 1

test_input = { "nums": [32,84,93,31,61,78,15,52,100,65] }
assert my_solution.minimumRightShifts(**test_input) == -1

test_input = { "nums": [61,72,90,3,8,17,23,55] }
assert my_solution.minimumRightShifts(**test_input) == 5

test_input = { "nums": [19,30,44,95,13] }
assert my_solution.minimumRightShifts(**test_input) == 1

test_input = { "nums": [42,46,66,71,87,3,4,5,14] }
assert my_solution.minimumRightShifts(**test_input) == 4

test_input = { "nums": [13,57,7] }
assert my_solution.minimumRightShifts(**test_input) == 1