Buggy python submission (verdict: Time Limit Exceeded):
def main():
    from collections import namedtuple
    from heapq import heappop, heappush
    from operator import attrgetter
    import sys
    input = sys.stdin.readline

    Prog = namedtuple('Prog', 'L R ch')
    Prog.__eq__ = lambda self, other: self.R == other.R
    Prog.__lt__ = lambda self, other: self.R > other.R  # heapqで大きい方から出すため逆で定義

    N, C = map(int, input().split())
    ps = []
    for _ in range(N):
        p = Prog(*map(int, input().split()))
        ps.append(p)
    ps.sort(key=attrgetter('R'))

    rec = []
    for p in ps:
        tank = []
        while rec:
            recorder = heappop(rec)
            if (recorder.ch == p.ch and recorder.R <= p.L) or (recorder.R < p.L): break
            tank.append(recorder)
        for r in tank: heappush(rec, r)
        heappush(rec, p)
    print(len(rec))


if __name__ == '__main__':
    main()


Fixed submission:
t_max = 10 ** 5

N, C = map(int, input().split())
imos = [[0] * (t_max + 1) for _ in range(C + 1)]
# imos[c][x]:=チャンネルc,時刻xの使用有無
# c: 1-indexed
# x: 1-indexed

for _ in range(N):
    s, t, c = map(int, input().split())
    imos[c][s] += 1
    imos[c][t] -= 1

for c in range(1, C + 1):
    for i in range(1, t_max + 1):
        imos[c][i] += imos[c][i - 1]
        if imos[c][i] > 0 and imos[c][i - 1] == 0:
            imos[c][i - 1] = imos[c][i]

ans = 0
for i in range(1, t_max + 1):
    ans = max(ans, sum(imos[c][i] for c in range(1, C + 1)))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    from collections import namedtuple
    from heapq import heappop, heappush
    from operator import attrgetter
    import sys
    input = sys.stdin.readline

    Prog = namedtuple('Prog', 'L R ch')
    Prog.__eq__ = lambda self, other: self.R == other.R
    Prog.__lt__ = lambda self, other: self.R > other.R  # heapqで大きい方から出すため逆で定義

    N, C = map(int, input().split())
    ps = []
    for _ in range(N):
        p = Prog(*map(int, input().split()))
        ps.append(p)
    ps.sort(key=attrgetter('R'))

    rec = []
    for p in ps:
        tank = []
        while rec:
            if p.L < rec[0].R: continue
            recorder = heappop(rec)
            if (recorder.ch == p.ch and recorder.R <= p.L) or (recorder.R < p.L): break
            tank.append(recorder)
        for r in tank: heappush(rec, r)
        heappush(rec, p)
    print(len(rec))


if __name__ == '__main__':
    main()


Fixed submission:
t_max = 10 ** 5

N, C = map(int, input().split())
imos = [[0] * (t_max + 1) for _ in range(C + 1)]
# imos[c][x]:=チャンネルc,時刻xの使用有無
# c: 1-indexed
# x: 1-indexed

for _ in range(N):
    s, t, c = map(int, input().split())
    imos[c][s] += 1
    imos[c][t] -= 1

for c in range(1, C + 1):
    for i in range(1, t_max + 1):
        imos[c][i] += imos[c][i - 1]
        if imos[c][i] > 0 and imos[c][i - 1] == 0:
            imos[c][i - 1] = imos[c][i]

ans = 0
for i in range(1, t_max + 1):
    ans = max(ans, sum(imos[c][i] for c in range(1, C + 1)))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    from collections import namedtuple
    from heapq import heappop, heappush
    from operator import attrgetter
    import sys
    input = sys.stdin.readline

    Prog = namedtuple('Prog', 'L R ch')
    Prog.__eq__ = lambda self, other: self.R == other.R
    Prog.__lt__ = lambda self, other: self.R > other.R  # heapqで大きい方から出すため逆で定義

    N, C = map(int, input().split())
    ps = []
    for _ in range(N):
        p = Prog(*map(int, input().split()))
        ps.append(p)
    ps.sort(key=attrgetter('R'))

    rec = []
    for p in ps:
        tank = []
        while rec:
            if p.L < rec[0].R: continue
            recorder = heappop(rec)
            if (recorder.ch == p.ch and recorder.R <= p.L) or (recorder.R < p.L): break
            tank.append(recorder)
        for r in tank: heappush(rec, r)
        heappush(rec, p)
    print(len(rec))


