meetforever/GRPO_CL huggingface dataset:
user: We want to find the numbers higher or equal than 1000 that the sum of every four consecutives digits cannot be higher than a certain given value.
If the number is ``` num = d1d2d3d4d5d6 ```, and the maximum sum of 4 contiguous digits is ```maxSum```, then:
```python
d1 + d2 + d3 + d4 <= maxSum
d2 + d3 + d4 + d5 <= maxSum
d3 + d4 + d5 + d6 <= maxSum
```
For that purpose, we need to create a function, ```max_sumDig()```, that receives ```nMax```, as the max value of the interval to study (the range (1000, nMax) ), and a certain value, ```maxSum```, the maximum sum that every four consecutive digits should be less or equal to. The function should output the following list with the data detailed bellow:

```[(1), (2), (3)]```

(1) - the amount of numbers that satisfy the constraint presented above 

(2) - the closest number to the mean of the results, if there are more than one, the smallest number should be chosen.

(3) - the total sum of all the found numbers

Let's see a case with all the details:
```
max_sumDig(2000, 3) -------> [11, 1110, 12555]

(1) -There are 11 found numbers: 1000, 1001, 1002, 1010, 1011, 1020, 1100, 1101, 1110, 1200 and 2000

(2) - The mean of all the found numbers is:
      (1000 + 1001 + 1002 + 1010 + 1011 + 1020 + 1100 + 1101 + 1110 + 1200 + 2000) /11 = 1141.36363,  
      so 1110 is the number that is closest to that mean value.

(3) - 12555 is the sum of all the found numbers
      1000 + 1001 + 1002 + 1010 + 1011 + 1020 + 1100 + 1101 + 1110 + 1200 + 2000 = 12555

Finally, let's see another cases
```
max_sumDig(2000, 4) -----> [21, 1120, 23665]

max_sumDig(2000, 7) -----> [85, 1200, 99986]

max_sumDig(3000, 7) -----> [141, 1600, 220756]
```

Happy coding!!

Answer: {"fn_name": "max_sumDig", "inputs": [[2000, 3], [2000, 4], [2000, 7], [3000, 7], [4000, 4], [5000, 2], [5000, 3], [5000, 4], [5000, 5], [5000, 6], [5000, 7], [5000, 8], [5000, 9]], "outputs": [[[11, 1110, 12555]], [[21, 1120, 23665]], [[85, 1200, 99986]], [[141, 1600, 220756]], [[35, 2000, 58331]], [[5, 1100, 6111]], [[15, 1200, 21666]], [[35, 2000, 58331]], [[70, 2000, 132216]], [[122, 2010, 244875]], [[196, 2110, 413306]], [[296, 2200, 649951]], [[426, 2250, 967696]]]}
user: Assume you are creating a webshop and you would like to help the user in the search. You have products with brands, prices and name. You have the history of opened products (the most recently opened being the first item).

Your task is to create a list of brands ordered by popularity, if two brands have the same popularity level then choose the one which was opened last from the two and second the other one.

Product popularity is calculated from the history. If a product is more times in the history than it is more popular.

Your function will have one parameter which will be always an array/list of object.

example product:
{
  name: "Phone",
  price: 25,
  brand: "Fake brand"
}

Answer: {"fn_name": "sorted_brands", "inputs": [[[]]], "outputs": [[[]]]}
user: # Rock Paper Scissors

Let's play! You have to return which player won! In case of a draw return `Draw!`.

Examples:

![rockpaperscissors](http://i.imgur.com/aimOQVX.png)

Answer: {"fn_name": "rps", "inputs": [["rock", "scissors"], ["scissors", "paper"], ["paper", "rock"], ["scissors", "rock"], ["paper", "scissors"], ["rock", "paper"], ["rock", "rock"], ["scissors", "scissors"], ["paper", "paper"]], "outputs": [["Player 1 won!"], ["Player 1 won!"], ["Player 1 won!"], ["Player 2 won!"], ["Player 2 won!"], ["Player 2 won!"], ["Draw!"], ["Draw!"], ["Draw!"]]}
user: Christmas is coming, and Santa has a long list to go through, to find who deserves presents for the big day. Go through a list of children, and return a list containing every child who appeared on Santa's list. Do not add any child more than once. Output should be sorted.
~~~if:java
For java, use Lists.
~~~

Comparison should be case sensitive and the returned list should contain only one copy of each name: `"Sam"` and `"sam"` are different, but `"sAm"` and `"sAm"` are not.

Answer: {"fn_name": "find_children", "inputs": [[["Jason", "Jackson", "Jordan", "Johnny"], ["Jason", "Jordan", "Jennifer"]], [["Jason", "Jackson", "Johnson", "JJ"], ["Jason", "James", "JJ"]], [["jASon", "JAsoN", "JaSON", "jasON"], ["JasoN", "jASOn", "JAsoN", "jASon", "JASON"]]], "outputs": [[["Jason", "Jordan"]], [["JJ", "Jason"]], [["JAsoN", "jASon"]]]}
user: FizzBuzz is often one of the first programming puzzles people learn. Now undo it with reverse FizzBuzz!

Write a function that accepts a string, which will always be a valid section of FizzBuzz. Your function must return an array that contains the numbers in order to generate the given section of FizzBuzz.

Notes:
- If the sequence can appear multiple times within FizzBuzz, return the numbers that generate the first instance of that sequence.
- All numbers in the sequence will be greater than zero.
- You will never receive an empty sequence.


## Examples
```
reverse_fizzbuzz("1 2 Fizz 4 Buzz")        -->  [1, 2, 3, 4, 5]
reverse_fizzbuzz("Fizz 688 689 FizzBuzz")  -->  [687, 688, 689, 690]
reverse_fizzbuzz("Fizz Buzz")              -->  [9, 10]
```

Answer: {"fn_name": "reverse_fizzbuzz", "inputs": [["1 2 Fizz 4 Buzz"], ["Fizz 688 689 FizzBuzz"], ["Fizz Buzz"], ["Fizz"], ["Buzz"], ["Buzz Fizz"], ["FizzBuzz"]], "outputs": [[[1, 2, 3, 4, 5]], [[687, 688, 689, 690]], [[9, 10]], [[3]], [[5]], [[5, 6]], [[15]]]}
user: There is enough money available on ATM in nominal value 10, 20, 50, 100, 200 and 500 dollars.

You are given money in nominal value of `n` with `1<=n<=1500`.

Try to find minimal number of notes that must be used to repay in dollars, or output -1 if it is impossible.

Good Luck!!!

Answer: {"fn_name": "solve", "inputs": [[770], [550], [10], [1250], [125], [666], [42]], "outputs": [[4], [2], [1], [4], [-1], [-1], [-1]]}
user: # Task:

Based on the received dimensions, `a` and `b`, of an ellipse, calculare its area and perimeter.

## Example:
```python
Input: ellipse(5,2)

