Given an integer array nums and an integer target, return the number of contiguous subarrays whose elements sum exactly to target.
A subarray is a contiguous slice of the array. Your function should count all valid subarrays, including overlapping ones.
nums: a list of integerstarget: an integertargetdef count_subarrays_with_sum(nums, target):