#K63927. Sum of Even Numbers in Subarray

    ID: 31862 Type: Default 1000ms 256MiB

Sum of Even Numbers in Subarray

Sum of Even Numbers in Subarray

This problem requires you to compute the sum of all even numbers in subarrays specified by queries. You are given an array of n integers and q queries. Each query provides two indices, l and r (1-indexed), and your task is to calculate the following sum:

$$\text{sum} = \sum_{i=l}^{r} \, \mathbf{1}_{\{a_i\,\text{is even}\}} \cdot a_i$$

where \(\mathbf{1}_{\{a_i\,\text{is even}\}}\) is the indicator function that returns 1 if \(a_i\) is even and 0 otherwise. The input is read from standard input and your output must be printed to standard output.

inputFormat

The first line contains two integers n and q, representing the number of elements in the array and the number of queries respectively. The second line contains n space-separated integers representing the array elements. Each of the next q lines contains two space-separated integers l and r (1-indexed), which specify the inclusive range for the query.

outputFormat

For each query, output the sum of all even numbers in the subarray defined by [l, r]. Each result should be printed on a new line.

## sample
5 3
1 2 3 4 5
1 3
2 5
1 5
2

6 6

</p>