human
Count of subarrays with sum at least K | Function to return the number of subarrays with sum atleast k.
To store the right index and the current sum.
To store the number of sub - arrays.
For all left indexes.
Get elements till current sum is less than k.
No such subarray is possible.
Add all possible subarrays.
Remove the left most element.
Return the required answer.
Driver code"
How can the above be solved in Python?
 Can you provide a code to count of subarrays with sum at least K and the other steps required?
assistant
#Here is code to count of subarrays with sum at least K and the other steps required.
 def k_sum ( a , n , k ) :
	r , sum = 0 , 0 ;
	ans = 0 ;
	for l in range ( n ) :
		while ( sum < k ) :
			if ( r == n ) :
				break ;
			else :
				sum += a [ r ] ;
				r += 1 ;
		if ( sum < k ) :
			break ;
		ans += n - r + 1 ;
		sum -= a [ l ] ;
	return ans ;
a = [ 6 , 1 , 2 , 7 ] ; k = 10 ;
n = len ( a ) ;
print ( k_sum ( a , n , k ) ) ;