Output: "Area: 31.4, perimeter: 23.1"
```

**Note:** The perimeter approximation formula you should use: `π * (3/2(a+b) - sqrt(ab))`

___

## Have fun :)

Answer: {"fn_name": "ellipse", "inputs": [[5, 2], [6, 8], [13, 1]], "outputs": [["Area: 31.4, perimeter: 23.1"], ["Area: 150.8, perimeter: 44.2"], ["Area: 40.8, perimeter: 54.6"]]}
user: Your task is to return the sum of Triangular Numbers up-to-and-including the `nth` Triangular Number.

Triangular Number: "any of the series of numbers (1, 3, 6, 10, 15, etc.) obtained by continued summation of the natural numbers 1, 2, 3, 4, 5, etc."

```
[01]
02 [03]
04 05 [06]
07 08 09 [10]
11 12 13 14 [15]
16 17 18 19 20 [21]
```

e.g. If `4` is given: `1 + 3 + 6 + 10 = 20`.

Triangular Numbers cannot be negative so return 0 if a negative number is given.

Answer: {"fn_name": "sum_triangular_numbers", "inputs": [[6], [34], [-291], [943], [-971]], "outputs": [[56], [7140], [0], [140205240], [0]]}
user: Your friend Rick is trying to send you a message, but he is concerned that it would get intercepted by his partner. He came up with a solution:

1) Add digits in random places within the message.

2) Split the resulting message in two. He wrote down every second character on one page, and the remaining ones on another. He then dispatched the two messages separately.

Write a function interweave(s1, s2) that reverses this operation to decode his message!

Example 1: interweave("hlo", "el") -> "hello"
Example 2: interweave("h3lo", "el4") -> "hello"

Rick's a bit peculiar about his formats. He would feel ashamed if he found out his message led to extra white spaces hanging around the edges of his message...

Answer: {"fn_name": "interweave", "inputs": [["", ""], ["hlo", "el"], ["h3lo", "el4"]], "outputs": [[""], ["hello"], ["hello"]]}
user: Welcome. In this kata, you are asked to square every digit of a number and concatenate them.

For example, if we run 9119 through the function, 811181 will come out, because 9^(2) is 81 and 1^(2) is 1.

**Note:** The function accepts an integer and returns an integer

Answer: {"fn_name": "square_digits", "inputs": [[3212], [2112]], "outputs": [[9414], [4114]]}
user: Given an array, return the reversed version of the array (a different kind of reverse though), you reverse portions of the array, you'll be given a length argument which represents the length of each portion you are to reverse.

E.g
  
  if after reversing some portions of the array and the length of the remaining portion in the array is not up to the length argument, just reverse them.
  

`selReverse(array, length)`

- array - array to reverse
- length - length of each portion to reverse

Note : if the length argument exceeds the array length, reverse all of them, if the length argument is zero do not reverse at all.

Answer: {"fn_name": "sel_reverse", "inputs": [[[2, 4, 6, 8, 10, 12, 14, 16], 3], [[2, 4, 6, 8, 10, 12, 14, 16], 2], [[1, 2, 3, 4, 5, 6], 2], [[1, 2, 3, 4, 5, 6], 0], [[1, 2, 3, 4, 5, 6], 10]], "outputs": [[[6, 4, 2, 12, 10, 8, 16, 14]], [[4, 2, 8, 6, 12, 10, 16, 14]], [[2, 1, 4, 3, 6, 5]], [[1, 2, 3, 4, 5, 6]], [[6, 5, 4, 3, 2, 1]]]}
user: Complete the function, which calculates how much you need to tip based on the total amount of the bill and the service. 

You need to consider the following ratings:

- Terrible: tip 0%
- Poor: tip 5%
- Good: tip 10%
- Great: tip 15%
- Excellent: tip 20%

The rating is **case insensitive** (so "great" = "GREAT"). If an unrecognised rating is received, then you need to return:

* `"Rating not recognised"` in Javascript, Python and Ruby...
* ...or `null` in Java
* ...or `-1` in C#

Because you're a nice person, you **always round up** the tip, regardless of the service.

Answer: {"fn_name": "calculate_tip", "inputs": [[30, "poor"], [20, "Excellent"], [20, "hi"], [107.65, "GReat"], [20, "great!"]], "outputs": [[2], [4], ["Rating not recognised"], [17], ["Rating not recognised"]]}
user: We are interested in obtaining two scores from a given integer:

**First score**: The sum of all the integers obtained from the power set of the digits of the given integer that have the same order 

E.g:
```
integer = 1234 ---> (1 + 2 + 3 + 4) + (12 + 13 + 14 + 23 + 24 + 34) + 
(123 + 124 + 134 + 234) + 1234 = 10 + 120 + 615 + 1234 = 1979
```
**Second score**: The sum of all the integers obtained from the all the contiguous substrings of the given integer as a string.

E.g.
```
integer = 1234 ---> (1 + 2 + 3 + 4) + (12 + 23 + 34) + (123 + 234) + 1234 = 10 + 69 + 357 + 1234 = 1670
```
The first integer, higher than ```100```, that has both scores with ```3``` common divisors is ```204```. Its first score is ```258``` and the second one ```234```. The common divisors for both scores are ```2, 3, 6```.

In fact the integers ```294``` and ```468``` are the ones in the range ```[100, 500]```, that have both scores with ```7``` common divisors, the maximum amount of common factors in that range.

Your task in this kata is to create a function that may find the integer or integers that have the maximum amount of common divisors for the scores described above.

The example given above will be:
```python
find_int_inrange(100, 500) == [7, 294, 468]
```
As you can see, the function should receive the limits of a range [a, b], and outputs an array with the maximum amount of factors, ```max_am_div``` and the found numbers sorted
```
find_int_inrange(a, b) ----> [max_am_div, k1, k2, ...., kn] # k1 < k2 < ...< kn
```
The function may output only one number.
```python
find_int_inrange(100, 300) == [7, 294]
```
Enjoy it!

Features of the random tests:
```
100 < a < b < 55000 
```

Answer: {"fn_name": "find_int_inrange", "inputs": [[100, 300], [100, 500], [300, 900]], "outputs": [[[7, 294]], [[7, 294, 468]], [[7, 468, 834]]]}
user: ### Count the number of Duplicates

Write a function that will return the count of **distinct case-insensitive** alphabetic characters and numeric digits that occur more than 
once in the input string. 
The input string can be assumed to contain only alphabets (both uppercase and lowercase) and numeric digits.


### Example
"abcde" -> 0             `# no characters repeats more than once`  
"aabbcde" -> 2           `# 'a' and 'b'`  
"aabBcde" -> 2           ``# 'a' occurs twice and 'b' twice (`b` and `B`)``  
"indivisibility" -> 1    `# 'i' occurs six times`  
"Indivisibilities" -> 2  `# 'i' occurs seven times and 's' occurs twice`  
"aA11" -> 2              `# 'a' and '1'`  
"ABBA" -> 2              `# 'A' and 'B' each occur twice`

