qyliang/CodeNanoFix huggingface dataset:
Buggy code:
from sys import stdin,stdout
inp = stdin.readline
out = stdout.write
n,m = map(int,inp().split())
h = [int(u) for u in inp().split()]
adj = [[] for _ in range(n)]
for i in range(m):
    u,v = map(int,inp().split())
    u -= 1
    v -= 1
    adj[u].append(v)
    adj[v].append(u)
marked = [False for _ in range(n)]
cnt = 0
for u in range(n):
    if marked[u]: continue
    good = True
    for v in adj[u]:
        if h[u] < h[v]:
            good = False
            break
        else: marked[v] = True
    if good: cnt += 1
out(str(cnt))

Fixed code:
from sys import stdin,stdout
inp = stdin.readline
out = stdout.write
n,m = map(int,inp().split())
h = [int(u) for u in inp().split()]
adj = [[] for _ in range(n)]
for i in range(m):
    u,v = map(int,inp().split())
    u -= 1
    v -= 1
    adj[u].append(v)
    adj[v].append(u)
marked = [False for _ in range(n)]
cnt = 0
for u in range(n):
    if marked[u]: continue
    good = True
    for v in adj[u]:
        if h[u] <= h[v]:
            good = False
            break
        else: marked[v] = True
    if good: cnt += 1
out(str(cnt))
Buggy code:
n,m = map(int, input().split())
h_a = list(map(int, input().split()))

m_l = [[0,0]]*m
r_l = [{}]*n
for i in range(m):
  r = list(map(int, input().split()))
  a = r[0] - 1
  b = r[1] - 1

  ral = set([]) if len(r_l[a]) == 0 else r_l[a]
  rbl = set([]) if len(r_l[b]) == 0 else r_l[b]

  ral.add(b)
  rbl.add(a)

  r_l[a] = ral
  r_l[b] = rbl
print(r_l)

cnt = 0
for ni in range(n):
  for r in r_l[ni]:
    if h_a[r] >= h_a[ni]:
      break
  else:
    cnt+=1

print(cnt)

Fixed code:
n,m = map(int, input().split())
h_a = list(map(int, input().split()))

m_l = [[0,0]]*m
r_l = [{}]*n
for i in range(m):
  r = list(map(int, input().split()))
  a = r[0] - 1
  b = r[1] - 1

  ral = set([]) if len(r_l[a]) == 0 else r_l[a]
  rbl = set([]) if len(r_l[b]) == 0 else r_l[b]

  ral.add(b)
  rbl.add(a)

  r_l[a] = ral
  r_l[b] = rbl

cnt = 0
for ni in range(n):
  for r in r_l[ni]:
    if h_a[r] >= h_a[ni]:
      break
  else:
    cnt+=1

print(cnt)
Buggy code:
n,m=map(int,input().split())
h=list(map(int, input().split()))
ans=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  if h[a-1]>h[b-1]:
        ans[b-1]+=1
  elif h[a-1]<h[b-1]:
        ans[a-1]+=1
print(ans.count(0))

Fixed code:
n,m=map(int,input().split())
h=list(map(int, input().split()))
ans=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  if h[a-1]>h[b-1]:
        ans[b-1]+=1
  elif h[a-1]<h[b-1]:
        ans[a-1]+=1
  else:
        ans[b-1]+=1
        ans[a-1]+=1
print(ans.count(0))
Buggy code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,m=map(int,input().split())
    H=[int(_) for _ in input().split()]
    HH= [0]*n

    for i in range(m):
        a,b=map(int,input().split())
        HH[a-1]=max(HH[a-1],H[b-1])
        HH[b-1]=max(HH[b-1],H[a-1])
    ans=0
    for i,hh in enumerate(HH):
        if H[i]>hh or hh==0:
            ans+=1
    print(HH)
    print(ans)

if __name__=='__main__':
    main()

Fixed code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,m=map(int,input().split())
    H=[int(_) for _ in input().split()]
    HH= [0]*n

    for i in range(m):
        a,b=map(int,input().split())
        HH[a-1]=max(HH[a-1],H[b-1])
        HH[b-1]=max(HH[b-1],H[a-1])
    ans=0
    for i,hh in enumerate(HH):
        if H[i]>hh or hh==0:
            ans+=1
    print(ans)

