Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    A, B = [], []
    AB = []
    for i in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
        AB.append([a, b])

    AB.sort(key=lambda x: x[1])

    time = 0
    while (len(AB) > 0):
        flag = True
        a, b = AB[0]
        if time + a <= b:
            time += a
            AB.pop(0)
            flag = False
        if flag:
            break
    if len(AB) == 0:
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    N = int(input())
    A, B = [], []
    AB = []
    for i in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
        AB.append([a, b])

    AB.sort(key=lambda x: x[1])

    time = 0
    count = 0
    for i in range(N):
        flag = True
        a, b = AB[i]
        if time + a <= b:
            time += a
            count += 1
            flag = False
        if flag:
            break

    if count == N:
        print('Yes')
    else:
        print('No')    

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    A, B = [], []
    AB = []
    for i in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
        AB.append([a, b])

    AB.sort(key=lambda x: x[1])

    time = 0
    while (len(AB) > 0):
        flag = True
        a, b = AB[0]
        if time + a <= b:
            time += a
            AB.pop(0)
            flag = False
        if flag:
            break
    if len(AB) == 0:
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    N = int(input())
    A, B = [], []
    AB = []
    for i in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
        AB.append([a, b])

    AB.sort(key=lambda x: x[1])

    time = 0
    count = 0
    for i in range(N):
        flag = True
        a, b = AB[i]
        if time + a <= b:
            time += a
            count += 1
            flag = False
        if flag:
            break

    if count == N:
        print('Yes')
    else:
        print('No')    

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    N = int(input())
    A, B = [], []
    AB = []
    for i in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
        AB.append([a, b])

    AB.sort(key=lambda x: x[1])

    time = 0
    while (len(AB) > 0):
        flag = True
        a, b = AB
        if time + a <= b:
            time += a
            AB.pop(0)
            flag = False
        if flag:
            break
    if len(AB) == 0:
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    N = int(input())
    A, B = [], []
    AB = []
    for i in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
        AB.append([a, b])

    AB.sort(key=lambda x: x[1])

    time = 0
    count = 0
    for i in range(N):
        flag = True
        a, b = AB[i]
        if time + a <= b:
            time += a
            count += 1
            flag = False
        if flag:
            break

    if count == N:
        print('Yes')
    else:
        print('No')    

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A, B = [], []
AB = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
    AB.append([a, b])

AB.sort(key=lambda x: x[1])

time = 0
while (len(AB) > 0):
    flag = True
    if time + AB[0][0] <= AB[0][1]:
        time += AB[0][0]
        AB.pop(0)
        flag = False
    if flag:
        break
if len(AB) == 0:
    print('Yes')
else:
    print('No')


Fixed submission:
def main():
    N = int(input())
    A, B = [], []
    AB = []
    for i in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
        AB.append([a, b])

    AB.sort(key=lambda x: x[1])

    time = 0
    count = 0
    for i in range(N):
        flag = True
        a, b = AB[i]
        if time + a <= b:
            time += a
            count += 1
            flag = False
        if flag:
            break

    if count == N:
        print('Yes')
    else:
        print('No')    

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A, B = [], []
AB = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
    AB.append([a, b])

AB.sort(key=lambda x: x[1])

time = 0
while (len(AB) > 0):
    flag = True
    if time + AB[0][0] <= AB[0][1]:
        time += AB[0][0]
        AB.pop(0)
        flag = False
    if flag:
        break
if len(AB) == 0:
    print('Yes')
else:
    print('No')


Fixed submission:
def main():
    N = int(input())
    A, B = [], []
    AB = []
    for i in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
        AB.append([a, b])

    AB.sort(key=lambda x: x[1])

    time = 0
    count = 0
    for i in range(N):
        flag = True
        a, b = AB[i]
        if time + a <= b:
            time += a
            count += 1
            flag = False
        if flag:
            break

    if count == N:
        print('Yes')
    else:
        print('No')    

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A, B = [], []
AB = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
    AB.append([a, b])

AB.sort(key=lambda x: x[1])

time = 0
while (len(AB) > 0):
    flag = True
    for i in range(len(AB)):
        if time + AB[i][0] <= AB[i][1]:
            time += AB[i][0]
            AB.pop(i)
            flag = False
            break
    if flag:
        break

if len(AB) == 0:
    print('Yes')
else:
    print('No')


Fixed submission:
def main():
    N = int(input())
    A, B = [], []
    AB = []
    for i in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
        AB.append([a, b])

    AB.sort(key=lambda x: x[1])

    time = 0
    count = 0
    for i in range(N):
        flag = True
        a, b = AB[i]
        if time + a <= b:
            time += a
            count += 1
            flag = False
        if flag:
            break

    if count == N:
        print('Yes')
    else:
        print('No')    

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A, B = [], []
AB = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
    AB.append([a, b])

AB.sort(key=lambda x: x[1])

time = 0
while (len(AB) > 0):
    flag = True
    for i in range(len(AB)):
        if time + AB[i][0] <= AB[i][1]:
            time += AB[i][0]
            AB.pop(i)
            flag = False
            break
    if flag:
        break

if len(AB) == 0:
    print('Yes')
else:
    print('No')


Fixed submission:
def main():
    N = int(input())
    A, B = [], []
    AB = []
    for i in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
        AB.append([a, b])

    AB.sort(key=lambda x: x[1])

    time = 0
    count = 0
    for i in range(N):
        flag = True
        a, b = AB[i]
        if time + a <= b:
            time += a
            count += 1
            flag = False
        if flag:
            break

    if count == N:
        print('Yes')
    else:
        print('No')    

if __name__ == "__main__":
    main()