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 numpy as np

N, C = map(int,input().split())
for i in range(N):
    s,t,c = map(int,input().split())
    T[c].append([s,t])
for i in range(len(T)):
    times = T[i]
    times.sort()
    idx = 0
    while len(times) > 1:
        if times[idx][1] == times[idx+1][0]:
            times[idx] = [times[idx][0], times[idx+1][1]]
            del times[idx+1]
            T[i] = times
        else:
            idx += 1
        if idx == len(times)-1:
            break
A = [0] * (10**5 + 1)
for u in T:
    if len(u) == 0:
        continue
    else:
        for times in u:
            A[times[0]-1] += 1
            A[times[1]] -= 1
print(max(np.cumsum(A)))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
#ABC80 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,C = LI()
cha = [[] for _ in range(C)]
ans = 0
lst = [0]*(10**5+1)
for _ in range(n):
    s,t,c = LI()
    cha[c-1].append([s,t])
for i in range(C):
    if len(cha[i]) == 0:
        continue
    cha[i].sort(key = itemgetter(0))
    s,t = cha[i][0]
    tmp = []
    for j in range(1,len(cha[i])):
        if t == cha[i][j][0]:
            t = cha[i][j][1]
        else:
            tmp.append([s,t])
            s,t = cha[i][j]
    tmp.append([s,t])
    for i,j in tmp:
        lst[i] += 1
        lst[j+1] -= 1
lst = list(accumulate(lst))
print(max(lst))

Submission status: Runtime Error

Solution code:
from heapq import *
from itertools import chain
n,c=map(int,input().split())
a=sorted([list(map(int,input().split()))for i in range(n)])
b=[[]for i in range(c+1)]
for i,j,h in a:
    if len(b[h])>0:
        if b[h][-1][1]==i:
            b[h][-1][1]=j
    else:
        b[h].append([i,j])
d=sorted(chain.from_iterable(b))
b=[d[0][1]]
for i,j in d[1:]:
    s=heappop(b)
    if i<=s:
        heappush(b,s)
        heappush(b,j)
    else:
        heppush(b,j)
print(len(b))

Submission status: Runtime Error

Solution code:
"""
https://atcoder.jp/contests/abc080/tasks/abc080_d
400

同じチャンネル同士でかぶりが発生するとアウト
imos
"""

N,C  = map(int, input().split())
t_max = 10**5
# c_imos = [[0]*t_max for t in range(C)]
imos = [0] * t_max
for i in range(N):
    s,t,c = map(int, input().split())
    c -= 1
    # t -= 1
    s -= 1
    # c_imos[c][s] += 1
    # c_imos[c][t] -= 1
    imos[s] += 1
    imos[t] -= 1 

    # for c_ in c_imos:
    #     print(list(accumulate(c_)))
    
from itertools import accumulate
print(max(list(accumulate(imos))))

Submission status: Runtime Error

Solution code:
N,C  = map(int, input().split())
t_max = 10**5
# c_imos = [[0]*t_max for t in range(C)]
imos = [0] * t_max
for i in range(N):
    s,t,c = map(int, input().split())
    c -= 1
    # t -= 1
    s -= 1
    # c_imos[c][s] += 1
    # c_imos[c][t] -= 1
    imos[s] += 1
    imos[t] -= 1 

    # for c_ in c_imos:
    #     print(list(accumulate(c_)))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
#ABC80 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


n,C = LI()
stc = [LI() for _ in range(n)]
L = []
for i in range(C):
    lst = []
    for j in range(n):
        s,t,c = stc[j]
        if i+1 == c:
            lst.append([s,t])
    lst.sort(key = itemgetter(0))
    lst2 = []
    j = 0
    while j < len(lst):
        if j < len(lst)-1:
            if lst[j][1] == lst[j+1][0]:
                lst2.append((lst[j][0],lst[j+1][1]))
                j += 2
                continue

        lst2.append(tuple(lst[j]))
        j += 1
    L.append(lst2)
x = [[0]*100001 for _ in range(C)]
for i in range(C):
    for j,k in L[i]:
        x[i][j] += 1
        x[i][k+1] -= 1
    x[i] = list(accumulate(x[i]))
ans = 0
for i in range(1,10**5+1):
    s = 0
    for j in range(C):
        if x[j][i] == 1:
            s += 1
    ans = max(ans,s)
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, C = map(int, input().split())
TV = [list(map(int, input().split())) for _ in range(N)]

