Buggy python submission (verdict: Runtime Error):
def main():
    N = int(input())
    A = []
    B = []
    b_max = 0
    for _ in range(N):
        a, b = map(int, input().split(" "))
        A.append(a)
        B.append(b)
        if b_max < b:
            b_max = b
    tasks = [0] * (b_max + 1)
    for i in range(N):
        tasks[B[i]] += A[i]
    time = 0
    flag = True
    for i, task in enumerate(tasks):
        if i == 0:
            continue
        time += task
        if time > i:
            flag = False
            break
    if flag:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    flag = True
    tascs = []
    for _ in range(N):
        a, b = map(int, input().split(" "))
        tmp = [a, b]
        tascs.append(tuple(tmp))
    tascs.sort(key=lambda x: x[1])
    passed_time = 0
    for tasc in tascs:
        passed_time += tasc[0]
        if passed_time > tasc[1]:
            flag = False
            break
    if flag:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    N = int(input())
    A = []
    B = []
    b_max = 0
    for _ in range(N):
        a, b = map(int, input().split(" "))
        A.append(a)
        B.append(b)
        if b_max < b:
            b_max = b
    tasks = [0] * (b_max + 1)
    for i in range(N):
        tasks[B[i]] += A[i]
    time = 0
    flag = True
    for i, task in enumerate(tasks):
        if i == 0 or task == 0:
            continue
        time += task
        if time > i:
            flag = False
            break
    if flag:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    flag = True
    tascs = []
    for _ in range(N):
        a, b = map(int, input().split(" "))
        tmp = [a, b]
        tascs.append(tuple(tmp))
    tascs.sort(key=lambda x: x[1])
    passed_time = 0
    for tasc in tascs:
        passed_time += tasc[0]
        if passed_time > tasc[1]:
            flag = False
            break
    if flag:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    N = int(input())
    A = []
    B = []
    for _ in range(N):
        a, b = map(int, input().split(" "))
        A.append(a)
        B.append(b)
    tasks = [0] * (max(B) + 1)
    for i in range(N):
        tasks[B[i]] += A[i]
    time = 0
    flag = True
    for i, task in enumerate(tasks):
        if i == 0 or task == 0:
            continue
        time += task
        if time > i:
            flag = False
            break
    if flag:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    flag = True
    tascs = []
    for _ in range(N):
        a, b = map(int, input().split(" "))
        tmp = [a, b]
        tascs.append(tuple(tmp))
    tascs.sort(key=lambda x: x[1])
    passed_time = 0
    for tasc in tascs:
        passed_time += tasc[0]
        if passed_time > tasc[1]:
            flag = False
            break
    if flag:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    A = []
    B = []
    for _ in range(N):
        a, b = map(int, input().split(" "))
        A.append(a)
        B.append(b)
    tasks = [[0] for _ in range(max(B) + 1)]
    for i in range(N):
        tasks[B[i]].append(A[i])
    time = 0
    flag = True
    for i, task in enumerate(tasks):
        if i == 0:
            continue
        time += sum(task)
        if time > i:
            flag = False
            break
    if flag:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    flag = True
    tascs = []
    for _ in range(N):
        a, b = map(int, input().split(" "))
        tmp = [a, b]
        tascs.append(tuple(tmp))
    tascs.sort(key=lambda x: x[1])
    passed_time = 0
    for tasc in tascs:
        passed_time += tasc[0]
        if passed_time > tasc[1]:
            flag = False
            break
    if flag:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()