Buggy python submission (verdict: Time Limit Exceeded):
N,M = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]
list_N = list(range(1,N+1))
for j in range(M):
    A,B = [int(i) for i in input().split()]
    if H[A-1]<H[B-1]:
        if A in list_N:
            list_N.remove(A)
    elif H[A-1]>H[B-1]:
        if B in list_N:
            list_N.remove(B)
    else:
        if A in list_N:
            list_N.remove(A)
        if B in list_N:
            list_N.remove(B)
print(len(list_N))

Fixed submission:
def set1():
    N,M = [int(i) for i in input().split()]
    H = [int(i) for i in input().split()]
    set_N = set([i for i in range(1, N+1)])
    for i in range(M):
        A,B = [int(i) for i in input().split()]
        if H[A-1] < H[B-1]:
            if A in set_N:
                set_N.remove(A)
        elif H[B-1] < H[A-1]:
            if B in set_N:
                set_N.remove(B)
        else:
            if A in set_N:
                set_N.remove(A)
            if B in set_N:
                set_N.remove(B)
    print(len(set_N))

if __name__ == "__main__":
    set1()

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
H = [int(i) for i in input().split()]
list_N = list(range(1,N+1))
for j in range(M):
    A,B = map(int,input().split())
    if H[A-1]<H[B-1]:
        if A in list_N:
            list_N.remove(A)
    elif H[A-1]>H[B-1]:
        if B in list_N:
            list_N.remove(B)
    else:
        if A in list_N:
            list_N.remove(A)
        if B in list_N:
            list_N.remove(B)
print(len(list_N))

Fixed submission:
def set1():
    N,M = [int(i) for i in input().split()]
    H = [int(i) for i in input().split()]
    set_N = set([i for i in range(1, N+1)])
    for i in range(M):
        A,B = [int(i) for i in input().split()]
        if H[A-1] < H[B-1]:
            if A in set_N:
                set_N.remove(A)
        elif H[B-1] < H[A-1]:
            if B in set_N:
                set_N.remove(B)
        else:
            if A in set_N:
                set_N.remove(A)
            if B in set_N:
                set_N.remove(B)
    print(len(set_N))

if __name__ == "__main__":
    set1()

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
H = [int(i) for i in input().split()]
AB = [list(map(int,input().split())) for _ in range(M)]
list_N = list(range(1,N+1))
for j in range(M):
    if H[AB[j][0]-1]<H[AB[j][1]-1]:
        if AB[j][0] in list_N:
            list_N.remove(AB[j][0])
    elif H[AB[j][0]-1]>H[AB[j][1]-1]:
        if AB[j][1] in list_N:
            list_N.remove(AB[j][1])
    else:
        if AB[j][0] in list_N:
            list_N.remove(AB[j][0])
        if AB[j][1] in list_N:
            list_N.remove(AB[j][1])
print(len(list_N))

Fixed submission:
def set1():
    N,M = [int(i) for i in input().split()]
    H = [int(i) for i in input().split()]
    set_N = set([i for i in range(1, N+1)])
    for i in range(M):
        A,B = [int(i) for i in input().split()]
        if H[A-1] < H[B-1]:
            if A in set_N:
                set_N.remove(A)
        elif H[B-1] < H[A-1]:
            if B in set_N:
                set_N.remove(B)
        else:
            if A in set_N:
                set_N.remove(A)
            if B in set_N:
                set_N.remove(B)
    print(len(set_N))

if __name__ == "__main__":
    set1()