TV = sorted([l for l in TV], key=lambda x: x[0])

X = []
for c in range(1, C + 1):
    TV_temp = [l for l in TV if l[2] == c]
    TV_T = list(zip(*TV_temp))
    l = []
    for tv in TV_temp:
        if tv[1] in TV_T[0]:
            i = TV_T[0].index(tv[1])
            l.append([tv[0], TV_T[1][i], c])
            TV_temp.pop(i)
        else:
            l.append(tv)
    
    X.extend(l)

TV = sorted([[l[0] - 0.5, l[1], l[2]] for l in X], key=lambda x: x[1])

c = 0
while TV:
    c += 1
    end = 0
    l_rem = []
    for i, tv in enumerate(TV):
        if tv[0] >= end:
            end = tv[1]
            l_rem.append(i)
    for i in reversed(l_rem):
        TV.pop(i)

print(c)

Submission status: Runtime Error

Solution code:
n,C=[int(i) for i in input().split()]
stc=[[int(i) for i in input().split()] for _ in range(n)]
stc.sort(key=lambda x:x[1])
stc.sort(key=lambda x:x[2])
time=[0]*(2*(10**5+1))
end=[[0]*(10**5) for _ in range(C)]

for s,t,c in stc:
    end[c-1][t]+=1

for s,t,c in stc:
    if end[c-1][s]==0:
        time[2*s-1]+=1
    time[2*t]-=1
for i in range(1,2*10**5+2):
    time[i]=time[i-1]+time[i]
print(max(time))

Submission status: Runtime Error

Solution code:
n,c=[int(i) for i in input().split()]
stc=sorted([[int(i) for i in input().split()] for _ in range(n)],key=lambda x:x[0])
time=[0]*(10**5)
for s,t,c in stc:
    time[s-1]+=1
    time[t]-=1
for i in range(10**5):
    time[i]=time[i-1]+time[i]
print(max(time))

Submission status: Runtime Error

Solution code:
import sys
from itertools import accumulate

# set test data
sys.stdin = open('sample.txt') # for test

# functions used
r = lambda: sys.stdin.readline().strip() #single: int(r()), line: map(int, r().split())
R = lambda: list(map(int, r().split())) # line: R(), lines: [R() for _ in range(n)]
Rmap = lambda: map(int, r().split())
# set inputs
N, C = R()
STC = [R() for _ in range(N)]
#  0.5sec as one unit
tbl = [[0]*(2*(10**5)+5) for _ in range(C)]

for s, t, c in STC:
    c -= 1
    # if we can record the programms continuously (ver1)
    if tbl[c][2*s] != 0:
        tbl[c][2*s] += 1
        tbl[c][2*t] -= 1
    # if we can record the programms continuously (ver2)
    elif tbl[c][2*t-1] != 0:
        tbl[c][2*t-1] -= 1
        tbl[c][2*s-1] += 1
    # else:
    else:
        tbl[c][2*s-1] = 1
        tbl[c][2*t] = -1

tbl2 = [list(accumulate(a)) for a in tbl]

ans = max([sum(x) for x in zip(*tbl2)])
print(ans)

# tmp = [sum(x) for x in zip(*tbl2)]

# res = 0
# for i in range(200002):
#     cc = 0
#     for j in range(C):
#         if tbl2[j][i]:
#             cc += 1
#     res = max(res, cc)
# print(res)

Submission status: Runtime Error

Solution code:
from itertools import accumulate

# functions used
r = lambda: sys.stdin.readline().strip() #single: int(r()), line: map(int, r().split())
R = lambda: list(map(int, r().split())) # line: R(), lines: [R() for _ in range(n)]
Rmap = lambda: map(int, r().split())
# set inputs
N, C = R()
STC = [R() for _ in range(N)]
tbl = [[0]*(2*(10**5)+5) for _ in range(C)]

# watch out: join tv programmes which are continuously broadcast in one channel
for s, t, c in STC:
    c -= 1
    if tbl[c][2*s] != 0:
        tbl[c][2*s] += 1
        tbl[c][2*t] -= 1
    elif tbl[c][2*t-1] != 0:
        tbl[c][2*t-1] -= 1
        tbl[c][2*s-1] += 1
    else:
        tbl[c][2*s-1] = 1
        tbl[c][2*t] = -1

