human
Give me a code to array range queries over range queries and the other steps required given the following:
Array range queries over range queries | Function to create the record array.
Driver Code.
Build query matrix.
If query is of type 2 then function call to record_sum.
If query is of type 1 then simply add 1 to the record array.
for type 1 queries adding the contains of record array to the main array record array.
printing the array"
Solution in Python:
assistant
#Here is code to array range queries over range queries and the other steps required.
 def record_sum ( record , l , r , n , adder ) :
	for i in range ( l , r + 1 ) :
		record [ i ] += adder
n = 5
m = 5
arr = [ 0 ] * n
query = [ [ 1 , 1 , 2 ] , [ 1 , 4 , 5 ] , [ 2 , 1 , 2 ] , [ 2 , 1 , 3 ] , [ 2 , 3 , 4 ] ]
record = [ 0 ] * m
for i in range ( m - 1 , - 1 , - 1 ) :
	if ( query [ i ] [ 0 ] == 2 ) :
		record_sum ( record , query [ i ] [ 1 ] - 1 , query [ i ] [ 2 ] - 1 , m , record [ i ] + 1 )
	else :
		record_sum ( record , i , i , m , 1 )
for i in range ( m ) :
	if ( query [ i ] [ 0 ] == 1 ) :
		record_sum ( arr , query [ i ] [ 1 ] - 1 , query [ i ] [ 2 ] - 1 , n , record [ i ] )
for i in range ( n ) :
	print ( arr [ i ] , end = ' ▁ ' )