if __name__=='__main__':
    main()
Buggy code:
N,M = map(int,input().split())
H=list(map(int,input().split()))
ABmap=[[] for i in range(N)]
count=0
for i in range(M):
    A,B=map(lambda x:x-1,map(int,input().split()))
    ABmap[A].append(H[B])
    ABmap[B].append(H[A])
        
for i in range(N):
    #print(ABmap[i])
    #print(ABmap.count(H[i]))
    if max(ABmap[i])<H[i]:
        count+=1
print(count)
        
    

Fixed code:
N,M = map(int,input().split())
H=list(map(int,input().split()))
ABmap=[[] for i in range(N)]
count=0
for i in range(M):
    A,B=map(lambda x:x-1,map(int,input().split()))
    ABmap[A].append(H[B])
    ABmap[B].append(H[A])
        
for i in range(N):
    if len(ABmap[i])==0:
        count+=1
    elif max(ABmap[i])<H[i]:
        count+=1
   # print(ABmap[i])
print(count)
Buggy code:
n,m = map(int,input().split())
H = list(map(int,input().split()))
p = [0]*n
for i in range(m):
    a,b = map(int,input().split())
    if H[a-1] >= H[b-1]:
        H[b-1] = -1
    if H[a-1] <= H[b-1]:
        H[a-1] = -1
print(p.count(0))


Fixed code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
p = [0]*n
for i in range(m):
    a,b = map(int,input().split())
    if h[a-1] >= h[b-1]:
        p[b-1] = -1
    if h[a-1] <= h[b-1]:
        p[a-1] = -1
print(p.count(0))
Buggy code:
N , M = map(int,input().split())
h = list(map(int, input().split()))
graph = [[] for _ in range(N)]
for _ in range(M):
    a , b = map(int,input().split())
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)
ans=0

for index,i in enumerate(graph):
    judge=1
    for j in i:
        if h[index] < h[j]:
            judge=0
            break
    if judge==1:
        ans+=1
print(ans)
    

Fixed code:
N , M = map(int,input().split())
h = list(map(int, input().split()))
graph = [[] for _ in range(N)]
for _ in range(M):
    a , b = map(int,input().split())
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)
ans=0
 
for index,i in enumerate(graph):
    judge=1
    for j in i:
        if h[index] <= h[j]:
            judge=0
            break
    if judge==1:
        ans+=1
print(ans)
Buggy code:
#C
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]
# print(ab)
t=[0]*n
for i in ab:
    if h[i[0] - 1] > h[i[1] - 1]:
        t[i[1] - 1] = -1
    elif h[i[0] - 1] < h[i[1] - 1]:
        t[i[0] - 1] = -1
# print(t)
count=0
for i in t:
    if i == 0:
        count += 1
print(count)

Fixed code:
#C
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]
# print(ab)
t=[0]*n
for i in ab:
    # print(i)
    if h[i[0] - 1] > h[i[1] - 1]:
        t[i[1] - 1] = -1
    elif h[i[0] - 1] < h[i[1] - 1]:
        t[i[0] - 1] = -1
    elif h[i[0] - 1] == h[i[1] - 1]:
        t[i[0] - 1] = t[i[1] - 1] = -1
# print(t)
count=0
for i in t:
    if i == 0:
        count += 1
print(count)
Buggy code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
H = set(range(n))
print(h)
for i in range(m):
    a,b = map(int,input().split())
    if h[a-1] <= h[b-1]:
        H.discard(a-1)
    if h[a-1] >= h[b-1]:
        H.discard(b-1)

print(len(H))

Fixed code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
H = set(range(n))
for i in range(m):
    a,b = map(int,input().split())
    if h[a-1] <= h[b-1]:
        H.discard(a-1)
    if h[a-1] >= h[b-1]:
        H.discard(b-1)

print(len(H))
Buggy code:
import numpy as np

N,M = [int(i) for i in input().split(" ")]
H = [int(i) for i in input().split(" ")]
mh = np.zeros([N])
for i in range(M):
    a,b = [int(i)-1 for i in input().split(" ")]
    mh[a] = max(mh[a],h[b])
    mh[b] = max(mh[b],h[a])

