Buggy python submission (verdict: Runtime Error):
N = int(input())
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]
ans = -float("inf")
for i in range(1, 2 ** 10):
    b, s = i, 0
    cnt = [0 for _ in range(N)]
    while b > 0:
        if b & 1:
            for j in range(N):
                cnt[j] += F[j][s]
        s += 1
        b >>= 1
    sub_ans = 0
    for j in range(N):
        sub_ans += P[j][cnt[j]]
    ans = max(ans, sub_ans)
print(ans)


Fixed submission:
import sys

def main():
    input = sys.stdin.readline
    N, C = map(int, input().split())
    dic = [[] for _ in range(C + 1)]
    for _ in range(N):
        s, t, c = input().split()
        dic[int(c)].append([int(s), int(t)])
    for c in range(C + 1):
        l = len(dic[c])
        if l == 1:
            continue
        dic[c] = sorted(dic[c])
        i = 0
        while i < l - 1:
            if i < l - 1 and dic[c][i][1] == dic[c][i + 1][0]:
                dic[c][i + 1][0] += 1
            else:
                i += 1
    f = [0 for _ in range(100002)]
    for c in range(C + 1):
        for t in dic[c]:
            f[t[0]] += 1
            f[t[1] + 1] -= 1
    ans = 0
    for i in range(1, 100001):
        f[i] += f[i - 1]
        if ans < f[i]:
            ans = f[i]
    print(ans)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys

def main():
    input = sys.stdin.readline
    N, C = map(int, input().split())
    dic = [[] for _ in range(C + 1)]
    for _ in range(N):
        s, t, c = input().split()
        dic[int(c)].append([int(s), int(t)])
    for c in range(C + 1):
        l = len(dic[c])
        if l == 1:
            continue
        dic[c] = sorted(dic[c])
        i = 0
        while i < l - 1:
            if i < l - 1 and dic[c][i][1] == dic[c][i + 1][0]:
                dic[c][i + 1][0] = dic[c][i][0]
                dic[c].pop(i)
                l -= 1
            else:
                i += 1
    f = [0 for _ in range(100002)]
    for c in range(C + 1):
        for t in dic[c]:
            f[t[0]] += 1
            f[t[1] + 1] -= 1

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

if __name__ == "__main__":
    main()

Fixed submission:
import sys

def main():
    input = sys.stdin.readline
    N, C = map(int, input().split())
    dic = [[] for _ in range(C + 1)]
    for _ in range(N):
        s, t, c = input().split()
        dic[int(c)].append([int(s), int(t)])
    for c in range(C + 1):
        l = len(dic[c])
        if l == 1:
            continue
        dic[c] = sorted(dic[c])
        i = 0
        while i < l - 1:
            if i < l - 1 and dic[c][i][1] == dic[c][i + 1][0]:
                dic[c][i + 1][0] += 1
            else:
                i += 1
    f = [0 for _ in range(100002)]
    for c in range(C + 1):
        for t in dic[c]:
            f[t[0]] += 1
            f[t[1] + 1] -= 1
    ans = 0
    for i in range(1, 100001):
        f[i] += f[i - 1]
        if ans < f[i]:
            ans = f[i]
    print(ans)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N, C = map(int, input().split())
dic = [[] for _ in range(C + 1)]
for _ in range(N):
    s, t, c = map(int, input().split())
    dic[c].append([s, t])
for c in range(C + 1):
    dic[c] = sorted(dic[c])
    l = len(dic[c])
    i = 0
    while i < l - 1:
        if i < l - 1 and dic[c][i][1] == dic[c][i + 1][0]:
            dic[c][i + 1][0] = dic[c][i][0]
            dic[c].pop(i)
            l -= 1
        else:
            i += 1
f = [0 for _ in range(100002)]
for c in range(C + 1):
    for t in dic[c]:
        f[t[0]] += 1
        f[t[1] + 1] -= 1

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


Fixed submission:
import sys

