Array Manipulation
Difficulty: Hard

Starting with a 1-indexed array of zeros and a list of operations, for each operation add a value to each the array element between two given indices, inclusive.  Once all operations have been performed, return the maximum value in the array.  

**Example**  
$n = 10$  
$queries = [[1, 5, 3], [4, 8, 7], [6, 9, 1]$  

Queries are interpreted as follows:  
```
    a b k
    1 5 3
    4 8 7
    6 9 1
```
Add the values of $k$ between the indices $a$ and $b$ inclusive:
```
index->	 1 2 3  4  5 6 7 8 9 10
	[0,0,0, 0, 0,0,0,0,0, 0]
	[3,3,3, 3, 3,0,0,0,0, 0]
	[3,3,3,10,10,7,7,7,0, 0]
	[3,3,3,10,10,8,8,8,1, 0]
```

The largest value is $10$ after all operations are performed.  

**Function Description**  

Complete the function *arrayManipulation* in the editor below.  

arrayManipulation has the following parameters:

- *int n* - the number of elements in the array  
- *int queries[q][3]* - a two dimensional array of queries where each *queries[i]* contains three integers, *a*, *b*, and *k*.  

**Returns**  

- *int* - the maximum value in the resultant array  

Input Format:
The first line contains two space-separated integers $n$ and $m$, the size of the array and the number of operations.  
Each of the next $m$ lines contains three space-separated integers $a$, $b$ and $k$, the left index, right index and summand.  

Output Format:

Sample Input:
    5 3
    1 2 100
	2 5 100
	3 4 100


Sample Output:
    200


Python 3 starter code:
#
# Complete the 'arrayManipulation' function below.
#
# The function is expected to return a LONG_INTEGER.
# The function accepts following parameters:
#  1. INTEGER n
#  2. 2D_INTEGER_ARRAY queries
#

def arrayManipulation(n, queries):
    # Write your code here




Reference solution (C++):
```cpp
#include <bits/stdc++.h>

using namespace std;
long a[400009];

int main() {
    
    int n;
    int m;
    cin >> n >> m;
    vector < pair < int, int > > v;
    
    for(int a0 = 0; a0 < m; a0++) {
    
        int a;
        int b;
        int k;
        cin >> a >> b >> k;
        
        //storing the query
        //this will add k in the prefix sum for index >= a
        v.push_back(make_pair(a, k));
        
        //adding -1*k will remove k from the prefix sum for index > b 
        v.push_back(make_pair(b+1, -1 * k));
    }
    
    long mx = 0, sum = 0;
    
    sort(v.begin(), v.end());
    
    for(int i=0 ; i<2*m; i++) {
    
        sum += v[i].second;
        mx = max(mx, sum);
        
    }
        
    cout<<mx<<endl;
    return 0;
}
```