ans = 0
for i in range(N):
    if mh[i] < h[i]:
        ans += 1

print(ans)

Fixed code:
import numpy as np

N,M = [int(i) for i in input().split(" ")]
H = [int(i) for i in input().split(" ")]
mh = np.zeros([N])
for i in range(M):
    a,b = [int(i)-1 for i in input().split(" ")]
    mh[a] = max(mh[a],H[b])
    mh[b] = max(mh[b],H[a])

ans = 0
for i in range(N):
    if mh[i] < H[i]:
        ans += 1

print(ans)
Buggy code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
a = [0] * m
b = [0] * m
for i in range(m):
    a[i], b[i] = map(int, input().split())

cnt = 0

lose_flag = [0] * n
for j in range(m):
    if h[a[j]-1] < h[b[j]-1]:
        lose_flag[a[j]-1] = 1
    elif h[a[j]-1] > h[b[j]-1]:
        lose_flag[b[j]-1] = 1
    elif h[a[j]-1] == h[b[j]-1]:
        lose_flag[a[j]-1] = 1
        lose_flag[b[j]-1] = 1

cnt += lose_flag.count(0)
print(lose_flag)
print(cnt)

Fixed code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
a = [0] * m
b = [0] * m
for i in range(m):
    a[i], b[i] = map(int, input().split())

cnt = 0

lose_flag = [0] * n
for j in range(m):
    if h[a[j]-1] < h[b[j]-1]:
        lose_flag[a[j]-1] = 1
    elif h[a[j]-1] > h[b[j]-1]:
        lose_flag[b[j]-1] = 1
    elif h[a[j]-1] == h[b[j]-1]:
        lose_flag[a[j]-1] = 1
        lose_flag[b[j]-1] = 1

cnt += lose_flag.count(0)

print(cnt)
Buggy code:
n,m=map(int,input().split())
h=list(map(int,input().split()))
for i in range(m):
  a,b=map(int,input().split())
  if h[a-1]>h[b-1]:
    h[b-1]=0
  elif h[a-1]<h[b-1]:
    h[a-1]=0
print(n-h.count(0))


Fixed code:
n,m=map(int,input().split())
h=list(map(int,input().split()))
x=[i for i in range(1,n+1)]
for i in range(m):
  a,b=map(int,input().split())
  if h[a-1]>h[b-1]:
    x[b-1]=0
  elif h[a-1]<h[b-1]:
    x[a-1]=0
  else:
    x[a-1]=0
    x[b-1]=0
print(n-x.count(0))
Buggy code:
N, M = map(int, input().split())
l = input().split()
n = list()
H = list()
for i in range(N):
  H.append(int(l[i]))
  n.append(int(l[i]))
for i in range(M):
  Ai, Bi = map(int,input().split())
  if H[Ai-1] > H[Bi-1]:
    n[Bi-1] = 0
  else:
    n[Ai-1] = 0
r = 0
for i in range(N):
  if n[i] != 0:
    r += 1
print(r)

Fixed code:
N, M = map(int, input().split())
l = input().split()
n = list()
H = list()
for i in range(N):
  H.append(int(l[i]))
  n.append(int(l[i]))
for i in range(M):
  Ai, Bi = map(int,input().split())
  if H[Ai-1] > H[Bi-1]:
    n[Bi-1] = 0
  elif H[Ai-1] < H[Bi-1]:
    n[Ai-1] = 0
  else:
    n[Bi-1] = 0
    n[Ai-1] = 0
r = 0
for i in range(N):
  if n[i] != 0:
    r += 1
print(r)
Buggy code:
N,M = map(int, input().split())

goodObservatory = [1]*N
H = []
H = input()

for i in range(M):
	A,B = map(int, input().split())
	if H[A-1] > H[B-1]:
		goodObservatory[B-1] = 0
	elif H[A-1] < H[B-1]:
		goodObservatory[A-1] = 0
	elif H[A-1] == H[B-1]:
		goodObservatory[A-1] = 0
		goodObservatory[B-1] = 0

print(sum(goodObservatory))

Fixed code:
N,M = map(int, input().split())

goodObservatory = [1]*N

