Functionality to Implement:
You need to implement a function named count_valid_subarrays that takes in an array of integers and a list of query integers, and returns a list of counts of valid subarrays for each query. A subarray is considered valid if the sum of its elements is less than or equal to the corresponding query value.
Input/Output Requirements:
Input:
a: A list of integers (1 ≤ len(a) ≤ 10^5, -10^6 ≤ a[i] ≤ 10^6)
queries: A list of integers (1 ≤ len(queries) ≤ 10^5, 0 ≤ queries[i] ≤ 10^18)
Output:
A list of integers where each integer is the count of valid subarrays for the corresponding query in queries.
Constraints:
The solution should be efficient enough to handle the maximum input sizes within a reasonable time frame.
Implementation Details:
You can use the provided implementation as a reference but make sure to write your code in a file named /app/solution.py.
Ensure that your implementation adheres to the input and output specifications provided above.