Problem:


Score : 400 points

Problem Statement

Joisino is planning to record N TV programs with recorders.

The TV can receive C channels numbered 1 through C.

The i-th program that she wants to record will be broadcast from time s_i to time t_i (including time s_i but not t_i) on Channel c_i.

Here, there will never be more than one program that are broadcast on the same channel at the same time.

When the recorder is recording a channel from time S to time T (including time S but not T), it cannot record other channels from time S-0.5 to time T (including time S-0.5 but not T).

Find the minimum number of recorders required to record the channels so that all the N programs are completely recorded.

Constraints

1≤N≤10^5

1≤C≤30

1≤s_i<t_i≤10^5

1≤c_i≤C

If c_i=c_j and i≠j, either t_i≤s_j or s_i≥t_j.

All input values are integers.

Input

Input is given from Standard Input in the following format:

N C
s_1 t_1 c_1
:
s_N t_N c_N

Output

When the minimum required number of recorders is x, print the value of x.

Sample Input 1

3 2
1 7 2
7 8 1
8 12 1

Sample Output 1

2

Two recorders can record all the programs, for example, as follows:

With the first recorder, record Channel 2 from time 1 to time 7. The first program will be recorded. Note that this recorder will be unable to record other channels from time 0.5 to time 7.

With the second recorder, record Channel 1 from time 7 to time 12. The second and third programs will be recorded. Note that this recorder will be unable to record other channels from time 6.5 to time 12.

Sample Input 2

3 4
1 3 2
3 4 4
1 4 3

Sample Output 2

3

There may be a channel where there is no program to record.

Sample Input 3

9 4
56 60 4
33 37 2
89 90 3
32 43 1
67 68 3
49 51 3
31 32 3
70 71 1
11 12 3

Sample Output 3

2



Sample input:
3 2
1 7 2
7 8 1
8 12 1


Sample output:
2

Submission status: Runtime Error

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
import numpy as np
#decimal.getcontext().prec = 10

N, C = MAP()

n = [[] for _ in range(C)]
for _ in range(N):
	s, t, c = MAP()
	n[c-1].append((s, t))

m = [[] for _ in range(C)]

for i in range(C):
	if n[i] == []:
		continue
	n[i].sort(key = lambda y:y[0])
	s = n[i][0][0]
	t = n[i][0][1]
	L = len(n[i])
	n[i].append((0, 0))
	for j in range(L):
		if j < L and n[i][j][1] == n[i][j+1][0]:
			t = n[i][j+1][i+1]
		else:
			m[i].append((s, t))
			s = n[i][j+1][0]
			t = n[i][j+1][1]

#print(m)
cnt = [0]*(10**5+1)

for x in m:
	for s, t in x:
		cnt[s-1] += 1
		cnt[t] -= 1


cnt = list(accumulate(cnt))
#print(cnt)
print(max(cnt))

Submission status: Runtime Error

Solution code:
N, C = map(int, input().split())
stc = [list(map(lambda x:2*int(x), input().split())) for _ in range(N)]

stc = sorted(stc, key=lambda x:(x[2], x[0], x[1]))
l = []
i = N-1
s, t, c = 0, 0, 0
while i >= 0:
    if stc[i][2] == stc[i-1][2] and stc[i][0] == stc[i-1][1]:
        s = stc[i-1][0]
        if t == 0:
            t = stc[i][1]
        c = stc[i][2]
    else:
        if s != 0:
            l += [[s, t, c]]
            s, t, c = 0, 0, 0
        else:
            l += [stc[i]]

    i -= 1
        
imos = [0]*(10**5+1)
for s, t, c in l:
    imos[s-1] += 1
    imos[t] -= 1

for i in range(len(imos)-1):
    imos[i] = imos[i] + imos[i-1]

print(max(imos))

Submission status: Runtime Error