H = list(map(int, input().split()))

for i in range(M):
	A,B = map(int, input().split())
	if H[A-1] > H[B-1]:
		goodObservatory[B-1] = 0
	elif H[A-1] < H[B-1]:
		goodObservatory[A-1] = 0
	elif H[A-1] == H[B-1]:
		goodObservatory[A-1] = 0
		goodObservatory[B-1] = 0

print(sum(goodObservatory))
Buggy code:
import sys
import math
import itertools
n,m=map(int,input().split())
h = list(map(int, input().split()))
ans=[True]*n
lis = [] * n
for i in range(len(h)):
    lis.append(h[i])
print(lis)
for i in range(m):
    a, b = map(int, input().split())
    lis[a - 1] = max(lis[a - 1], lis[b-1])
    lis[b - 1] = max(lis[b - 1], lis[a - 1])
    lis[a - 1] = max(lis[a - 1], lis[b-1])
ans = 0
print(lis)
for i in range(n):
    if (lis[i] != h[i]):
        ans += 1
print(ans)

Fixed code:
import sys
import math
import itertools

n, m = map(int, input().split())
h = list(map(int, input().split()))
ans = [True] * n
lis = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    lis[a - 1] = max(lis[a - 1], h[b - 1])
    lis[b - 1] = max(lis[b - 1], h[a - 1])
ans = 0
for i in range(n):
    if lis[i] < h [i]:
        ans += 1
print(ans)
Buggy code:
import sys
import math

n, m = map(int, input().split())
h = list(map(int, input().split()))
bli = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    bli[a - 1] = max(h[a - 1],max(bli[a-1],h[b - 1]))
    bli[b - 1] = max(h[b - 1],max(bli[b-1] ,h[a - 1]))
cnt = 0
for i in range(n):
    if h[i] >= bli[i]:
        cnt += 1
print(cnt)


Fixed code:
import sys
import math

n, m = map(int, input().split())
h = list(map(int, input().split()))
ma = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    ma[a - 1] = max(ma[a-1],h[b - 1])
    ma[b - 1] = max(ma[b-1] ,h[a - 1])
cnt = 0
for i in range(n):
    if h[i] > ma[i]:
        cnt += 1
print(cnt)
Buggy code:
def main():
    n, m = [int(x) for x in input().split()]
    heights = tuple(int(x) for x in input().split())
    adjacents_heights = [set() for _ in range(n)]
    print(heights)
    for i in range(m):
        a, b = [int(x) - 1 for x in input().split()]
        adjacents_heights[a].add(heights[b])
        adjacents_heights[b].add(heights[a])
    ans = 0
    print(adjacents_heights)
    for h, ahs in zip(heights, adjacents_heights):
        if not ahs:
            ans += 1
            continue
        elif h > max(ahs):
            ans += 1

    return ans


if __name__ == '__main__':
    print(main())


Fixed code:
def main():
    n, m = [int(x) for x in input().split()]
    heights = tuple(int(x) for x in input().split())
    adjacents_heights = [set() for _ in range(n)]
    for i in range(m):
        a, b = [int(x) - 1 for x in input().split()]
        adjacents_heights[a].add(heights[b])
        adjacents_heights[b].add(heights[a])
    ans = 0
    for h, ahs in zip(heights, adjacents_heights):
        if not ahs:
            ans += 1
            continue
        elif h > max(ahs):
            ans += 1

    return ans


if __name__ == '__main__':
    print(main())
Buggy code:
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
h = list(map(int, input().split()))
h_cond = [True]*n
count = 0

for i in range(m):
    tmp_a, tmp_b = map(int, input().split())
    if h[tmp_a-1] < h[tmp_b-1]:
        h_cond[tmp_a-1] = False
    elif h[tmp_a-1] > h[tmp_b-1]:
        h_cond[tmp_b-1] = False
    else:
        h_cond[tmp_a - 1] = False
        h_cond[tmp_b - 1] = False

# print(h_cond)
# print(route)
for idx, hi in enumerate(route):
    if h_cond[idx]:
        count += 1

print(count)


Fixed code:
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
h = list(map(int, input().split()))
h_cond = [True]*n
count = 0

