#C11224. Taco Range Sum Query
Taco Range Sum Query
Taco Range Sum Query
You are given an array of n integers and q queries. For each query, you are asked to compute the sum of a subarray from index \( L \) to \( R \) (1-indexed). This problem can be efficiently solved by precomputing a prefix sum array.
Task: For each query, output the sum of the elements between indices \( L \) and \( R \) (inclusive).
Note: Input is read from the standard input and output is written to the standard output.
inputFormat
The first line of input contains two integers \( n \) and \( q \), where \( n \) is the number of elements in the array and \( q \) is the number of queries.
The second line contains \( n \) space-separated integers representing the array elements.
Each of the following \( q \) lines contains two integers \( L \) and \( R \) representing a query. The array is 1-indexed.
outputFormat
For each query, output a single line containing the sum of the subarray from index \( L \) to \( R \).
## sample5 3
1 2 3 4 5
1 3
2 4
1 5
6
9
15
</p>