Solution code:
def main():
    from itertools import accumulate
    n, c, *stc = map(int, open(0).read().split())
    table = [0] * (10 ** 5 + 2)
    m = list(zip(stc[::3], stc[1::3], stc[2::3]))
    m = sorted(key=lambda a: (a[2], a[0], a[1]))

    ch_ = 0
    t_ = 0
    for s, t, ch in m:
        if ch != ch_:
            ch_ = ch
            t_ = 0
        if t_ == s:
            table[t_ + 1] += 1
        else:
            table[s] += 1

        table[t + 1] -= 1
        t_ = t

    *x, = accumulate(table)
    ans = max(x)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def main():
    from itertools import accumulate
    n, c, *stc = map(int, open(0).read().split())
    table = [0] * (10 ** 5 + 1)
    m = list(zip(stc[::3], stc[1::3], stc[2::3]))
    m.sort(key=lambda a: (a[2], a[0], a[1]))

    ch_ = 0
    t_ = 0
    for s, t, ch in m:
        if ch != ch_:
            ch_ = ch
            t_ = 0
        if t_ == s:
            table[t_ + 1] += 1
        else:
            table[s] += 1

        table[t + 1] -= 1
        t_ = t

    *x, = accumulate(table)
    ans = max(x)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import sys

N,C = map(int,sys.stdin.readline().split())
stc = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
M = 10**5
imos_s=[set() for _ in range(M+1)]
imos_e=[set() for _ in range(M+1)]

for s,t,c in stc:
    imos_s[s].add(c)
    imos_e[t+1].add(c)

#print(imos_s)
#print(imos_e)
s = set()
imos=[set()]*(M+1)
ret = 0
for i in range(M):
    imos[i+1] = (imos[i]-imos_e[i])|(imos_s[i])
    ret = max(ret,len(imos[i+1]))
#print(imos)
print(ret)

Submission status: Runtime Error

Solution code:
n,C=map(int,input().split())
dp=[[0 for i in range(100001)] for j in range(31)]
for i in range(n):
  s,t,c=map(int,input().split())
  t+=1
  dp[c][s]+=1
  dp[c][t]-=1
nm=[0 for i in range(100001)]
for i in range(31):
  s=1
  for j in range(1,100001):
    dp[i][j]+=dp[i][j-1]
    if dp[i][j]==0 and dp[i][j-1]==1:
      nm[s]+=1
      nm[j]-=1
    elif dp[i][j]==1 and dp[i][j-1]==0:
      s=j
for i in range(1,100001):
  nm[i]+=nm[i-1]
print(max(nm))

Submission status: Runtime Error

Solution code:
n, c = map(int, input().split())
# input時に前処理として以下のことをしておく
#   * 開始時間を-1(-0.5の制約だが、-1しても変わらないので-1する)しておく

# テレビ局の番組をチャンネルごとに登録
r = [[0 for i in range(c)] for j in range(100)]
for _ in range(n):
    s,t,c = map(int, input().split())
    for j in range(s-1, t):
        r[j][c - 1] = 1
# print(*r,sep='\n')

ans = 0
for i in range(len(r)):
    ans = max(ans, sum(r[i]))
print(ans)


# 補足
# チャンネル数4の場合以下のような配列ができる
# 1行でとある時間のチャンネル状態(1: 録画する, 0: 録画しない)がつく
#[0, 0, 0, 0]
#[0, 0, 1, 0]
#[1, 1, 1, 0]  <- この時間で3チャンネル録画が必要
#[1, 1, 0, 0]  <- この時間で2チャンネル録画が必要
#[1, 1, 0, 0]
#[1, 0, 0, 0]

Submission status: Runtime Error

Solution code:
# 1-index
from sys import stdin
import numpy as np
N, C = [int(x) for x in stdin.readline().rstrip().split()]
imos = [[0]*(10**5+1) for i in range(C+1)]

for i in range(N):
    s, t, c = [int(x) for x in stdin.readline().rstrip().split()]
    imos[c][s] += 1
    if t <= 10**5:
        imos[c][t+1] -= 1