for i in range(m):
    tmp_a, tmp_b = map(int, input().split())
    if h[tmp_a-1] < h[tmp_b-1]:
        h_cond[tmp_a-1] = False
    elif h[tmp_a-1] > h[tmp_b-1]:
        h_cond[tmp_b-1] = False
    else:
        h_cond[tmp_a - 1] = False
        h_cond[tmp_b - 1] = False

# print(h_cond)
# print(route)
for idx, hi in enumerate(h_cond):
    if h_cond[idx]:
        count += 1

print(count)
Buggy code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
pairs = [list(map(int, input().split())) for _ in range(m)]

ans = [1] * n

for i in range(m):
    if h[pairs[i][0] - 1] < h[pairs[i][1] - 1]:
        ans[pairs[i][0] - 1] = 0
        ans[pairs[i][1] - 1] = 1
    else:
        ans[pairs[i][0] - 1] = 1
        ans[pairs[i][1] - 1] = 0      

print(sum(ans))

Fixed code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
pairs = [list(map(int, input().split())) for _ in range(m)]

ans = [1] * n

for i in range(m):
    if h[pairs[i][0] - 1] < h[pairs[i][1] - 1]:
        ans[pairs[i][0] - 1] = 0
    elif h[pairs[i][0] - 1] == h[pairs[i][1] - 1]:
        ans[pairs[i][0] - 1] = 0
        ans[pairs[i][1] - 1] = 0 
    else:
        ans[pairs[i][1] - 1] = 0      

print(sum(ans))
Buggy code:
#!/usr/bin/env python3

from typing import Iterable


def main() -> None:
    N, M = rmi()
    H = rmi()
    A, B = [], []
    for m in range(M):
        a, b = rmi()
        A.append(a)
        B.append(b)
    cand = set(range(1, N + 1))
    for m in range(M):
        a, b = A[m], B[m]
        ha, hb = H[a - 1], H[b - 1]
        if ha == hb:
            continue
        lower = a if H[a - 1] < H[b - 1] else b
        if lower in cand:
            cand.remove(lower)
    w(len(cand))


def r() -> str:
    return input().strip()


def ri() -> int:
    return int(r())


def rmi(delim: str = ' ') -> int:
    return tuple(map(int, input().split(delim)))


def w(data) -> None:
    print(data)


def wm(data: Iterable) -> None:
    print(' '.join(data))


if __name__ == '__main__':
    main()


Fixed code:
#!/usr/bin/env python3

from typing import Iterable


def main() -> None:
    N, M = rmi()
    H = rmi()
    A, B = [], []
    for m in range(M):
        a, b = rmi()
        A.append(a)
        B.append(b)
    cand = set(range(1, N + 1))
    for m in range(M):
        a, b = A[m], B[m]
        ha, hb = H[a - 1], H[b - 1]
        if ha == hb:
            if a in cand:
                cand.remove(a)
            if b in cand:
                cand.remove(b)
        else:
            lower = a if ha < hb else b
            if lower in cand:
                cand.remove(lower)
    w(len(cand))


def r() -> str:
    return input().strip()


def ri() -> int:
    return int(r())


def rmi(delim: str = ' ') -> int:
    return tuple(map(int, input().split(delim)))


def w(data) -> None:
    print(data)


def wm(data: Iterable) -> None:
    print(' '.join(data))


if __name__ == '__main__':
    main()
Buggy code:
N, M = map(int, input().split())
H = [int(x) for x in input().split()]
AB = [[int(x) for x in input().split()] for _ in range(M)]

li = [0] + [-1] * N
for a, b in AB:
    ma = max(H[a-1], H[b-1])
    if ma==H[a-1]:
        li[b]=-4
#     elif ma==H[b-1]:
#         li[a]=-4
    else:
        li[a]=-4
        li[b]=-4

#     if H[a-1]>H[b-1]:
#         li[b]=-4
#     elif H[b-1]>H[a-1]:
#         li[a]=-4
#     else:
#         li[a] = li[b] = -4

cnt=0

for i in range(N+1):
    if i==0:
        continue
    if li[i]==-4:
        cnt+=1
print(N-cnt)

