Buggy python submission (verdict: Runtime Error):
def main():
    N,C = [int(_n) for _n in input().split()]
    L = 100000
    table = [[0]*L for _ in range(C)]
    for i in range(N):
        s,t,c = [int(_n) for _n in input().split()]
        c -= 1
        s -= 1
        t -= 1
        table[c][s] += 1
        table[c][t+1] -= 1 
    for c in range(C):
        for j in range(L-1):
            table[c][j+1] += table[c][j]
    for i in range(C):
        for j in range(L):
            table[i][j] = min(1, table[i][j])
    for j in range(L):
        for c in range(C-1):
            table[c+1][j] += table[c][j]
    print(max(table[C-1]))
    # print(table)
    # print(table)
    # acc = [0] * len(times)
    # progs.sort(key = lambda x:x[2])



main()

Fixed submission:
def main():
    N,C = [int(_n) for _n in input().split()]
    L = 100010
    table = [[0]*L for _ in range(C)]
    for i in range(N):
        s,t,c = [int(_n) for _n in input().split()]
        c -= 1
        s -= 1
        t -= 1
        table[c][s] += 1
        table[c][t+1] -= 1 
    for c in range(C):
        for j in range(L-1):
            table[c][j+1] += table[c][j]
    for i in range(C):
        for j in range(L):
            table[i][j] = min(1, table[i][j])
    for j in range(L):
        for c in range(C-1):
            table[c+1][j] += table[c][j]
    print(max(table[C-1]))
    # print(table)
    # print(table)
    # acc = [0] * len(times)
    # progs.sort(key = lambda x:x[2])



main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N,C = [int(_n) for _n in input().split()]
    progs = [[] for _ in range(C)]
    times = set()
    for i in range(N):
        s,t,c = [int(_n) for _n in input().split()]
        c -= 1
        progs[c].append((s,t))
        times = times.union([s,t])
    times = list(times)
    times.sort()
    rev_times = {}
    for i,t in enumerate(times):
        rev_times[t] =i
    progs2 = []
    for i in range(C):
        p = progs[i]
        if len(p) == 0:
            continue
        p.sort(key = lambda x:x[0])
        res = []
        start = p[0][0]
        last = p[0][1]
        for pr in p[1:]:
            if last == pr[0]:
                last = pr[1]
            else:
                res.append((start,last))
                start = pr[0]
                last = pr[1]
        res.append((start,last))
        progs2.extend(res)
    acc = [0] * (len(times)+1)
    for p in progs2:
        acc[rev_times[p[0]]]+=1
        acc[rev_times[p[1]]+1]-=1
    for i in range(len(acc)-1):
        acc[i+1] += acc[i]
    print(max(acc))
    # acc = [0] * len(times)
    # progs.sort(key = lambda x:x[2])



main()

Fixed submission:
def main():
    N,C = [int(_n) for _n in input().split()]
    L = 100010
    table = [[0]*L for _ in range(C)]
    for i in range(N):
        s,t,c = [int(_n) for _n in input().split()]
        c -= 1
        s -= 1
        t -= 1
        table[c][s] += 1
        table[c][t+1] -= 1 
    for c in range(C):
        for j in range(L-1):
            table[c][j+1] += table[c][j]
    for i in range(C):
        for j in range(L):
            table[i][j] = min(1, table[i][j])
    for j in range(L):
        for c in range(C-1):
            table[c+1][j] += table[c][j]
    print(max(table[C-1]))
    # print(table)
    # print(table)
    # acc = [0] * len(times)
    # progs.sort(key = lambda x:x[2])



main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N,C = [int(_n) for _n in input().split()]
    progs = [[] for _ in range(C)]
    times = set()
    for i in range(N):
        s,t,c = [int(_n) for _n in input().split()]
        c -= 1
        progs[c].append((s,t))
        times = times.union([s,t])
    times = list(times)
    times.sort()
    rev_times = {}
    for i,t in enumerate(times):
        rev_times[t] =i
    progs2 = []
    for i in range(C):
        p = progs[i]
        if len(p) == 0:
            continue
        p.sort(key = lambda x:x[0])
        res = []
        start = p[0][0]
        last = p[0][1]
        for pr in p[1:]:
            if last == pr[0]:
                last = pr[1]
            else:
                res.append((start,last))
                start = pr[0]
                last = pr[1]
        res.append((start,last))
        progs2.extend(res)
    acc = [0] * (len(times)+1)
    for p in progs2:
        acc[rev_times[p[0]]]+=1
        acc[rev_times[p[1]]+1]-=1
    for i in range(len(acc)-1):
        acc[i+1] += acc[i]
    print(max(acc))
    # acc = [0] * len(times)
    # progs.sort(key = lambda x:x[2])



main()

Fixed submission:
def main():
    N,C = [int(_n) for _n in input().split()]
    L = 100010
    table = [[0]*L for _ in range(C)]
    for i in range(N):
        s,t,c = [int(_n) for _n in input().split()]
        c -= 1
        s -= 1
        t -= 1
        table[c][s] += 1
        table[c][t+1] -= 1 
    for c in range(C):
        for j in range(L-1):
            table[c][j+1] += table[c][j]
    for i in range(C):
        for j in range(L):
            table[i][j] = min(1, table[i][j])
    for j in range(L):
        for c in range(C-1):
            table[c+1][j] += table[c][j]
    print(max(table[C-1]))
    # print(table)
    # print(table)
    # acc = [0] * len(times)
    # progs.sort(key = lambda x:x[2])



main()