imos = np.array(imos)
# print(np.cumsum(imos,axis=1))
ans = max(np.cumsum(imos, axis=1).sum(axis=0))
print(ans)

Submission status: Runtime Error

Solution code:
# 1-index
from sys import stdin
import numpy as np
N,C = [int(x) for x in stdin.readline().rstrip().split()]
imos = [[0]*(10**5+1) for i in range(C+1)]

for i in range(N):
    s,t,c = [int(x) for x in stdin.readline().rstrip().split()]
    imos[c][s] += 1
    imos[c][t+1] -= 1

imos = np.array(imos)
#print(np.cumsum(imos,axis=1))
ans = max(np.cumsum(imos,axis=1).sum(axis=0))
print(ans)

Submission status: Runtime Error

Solution code:
N,C = map(int, input().split())
s =[0]*N
t =[0]*N
c =[0]*N
for i in range(N):
    s[i],t[i],c[i] = map(int, input().split())

imos = [0]*int(1e5+1)
for i in range(N):
    imos[s[i]]+=1
    imos[t[i]+1]-=1

ans = 0
for i in range(1,int(1e5+1)):
    imos[i]=imos[i-1]+imos[i]
    ans = max(ans,imos[i])
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
N,C=map(int, input().split())

#s~tでc
L=np.zeros((C, 10**5+2),dtype="int")

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