Fixed code:
N, M = map(int, input().split())
H = [int(x) for x in input().split()]
AB = [[int(x) for x in input().split()] for _ in range(M)]

li = [0] + [-1] * N
for a, b in AB:
#     ma = max(H[a-1], H[b-1])
#     if ma==H[a-1]:
#         li[b]=-4
#     elif H[a-1]==H[b-1]:
#         li[a]=-4
#         li[b]=-4
#     else:
#         li[a]=-4
#     print(li)

    if H[a-1]>H[b-1]:
        li[b]=-4
    elif H[b-1]>H[a-1]:
        li[a]=-4
    else:
        li[a] = li[b] = -4

cnt=0

for i in range(N+1):
    if i==0:
        continue
    if li[i]==-4:
        cnt+=1
print(N-cnt)
Buggy code:
N, M = map(int, input().split())
H = list(map(int, input().split()))

r = [1] * len(H)
a = []
for i in range(M):
    A, B = map(int, input().split())
    if H[A - 1] > H[B - 1]:
        r[B - 1] = 0
    if H[B - 1] > H[A - 1]:
        r[A - 1] = 0

print(r.count(1))


Fixed code:
N, M = map(int, input().split())
H = list(map(int, input().split()))

r = [1] * len(H)
a = []
for i in range(M):
    A, B = map(int, input().split())
    if H[A - 1] >= H[B - 1]:
        r[B - 1] = 0
    if H[B - 1] >= H[A - 1]:
        r[A - 1] = 0

print(r.count(1))
Buggy code:
N,M = list(map(int,input().split()))
higher = list(map(int,input().split()))
safety = [0] * (N+1)
for i in range(M):
    B = list(map(int,input().split()))
    if higher[B[0]-1] > higher[B[1]-1]:
        safety[B[1]] = 1
    else:
        safety[B[0]] = 1
print(sum(safety))

Fixed code:
N,M = list(map(int,input().split()))
higher = list(map(int,input().split()))
safety = [0] * (N)
for i in range(M):
    B = list(map(int,input().split()))
    if higher[B[0]-1] > higher[B[1]-1]:
        safety[B[1]-1] = 1
    elif higher[B[1]-1] > higher[B[0]-1]:
        safety[B[0]-1] = 1
    elif higher[B[1]-1] == higher[B[0]-1]:
        safety[B[0]-1] = 1
        safety[B[1]-1] = 1
print(N-sum(safety))
Buggy code:
N,M=map(int,input().split())
high_list=list(map(int,input().split()))
highest=[True]*N
for i in range(M):
    a,b=map(int,input().split()))
    if(high_list[a-1]>=high_list[b-1]):
        highest[b-1]=False
    if(high_list[a-1]<=high_list[b-1]):
        highest[a-1]=False
print(sum(highest))




Fixed code:
N,M=map(int,input().split())
high_list=list(map(int,input().split()))
highest=[True]*N
for i in range(M):
    a,b=map(int,input().split())
    if(high_list[a-1]>=high_list[b-1]):
        highest[b-1]=False
    if(high_list[a-1]<=high_list[b-1]):
        highest[a-1]=False
print(sum(highest))
Buggy code:
N, M = map(int, input().split())
H = [int(h) for h in input().split()]
AB = []
for i in range(M):
    A, B = map(int, input().split())
    AB.append([A,B])

H01 = [1]*N
for i in range(M):
    A,B = AB[i]
    if(H[A-1]<H[B-1]):
        H01[A-1] = 0
        H01[B-1] = 1
    else:
        H01[A-1] = 1
        H01[B-1] = 0
print(sum(H01))

Fixed code:
N, M = map(int, input().split())
H = [int(h) for h in input().split()]
AB = []
for i in range(M):
    A, B = map(int, input().split())
    AB.append([A,B])

H01 = [1]*N
for i in range(M):
    A,B = AB[i]
    if(H[A-1]<H[B-1]):
        H01[A-1] = 0
        if(H01[B-1]!=0):
            H01[B-1] = 1
    elif(H[A-1]==H[B-1]):
        H01[A-1] = 0
        H01[B-1] = 0
    else:
        if(H01[A-1]!=0):
            H01[A-1] = 1
        H01[B-1] = 0