tbl2 = [list(accumulate(a)) for a in tbl]
ans = max([sum(x) for x in zip(*tbl2)])
print(ans)

Submission status: Runtime Error

Solution code:
from functools import reduce
import math
import collections

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]
    N_max = 10005
    N, C = (int(_) for _ in input().split())
    s = []
    t = []
    c = []
    for i in range(N):
        s1, s2,s3 = (int(_) for _ in input().split())
        s.append(s1)
        t.append(s2)
        c.append(s3)
        
    d = []
    d.append([0]*N_max)
    for i in range(N):
        for d_i in range(len(d)):
            can_insert_channel = True
            for d_j in range(s[i],t[i]+1):
                if d_j == s[i]:
                    if d[d_i][d_j] == c[i] or d[d_i][d_j] == 0:
                        continue
                    else:
                        can_insert_channel = False
                        break
                if d[d_i][d_j] != 0:
                    can_insert_channel = False
                    break
                
            if can_insert_channel:
                for j in range(s[i],t[i]+1):
                    d[d_i][j] = c[i]
                break
            elif d_i == len(d)-1:
                d.append([0]*N_max)
                for j in range(s[i],t[i]+1):                    
                    d[d_i+1][j]= c[i]
    # for i in range(len(d)):
    #     print(list(d[i]))
    print(len(d))
    
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
from functools import reduce
import math
import collections

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]
    N_max = 10005
    N, C = (int(_) for _ in input().split())
    s = []
    t = []
    c = []
    for i in range(N):
        s1, s2,s3 = (int(_) for _ in input().split())
        s.append(s1)
        t.append(s2)
        c.append(s3)
        
    d = []
    d.append([0]*N_max)
    for i in range(N):
        for d_i in range(len(d)):
            can_insert_channel = True
            for d_j in range(s[i],t[i]+1):
                if d_j == s[i]:
                    if d[d_i][d_j] == c[i] or d[d_i][d_j] == 0:
                        continue
                    else:
                        can_insert_channel = False
                        break
                if d[d_i][d_j] != 0:
                    can_insert_channel = False
                    break
                
            if can_insert_channel:
                for j in range(s[i],t[i]+1):
                    d[d_i][j] = c[i]
                break
            elif d_i == len(d)-1:
                d.append([0]*N_max)
                for j in range(s[i],t[i]+1):                    
                    d[d_i+1][j]= c[i]
    for i in range(len(d)):
        print(list(d[i]))
    print(len(d))
    
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
from functools import reduce
import math
import collections

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]
    N_max = 100000
    N, C = (int(_) for _ in input().split())
    s = []
    t = []
    c = []
    for i in range(N):
        s1, s2,s3 = (int(_) for _ in input().split())
        s.append(s1)
        t.append(s2)
        c.append(s3)
        
    d = []
    d.append([0]*N_max)
    for i in range(N):
        for d_i in range(len(d)):
            can_insert_channel = True
            for d_j in range(s[i],t[i]+1):
                if d_j == s[i]:
                    if d[d_i][d_j] == c[i] or d[d_i][d_j] == 0:
                        continue
                    else:
                        can_insert_channel = False
                        break
                if d[d_i][d_j] != 0:
                    can_insert_channel = False
                    break
                
            if can_insert_channel:
                for j in range(s[i],t[i]+1):
                    d[d_i][j] = c[i]
                break
            elif d_i == len(d)-1:
                d.append([0]*N_max)
                for j in range(s[i],t[i]+1):                    
                    d[d_i+1][j]= c[i]
    # for i in range(len(d)):
    #     print(list(d[i]))
    print(len(d))
    
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N, C = map(int, input().split())
num = 10#**5+1
count = [0]*(num)
channel = [0]*num
for i in range(N):
    s, t, c = map(int, input().split())
    print(count)
    if channel[s]==c and channel[t-1]==c:
        count[s]+=1
        count[t-1]-=1
    elif channel[s]==c:#はじめ＝終わり
        count[s]+=1
        count[t]-=1
    elif channel[t-1]==c:
        count[t-1]-=1
        count[s-1]+=1
    else:
        count[s-1]+=1
        count[t]-=1
    channel[s-1]=c
    channel[t]=c
print(count)
for i in range(1, num):
    count[i]+=count[i-1]
print(max(count))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
from itertools import accumulate
INF = float("inf")