L=np.cumsum(L, axis=1)
print(max(np.sum(L,axis=0))

Submission status: Runtime Error

Solution code:
import numpy as np
N, C = map(int,input().split())
T1 = [[] for _ in range(C)]
for _ in range(N):
    s, t, c = map(int,input().split())
    T1[c-1].append([s,t])
for i in range(C):
    T1[i].sort()
T2 = [[] for _ in range(C)]
for i in range(C):
    for s, t in T1[i]:
        if len(T2[i]) != 0 and T2[i][-1][1] == s:
            T2[i][-1][1] = t
        else:
            T2[i].append([s,t])
L = np.zeros(10 ** 5 + 1, int)
for i in range(C):
    for time in T2[i]:
        L[time[0]-1] += 1
        L[time[1]+1] -= 1

ans = L.cumsum().max()
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
N, C = map(int,input().split())
T1 = [[] for _ in range(C)]
for _ in range(N):
    s, t, c = map(int,input().split())
    T1[c-1].append([s,t])
for i in range(C):
    T1[i].sort()
T2 = [[] for _ in range(C)]
for i in range(C):
    for s, t in T1[i]:
        if len(T2[i]) != 0 and T2[i][-1][1] == s:
            T2[i][-1][1] = t
        else:
            T2[i].append([s,t])
L = np.zeros(10 ** 5 + 1, int)
for i in range(C):
    for time in T2[i]:
        L[time[0]-1] += 1a
        L[time[1]+1] -= 1

ans = L.cumsum().max()
print(ans)

Submission status: Runtime Error

Solution code:
N, C = map(int, input().split())
table = [[0]*(10**5 + 1) for i in range(C)]

st = [[] for i in range(C)]
for i in range(N):
  s, t, c = map(int, input().split())
  st[c-1].append([s, t])

st_new = [[] for i in range(C)]
for c in range(C):
  if st[c]:
    st[c].sort()
    st_new[c].append(st[c][0])
    n = len(st[c])
    for i in range(1, n):
      si, ti = st[c][i]
      sii, tii = st_new[c][-1]
      if si == tii:
        st_new[c][i-1][1] = ti
      else:
        st_new[c].append([si, ti])

for c in range(C):
  for s, t in st_new[c]:
    table[c][s-1] += 1
    table[c][t] -= 1
  
for c in range(C):
  for i in range(1, 10**5+1):
    table[c][i] += table[c][i-1]

ans = 0
for i in range(10**5 + 1):
  num = 0
  for c in range(C):
    num += table[c][i]
  ans = max(ans, num)

print(ans)

Submission status: Runtime Error

Solution code:
N, C = map(int, input().split())
table = [[0]*(10**5 + 1) for i in range(C)]

st = [[] for i in range(C)]
for i in range(N):
  s, t, c = map(int, input().split())
  st[c-1].append([s, t])

st_new = [[] for i in range(C)]
for c in range(C):
  if st[c]:
    st[c].sort()
    st_new[c].append(st[c][0])
    n = len(st[c])
    for i in range(1, n):
      si, ti = st[c][i]
      sii, tii = st_new[c][i-1]
      if si == tii:
        st_new[c][i-1][1] = ti
      else:
        st_new[c].append([si, ti])

for c in range(C):
  for s, t in st_new[c]:
    table[c][s-1] += 1
    table[c][t] -= 1
  
for c in range(C):
  for i in range(1, 10**5+1):
    table[c][i] += table[c][i-1]

ans = 0
for i in range(10**5 + 1):
  num = 0
  for c in range(C):
    num += table[c][i]
  ans = max(ans, num)

print(ans)

Submission status: Runtime Error

Solution code:
n, c = map(int, input().split())
cnt = [0] * (10 ** 5 + 1)
cnt_sum = [0] * (10 ** 5 + 1)
for _ in range(n):
    s, t, _c = map(int, input().split())
    cnt[s] += 1
    cnt[t + 1] -= 1
cnt_sum[0] = cnt[0]
for i in range(1, 10 ** 5 + 1):
    cnt_sum[i] = cnt_sum[i - 1] + cnt[i]
print(max(cnt_sum))

Submission status: Runtime Error

Solution code:
from itertools import accumulate

MAX_T = 10 ** 5

n, c = map(int, input().split())
time = []
channel = []
for _ in range(n):
    s, t, c = map(int, input().split())
    time.append((s, t))
    channel.append(c)

n_program = [0 for _ in range(MAX_T + 1)]

for s, t in time:
    n_program[s] += 1
    n_program[t + 1] -= 1

n_program = accumulate(n_program)

answer = max(n_program)
print(answer)

Submission status: Runtime Error

Solution code:
#recording
N,C=map(int,input().split())
plus=[[0 for i in range(10**5+1)]for j in range(C+1)]
minus=[[0 for i in range(10**5+1)]for j in range(C+1)]
for _ in range(N):
    s,t,c=map(int,input().split())
    plus[c][s]=1
    minus[c][t+1]=-1
for c in range(1,C+1):
    for i in range(1,10**5+1):
        plus[c][i]+=plus[c][i-1]
        minus[c][i]+=minus[c][i-1]
ans=0
for i in range(10**5+1):
    sums=0
    for k in range(1,C+1):
        sums+=(plus[k][i]+minus[k][i])
    
    ans=max(sums,ans)
print(ans)

Submission status: Runtime Error

Solution code:
import sys
from operator import itemgetter
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n,c = map(int,readline().split())
ch = []*c
for i in range(n):
    s,t,c = map(int,readline().split())
    ch[c-1].append([s,t])
imos = [0]*(10**5+1)
for i in ch:
    i.sort()
    for j in range(1,len(i)):
        s,t = i[j]
        if i[j-1][1] < s:
            imos[s-1] += 1
        else:
            imos[s] += 1
        imos[t] -= 1

for i in range(1,len(imos)):
    imos[i] += imos[i-1]

print(max(imos))

Submission status: Runtime Error

Solution code:
import numpy as np
import sys


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


def input():
    return sys.stdin.readline().strip()


def main():
    N, C = map(int, input().split())
    MAX = 10 ** 5 + 1
    vals = [0] * MAX
    for _ in range(N):
        s, t, c = map(int, input().split())
        vals[s] += 1
        vals[t + 1] -= 1
    cumsum = np.cumsum(vals)
    ans = max(cumsum)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
from collections import defaultdict as dd
N, C = tuple(map(int, input().split()))
events = []
tmax = 0
dic=dd(list)
for i in range(N):
    s, t, c = map(int, input().split())
    dic[c].append((s,t))
eps = 0.5
for k,v in dic.items():
    v1 = sorted(v)
    lev = len(v)
    prev = [-1,-1]
    for i,val in enumerate(v1):
        if tmax < val[1]:
            tmax = val[1]
        if prev == [-1,-1]:
            prev[0] = val[0]
            prev[1] = val[1] # end_time
            if lev != 1:
                continue
            else:
                events.append((prev[0]-eps, 1))
                events.append((prev[1], 0))
                break
        if prev[1] == val[0]:# prev_end == now_start
            prev[1] = val[1]
            if i == lev - 1:
                events.append((prev[0] - eps, 1))
                events.append((prev[1], 0))
                break
        else:
            events.append((prev[0]-eps, 1))
            events.append((prev[1], 0))
            prev = val
            if i==lev-1:
                events.append((val[0]-eps, 1))
                events.append((val[1], 0))
                break
events.sort()
print("1")
exit()
idx = 0
cnt = 0
res = 0
events.append((0,-1))
for t in range(tmax + 1):
    while events[idx][0] <= t:
        event = events[idx]
        if event[1] == 1:
            cnt += 1
            if res < cnt:
                res = cnt
        elif event[1] == 0:
            cnt -= 1
        else:
            break
        idx += 1
print(res)

Submission status: Runtime Error

Solution code:
from collections import defaultdict as dd
N, C = tuple(map(int, input().split()))
events = []
tmax = 0
dic=dd(list)
for i in range(N):
    s, t, c = map(int, input().split())
    dic[c].append((s,t))
eps = 0.5
for k,v in dic.items():
    v1 = sorted(v)
    lev = len(v)
    prev = [-1,-1]
    for i,val in enumerate(v1):
        if tmax < val[1]:
            tmax = val[1]
        if prev == [-1,-1]:
            prev[0] = val[0]
            prev[1] = val[1] # end_time
            if lev != 1:
                continue
            else:
                events.append((prev[0]-eps, 1))
                events.append((prev[1], 0))
                break
        if prev[1] == val[0]:# prev_end == now_start
            prev[1] = val[1]
            if i == lev - 1:
                events.append((prev[0] - eps, 1))
                events.append((prev[1], 0))
                break
        else:
            events.append((prev[0]-eps, 1))
            events.append((prev[1], 0))
            prev = val
            if i==lev-1:
                events.append((val[0]-eps, 1))
                events.append((val[1], 0))
                break
events.sort()
idx = 0
cnt = 0
res = 0
events.append((0,-1))
for t in range(tmax + 1):
    while events[idx][0] <= t:
        event = events[idx]
        if event[1] == 1:
            cnt += 1
            if res < cnt:
                res = cnt
        elif event[1] == 0:
            cnt -= 1
        else:
            break
        idx += 1
print(res)

Submission status: Runtime Error

Solution code:
from collections import defaultdict as dd
N, C = tuple(map(int, input().split()))
events = []
tmax = 0
dic=dd(list)
for i in range(N):
    s, t, c = map(int, input().split())
    dic[c].append((s,t))
eps = 0.5
for k,v in dic.items():
    v1 = sorted(v)
    lev = len(v)
    prev = [-1,-1]
    for i,val in enumerate(v1):
        if tmax < val[1]:
            tmax = val[1]
        if prev == [-1,-1]:
            prev[0] = val[0]
            prev[1] = val[1] # end_time
            if lev != 1:
                continue
            else:
                events.append((prev[0]-eps, 1))
                events.append((prev[1], 0))
                break
        if i==lev-1:
            events.append((prev[0]-eps, 1))
            events.append((prev[1], 0))
            break
        if prev[1] == val[0]:# prev_end == now_start
            prev[1] = val[1]
        else:
            events.append((prev[0]-eps, 1))
            events.append((prev[1], 0))
            prev = val
events.sort()
idx = 0
cnt = 0
res = 0
events.append((0,-1))
for t in range(tmax + 1):
    while events[idx][0] <= t:
        event = events[idx]
        if event[1] == 1:
            cnt += 1
            if res < cnt:
                res = cnt
        elif event[1] == 0:
            cnt -= 1
        else:
            break
        idx += 1
print(res)

Submission status: Runtime Error

Solution code:
from collections import defaultdict as dd
N, C = tuple(map(int, input().split()))
events = []
tmax = 0
dic=dd(list)
for i in range(N):
    s, t, c = map(int, input().split())
    dic[c].append((s,t))
eps = 0.5
for k,v in dic.items():
    v1 = sorted(v)
    lev = len(v)
    prev = [-1,-1]
    for i,val in enumerate(v1):
        if tmax < val[1]:
            tmax = val[1]
        if prev == [-1,-1]:
            prev[0] = val[0]
            prev[1] = val[1] # end_time
            if lev != 1:
                continue
            else:
                events.append((prev[0]-eps, 1))
                events.append((prev[1], 0))
                break
        if prev[1] == val[0]:# prev_end == now_start
            prev[1] = val[1]
        else:
            events.append((prev[0]-eps, 1))
            events.append((prev[1], 0))
            prev = val
        if i==lev-1:
            events.append((prev[0]-eps, 1))
            events.append((prev[1], 0))
events.sort()
idx = 0
cnt = 0
res = 0
events.append((0,-1))
for t in range(tmax + 1):
    while events[idx][0] <= t:
        event = events[idx]
        if event[1] == 1:
            cnt += 1
            if res < cnt:
                res = cnt
        elif event[1] == 0:
            cnt -= 1
        else:
            break
        idx += 1
print(res)

Submission status: Runtime Error

Solution code:
N, C = tuple(map(int, input().split()))
    events = []
    tmax = 0
    for i in range(N):
        s, t, c = map(int, input().split())
        start = (s-0.5, 1)
        end = (t, 0)
        events.append(start)
        events.append(end)
        if tmax < t:
            tmax = t
    events.sort()
    idx = 0
    cnt = 0
    res = 0
    events.append((0,-1))
    for t in range(tmax + 1):
        while events[idx][0] <= t:
            event = events[idx]
            if event[1] == 1:
                cnt += 1
                if res < cnt:
                    res = cnt
            elif event[1] == 0:
                cnt -= 1
            else:
                break
            idx += 1
    print(res)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline

N, C = [int(x) for x in input().split()]
imos = [0]*(10**6 + 1)

for _ in range(N):
    s, t, c = [int(x) for x in input().split()]
    s *= 10
    t *= 10
    imos[max(0, s - 5)] += 1
    imos[t + 1] -= 1

from itertools import accumulate

csum = list(accumulate(imos))

print(max(csum))

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline

N, C = [int(x) for x in input().split()]
imos = [0]*(10**6 + 1)

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

from itertools import accumulate

csum = list(accumulate(imos))

print(max(csum))

Submission status: Runtime Error

Solution code:
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()

Submission status: Runtime Error

Solution code:

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))

