AT_awc0004_e 区間の合計
Description
Takahashi has a sequence of $ N $ integers $ A = (A_1, A_2, \ldots, A_N) $ . Each element $ A_i $ may take a negative value.
Takahashi wants to select a **contiguous subarray** from this sequence such that the sum of its elements is exactly equal to the integer $ K $ , where $ K $ is the target sum value. Find the number of ways to choose such a subarray.
More precisely, find the number of pairs of integers $ (l, r) $ satisfying $ 1 \leq l \leq r \leq N $ such that
$$A\_l + A\_{l+1} + \\cdots + A\_r = K$$
Input Format
> $ N $ $ K $ $ A_1 $ $ A_2 $ $ \cdots $ $ A_N $
- The first line contains the integer $ N $ representing the number of elements in the sequence and the integer $ K $ representing the target sum value, separated by a space.
- The second line contains the integers $ A_1, A_2, \ldots, A_N $ representing each element of the sequence, separated by spaces.
Output Format
Print the number of pairs of integers $ (l, r) $ that satisfy the condition, on a single line.
Explanation/Hint
### Constraints
- $ 1 \leq N \leq 2 \times 10^5 $
- $ -10^9 \leq K \leq 10^9 $
- $ -10^9 \leq A_i \leq 10^9 $
- All inputs are integers