#C13460. Median of Nested List

    ID: 43001 Type: Default 1000ms 256MiB

Median of Nested List

Median of Nested List

You are given a list that may contain nested sublists. Your task is to compute the median of all the numerical values found in the outer list and its immediate nested sublists. Note that if a nested sublist contains another nested list (i.e. deeper than one level), the inner nested list should be ignored.

The median is defined as follows: if the sorted list has an odd number of elements, the median is the middle element. If it has an even number of elements, the median is \(\frac{a+b}{2}\), where \(a\) and \(b\) are the two middle elements.

If there are no numerical values, output None.

inputFormat

The input is read from standard input (stdin) as a single line. The line contains a JSON array. Each element in the array can either be a number or a list. In the case of a list, only the first level of items will be processed; if any sublist is encountered within these nested lists, they should be ignored. Non-numeric elements (such as strings) should also be ignored.

outputFormat

Print to standard output (stdout) the median of all the numerical values found according to the rules above. If there is no numerical value, print None.

## sample
[1, 2, 3, [4, 5], 6]
3.5