Submission status: Runtime Error

Solution code:
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))

Submission status: Runtime Error

Solution code:
n,c = map(int,input().split())
stc = [[int(i) for i in input().split()] for j in range(n)]

ans = 0

stc.sort(key=lambda x:(x[2],x[1],x[0]))

time = 10**5+1

c_imos = [[0 for i in range(time)] for j in range(c)]

for i in range(n):
    c_imos[stc[i][2]-1][stc[i][0]-1] += 1
    c_imos[stc[i][2]-1][stc[i][1]] -= 1

#print(c_imos)

nd_v = [[0 for i in range(time)] for j in range(c)]

for i in range(c):
    for j in range(time):
        if j == 0:
            if c_imos[i][j] == 1:
                nd_v[i][j] = 1
        else:q
            nd_v[i][j] = max(0,min(1,nd_v[i][j-1] + c_imos[i][j]))
#print(nd_v)

ans = 1

for i in range(time-1):
    tmp = 0
    for j in range(c):
        tmp += nd_v[j][i]
    ans = max(tmp,ans)

print(ans)

exit()
    
c_num = stc[0][2]
t_num = stc[0][1]
idx = 0
print(stc)
for i in range(1,n):
    print(t_num,i)
    if stc[idx+i][2] == c_num:
        if stc[idx+i][0] == t_num:
            stc[idx+i-1][1] = stc[idx+i][1]
            t_num = stc[idx+i][1]
            del stc[idx+i]
            idx -= 1
        else:
            print(t_num,t_num,t_num)
            c_num = stc[idx+i][2]
            t_num = stc[idx+i][1]