if __name__ == '__main__':
    main()


Fixed submission:
t_max = 10 ** 5

N, C = map(int, input().split())
imos = [[0] * (t_max + 1) for _ in range(C + 1)]
# imos[c][x]:=チャンネルc,時刻xの使用有無
# c: 1-indexed
# x: 1-indexed

for _ in range(N):
    s, t, c = map(int, input().split())
    imos[c][s] += 1
    imos[c][t] -= 1

for c in range(1, C + 1):
    for i in range(1, t_max + 1):
        imos[c][i] += imos[c][i - 1]
        if imos[c][i] > 0 and imos[c][i - 1] == 0:
            imos[c][i - 1] = imos[c][i]

ans = 0
for i in range(1, t_max + 1):
    ans = max(ans, sum(imos[c][i] for c in range(1, C + 1)))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
t_max = 10 ** 5

N, C = map(int, input().split())
imos = [[0] * (t_max + 1) for _ in range(C + 1)]
# imos[c][x]:=チャンネルc,時刻xの使用有無
# c: 1-indexed
# x: 1-indexed

for _ in range(N):
    s, t, c = map(int, input().split())
    imos[c][s] += 1
    imos[c][t] -= 1

for c in range(1, C + 1):
    for i in range(1, t_max + 1):
        imos[c][i] += imos[c][i - 1]
        if imos[c][i] > 0 and imos[c][i - 1] == 0:
            imos[c][i - 1] = imos[c][i]

ans = 0
for i in range(1, t_max + 1):
    ans = max(ans, sum(imos[c][i] for c in range(1, C + 1)))
print(ans)


Fixed submission:
t_max = 10 ** 5

N, C = map(int, input().split())
imos = [[0] * (t_max + 1) for _ in range(C + 1)]
# imos[c][x]:=チャンネルc,時刻xの使用有無
# c: 1-indexed
# x: 1-indexed

for _ in range(N):
    s, t, c = map(int, input().split())
    imos[c][s] += 1
    imos[c][t] -= 1

for c in range(1, C + 1):
    for i in range(1, t_max + 1):
        imos[c][i] += imos[c][i - 1]
        if imos[c][i] > 0 and imos[c][i - 1] == 0:
            imos[c][i - 1] = imos[c][i]

ans = 0
for i in range(1, t_max + 1):
    ans = max(ans, sum(imos[c][i] for c in range(1, C + 1)))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
t_max = 10 ** 5

N, C = map(int, input().split())
imos = [[0] * (t_max + 1) for _ in range(C + 1)]
# imos[c][x]:=チャンネルc,時刻xの使用有無
# c: 1-indexed
# x: 1-indexed

for _ in range(N):
    s, t, c = map(int, input().split())
    imos[c][s] += 1
    imos[c][t] -= 1

for c in range(1, C + 1):
    for i in range(1, t_max + 1):
        imos[c][i] += imos[c][i - 1]

for c in range(1, C + 1):
    for i in range(1, t_max + 1):
        x = imos[c][i]
        if x > 0 and imos[c][i - 1] == 0:
            imos[c][i - 1] = x

ans = 0
for i in range(1, t_max + 1):
    ans = max(ans, sum(imos[c][i] for c in range(1, C + 1)))
print(ans)


Fixed submission:
t_max = 10 ** 5

N, C = map(int, input().split())
imos = [[0] * (t_max + 1) for _ in range(C + 1)]
# imos[c][x]:=チャンネルc,時刻xの使用有無
# c: 1-indexed
# x: 1-indexed

for _ in range(N):
    s, t, c = map(int, input().split())
    imos[c][s] += 1
    imos[c][t] -= 1

for c in range(1, C + 1):
    for i in range(1, t_max + 1):
        imos[c][i] += imos[c][i - 1]
        if imos[c][i] > 0 and imos[c][i - 1] == 0:
            imos[c][i - 1] = imos[c][i]

ans = 0
for i in range(1, t_max + 1):
    ans = max(ans, sum(imos[c][i] for c in range(1, C + 1)))
print(ans)