• + 0 comments

    Just improved your code a bit. - split() is slightly faster than split("") - an if was not needed as always true - variables names fit those used in the exercise

    if __name__ == "__main__":
        n, m = [int(n) for n in input().split()]
        l = [0]*(n+1)
        for _ in range(m):
            a, b, k = [int(n) for n in input().split()]
            l[a-1] += k
            l[b] -= k;
        max = a = 0
        for i in l:
           a+=i;
           if max<a:
                max=a;
        print(max)