stc.sort(key=lambda x:x[1])
print(stc)
exit()
tmp = stc[0][1]

ans = 1
ans_tmp = 1

for i in range(1,len(stc)):
    for j in range(i+1,len(stc)):
        if tmp >= stc[j][0]:
            ans_tmp += 1
        else:
            tmp = stc[j][0]
            ans = max(ans_tmp,ans)

Submission status: Runtime Error

Solution code:
n,c = map(int,input().split())
stc = [[int(i) for i in input().split()] for j in range(n)]

ans = 0

stc.sort(key=lambda x:(x[2],x[1],x[0]))

time = 10**5

c_imos = [[0 for i in range(time)] for j in range(c)]

for i in range(n):
    c_imos[stc[i][2]-1][stc[i][0]-1] += 1
    c_imos[stc[i][2]-1][stc[i][1]] -= 1

#print(c_imos)

nd_v = [[0 for i in range(time)] for j in range(c)]

for i in range(c):
    for j in range(time):
        if j == 0:
            if c_imos[i][j] == 1:
                nd_v[i][j] = 1
        else:
            nd_v[i][j] = min(1,nd_v[i][j-1] + c_imos[i][j])
#print(nd_v)

ans = 1

for i in range(time):
    tmp = 0
    for j in range(c):
        tmp += nd_v[j][i]
    ans = max(tmp,ans)

