Problem:
The Maximum Number of Customers $N$ persons visited a restaurant. The restaurant is open from 0 to $T$. The $i$-th person entered the restaurant at $l_i$ and left at $r_i$. Find the maximum number of persons during the business hours. Constraints  $ 1 \leq N \leq 10^5 $  $ 1 \leq T \leq 10^5 $  $ 0 \leq l_i < r_i \leq T $  Input The input is given in the following format. $N$ $T$ $l_1$ $r_1$ $l_2$ $r_2$ : $l_N$ $r_N$  Output Print the maximum number of persons in a line. Sample Input 1 6 10
0 2
1 3
2 6
3 8
4 10
5 10 Sample Output 1 4 Sample Input 2 2 2
0 1
1 2 Sample Output 2 1

Solution (Python):
n, t = map(int,raw_input().split())

arr = [0 for i in range(t+1)]

for i in range(n):
	start, end = map(int,raw_input().split())
	arr[start] += 1
	arr[end] -= 1

cs = [arr[0] for i in range(t+1)]

for i in range(1,t+1):
	cs[i] = cs[i-1] + arr[i]

print max(cs)

Solution (Python):
from itertools import accumulate

n, t = map(int, input().split())
a = [0] * (t + 1)
for l, r in (map(int, input().split()) for _ in range(n)):
    a[l] += 1
    a[r] -= 1
print(max(accumulate(a)))

Solution (Python):
N,T = map(int, input().split())
imos = [0]*(T+1)
for i in range(N):
	s,e = map(int, input().split())
	imos[s] += 1
	imos[e] -= 1
m = 0
num = 0
for i in imos:
	num += i
	m = max(num, m)
print(m)

Solution (Python):
import sys
input = sys.stdin.readline

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

imos = [0 for _ in range(T + 1)]

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

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

print(max(imos))

Solution (Python):
from itertools import accumulate
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N, T = map(int, input().split())
time = [0] * (T + 2)
for _ in range(N):
    l, r = map(int, input().split())
    time[l] += 1
    time[r] -= 1

print(max(accumulate(time)))

Solution (Python):
def main():
    n,t = map(int,input().split())
    t+=1
    T = [0]*t
    for _ in range(n):
        l,r = map(int,input().split())
        T[l]+=1
        T[r]-=1
    num = 0
    res = 0
    for i in range(t):
        num += T[i]
        res = max(num,res)
    print (res)

if __name__ == '__main__':
    main()

Solution (Python):
n,t = map(int,input().split())
a = [0] * (t+1)
for _ in range(n):
	l, r = map(int,input().split())
	a[l] += 1
	a[r] -= 1

ans = 0
current = 0
for i in range(t+1):
	current += a[i]
	ans = max([ans, current])

print(ans)

Solution (Python):



from collections import Counter,deque


from sys import stdin,setrecursionlimit










setrecursionlimit(10**6)
input=stdin.readline

n,t=map(int,input().split())
ac=[0]*(t+1)
for _ in range(n):
    l,r=map(int,input().split())
    ac[l]+=1
    ac[r]-=1
for i in range(1,t+1):
    ac[i]+=ac[i-1]
print(max(ac))

Solution (Python):
N,T = map(int,input().split())
Data = [0]*(T+1)
Ans  = [0]*(T+1)
for _ in range(N):
    l,r = map(int,input().split())
    Data[l] += 1
    Data[r] -= 1

Ans[0] = Data[0]
for i in range(1,T+1):
    Ans[i] = Data[i]+Ans[i-1]
print(max(Ans))

Solution (Python):
from itertools import accumulate

n, t = [int(x) for x in input().split()]

T = [0]*(t+1)

for _ in range(n):
    l, r = [int(x) for x in input().split()]
    T[l] += 1
    T[r] -= 1

print(max(accumulate(T)))

Solution (Python):
from collections import deque

N, T = map(int, input().split())
queue = deque()

for i in range(N):
    l, r = map(int, input().split())
    queue.extend([(l, 1), (r, -1)])
queue = sorted(queue)

ans = p = 0

for t, s in queue:
    if s == 1:
        p += 1
        ans = max(ans, p)
    else:
        p -= 1
    
print(max(ans, p))

Solution (Python):
if __name__ == "__main__":
    N, T = map(lambda x: int(x), input().split())
    table = [0] * (T + 1)
    for idx in range(N):
        l, r = map(lambda x: int(x), input().split())
        table[l] += 1
        table[r] -= 1

    ans = table[0]
    for idx in range(1, T + 1):
        table[idx] += table[idx - 1]
        ans = max(ans, table[idx])

    print(ans)

Solution (Python):
n,t=map(int, input().split( ))
L=[0 for i in range(t+1)]
R=[0 for i in range(t+1)]
for i in range(n):
    l,r=map(int, input().split( ))
    L[l]+=1
    R[r]+=1

mx=0
tmp=0
for i in range(t+1):
    tmp+=L[i]
    tmp-=R[i]
    if tmp>mx:
        mx=tmp
print(mx)

Solution (Python):

"""
Cumulative Sum - The Maximum Number of Customers
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_5_A&lang=jp

"""
import sys


def solve(events):
    ans, customer = 0, 0
    for _, e in events:
        customer += e
        ans = max(ans, customer)
    return ans


def main(args):
    N, T = map(int, input().split())
    events = []
    for _ in range(N):
        l, r = map(int, input().split())
        events.append((l, 1))
        events.append((r, -1))
    ans = solve(sorted(events))
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):
n, t = map(int, input().split())
box = []
for _ in range(n):
    s, t = map(int, input().split())
    box.append((s,1))
    box.append((t,0))

box = sorted(box)
cnt = 0
ans = 0
for x in box:
    a, b = x
    if b == 0:
        cnt -= 1
    else:
        cnt += 1
    ans = max(ans,cnt)
print(ans)

Solution (Python):
from itertools import accumulate
n,t=map(int,input().split())
timeline=[0 for i in range(t+1)]
for i in range(n):
    a,b=map(int,input().split())
    timeline[a]+=1
    timeline[b]-=1
print(max(accumulate(timeline)))

Solution (Python):
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop



BIG_NUM = 2000000000
HUGE_NUM = 9999999999999999
MOD = 1000000007
EPS = 0.000000001



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

table = [0]*(T+1)

for loop in range(N):
    left,right = map(int,input().split())
    table[left] += 1
    table[right] -= 1

ans = table[0]
for i in range(1,T+1):
    table[i] += table[i-1]
    ans = max(ans,table[i])

print("%d"%(ans))

Solution (Python):
N, T = map(int, input().split())
D = [0]*(T+1)
for i in range(N):
    l, r = map(int, input().split())
    D[l] += 1; D[r] -= 1
for i in range(T):
    D[i+1] += D[i]
print(max(D))

Solution (Python):




def run():
    n, t = [int(i) for i in input().split()]
    sch = [0] * (t+1)

    for _ in range(n):
        enter, leave = [int(i) for i in input().split()]
        sch[enter] += 1
        sch[leave] -= 1

    c = 0
    maxc = 0
    for i in sch:
        c += i
        if c >= maxc:
            maxc = c

    print(maxc)


if __name__ == '__main__':
    run()

Solution (Python):
n,t = map(int, input().split(" "))
num = [0 for i in range(t)]
for i in range(n):
    l,r = map(int, input().split(" "))
    num[l] += 1
    if r < t:
        num[r] -= 1
for i in range(1,t):
    num[i] += num[i-1]
print(max(num))