• + 0 comments

    !/bin/python3

    import math import os import random import re import sys

    def solve(n, operations): count = 0 for i in range(m): l = operations[i] a = l[0] b = l[1] k = l[2] count += (b-a+1)*k return count//n

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

    first_multiple_input = input().rstrip().split()
    
    n = int(first_multiple_input[0])
    
    m = int(first_multiple_input[1])
    
    operations = []
    
    for _ in range(m):
        operations.append(list(map(int, input().rstrip().split())))
    
    result = solve(n, operations)
    
    fptr.write(str(result) + '\n')
    
    fptr.close()