print(ans)

exit()
    
c_num = stc[0][2]
t_num = stc[0][1]
idx = 0
print(stc)
for i in range(1,n):
    print(t_num,i)
    if stc[idx+i][2] == c_num:
        if stc[idx+i][0] == t_num:
            stc[idx+i-1][1] = stc[idx+i][1]
            t_num = stc[idx+i][1]
            del stc[idx+i]
            idx -= 1
        else:
            print(t_num,t_num,t_num)
            c_num = stc[idx+i][2]
            t_num = stc[idx+i][1]

stc.sort(key=lambda x:x[1])
print(stc)
exit()
tmp = stc[0][1]

ans = 1
ans_tmp = 1

for i in range(1,len(stc)):
    for j in range(i+1,len(stc)):
        if tmp >= stc[j][0]:
            ans_tmp += 1
        else:
            tmp = stc[j][0]
            ans = max(ans_tmp,ans)

Submission status: Runtime Error

Solution code:
import sys
from collections import *
import heapq
import math
from math import gcd
import bisect
import copy
from itertools import permutations,accumulate,combinations,product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,c=map(int,input().split())
stc=[list(map(int,input().split())) for i in range(n)]
stc.sort()
lst=[0]*c
for i in range(n):
    for j in range(c):
        if lst[j]==0:
            lst[j]=stc[i]
            break
        else:
            if lst[j][2]==stc[i][2]:
                lst[j]=stc[i]
                break
            elif lst[j][1]+1<stc[i][1]:
                lst[j]=stc[i]
                break

ans=0
for i in range(c):
    if lst[i]!=0:
        ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