def solve(N: int, C: int, s: "List[int]", t: "List[int]", c: "List[int]"):
    # いもす法
    seq = [0]*(2*10**5)
    for sv, tv, cv in zip(s, t, c):
        seq[2*sv-1] += 1
        seq[2*tv] -= 1
    acc = list(accumulate(seq))
    # print(seq)
    # print(acc)
    print(max(acc))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    s = [int()] * (N)  # type: "List[int]"
    t = [int()] * (N)  # type: "List[int]"
    c = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        s[i] = int(next(tokens))
        t[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, C, s, t, c)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
from itertools import accumulate
INF = float("inf")


def solve(N: int, C: int, s: "List[int]", t: "List[int]", c: "List[int]"):
    # いもす法
    seq = [0]*(10**5+1)
    for sv, tv, cv in zip(s, t, c):
        seq[sv] += 1
        seq[tv+1] -= 1
    acc = list(accumulate(seq))
    # print(seq)
    # print(acc)
    print(max(acc))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    s = [int()] * (N)  # type: "List[int]"
    t = [int()] * (N)  # type: "List[int]"
    c = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        s[i] = int(next(tokens))
        t[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, C, s, t, c)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
from itertools import accumulate
INF = float("inf")


def solve(N: int, C: int, s: "List[int]", t: "List[int]", c: "List[int]"):
    # いもす法
    seq = [0]*(10**5)
    for sv, tv, cv in zip(s, t, c):
        seq[sv] += 1
        seq[tv+1] -= 1
    acc = list(accumulate(seq))
    # print(seq)
    # print(acc)
    print(max(acc))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    s = [int()] * (N)  # type: "List[int]"
    t = [int()] * (N)  # type: "List[int]"
    c = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        s[i] = int(next(tokens))
        t[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, C, s, t, c)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n,c=map(int,input().split())
d=[[] for i in range(c)]
w=[0]*100002
for i in range(n):
    s,t,x=map(int,input().split())
    d[x-1].append((s,t))

for i in range(c):
    d[i].sort()
    e=0
    for j in range(len(d[i])):
        if len(d[i])==1:
            w[d[i][0][0]]+=1
            w[d[i][0][1]+1]-=1
        elif j==0:
            w[d[i][0][0]]+=1
            e=d[i][0][1]
        elif j+1==len(d[i]):
            if e!=d[i][j][0]:
                w[e+1]-=1
                w[d[i][j][0]]+=1
            w[d[i][j][1]+1]-=1
        else:
            if e==d[i][j][0]:
                e=d[[i][j][1]]
            else:
                w[e+1]-=1
                w[d[i][j][0]]+=1
                e=d[i][j][1]
ans=chk=0
for i in w:
    chk+=i
    ans=max(ans,chk)
print(ans)

Submission status: Runtime Error

Solution code:
n,c=map(int,input().split())
d=[[] for i in range(c)]
w=[0]*100001
for i in range(n):
    s,t,x=map(int,input().split())
    d[x-1].append((s,t))
for i in range(c):
    d[i].sort()
    e=0
    for j in range(len(d[i])):
        if len(d[i])==1:
            w[d[i][0][0]]+=1
            w[d[i][0][1]+1]-=1
        elif j==0:
            w[d[i][0][0]]+=1
            e=d[i][0][1]
        elif j+1==len(d[i]):
            if e==d[i][j][0]:
                w[d[i][j][1]+1]-=1
            else:
                w[e+1]-=1
                w[d[i][j][0]]+=1
                w[d[i][j][1]+1]-=1
        else:
            if e==d[i][j][0]:
                e=d[[i][j][1]]
            else:
                w[e+1]-=1
                w[d[i][j][0]]+=1
                e=d[i][j][1]
ans=chk=0
for i in w:
    chk+=i
    ans=max(ans,chk)
print(ans)

Submission status: Runtime Error

Solution code:
n,c=map(int,input().split())
d=[[] for i in range(c)]
w=[0]*100001
for i in range(n):
    s,t,c=map(int,input().split())
    d[c-1].append((s,t))
for i in range(c):
    d[i].sort()
    e=d[i][0][1]
    for j in range(len(d[i])):
        if len(d[i])==1:
            w[d[i][0][0]]+=1
            w[d[i][0][1]+1]-=1
        elif j==0:
            w[d[i][0][0]]+=1
            e=d[i][0][1]
        elif j+1==len(d[i]):
            if e==d[i][j][0]:
                w[d[i][j][1]+1]-=1
            else:
                w[e+1]-=1
                w[d[i][j][0]]+=1
                w[d[i][j][1]+1]-=1
        else:
            if e==d[i][j][0]:
                e=d[[i][j][1]]
            else:
                w[e+1]-=1
                w[d[i][j][0]]+=1
                e=d[i][j][1]