Answer: {"fn_name": "duplicate_count", "inputs": [[""], ["abcde"], ["abcdeaa"], ["abcdeaB"], ["Indivisibilities"]], "outputs": [[0], [0], [1], [2], [2]]}
user: The [half-life](https://en.wikipedia.org/wiki/Half-life) of a radioactive substance is the time it takes (on average) for one-half of its atoms to undergo radioactive decay.

# Task Overview
Given the initial quantity of a radioactive substance, the quantity remaining after a given period of time, and the period of time, return the half life of that substance. 

# Usage Examples

```if:csharp
Documentation:
Kata.HalfLife Method (Double, Double, Int32)

Returns the half-life for a substance given the initial quantity, the remaining quantity, and the elasped time.

Syntax


public
static
double HalfLife(
double quantityInitial,
    double quantityRemaining,
int time
    )
  



Parameters

quantityInitial

Type: System.Double
The initial amount of the substance.

quantityRemaining

Type: System.Double
The current amount of the substance.

time

Type: System.Int32
The amount of time elapsed.

Return Value

Type: System.Double
  A floating-point number representing the half-life of the substance.

```

Answer: {"fn_name": "half_life", "inputs": [[10, 5, 1], [8, 4, 2], [12, 3, 2]], "outputs": [[1], [2], [1]]}
user: #Detail

[Countdown](https://en.wikipedia.org/wiki/Countdown_(game_show) is a British game show with number and word puzzles. The letters round consists of the contestant picking 9 shuffled letters - either picking from the vowel pile or the consonant pile. The contestants are given 30 seconds to try to come up with the longest English word they can think of with the available letters - letters can not be used more than once unless there is another of the same character.

#Task

Given an uppercase 9 letter string, ```letters```, find the longest word that can be made with some or all of the letters. The preloaded array ```words``` (or ```$words``` in Ruby) contains a bunch of uppercase words that you will have to loop through. Only return the longest word; if there is more than one, return the words of the same lengths in alphabetical order. If there are no words that can be made from the letters given, return ```None/nil/null```.

##Examples

```
letters = "ZZZZZZZZZ"
longest word = None

letters = "POVMERKIA", 
longest word = ["VAMPIRE"]

letters = "DVAVPALEM"
longest word = ["VAMPED", "VALVED", "PALMED"]

```

Answer: {"fn_name": "longest_word", "inputs": [[""], ["MKMKMKMKM"], ["IIIWUGEZI"]], "outputs": [[null], [null], [null]]}
user: # Task
 A lock has `n` buttons in it, numbered from `1 to n`. To open the lock, you have to press all buttons in some order, i.e. a key to the lock is a permutation of the first `n` integers. If you push the right button in the right order, it will be pressed into the lock. Otherwise all pressed buttons will pop out. When all buttons are pressed into the lock, it opens.
 
 Your task is to calculate the number of times you've got to push buttons in order to open the lock in the `worst-case scenario`.

# Example

 For `n = 3`, the result should be `7`.
 ```
 Let's assume the right order is 3-2-1.
 In the worst-case scenario, we press the buttons:
 Press 1, wrong, button 1 pop out
 Press 2, wrong, button 2 pop out
 Press 3, right, button 3 pressed in
 Press 1, wrong, button 1,3 pop out
 Press 3, right, button 3 pressed in
 Press 2, right, button 2 pressed in
 Press 1, right, button 1 pressed in
 We pressed button total 7 times.``` 
 
 For `n = 4`, the result should be `14`.
 ```
 Let's assume the right order is 4-3-2-1.
 In the worst-case scenario, we press the buttons:
 Press 1, wrong, button 1 pop out
 Press 2, wrong, button 2 pop out
 Press 3, wrong, button 3 pop out
 Press 4, right, button 4 pressed in
 Press 1, wrong, button 1,4 pop out
 Press 4, right, button 4 pressed in
 Press 2, wrong, button 2,4 pop out
 Press 4, right, button 4 pressed in
 Press 3, right, button 3 pressed in
 Press 1, wrong, button 1,3,4 pop out
 Press 4, right, button 4 pressed in
 Press 3, right, button 3 pressed in
 Press 2, right, button 2 pressed in
 Press 1, right, button 1 pressed in
 We pressed button total 14 times.``` 

# Input/Output


 - `[input]` integer `n`

  The number of buttons in the lock.
  
  `0 < n ≤ 2000`


 - `[output]` an integer

 The number of times you've got to push buttons in the `worst-case scenario`.

Answer: {"fn_name": "press_button", "inputs": [[1], [3], [4], [10], [2000]], "outputs": [[1], [7], [14], [175], [1333335000]]}
user: Write a function which outputs the positions of matching bracket pairs. The output should be a dictionary with keys the positions of the open brackets '(' and values the corresponding positions of the closing brackets ')'.

For example: input = "(first)and(second)" should return {0:6, 10:17}

If brackets cannot be paired or if the order is invalid (e.g. ')(') return False. In this kata we care only about the positions of round brackets '()', other types of brackets should be ignored.

Answer: {"fn_name": "bracket_pairs", "inputs": [["len(list)"], ["string"], [""], ["def f(x"], [")("], ["(a(b)c()d)"], ["f(x[0])"]], "outputs": [[{"3": 8}], [{}], [{}], [false], [false], [{"0": 9, "2": 4, "6": 7}], [{"1": 6}]]}
user: # Task

Your task is to sort the characters in a string according to the following rules:
```
- Rule1: English alphabets are arranged from A to Z, case insensitive.
  ie. "Type" --> "epTy"
- Rule2: If the uppercase and lowercase of an English alphabet exist
  at the same time, they are arranged in the order of oringal input.
  ie. "BabA" --> "aABb"
- Rule3: non English alphabet remain in their original position.
  ie. "By?e" --> "Be?y"
```

# Input/Output


`[input]` string `s`

A non empty string contains any characters(English alphabets or non English alphabets).

`[output]` a string

A sorted string according to the rules above.

# Example


For `s = "cba"`, the output should be `"abc"`.

For `s = "Cba"`, the output should be `"abC"`.

For `s = "cCBbAa"`, the output should be `"AaBbcC"`.

For `s = "c b a"`, the output should be `"a b c"`.

For `s = "-c--b--a-"`, the output should be `"-a--b--c-"`.

For `s = "Codewars"`, the output should be `"aCdeorsw"`.

Answer: {"fn_name": "sort_string", "inputs": [["a"], ["cba"], ["Cba"], ["cCBbAa"], ["!"], ["c b a"], ["-c--b--a-"], ["cbaCcC"], ["Codewars"], [" MkWD{RB=//k-^ J@,xH Vfi uAz+$ kV _[ }a!}%pSBwn !kKB (b  q PQF +}wS  .kfU r wFNEs#NsR UVMdG"]], "outputs": [["a"], ["abc"], ["abC"], ["AaBbcC"], ["!"], ["a b c"], ["-a--b--c-"], ["abcCcC"], ["aCdeorsw"], [" AaBB{Bb=//D-^ d@,Ef FfF GHi+$ Jk _[ }k!}%kkKkM !MnN (N  p PqQ +}Rr  .RSS s suUUV#VVW wwwxz"]]}
user: Implement a function which behaves like the 'uniq -c' command in UNIX. 

It takes as input a sequence and returns a sequence in which all duplicate elements following each other have been reduced to one instance together with the number of times a duplicate elements occurred in the original array.

Example:

```python
['a','a','b','b','c','a','b','c'] --> [('a',2),('b',2),('c',1),('a',1),('b',1),('c',1)]
```

Answer: {"fn_name": "uniq_c", "inputs": [[["a", "a", "b", "b", "c", "a", "b", "c"]], [["a", "a", "a", "b", "b", "b", "c", "c", "c"]], [[null, "a", "a"]], [["foo"]], [[""]], [[]]], "outputs": [[[["a", 2], ["b", 2], ["c", 1], ["a", 1], ["b", 1], ["c", 1]]], [[["a", 3], ["b", 3], ["c", 3]]], [[[null, 1], ["a", 2]]], [[["foo", 1]]], [[["", 1]]], [[]]]}
user: Leonardo Fibonacci in a rare portrait of his younger days

I assume you are all familiar with the famous Fibonacci sequence, having to get each number as the sum of the previous two (and typically starting with either `[0,1]` or `[1,1]` as the first numbers).

While there are plenty of variation on it ([including](https://www.codewars.com/kata/tribonacci-sequence) [a few](https://www.codewars.com/kata/fibonacci-tribonacci-and-friends) [I wrote](https://www.codewars.com/kata/triple-shiftian-numbers/)), usually the catch is all the same: get a starting (signature) list of numbers, then proceed creating more with the given rules.

What if you were to get to get two parameters, one with the signature (starting value) and the other with the number you need to sum at each iteration to obtain the next one?

And there you have it, getting 3 parameters:

* a signature of length `length`
* a second parameter is a list/array of indexes of the last `length` elements you need to use to obtain the next item in the sequence (consider you can end up not using a few or summing the same number multiple times)' in other words, if you get a signature of length `5` and `[1,4,2]` as indexes, at each iteration you generate the next number by summing the 2nd, 5th and 3rd element (the ones with indexes `[1,4,2]`) of the last 5 numbers
* a third and final parameter is of course which sequence element you need to return (starting from zero, I don't want to bother you with adding/removing 1s or just coping with the fact that after years on CodeWars we all count as computers do):

```python
custom_fib([1,1],[0,1],2) == 2 #classical fibonacci!
custom_fib([1,1],[0,1],3) == 3 #classical fibonacci!
custom_fib([1,1],[0,1],4) == 5 #classical fibonacci!
custom_fib([3,5,2],[0,1,2],4) == 17 #similar to my Tribonacci
custom_fib([7,3,4,1],[1,1],6) == 2 #can you figure out how it worked ;)?
```

Answer: {"fn_name": "custom_fib", "inputs": [[[1, 1], [0, 1], 2], [[1, 1], [0, 1], 3], [[1, 1], [0, 1], 4], [[3, 5, 2], [0, 1, 2], 4], [[7, 3, 4, 1], [1, 1], 6]], "outputs": [[2], [3], [5], [17], [2]]}
user: >When no more interesting kata can be resolved, I just choose to create the new kata, to solve their own, to enjoy the process  --myjinxin2015 said

# Description:

```if:javascript
Given an array `arr` that contains some integers(positive, negative or 0), and a `range` list such as `[[start1,end1],[start2,end2],...]`, start and end are the index of `arr` and start always less than end. Your task is to calculate the sum value of each range (start index and end index are both inclusive), and return the maximum sum value.
```
```if:ruby
Given an array (`arr`) of integers and an array (`ranges`) of ranges (e.g. `[[1, 32], [16, 24],...]`), which represent an index range of `arr`, calculate the sum of each range (start index and end index are both inclusive) of `arr`, and return the maximum sum.
```
```if:php
Given an array `$a` that contains some integers and a `$range` list such as `[[$start1, $end1], [$start2, $end2], ... ]` where `$start(n)` and `$end(n)` are valid keys of the non-associative array `$a` and `$start(n)` is always guaranteed to be strictly less than `$end(n)`.  Your task is to calculate the sum value of each range (start index and end index are both inclusive) and return the maximum sum value.
```
```if:haskell
Given a list `arr` that contains some integers(positive, negative or 0), and a `range` list such as `[(start1,end1),(start2,end2),...]`, start and end are the index of `arr` and start always less than end. Your task is to calculate the sum value of each range (start index and end index are both inclusive), and return the maximum sum value.
```

For example:
 
# Note:

 - `arr`/`$a` always has at least 5 elements;
 - `range`/`$range`/`ranges` always has at least 1 element;
 - All inputs are valid;
 - This is a simple version, if you want some challenge, please [try the challenge version](https://www.codewars.com/kata/the-maximum-sum-value-of-ranges-challenge-version/).

# Some Examples

Answer: {"fn_name": "max_sum", "inputs": [[[1, -2, 3, 4, -5, -4, 3, 2, 1], [[1, 3], [0, 4], [6, 8]]], [[1, -2, 3, 4, -5, -4, 3, 2, 1], [[1, 3]]], [[1, -2, 3, 4, -5, -4, 3, 2, 1], [[1, 4], [2, 5]]], [[11, -22, 31, 34, -45, -46, 35, 32, 21], [[1, 4], [0, 3], [6, 8], [0, 8]]]], "outputs": [[6], [5], [0], [88]]}