a

Submission status: Runtime Error

Solution code:
import sys
input=sys.stdin.buffer.readline
n,c=map(int,input().split())
a=[ [0 for _ in range(10**5+2)] for _ in range(c)]
for _ in range(n):
    s,t,cc=map(int,input().split())
    cc-=1
#    print(s-1,end=' s-1\n')
    a[cc][s-1]+=1
    a[cc][t]-=1
    '''for i in range(s-1,t):
        a[cc][i]=1'''
for i in range(c):
    for j in range(1,10**5+1):
#        print(i,j)
        a[i][j]+=a[i][j-1]
        assert a[i][j]<=1

ans=1
for j in range(0,10**5):
    su=0
#    print(c,'hello')
    for i in range(c):
#        print('asdf hello')
#        print(j,i,a[i][j])
        su+=a[i][j]
    ans=max(ans,su)
print(ans)

Submission status: Runtime Error

Solution code:
import sys
input=sys.stdin.buffer.readline
n,c=map(int,input().split())
a=[ [0 for _ in range(10**5+2)] for _ in range(c)]
for _ in range(n):
    s,t,cc=map(int,input().split())
    cc-=1
#    print(s-1,end=' s-1\n')
    a[cc][s-1]+=1
    a[cc][t]-=1
    '''for i in range(s-1,t):
        a[cc][i]=1'''
for i in range(c):
    for j in range(1,10**5+1):
        a[i][j]+=a[i][j-1]

ans=1
for j in range(0,10**5):
    su=0
#    print(c,'hello')
    for i in range(c):
#        print('asdf hello')
#        print(j,i,a[i][j])
        assert a[i][j]<=1
        su+=a[i][j]
    ans=max(ans,su)
print(ans)

Submission status: Runtime Error

Solution code:
n,C=map(int,input().split())
import collections
d=collections.defaultdict(list)
for i in range(n):
    s,t,c=map(int,input().split())
    d[c].append((s,t))
T=[0 for i in range(2*10**5+1)]
for i in d.values():
    i.sort()
    T[i[0][0]*2-1]+=1
    T[i[-1][1]*2+1]-=1
    for x,y in zip(i,i[1:]):
        s1,t1=x
        s2,t2=y
        if t1!=s2:
            T[s2*2-1]+=1
            T[t1*2+1]-=1
from itertools import accumulate
T=list(accumulate(T))
print(max(T))

Submission status: Runtime Error

Solution code:
N, C = map(int, input().split())
MAX_N = (10 ** 5 + 1)
X = [0] * MAX_N
for _ in range(N):
    s, t, c = map(int, input().split())
    X[s] += 1
    X[t+1] -= 1
# print(X)
ans = [0] * MAX_N
for i in range(MAX_N - 1):
    ans[i + 1] = ans[i] + X[i]
# print(ans)
print(max(ans))

Submission status: Runtime Error

Solution code:
N,C=map(int,input().split())
ch=[[] for i in range(31)]
for i in range(N):
  s,t,c=map(int,input().split())
  ch[c].append([s,t])
arr=[[] for i in range(31)]
start=[]
end=[]
for i in range(31):
  score=[0]*(10**5+1)
  for j in range(len(ch[i])):
    score[ch[i][j][0]]+=1
    score[ch[i][j][1]]-=1
  for j in range(10**5+1):
    if score[j]==1:
      start.append(j)
    if score[j]==-1:
      end.append(j)
ans=[0]*(10**5+1)
for i in start:
  ans[i]+=1
for j in end:
  ans[j+1]-=1
for i in range(10**5):
  ans[i+1]+=ans[i]
print(max(ans))

Submission status: Runtime Error

Solution code:
import numpy as np
n,c = map(int,input().split())
d = [0]*(10**5)
for _ in range(n):
    s,t,c = map(int,input().split())
    d[s-1] += 1
    d[t] -= 1
d = np.cumsum(d)
print(max(d))