Buggy python submission (verdict: Time Limit Exceeded):
N, M = [ int(i) for i in input().strip().split(' ') ]
H    = [ int(i) for i in input().strip().split(' ') ]
paths = []
good_flags = [1 for _ in range(N)]

for _m in range(M):
    path = input().strip().split(' ')
    path = int(path[0]), int(path[1])
    # path = path if path[0] < path[1] else (path[1], path[0])
#    if path not in paths:

    p1, p2 = path if path[0] < path[1] else (path[1], path[0])
    if (p1, p2) in paths:
        continue

    if H[p1-1] > H[p2-1]:
        good_flags[p2-1] = 0
    elif H[p1-1] < H[p2-1]:
        good_flags[p1-1] = 0
    else:
        good_flags[p1-1] = 0
        good_flags[p2-1] = 0        

    paths.append(path) 

print(sum(good_flags))

Fixed submission:
N, M = [ int(i) for i in input().strip().split(' ') ]
H    = [ int(i) for i in input().strip().split(' ') ]
paths = []
max_neighbor = [ 0 for _ in range(N)]

for _m in range(M):
    path = input().strip().split(' ')
    path = int(path[0]), int(path[1])
    max_neighbor[path[0]-1] = max(max_neighbor[path[0]-1], H[path[1]-1])
    max_neighbor[path[1]-1] = max(max_neighbor[path[1]-1], H[path[0]-1])
count = 0
for n in range(N):
    if max_neighbor[n] < H[n]:
        count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = [ int(i) for i in input().strip().split(' ') ]
H    = [ int(i) for i in input().strip().split(' ') ]
paths = []
for _m in range(M):
    path = input().strip().split(' ')
    path = int(path[0]), int(path[1])
    path = path if path[0] < path[1] else (path[1], path[0])
    if path not in paths:
        paths.append(path)
good_flags = [1 for _ in range(N)]

for p1, p2 in paths:
    if H[p1-1] > H[p2-1]:
        good_flags[p2-1] = 0
    elif H[p1-1] < H[p2-1]:
        good_flags[p1-1] = 0
    else:
        good_flags[p1-1] = 0
        good_flags[p2-1] = 0        

print(sum(good_flags))

Fixed submission:
N, M = [ int(i) for i in input().strip().split(' ') ]
H    = [ int(i) for i in input().strip().split(' ') ]
paths = []
max_neighbor = [ 0 for _ in range(N)]

for _m in range(M):
    path = input().strip().split(' ')
    path = int(path[0]), int(path[1])
    max_neighbor[path[0]-1] = max(max_neighbor[path[0]-1], H[path[1]-1])
    max_neighbor[path[1]-1] = max(max_neighbor[path[1]-1], H[path[0]-1])
count = 0
for n in range(N):
    if max_neighbor[n] < H[n]:
        count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = [ int(i) for i in input().strip().split(' ') ]
H    = [ int(i) for i in input().strip().split(' ') ]
paths = []
for _m in range(M):
    path = input().strip().split(' ')
    path = int(path[0]), int(path[1])
    path = path if path[0] < path[1] else (path[1], path[0])
    if path not in paths:
        paths.append(path)
all_paths = []
for path in paths:
    all_paths += path
all_paths = set(all_paths)
count = 0
for n in range(1, N+1):
    is_good = 1
    if n not in all_paths:
        count += is_good
        continue
    for path in paths:
        if n not in list(path):
            continue
        if (path[0] == n):
            if (H[n-1] <= H[path[1]-1]):
                is_good = 0
                break
        else:
            if (H[n-1] <= H[path[0]-1]):
                is_good = 0
                break    
    count += is_good
print(count)

Fixed submission:
N, M = [ int(i) for i in input().strip().split(' ') ]
H    = [ int(i) for i in input().strip().split(' ') ]
paths = []
max_neighbor = [ 0 for _ in range(N)]

for _m in range(M):
    path = input().strip().split(' ')
    path = int(path[0]), int(path[1])
    max_neighbor[path[0]-1] = max(max_neighbor[path[0]-1], H[path[1]-1])
    max_neighbor[path[1]-1] = max(max_neighbor[path[1]-1], H[path[0]-1])
count = 0
for n in range(N):
    if max_neighbor[n] < H[n]:
        count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = [ int(i) for i in input().strip().split(' ') ]
H    = [ int(i) for i in input().strip().split(' ') ]
paths = []
for _m in range(M):
    path = input().strip().split(' ')
    path = int(path[0]), int(path[1])
    path = path if path[0] < path[1] else (path[1], path[0])
    if path not in paths:
        paths.append(path)
all_paths = []
for path in paths:
    all_paths += path