ans=chk=0
for i in w:
    chk+=i
    ans=max(ans,chk)
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
ans = 0
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
div = make_divisors(n)
for i in div[1:]:
    if n//(i-1)==n%(i-1):
        ans += i-1

print(ans)

Submission status: Runtime Error

Solution code:
from heapq import heapify, heappush, heappop

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

ans = 1
recl = [(stc[0][1], stc[0][2])]
for s, t, c in stc[1:]:
  endr = heappop(recl)
  if c == endr[1]:
    heappush(recl, (t, c))
  else:
    if s <= endr[0]:
      if len(recl + 1) == ans:
        ans += 1
      heappush(recl, (t, c))
      heappush(recl, endr)
    else:
      heappush(recl, (t, c))

print(ans)

Submission status: Runtime Error

Solution code:
N,C=map(int, input().split())

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

Y=[]
for z in [sorted(z) for z in Z if len(z) > 0]:
	for i in range(len(z)-1):
		if z[i][1] == z[i+1][0]:
			z[i+1][0] = z[i][0]
		else:
			Y.append(z[i])
	Y.append(z.pop())

X=[0 for _ in range(10**5+1)]
for s,t in Y:
	X[s] += 1
	X[t+1] -= 1

for i in range(1, 10**5+1):
	X[i] += X[i-1]

print(max(X))

Submission status: Runtime Error

Solution code:
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math


## input
N,C = map(int, input().split())
Cn = [[0 for j in range(10**5+1)] for i in range(C)]
An = [0 for j in range(10**5*2+1)]
for i in range(N):
  s,t,c = map(int, input().split())
  if Cn[c-1][s*2] == -1:
    An[s*2] += 1
  else:
    An[s*2-1] += 1
  An[t*2] -= 1

  Cn[c-1][s] += 1
  Cn[c-1][t] -= 1

for i in range(1,10**5*2+1):
  An[i] += An[i-1]

print(max(An))

Submission status: Runtime Error

Solution code:
#D問題
N,C=map(int,input().split())
S=[]
T=[]
C=[]
for i in range(N):
    s,t,c=map(int,input().split())
    S.append(s)
    T.append(t)
    C.append(c)
SMAX=max(S)
TMAX=max(T)
Scount=[0 for i in range(SMAX+2)]
Tcount=[0 for i in range(TMAX+2)]
for i in range(N):
    Scount[S[i]]+=1
    Tcount[T[i]]+=1
count=[]
for i in range(1,TMAX+1):
    if i == 1:
        kari=0
    else:
        kari=count[-1]
    kari+=Scount[i]
    kari-=Tcount[i-1]
    count.append(kari)
print(max(count))

Submission status: Runtime Error

Solution code:
N,C = map(int,input().split())
tv_times = [[int(j) for j in input().split()] for i in range(N)]

channells = {}
for i in range(C+1):
    channells[i] = []
max_end = -1

for i in range(N):
    s,g,c = tv_times[i]
    max_end = max(max_end,g)
    channells[c] += [s,g]

