#C1732. Counting Subarrays with Given Sum

    ID: 44970 Type: Default 1000ms 256MiB

Counting Subarrays with Given Sum

Counting Subarrays with Given Sum

You are given an array of integers and an integer \( t \). Your task is to count the number of contiguous subarrays (subsegments) whose sum is exactly equal to \( t \). Specifically, for an array \( a_1, a_2, \ldots, a_n \), you need to count the number of pairs of indices \( (i, j) \) with \( 1 \le i \le j \le n \) such that

[ \sum_{k=i}^{j} a_k = t ]

Please note that the subarrays are contiguous segments of the array. The solution should read input from stdin and output the answer to stdout.

inputFormat

The first line contains two integers \( n \) and \( t \), where \( n \) is the number of elements in the array and \( t \) is the target sum.

The second line contains \( n \) integers separated by spaces, representing the elements of the array.

outputFormat

Output a single integer: the number of contiguous subarrays whose sum equals \( t \).

## sample
5 5
1 2 3 4 5
2

</p>