all_paths = set(all_paths)
count = 0
for n in range(1, N+1):
    is_good = 1
    if n not in all_paths:
        count += is_good
        continue

    for path in paths:
        if n not in list(path):
            continue
        if (path[0] == n) and (H[n-1] <= H[path[1]-1]):
            is_good = 0
            break
        if (path[1] == n) and (H[n-1] <= H[path[0]-1]):
            is_good = 0
            break    
    count += is_good
print(count)

Fixed submission:
N, M = [ int(i) for i in input().strip().split(' ') ]
H    = [ int(i) for i in input().strip().split(' ') ]
paths = []
max_neighbor = [ 0 for _ in range(N)]

for _m in range(M):
    path = input().strip().split(' ')
    path = int(path[0]), int(path[1])
    max_neighbor[path[0]-1] = max(max_neighbor[path[0]-1], H[path[1]-1])
    max_neighbor[path[1]-1] = max(max_neighbor[path[1]-1], H[path[0]-1])
count = 0
for n in range(N):
    if max_neighbor[n] < H[n]:
        count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = [ int(i) for i in input().strip().split(' ') ]
H    = [ int(i) for i in input().strip().split(' ') ]
paths = [ input().strip().split(' ') for _m in range(M)]
paths = [ [int(p1), int(p2)] for p1, p2 in paths ]
all_paths = []
for path in paths:
    all_paths += path

count = 0
for n in range(1, N+1):
    is_good = 1
    if n not in all_paths:
        count += is_good
        continue

    for path in paths:
        if n not in list(path):
            continue
        if (path[0] == n) and (H[n-1] <= H[path[1]-1]):
            is_good = 0
            break
        if (path[1] == n) and (H[n-1] <= H[path[0]-1]):
            is_good = 0
            break    
    count += is_good
print(count)

Fixed submission:
N, M = [ int(i) for i in input().strip().split(' ') ]
H    = [ int(i) for i in input().strip().split(' ') ]
paths = []
max_neighbor = [ 0 for _ in range(N)]

for _m in range(M):
    path = input().strip().split(' ')
    path = int(path[0]), int(path[1])
    max_neighbor[path[0]-1] = max(max_neighbor[path[0]-1], H[path[1]-1])
    max_neighbor[path[1]-1] = max(max_neighbor[path[1]-1], H[path[0]-1])
count = 0
for n in range(N):
    if max_neighbor[n] < H[n]:
        count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = [ int(i) for i in input().strip().split(' ') ]
H    = [ int(i) for i in input().strip().split(' ') ]
paths = [ input().strip().split(' ') for _m in range(M)]
paths = [ [int(p1), int(p2)] for p1, p2 in paths ]
count = 0
for n in range(1, N+1):
    is_good = True
    for path in paths:
        if n not in list(path):
            continue
        if (path[0] == n) and (H[n-1] <= H[path[1]-1]):
            is_good = False
            break
        if (path[1] == n) and (H[n-1] <= H[path[0]-1]):
            is_good = False
            break
    
    if is_good:
        count += 1
print(count)

Fixed submission:
N, M = [ int(i) for i in input().strip().split(' ') ]
H    = [ int(i) for i in input().strip().split(' ') ]
paths = []
max_neighbor = [ 0 for _ in range(N)]

for _m in range(M):
    path = input().strip().split(' ')
    path = int(path[0]), int(path[1])
    max_neighbor[path[0]-1] = max(max_neighbor[path[0]-1], H[path[1]-1])
    max_neighbor[path[1]-1] = max(max_neighbor[path[1]-1], H[path[0]-1])
count = 0
for n in range(N):
    if max_neighbor[n] < H[n]:
        count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = [ int(i) for i in input().strip().split(' ') ]
H = [ int(i) for i in input().strip().split(' ') ]

paths = [ input().strip().split(' ') for _m in range(M)]
count = 0
for n in range(1, N+1):
    is_good = True
    
    for path in paths:
        if (int(path[0]) == n) and (H[n-1] <= H[int(path[1])-1]):
            is_good = False
            break
        if (int(path[1]) == n) and (H[n-1] <= H[int(path[0])-1]):
            is_good = False
            break
    
    if is_good:
        count += 1
print(count)

Fixed submission:
N, M = [ int(i) for i in input().strip().split(' ') ]
H    = [ int(i) for i in input().strip().split(' ') ]
paths = []
max_neighbor = [ 0 for _ in range(N)]

for _m in range(M):
    path = input().strip().split(' ')
    path = int(path[0]), int(path[1])
    max_neighbor[path[0]-1] = max(max_neighbor[path[0]-1], H[path[1]-1])
    max_neighbor[path[1]-1] = max(max_neighbor[path[1]-1], H[path[0]-1])
count = 0
for n in range(N):
    if max_neighbor[n] < H[n]:
        count += 1
print(count)