<jupyter_start><jupyter_text>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.<jupyter_code>def main():
    n, m = map(int, input().split())
    xs = [0] * (n + 2)

    for _ in range(m):
        a, b, k = map(int, input().split())
        xs[a] += k
        xs[b + 1] -= k

    answer = 0
    current = 0

    for x in xs:
        current += x
        answer = max(answer, current)

    print(answer)


if __name__ == '__main__':
    main()
import math
import os
import random
import re
import sys

# Complete the arrayManipulation function below.
def arrayManipulation(n, queries):   
    res = [0]*(n+1)
    for row in range(len(queries)):
        a = queries[row][0]
        b = queries[row][1]
        k = queries[row][2]
        res[a-1] += k
        res[b] -= k
    sm = 0
    mx = 0
    for i in range(len(res)):
        sm += res[i]
        if sm > mx:
            mx = sm
    return mx

if __name__ == '__main__':
    fptr = open(os.environ['OUTPUT_PATH'], 'w')

    nm = input().split()

    n = int(nm[0])

    m = int(nm[1])

    queries = []

    for _ in range(m):
        queries.append(list(map(int, input().rstrip().split())))

    result = arrayManipulation(n, queries)

    fptr.write(str(result) + '\n')

    fptr.close()<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup