Buggy python submission (verdict: Runtime Error):
def popcount(n):
	res=0
	while n > 0:
		res += n % 2;
		n //= 2
	return res
n=0
def init_seg(_n):
	global n
	n = 1
	while n < _n:
		n *= 2
MAX_N=131072
data=[0]*MAX_N
datb=[0]*MAX_N

def add(a, b, x, k, l, r):
	if a <=l and r <= b:
		data[k] += x
	elif l < b and a < r:
		datb[k] += (min(b,r) - max(a,l))*x
		add(a, b, x, 2 * k + 1, l, (l + r) / 2)
		add(a, b, x, 2 * k + 2, (l + r) / 2, r)

def sum(a, b, k, l, r):
	if b <=l or r <= a:
		return 0
	elif a <= l and r <= b:
		return data[k] * (r - l) + datb[k]
	else:
		res = (min(b, r) - max(a, l)) * data[k]
		res += sum(a, b, 2 * k + 1, l, (l + r) / 2)
		res += sum(a, b, 2 * k + 2, (l + r) / 2, r)
		return int(res)

def main():
	N,C=map(int,input().split())
	init_seg(N)
	global n
	for i in range(n):
		add(i, i + 1, 0, 0, 0, n)

	for i in range(N):
		s,t,c=map(int,input().split())
		add(s, t, 2**(c-1), 0, 0, n)

	res=0
	for i in range(1,int(1e5)):
		prev=sum(i - 1, i, 0, 0, n)
		curr=sum(i, i+1, 0, 0, n)
		if prev == curr:
			res = max(res, popcount(curr))
		else:
			res = max(res, popcount(curr | prev))

	print(res)

if __name__ == '__main__':
	main()



Fixed submission:
N,C=map(int,input().split())
f=[[0]*int(1e5) for _ in range(C)]

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

print(max(map(sum,zip(*f))))

Buggy python submission (verdict: Time Limit Exceeded):
def popcount(n):
	res=0
	while n > 0:
		res += n % 2;
		n //= 2
	return res
n=0
def init_seg(_n):
	global n
	n = 1
	while n < _n:
		n *= 2
MAX_N=262144
data=[0]*MAX_N
datb=[0]*MAX_N

def add(a, b, x, k, l, r):
	if a <=l and r <= b:
		data[k] += x
	elif l < b and a < r:
		datb[k] += (min(b,r) - max(a,l))*x
		add(a, b, x, 2 * k + 1, l, (l + r) / 2)
		add(a, b, x, 2 * k + 2, (l + r) / 2, r)

def sum(a, b, k, l, r):
	if b <=l or r <= a:
		return 0
	elif a <= l and r <= b:
		return data[k] * (r - l) + datb[k]
	else:
		res = (min(b, r) - max(a, l)) * data[k]
		res += sum(a, b, 2 * k + 1, l, (l + r) / 2)
		res += sum(a, b, 2 * k + 2, (l + r) / 2, r)
		return int(res)

def main():
	init_seg(int(1e5))
	global n
	for i in range(n):
		add(i, i + 1, 0, 0, 0, n)

	N,C=map(int,input().split())
	for i in range(N):
		s,t,c=map(int,input().split())
		add(s, t, 2**(c-1), 0, 0, n)

	res=0
	for i in range(1,int(1e5)):
		prev=sum(i - 1, i, 0, 0, n)
		curr=sum(i, i+1, 0, 0, n)
		if prev == curr:
			res = max(res, popcount(curr))
		else:
			res = max(res, popcount(curr | prev))

	print(res)

if __name__ == '__main__':
	main()



Fixed submission:
N,C=map(int,input().split())
f=[[0]*int(1e5) for _ in range(C)]

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

print(max(map(sum,zip(*f))))

Buggy python submission (verdict: Runtime Error):
def popcount(n):
	res=0
	while n > 0:
		res += n%2;
		n /= 2
	return res
n=0
def init_seg(_n):
	n=1
	while(n < _n) n *= 2

data=[0]*n
datb=[0]*n

def add(a,b,x,k,l,r):
	if a <=l and r <= b:
		data[k] += x
	else:
		datb[k] += (min(b,r) - max(a,l))*x
		add(a,b,x,2*k+1,l,(l+r)/2)
		add(a,b,x,2*k+2,(l+r)/2,r)

def sum(a,b,k,l,r):
	if b <=l or r <=a:
		return 0
	elif a <= l and r <= b:
		return data[k] * (r - l) + datb[k]
	else:
		res=(min(b,r) - max(a,l)) * data[k]
		res+=sum(a,b,2*k+1,l,(l+r)/2)
		res+=sum(a,b,2*k+2,(l+r)/2,r)
		return res

init_seg(1e5)
for i in range(n):
	add(i,i+1,0,0,0,n)

N,C=map(int,input().split())
for i in range(N):
	s,t,c=map(int,input().split())
	add(s,t,2**(c-1),0,0,n)

res=0
for i in range(1,1e5):
	prev=sum(i-1,i,0,0,n)
	curr=sum(i,i+1,0,0,n)
	if prev == curr:
		res = max(res, popcount(curr))
	else:
		res = max(res, popcount(curr | prev))

print(res)



Fixed submission:
N,C=map(int,input().split())
f=[[0]*int(1e5) for _ in range(C)]

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

print(max(map(sum,zip(*f))))

Buggy python submission (verdict: Runtime Error):
def popcount(n):
	res=0
	while n > 0:
		res += n%2;
		n /= 2
	return res
n=0
def init_seg(_n):
	n=1
	while(n < _n) n *= 2

data=[0]*n
datb=[0]*n

def add(a,b,x,k,l,r):
	if a <=l and r <= b:
		data[k] += x
	else:
		datb[k] += (min(b,r) - max(a,l))*x
		add(a,b,x,2*k+1,l,(l+r)/2)
		add(a,b,x,2*k+2,(l+r)/2,r)

def sum(a,b,k,l,r):
	if b <=l or r <=a:
		return 0
	elif a <= l and r <= b:
		return data[k] * (r - l) + datb[k]
	else:
		res=(min(b,r) - max(a,l)) * data[k]
		res+=sum(a,b,2*k+1,l,(l+r)/2)
		res+=sum(a,b,2*k+2,(l+r)/2,r)
		return res

init_seg(1e5)
for i in range(n):
	add(i,i+1,0,0,0,n)

N,C=map(int,input().split())
for i in range(N):
	s,t,c=map(int,input().split())
	add(s,t,2**(c-1),0,0,n)

res=0
for i in range(1:1e5):
	prev=sum(i-1,i,0,0,n)
	curr=sum(i,i+1,0,0,n)
	if prev == curr:
		res = max(res, popcount(curr))
	else:
		res = max(res, popcount(curr | prev))

print(res)



Fixed submission:
N,C=map(int,input().split())
f=[[0]*int(1e5) for _ in range(C)]

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

print(max(map(sum,zip(*f))))