Buggy python submission (verdict: Runtime Error):

import heapq
from collections import defaultdict, deque
from math import ceil, factorial, gcd
from itertools import accumulate
import sys
import bisect


sys.setrecursionlimit(10 ** 7)
INF = float("inf")
MOD = 10 ** 9 + 7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
smii = lambda: sorted(map(int, input().split()))

# ----------

N, K = mii()

channels = defaultdict(list)
for i in range(N):
    s, t, c = mii()
    channels[c].append([s, t])

for name, times in channels.items():
    times.sort()
    new = []
    for i, time in enumerate(times):
        s, t = time
        if i == 0:
            new.append([s, t])
            continue
        if s == new[-1][1]:
            new[-1][1] = t
        else:
            new.append([s, t])
    channels[name] = new

timetable = [0] * 100010
for name, times in channels.items():
    for s, t in times:
        timetable[s] += 1
        timetable[t+1] -= 1

acc = accumulate(timetable)

print(max(acc))




Fixed submission:
from collections import defaultdict
from itertools import accumulate


N, K = map(int, input().split())

timetables = defaultdict(list)
for i in range(N):
    s, t, c = map(int, input().split())
    timetables[c].append([s, t])

for name, times in timetables.items():
    times.sort()
    new = []
    for i, time in enumerate(times):
        s, t = time
        if i == 0:
            new.append([s, t])
            continue
        if s == new[-1][1]:
            new[-1][1] = t
        else:
            new.append([s, t])
    timetables[name] = new

time_count = [0] * 100010
for name, times in timetables.items():
    for s, t in times:
        time_count[s] += 1
        time_count[t + 1] -= 1

acc = accumulate(time_count)

print(max(acc))

Buggy python submission (verdict: Runtime Error):
import heapq
from collections import defaultdict, deque
from math import ceil, factorial, gcd
from itertools import accumulate
import sys
import bisect


sys.setrecursionlimit(10 ** 7)
INF = float("inf")
MOD = 10 ** 9 + 7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
smii = lambda: sorted(map(int, input().split()))

# ----------

N, K = mii()

channels = defaultdict(list)
for i in range(N):
    s, t, c = mii()
    channels[c].append([s, t])

for name, times in channels.items():
    times.sort()
    new = []
    for i, time in enumerate(times):
        s, t = time
        if i == 0:
            new.append([s, t])
            continue
        if s == new[-1][1]:
            new[-1][1] = t
        else:
            new.append([s, t])
    channels[name] = new

timetable = [0] * 100010
for name, times in channels.items():
    for s, t in times:
        timetable[s] += 1
        timetable[t+1] -= 1

acc = accumulate(timetable)

print(max(acc))


Fixed submission:
from collections import defaultdict
from itertools import accumulate


N, K = map(int, input().split())

timetables = defaultdict(list)
for i in range(N):
    s, t, c = map(int, input().split())
    timetables[c].append([s, t])

for name, times in timetables.items():
    times.sort()
    new = []
    for i, time in enumerate(times):
        s, t = time
        if i == 0:
            new.append([s, t])
            continue
        if s == new[-1][1]:
            new[-1][1] = t
        else:
            new.append([s, t])
    timetables[name] = new

time_count = [0] * 100010
for name, times in timetables.items():
    for s, t in times:
        time_count[s] += 1
        time_count[t + 1] -= 1

acc = accumulate(time_count)

print(max(acc))