print(sum(H01))
Buggy code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
Height = []
Good = []
for i in range(N):
    Height.append(H[i])
    Good.append(0)
for i in range(M):
    A, B = map(int, input().split())
    if Height[A - 1] < Height[B - 1]:
        Good[A - 1] = 1
    if Height[A - 1] > Height[B - 1]:
        Good[B - 1] = 1
    else:
        Good[A - 1] = 1
        Good[B - 1] = 1
n = 0
for i in range(N):
    if Good[i] == 0:
        n += 1
print(n)

Fixed code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
Height = []
Good = []
for i in range(N):
    Height.append(H[i])
    Good.append(0)
for i in range(M):
    A, B = map(int, input().split())
    if Height[A - 1] < Height[B - 1]:
        Good[A - 1] = 1
    elif Height[A - 1] > Height[B - 1]:
        Good[B - 1] = 1
    else:
        Good[A - 1] = 1
        Good[B - 1] = 1
n = 0
for i in range(N):
    if Good[i] == 0:
        n += 1
print(n)
Buggy code:
N, M = map(int,input().split())
good = [0]*N

H = list(map(int,input().split()))

for j in range(M):
  a, b = map(int,input().split())
  if(H[a-1] == H[b-1]):
    good[a-1] += 1
    good[b-1] += 1
  elif(H[a-1] < H[b-1]):
    good[a-1] += 1
  elif(H[b-1] < H[a-1]:
    good[b-1] += 1
count = 0
for i in range(N):
  if(good[i] == 0):
    count += 1
print(count)

Fixed code:
N, M = map(int,input().split())
good = [0]*N

H = list(map(int,input().split()))

for j in range(M):
  a, b = map(int,input().split())
  if(H[a-1] == H[b-1]):
    good[a-1] += 1
    good[b-1] += 1
  elif(H[a-1] < H[b-1]):
    good[a-1] += 1
  else:
    good[b-1] += 1
count = 0
for i in range(N):
  if(good[i] == 0):
    count += 1
print(count)
Buggy code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
x = [1]*n
for i in range(m):
    a,b = map(int,input().split())
    if h[a-1]>h[b-1]:
        x[b-1] = 0
    elif h[a-1]<h[b-1]:
        x[a-1] = 0
    else:
        next
print(x.count(1))



Fixed code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
x = [1]*n
for i in range(m):
    a,b = map(int,input().split())
    if h[a-1]>h[b-1]:
        x[b-1] = 0
    elif h[a-1]<h[b-1]:
        x[a-1] = 0
    else:
        x[a-1] = 0
        x[b-1] = 0
print(x.count(1))
Buggy code:
# -*- coding: utf-8 -*-

n, m = list(map(int, input().split()))
h = list(map(int, input().split()))
to = [[] for i in range(n)]

for i in range(m):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    print(a, b)
    to[a].append(b)
    to[b].append(a)

ans = 0

for i in range(n):
    ok = True
    for j in to[i]:
        if(h[i] <= h[j]):
            ok = False
    if(ok):
        ans += 1

print(ans)


Fixed code:
# -*- coding: utf-8 -*-

n, m = list(map(int, input().split()))
h = list(map(int, input().split()))
to = [[] for i in range(n)]

for i in range(m):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    to[a].append(b)
    to[b].append(a)

ans = 0

for i in range(n):
    ok = True
    for j in to[i]:
        if(h[i] <= h[j]):
            ok = False
    if(ok):
        ans += 1

print(ans)
Buggy code:
n,m=map(int,input().split())
h=list(map(int,input().split()))
a = [0] * m
b = [0] * m
l=[0]*n
count=0
for i in range(m):
    a[i], b[i]=map(int, input().split())
    l[a-1]=max(l[a-1],h[b-1])
    l[b-1]=max(l[b-1],h[a-1])
for i in range(n):
    if h[i]>l[i]:
        count=count+1
print(count)

Fixed code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
l = [0]*n
 
for i in range(m):
    a, b = map(int, input().split())
    l[a-1] = max(l[a-1], h[b-1])
    l[b-1] = max(l[b-1], h[a-1])
 
count = 0
for i in range(n):
    if h[i] > l[i]:
        count += 1
 
print(count)