def main():
    input = sys.stdin.readline
    N, C = map(int, input().split())
    dic = [[] for _ in range(C + 1)]
    for _ in range(N):
        s, t, c = input().split()
        dic[int(c)].append([int(s), int(t)])
    for c in range(C + 1):
        l = len(dic[c])
        if l == 1:
            continue
        dic[c] = sorted(dic[c])
        i = 0
        while i < l - 1:
            if i < l - 1 and dic[c][i][1] == dic[c][i + 1][0]:
                dic[c][i + 1][0] += 1
            else:
                i += 1
    f = [0 for _ in range(100002)]
    for c in range(C + 1):
        for t in dic[c]:
            f[t[0]] += 1
            f[t[1] + 1] -= 1
    ans = 0
    for i in range(1, 100001):
        f[i] += f[i - 1]
        if ans < f[i]:
            ans = f[i]
    print(ans)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
N, C = map(int, input().split())
dic = [[] for _ in range(C + 1)]
for _ in range(N):
    s, t, c = map(int, input().split())
    dic[c].append([s, t])
for c in range(C + 1):
    dic[c] = sorted(dic[c])
    l = len(dic[c])
    i = 0
    while i < l - 1:
        if i < l - 1 and dic[c][i][1] == dic[c][i + 1][0]:
            dic[c][i + 1][0] = dic[c][i][0]
            dic[c].pop(i)
            l -= 1
        else:
            i += 1
f = [0 for _ in range(100002)]
for c in range(C + 1):
    for t in dic[c]:
        f[t[0]] += 1
        f[t[1] + 1] -= 1

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

Fixed submission:
import sys

def main():
    input = sys.stdin.readline
    N, C = map(int, input().split())
    dic = [[] for _ in range(C + 1)]
    for _ in range(N):
        s, t, c = input().split()
        dic[int(c)].append([int(s), int(t)])
    for c in range(C + 1):
        l = len(dic[c])
        if l == 1:
            continue
        dic[c] = sorted(dic[c])
        i = 0
        while i < l - 1:
            if i < l - 1 and dic[c][i][1] == dic[c][i + 1][0]:
                dic[c][i + 1][0] += 1
            else:
                i += 1
    f = [0 for _ in range(100002)]
    for c in range(C + 1):
        for t in dic[c]:
            f[t[0]] += 1
            f[t[1] + 1] -= 1
    ans = 0
    for i in range(1, 100001):
        f[i] += f[i - 1]
        if ans < f[i]:
            ans = f[i]
    print(ans)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
N, C = map(int, input().split())
dic = defaultdict(list)
for _ in range(N):
    s, t, c = input().split()
    dic[c].append([int(s), int(t)])
for c in dic:
    dic[c] = sorted(dic[c])
    l = len(dic[c])
    i = 0
    while i < l - 1:
        if i < l - 1 and dic[c][i][1] == dic[c][i + 1][0]:
            dic[c][i + 1][0] = dic[c][i][0]
            dic[c].pop(i)
            l -= 1
        else:
            i += 1
f = [0 for _ in range(10 ** 5 + 2)]
for c in dic:
    for t in dic[c]:
        f[t[0]] += 1
        f[t[1] + 1] -= 1

ans = 0
for i in range(1, 10 ** 5 + 1):
    f[i] += f[i - 1]
    if ans < f[i]:
        ans = f[i]
print(ans)

Fixed submission:
import sys

def main():
    input = sys.stdin.readline
    N, C = map(int, input().split())
    dic = [[] for _ in range(C + 1)]
    for _ in range(N):
        s, t, c = input().split()
        dic[int(c)].append([int(s), int(t)])
    for c in range(C + 1):
        l = len(dic[c])
        if l == 1:
            continue
        dic[c] = sorted(dic[c])
        i = 0
        while i < l - 1:
            if i < l - 1 and dic[c][i][1] == dic[c][i + 1][0]:
                dic[c][i + 1][0] += 1
            else:
                i += 1
    f = [0 for _ in range(100002)]
    for c in range(C + 1):
        for t in dic[c]:
            f[t[0]] += 1
            f[t[1] + 1] -= 1
    ans = 0
    for i in range(1, 100001):
        f[i] += f[i - 1]
        if ans < f[i]:
            ans = f[i]
    print(ans)

if __name__ == "__main__":
    main()