#C2454. Deep Sum of Nested Lists

    ID: 45772 Type: Default 1000ms 256MiB

Deep Sum of Nested Lists

Deep Sum of Nested Lists

You are given a nested list which contains integers and other lists. Your task is to compute the sum of all integers contained in the nested list regardless of its depth.

Mathematically, if we denote the nested list as (L), then you must compute: [ S = \sum_{x \in L} x ] where each element (x) is an integer found by traversing all sublists recursively.

This problem tests your ability to perform recursive traversal and aggregation in data structures.

inputFormat

The input is provided via standard input (stdin) as a single line containing a valid JSON representation of a nested list of integers. For example: [1, [2, 3], [4, [5, 6]]].

outputFormat

Output the total sum of all integers in the nested list to standard output (stdout) as a single integer.## sample

[1, 2, 3]
6