tv_times = []
f = [0 for i in range(max_end+1)]
for cha in channells.keys():
    remove_list = []
    time = channells[cha]
    for i in range(1,len(time)-1):
        if time[i] == time[i+1]:
            remove_list.append(time[i])
    for i in range(len(remove_list)):
        for j in range(2):
            time.remove_list[i]
    time.sort()
    # print(time)
    # print(time)
    # print(f)
    for i in range(len(time)//2):
        f[max(time[2*i]-1,0)] += 1
        f[time[2*i+1]] -= 1

ans = -1
for i in range(1,max_end+1):
    f[i] += f[i-1]
    if ans < f[i]:
        ans = f[i]

# print(f)
print(ans)

Submission status: Runtime Error

Solution code:
N,C = map(int,input().split())
tv_times = [[int(j) for j in input().split()] for i in range(N)]

channells = {}
for i in range(C+1):
    channells[i] = []
max_end = -1

for i in range(N):
    s,g,c = tv_times[i]
    max_end = max(max_end,g)
    channells[c] += [s,g]

tv_times = []
f = [0 for i in range(max_end+1)]
for cha in channells.keys():
    remove_list = []
    time = channells[cha]
    for i in range(1,len(time)-1):
        if time[i] == time[i+1]:
            remove_list.append(time[2*i+1])
    time = list(set(time)-set(remove_list))
    time.sort()
    # print(time)
    # print(time)
    # print(f)
    for i in range(len(time)//2):
        f[max(time[2*i]-1,0)] += 1
        f[time[2*i+1]] -= 1

ans = -1
for i in range(1,max_end+1):
    f[i] += f[i-1]
    if ans < f[i]:
        ans = f[i]

# print(f)
print(ans)

Submission status: Runtime Error

Solution code:
N,C = map(int,input().split())
tv_times = [[int(j) for j in input().split()] for i in range(N)]

channells = {}
for i in range(C+1):
    channells[i] = []
max_end = -1

for i in range(N):
    s,g,c = tv_times[i]
    max_end = max(max_end,g)
    channells[c] += [s,g]

tv_times = []
f = [0 for i in range(max_end+1)]
for cha in channells.keys():
    remove_list = []
    time = channells[cha]
    for i in range(len(time)-1):
        if time[i] == time[i+1]:
            remove_list.append(time[2*i+1])
    time = list(set(time)-set(remove_list))
    time.sort()
    # print(time)
    # print(time)
    # print(f)
    for i in range(len(time)//2):
        f[max(time[2*i]-1,0)] += 1
        f[time[2*i+1]] -= 1

ans = -1
for i in range(1,max_end+1):
    f[i] += f[i-1]
    if ans < f[i]:
        ans = f[i]

# print(f)
print(ans)

Submission status: Runtime Error

Solution code:
N,C = map(int,input().split())
tv_times = [[int(j) for j in input().split()] for i in range(N)]

channells = {}
for i in range(C+1):
    channells[i] = []
max_end = -1

for i in range(N):
    s,g,c = tv_times[i]
    max_end = max(max_end,g)
    channells[c] += [s,g]

tv_times = []
f = [0 for i in range(max_end+1)]
for cha in channells.keys():
    remove_list = []
    time = channells[cha]
    time.sort()
    for i in range(len(time)//2-1):
        if time[2*i+1] == time[2*i+2]:
            remove_list.append(time[i])
    for i in range(len(remove_list)):
        time.remove(remove_list[i])
        time.remove(remove_list[i])
    # print(time)
    # print(f)
    for i in range(len(time)//2):
        f[max(time[2*i]-1,0)] += 1
        f[time[2*i+1]] -= 1

ans = -1
for i in range(1,max_end):
    f[i] += f[i-1]
    if ans < f[i]:
        ans = f[i]

# print(f)
print(ans)

Submission status: Runtime Error

Solution code:
import collections
n,c  = map(int,input().split())                     
channels = [list(map(int,input().split())) for i in range(n)]
print(channels)
channel_set = [list(range(i[0],i[1]+1)) for i in channels]
channels = []                                                
for ch in channel_set:
    channels.extend(ch)                                   
print(channels)                                  
#map(int,input().split())                                           c = collections.Counter(channels)
print(c.most_common()[0][1])

Submission status: Runtime Error

Solution code:
N,C=map(int,input().split())
T=10**5+2
sm=[0]*(T)
l=[]
r=[]
c=[]
for i in range(N):
    s,t,k=map(int,input().split())
    l.append(s)
    r.append(t)
    c.append(k)
for i in range(1,C+1):
    tt=[0]*T
    for j in range(N):
        if c[j]==i:
            tt[l[j]*2]+=1
            tt[r[j]*2+1]-=1
    for j in range(T):
        if tt[j]>0:
            sm[j-1]+=tt[j]
        else:
            sm[j]+=tt[j]
for j in range(T-1):
    sm[j+1]+=sm[j]
print(max(sm))

Submission status: Runtime Error

Solution code:
from itertools import accumulate
N, C = map(int, input().split())
TimeTable = [[0] * (10 ** 5 + 1) for i in range(C + 1)]
for i in range(N):
    s, t, c = map(int, input().split())
    TimeTable[c][s] += 1
    TimeTable[c][t + 1] -= 1

for c in range(C + 1):
    TimeTable[c] = list(accumulate(TimeTable[c]))


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

print(ans)