qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
load_list = []
for m in range(M):
    A, B = map(int, input().split())
    load_list.append((A, B))

highest_list = []
for i in range(N):
    highest_list.append(1)

for m in range(M):
    if H[load_list[m][0] - 1] > H[load_list[m][1] - 1]:
        highest_list[load_list[m][1] - 1] = 0
    elif H[load_list[m][1] - 1] > H[load_list[m][0] - 1]:
        highest_list[load_list[m][0] - 1] = 0

print(highest_list.count(1))

Fixed code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
load_list = []
for m in range(M):
    A, B = map(int, input().split())
    load_list.append((A, B))

highest_list = []
for i in range(N):
    highest_list.append(1)

for m in range(M):
    if H[load_list[m][0] - 1] > H[load_list[m][1] - 1]:
        highest_list[load_list[m][1] - 1] = 0
    elif H[load_list[m][1] - 1] > H[load_list[m][0] - 1]:
        highest_list[load_list[m][0] - 1] = 0
    else:
        highest_list[load_list[m][0] - 1] = 0
        highest_list[load_list[m][1] - 1] = 0

print(highest_list.count(1))
Buggy code:
N,M=map(int,input().split())
H=list(map(int,input().split()))
l=[]

for i in range(M):
    l.append(list(map(int,input().split())))
    
ll=[0]*N

for j in l:
    if H[j[0]-1]-H[j[1]-1]>0:
        ll[j[1]-1]+=1
    elif H[j[0]-1]-H[j[1]-1]<0:    
        ll[j[0]-1]+=1
    else:
        continue
        
ans=0
for x in ll:
    if x==0:
        ans+=1

print(ans)

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

for i in range(M):
    l.append(list(map(int,input().split())))
    
ll=[0]*N

for j in l:
    if H[j[0]-1]-H[j[1]-1]>0:
        ll[j[1]-1]+=1
    elif H[j[0]-1]-H[j[1]-1]<0:    
        ll[j[0]-1]+=1
    else:
        ll[j[0]-1]+=1
        ll[j[1]-1]+=1
ans=0
for x in ll:
    if x==0:
        ans+=1

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

Fixed code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
g = [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    g[a].append(h[b])
    g[b].append(h[a])
ans = 0
for i in range(n):
    if len(g[i]) == 0:
        ans +=1
        continue
      
    if h[i] > max(g[i]):ans += 1
print(ans)
Buggy code:
n, m = map(int, input().split())
hs = list(map(int, input().split()))

edge = [[] for _ in range(n)]

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

print(edge)
cnt = 0

for node in range(n):
    good = True
    for neighbor in edge[node]:
        if hs[node] <= hs[neighbor]:
            good = False
    if good:
        cnt +=1

print(cnt)

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

edge = [[] for _ in range(n)]

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


cnt = 0

for node in range(n):
    good = True
    for neighbor in edge[node]:
        if hs[node] <= hs[neighbor]:
            good = False
    if good:
        cnt +=1

print(cnt)
Buggy code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
C = [1]*(N)
for i in range(M):
  a, b = map(int, input().split())
  if H[a-1] >= H[b-1]:
    H[b-1] = 0
  if H[b-1] >= H[a-1]:
    H[a-1] = 0
print(sum(C))

Fixed code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
C = [1]*(N)
for i in range(M):
  a, b = map(int, input().split())
  if H[a-1] >= H[b-1]:
    C[b-1] = 0
  if H[b-1] >= H[a-1]:
    C[a-1] = 0
print(sum(C))
Buggy code:
n,m = map(int, input().split())
h = list(map(int, input().split()))
path = [list(map(int, input().split())) for i in range(m)]

ans = [[i] for i in h]

for i in path:
    ans[i[0]-1].append(h[i[1]-1])
    ans[i[1]-1].append(h[i[0]-1])

count = 0
for i in ans:
    if i[0] == max(i):
        count += 1

print(count)


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

ans = [[i] for i in h]

for i in path:
    ans[i[0]-1].append(h[i[1]-1])
    ans[i[1]-1].append(h[i[0]-1])


count = 0
for i in ans:
    if len(i)==1:
      count += 1
    elif i[0] == max(i) and i.count(i[0])==1:
      count +=1
print(count)
Buggy code:
N,M=map(int,input().split(' '))
H=list(map(int,input().split(' ')))

data=[]
for n1 in range(N):
  data.append([])
  for n2 in range(N):
    data[n1].append(0)
    
for m in M:
  a,b=map(int,input().split(' '))
  data[a-1][b-1]=H[b-1]
  data[b-1][a-1]=H[a-1]
ans=0
for n in N:
  if H[n-1]>max(data[n-1]):
    ans+=1
print(ans)

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

data=[]
for n in range(N):
  data.append(H[n]-1)
    
for m in range(M):
  a,b=map(int,input().split(' '))
  data[a-1]=max(data[a-1],H[b-1])
  data[b-1]=max(data[b-1],H[a-1])
  
ans=0
for n in range(N):
  if H[n-1]-1==data[n-1]:
    ans+=1
print(ans)
Buggy code:
N, M = map(int, input().split())
H = [int(x) for x in input().split()]
A = [0] * M
B = [0] * M
F = [0] * N
for i in range(M):
    A[i], B[i] = map(int, input().split())
    F[A[i] - 1] = max(F[A[i] - 1], H[B[i] - 1])
    F[B[i] - 1] = max(F[B[i] - 1], H[A[i] - 1])

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

print(ans)


Fixed code:
N, M = map(int, input().split())
H = [int(x) for x in input().split()]
A = [0] * M
B = [0] * M
F = [0] * N
for i in range(M):
    A[i], B[i] = map(int, input().split())
    F[A[i] - 1] = max(F[A[i] - 1], H[B[i] - 1])
    F[B[i] - 1] = max(F[B[i] - 1], H[A[i] - 1])

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

print(ans)
Buggy code:
import sys
import collections
import itertools
import numpy as np

n,m = map(int, input().split())
al = np.ones(n,dtype="int8")
H = list(map(int, input().split()))
AB=[]

for i in range(m):
    AB.append(tuple(map(int, input().split())))

for t in range(m):
    A = AB[t][0]
    B = AB[t][1]

    bou1 = H[A-1]
    bou2 = H[B-1]
    if bou1<bou2:
        al[B-1] = al[B-1]-1
    elif bou2<bou1:
        al[A-1] = al[a-1]-1
    else:
        al[A-1] = al[a-1]-1
        al[B-1] = al[B-1]-1
print(np.count_nonzero(al>0))

Fixed code:
import sys
import collections
import itertools
import numpy as np

n,m = map(int, input().split())
al = np.ones(n,dtype="int8")
H = list(map(int, input().split()))
AB=[]

for i in range(m):
    AB.append(tuple(map(int, input().split())))

for t in range(m):
    A = AB[t][0]
    B = AB[t][1]
	
    bou1 = H[A-1]
    bou2 = H[B-1]
    if bou1<bou2:
        al[A-1] = al[A-1]-1
    elif bou2<bou1:
        al[B-1] = al[B-1]-1
    else:
        al[A-1] = al[A-1]-1
        al[B-1] = al[B-1]-1
print(np.count_nonzero(al==1))
Buggy code:
N,M =  map( int ,input().split())
H = list(map( int , input().split()))
A_B = [[0] * 2  for i in range(M)]
J = [0]*N
for i in range(M):
    A,B = map( int ,input().split())
    A_B[i][0] = A
    A_B[i][1] = B
for j in range(M):
    if H[A_B[j][0]-1] > H[A_B[j][1]-1]:
        if J[A_B[j][0]-1] != -1:
            J[A_B[j][0]-1] = 1
        J[A_B[j][1]-1] =-1
    elif H[A_B[j][0]-1] < H[A_B[j][1]-1]:
        if J[A_B[j][0]-1] != -1:
            J[A_B[j][0]-1] = 1
        J[A_B[j][1]-1] = 1
    else:
        J[A_B[j][0]-1] =-1
        J[A_B[j][1]-1] =-1
for l in range(N):
    if J[l] == 0:
        J[l] = 1
print(J.count(1))

Fixed code:
N,M =  map( int ,input().split())
H = list(map( int , input().split()))
A_B = [[0] * 2  for i in range(M)]
J = [0]*N
for i in range(M):
    A,B = map( int ,input().split())
    A_B[i][0] = A
    A_B[i][1] = B
for j in range(M):
    if H[A_B[j][0]-1] > H[A_B[j][1]-1]:
        if J[A_B[j][0]-1] != -1:
            J[A_B[j][0]-1] = 1
        J[A_B[j][1]-1] =-1
    elif H[A_B[j][0]-1] < H[A_B[j][1]-1]:
        J[A_B[j][0]-1] =-1
        if J[A_B[j][1]-1] != -1:
            J[A_B[j][1]-1] = 1
    else:
        J[A_B[j][0]-1] =-1
        J[A_B[j][1]-1] =-1
for l in range(N):
    if J[l] == 0:
        J[l] = 1
print(J.count(1))
Buggy code:
N,M =  map( int ,input().split())
H_list = list(map( int , input().split()))
A_B_list = [[0] * 2  for i in range(M)]
J_list = [0]*N
for i in range(M):
    A,B = map( int ,input().split())
    A_B_list[i][0] = A
    A_B_list[i][1] = B
for j in range(M):
    if H_list[A_B_list[j][0]-1] >= H_list[A_B_list[j][1]-1]:
        J_list[A_B_list[j][0]-1] = 1
        J_list[A_B_list[j][1]-1] =-1
    # elif H_list[A_B_list[j][0]-1] < H_list[A_B_list[j][1]-1]:
    else:
        J_list[A_B_list[j][0]-1] =-1
        J_list[A_B_list[j][1]-1] = 1
    # else:
    #     J_list[A_B_list[j][0]-1] =-1
    #     J_list[A_B_list[j][1]-1] =-1
for l in range(N):
    if J_list[l] == 0:
        J_list[l] = 1
print(J_list.count(1))
        
    

Fixed code:
N,M =  map( int ,input().split())
H_list = list(map( int , input().split()))
A_B_list = [[0] * 2  for i in range(M)]
J_list = [0]*N
for i in range(M):
    A,B = map( int ,input().split())
    A_B_list[i][0] = A
    A_B_list[i][1] = B
for j in range(M):
    if H_list[A_B_list[j][0]-1] > H_list[A_B_list[j][1]-1]:
        J_list[A_B_list[j][1]-1] =-1
    elif H_list[A_B_list[j][0]-1] < H_list[A_B_list[j][1]-1]:
        J_list[A_B_list[j][0]-1] =-1
    else:
        J_list[A_B_list[j][0]-1] =-1
        J_list[A_B_list[j][1]-1] =-1
print(J_list.count(0))
Buggy code:
import sys
def input():
  return list(map(int, sys.stdin.readline().strip().split()))

n, m = input()
h = input()
tmp = [[] for i in range(n)]
for i in range(m):
  a, b = input()
  tmp[b - 1].append(a - 1)
  tmp[a - 1].append(b - 1)
ans = 0
for i in range(n):
  flag = True
  for ele in tmp[i]:
    if(h[i] <= h[ele]):
  		flag = False
  if(flag): ans += 1
print(ans)

Fixed code:
import sys
def input():
  return list(map(int, sys.stdin.readline().strip().split()))

n, m = input()
h = input()
tmp = [[] for i in range(n)]
for i in range(m):
  a, b = input()
  tmp[b - 1].append(a - 1)
  tmp[a - 1].append(b - 1)
ans = 0
for i in range(n):
  flag = True
  for ele in tmp[i]:
    if(h[i] <= h[ele]): flag = False
  if(flag): ans += 1
print(ans)
Buggy code:
N,M = map(int, input().split())
print(M)
Hs = list(map(int, input().split()))
i = 0
ABs = []
while True:
  if M <= i:
    break
  ABs.append(list(map(int, input().split())))
  i += 1
r = [0] * N

for A, B in ABs:
  if Hs[A-1] <= Hs[B-1]:
    r[A-1] = -1
  if Hs[B-1] <= Hs[A-1]:
    r[B-1] = -1

print(r.count(0))


Fixed code:
N,M = map(int, input().split())
Hs = list(map(int, input().split()))
i = 0
ABs = []
while True:
  if M <= i:
    break
  ABs.append(list(map(int, input().split())))
  i += 1
r = [0] * N

for A, B in ABs:
  if Hs[A-1] <= Hs[B-1]:
    r[A-1] = -1

  if Hs[B-1] <= Hs[A-1]:
    r[B-1] = -1

print(r.count(0))
Buggy 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())
  if h[A-1] > h[B-1]:
    l[B - 1] = 0
  elif H[A - 1] < H[B - 1]:
    l[A - 1] = 0
  elif H[A - 1] == H[B - 1]:
    l[A - 1], l[B - 1] = 0, 0
print(l.count(1))

Fixed code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
l = [1] * N
for i in range(M):
    A, B = map(int, input().split())
    if H[A - 1] > H[B - 1]:
        l[B - 1] = 0
    elif H[A - 1] < H[B - 1]:
        l[A - 1] = 0
    elif H[A - 1] == H[B - 1]:
        l[A - 1], l[B - 1] = 0, 0
print(l.count(1))
Buggy code:
n, m = map(int,input().split())
h_list = list(map(int, input().split()))
good_list = [1 for i in range(n)]
for i in range(m):
  _a,_b = map(int, input().split())
  if h_list[_a-1] == h_list[_b-1]:
    pass
  elif h_list[_a-1] > h_list[_b-1]:
    good_list[_b-1] = 0
  else:
    good_list[_a-1] = 0
print(sum(good_list))

Fixed code:
n, m = map(int,input().split())
h_list = list(map(int, input().split()))
good_list = [1 for i in range(n)]
for i in range(m):
  _a,_b = map(int, input().split())
  if h_list[_a-1] == h_list[_b-1]:
    good_list[_a-1] = 0
    good_list[_b-1] = 0
  elif h_list[_a-1] > h_list[_b-1]:
    good_list[_b-1] = 0
  else:
    good_list[_a-1] = 0
print(sum(good_list))
Buggy code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
for _ in range(M):
    A, B = map(int, input().split())
    A, B = A-1, B-1
    if H[A] > H[B]:
        H[B] = 0
        
    elif H[B] > H[A]:
        H[A] = 0
        
    else:
        H[A], H[B] = 0, 0

count = 0
for i in range(N):
    if H[i] != 0:
        count+= 1

print(count)


Fixed code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
H_val = [H[i] for i in range(N)]
for _ in range(M):
    A, B = map(int, input().split())
    A, B = A-1, B-1
    if H[A] > H[B]:
        H_val[B] = 0
        
    elif H[B] > H[A]:
        H_val[A] = 0
        
    else:
        H_val[A], H_val[B] = 0, 0

count = 0
for i in range(N):
    if H_val[i] != 0:
        count+= 1

print(count)
Buggy code:
n, m = list(map(int, input().split()))

h = list(map(int, input().split()))
print(h)

yoi_warui = [0]*(n)
dokuritsu = [0]*(n)

for i in range(m):
    a, b = list(map(int, input().split()))
    dokuritsu[a-1] = 1
    dokuritsu[b-1] = 1
    if h[a-1] < h[b-1]:
        yoi_warui[a-1] = 1
    elif h[b-1] < h[a-1]:
        yoi_warui[b-1] = 1

print(yoi_warui.count(0)- dokuritsu.count(0))


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

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

yoi_warui = [0]*n
dokuritsu = [0]*n

for i in range(m):
    a, b = list(map(int, input().split()))
    dokuritsu[a-1] = 1
    dokuritsu[b-1] = 1
    if h[a-1] == h[b-1]:
        yoi_warui[a-1] = 1
        yoi_warui[b-1] = 1
    elif h[a-1] < h[b-1]:
        yoi_warui[a-1] = 1
    elif h[b-1] < h[a-1]:
        yoi_warui[b-1] = 1

print(yoi_warui.count(0))
Buggy code:
n, m = map(int, input().split())
H = list(map(int, input().split()))
X=[[0] for i in range(n)]
for i in range(m):
  a, b = map(int, input().split())
  X[a-1].append(b)
  X[b-1].append(a)
t=0
for i in range(n):
  E=list(H[k-1] for k in X[i])
  if max(E) < H[i]:
    t+=1
print(t)

Fixed code:
n, m = map(int, input().split())
H = list(map(int, input().split()))
X=[[] for i in range(n)]
for i in range(m):
  a, b = map(int, input().split())
  X[a-1].append(b)
  X[b-1].append(a)
t=0
for i in range(n):
  E=[0]+list(H[k-1] for k in X[i])
  if max(E) < H[i]:
    t+=1
print(t)
Buggy code:
word = list(map(int,input().split()))
hyoko = list(map(int,input().split()))
road = [0]*word[1]
for i in range(word[1]):
    road[i] = list(map(int,input().split()))
tenbo = [1]*word[0]

for j in range(word[1]):
    if hyoko[road[j][0]-1] > hyoko[road[j][1]-1]:
        tenbo[road[j][0]-1] *= 1
        tenbo[road[j][1]-1] = 0
    elif hyoko[road[j][0]-1] < hyoko[road[j][1]-1]:
        tenbo[road[j][0]-1] = 0
        tenbo[road[j][1]-1] *= 1
answer = word[0] - tenbo.count(0)
print(answer)

Fixed code:
word = list(map(int,input().split()))
hyoko = list(map(int,input().split()))
road = [0]*word[1]
for i in range(word[1]):
    road[i] = list(map(int,input().split()))
tenbo = [1]*word[0]

for j in range(word[1]):
    if hyoko[road[j][0]-1] > hyoko[road[j][1]-1]:
        tenbo[road[j][0]-1] *= 1
        tenbo[road[j][1]-1] = 0
    elif hyoko[road[j][0]-1] < hyoko[road[j][1]-1]:
        tenbo[road[j][0]-1] = 0
        tenbo[road[j][1]-1] *= 1
    else:
        tenbo[road[j][0]-1] = 0
        tenbo[road[j][1]-1] = 0
answer = word[0] - tenbo.count(0)
print(answer)
Buggy code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
A = []
B = []
for i in range(M):
  a, b = (map(int, input().split()))
  A.append(a)
  B.append(b)

flg = [1] * N
for i in range(M):
  if flg[A[i]-1] == 1 and H[A[i]-1] < H[B[i]-1]:
    flg[A[i]-1] = 0

for i in range(M):
  if flg[B[i]-1] == 1 and H[A[i]-1] > H[B[i]-1]:
    flg[B[i]-1] = 0

print(sum(flg))

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

flg = [1] * N
for i in range(M):
  if flg[A[i]-1] == 1 and H[A[i]-1] <= H[B[i]-1]:
    flg[A[i]-1] = 0

for i in range(M):
  if flg[B[i]-1] == 1 and H[A[i]-1] >= H[B[i]-1]:
    flg[B[i]-1] = 0

print(sum(flg))
Buggy code:
# n,m = map(int,input().split())
h_list = list(map(int,input().split()))
roads = []
for i in range(m):
    a,b = map(int,input().split())
    roads.append([a,b])
#print(roads)
terrace = [1] * n
for road in roads:
    if h_list[road[0]-1] > h_list[road[1]-1]:
        terrace[road[1]-1] = 0
    elif h_list[road[0]-1] == h_list[road[1]-1]:
        terrace[road[0]-1] = 0
        terrace[road[1]-1] = 0
    elif h_list[road[0]-1] < h_list[road[1]-1]:
        terrace[road[0]-1] = 0
print(terrace.count(1))

Fixed code:
n,m = map(int,input().split())
h_list = list(map(int,input().split()))
roads = []
for i in range(m):
    a,b = map(int,input().split())
    roads.append([a,b])
#print(roads)
terrace = [1] * n
for road in roads:
    if h_list[road[0]-1] > h_list[road[1]-1]:
        terrace[road[1]-1] = 0
    elif h_list[road[0]-1] == h_list[road[1]-1]:
        terrace[road[0]-1] = 0
        terrace[road[1]-1] = 0
    elif h_list[road[0]-1] < h_list[road[1]-1]:
        terrace[road[0]-1] = 0
print(terrace.count(1))
Buggy code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
p = [False] + [True]*n
A = []
B = []
for i in range(m):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)

for i in range(m):
    if h[A[i] - 1] > h[B[i] - 1]:
        p[B[i]] = False
    elif h[A[i] - 1] < h[B[i] - 1]:
        p[A[i]] = False
    else:
        p[A[i]] = False
        p[B[i]] = False
    print(p)
ans = [i for i in range(n + 1) if p[i]]

print(len(ans))


Fixed code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
p = [False] + [True]*n
A = []
B = []
for i in range(m):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)

for i in range(m):
    if h[A[i] - 1] > h[B[i] - 1]:
        p[B[i]] = False
    if h[A[i] - 1] < h[B[i] - 1]:
        p[A[i]] = False
    if h[A[i] - 1] == h[B[i] - 1]:
        p[A[i]] = False
        p[B[i]] = False
    
ans = [i for i in range(n + 1) if p[i]]

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

Fixed code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
ans = [1] * n
for i in range(m):
  a,b, = map(int,input().split())
  if h[a-1] >= h[b-1]:
    ans[b-1] =0
  if h[a-1] <= h[b-1]:
    ans[a-1] = 0
print(sum(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())
 

S=[1]*N

 
for m in range(M)
  if H[A[m]-1] == H[B[m]-1]:
    S[A[m]-1] = 0
    S[B[m]-1] = 0
  elif H[A[m]-1] <= H[B[m]-1]:
    S[A[m]-1] = 0
  elif H[A[m]-1] >= H[B[m]-1]
    S[B[m]-1] = 0

 
print(sum(S))   

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())
 
 
S=[1]*N
 
 
for m in range(M):
  if H[A[m]-1] == H[B[m]-1]:
    S[A[m]-1] = 0
    S[B[m]-1] = 0
  elif H[A[m]-1] <= H[B[m]-1]:
    S[A[m]-1] = 0
  elif H[A[m]-1] >= H[B[m]-1]:
    S[B[m]-1] = 0
 
 
print(sum(S))
Buggy code:
n,m=map(int,input().split())
h=list(map(int,input().split()))
ab=[list(map(int,input().split())) for i in range(m)]

ans=[1 for i in range(n)]

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

print(sum(ans))

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

ans=[1 for i in range(n)]

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

print(sum(ans))
Buggy code:
import numpy as np
N, M = map(int, input().split())
H = list(map(int, input().split()))
yoi = np.ones(M)
for i in range(M):
    A, B = map(int, input().split())
    if H[A-1] > H[B-1]:
        yoi[B-1] = 0
    elif H[B-1] > H[A-1]:
        yoi[A-1] = 0
    elif H[A-1]==H[B-1]:
        yoi[A-1] = 0
        yoi[B-1] = 0
print(int(np.sum(yoi)))

Fixed code:
import numpy as np
N, M = map(int, input().split())
H = list(map(int, input().split()))
yoi = np.ones(N)
for i in range(M):
    A, B = map(int, input().split())
    if H[A-1] > H[B-1]:
        yoi[B-1] = 0
    elif H[B-1] > H[A-1]:
        yoi[A-1] = 0
    elif H[A-1]==H[B-1]:
        yoi[A-1] = 0
        yoi[B-1] = 0
print(int(np.sum(yoi)))
Buggy code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
INF = 10**10
MOD = 10**9 + 7

N, M = map(int,input().split())
ok = [1] * N
H = list(map(int,input().split()))
for m in range(M):
    a, b = map(int,input().split())
    a-=1
    b-=1
    if H[a] < H[b]:
        ok[a] = 0
    elif H[a] > H[b]:
        ok[b] = 0
    # else:
    #     ok[a] = 0
    #     ok[b] = 0

print (sum(ok))
    

Fixed code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
INF = 10**10
MOD = 10**9 + 7

N, M = map(int,input().split())
ok = [1] * N
H = list(map(int,input().split()))
for m in range(M):
    a, b = map(int,input().split())
    a-=1
    b-=1
    if H[a] < H[b]:
        ok[a] = 0
    elif H[a] > H[b]:
        ok[b] = 0
    else:
        ok[a] = 0
        ok[b] = 0

print (sum(ok))
Buggy code:
N, M = map(int, input().split())
H = list(map(int, input().split()))

t = [0]*N
for i in range(M):
   a, b = map(int, input().split())
   t[a-1] = max(t[a-1], H[b-1])
   t[b-1] = max(t[b-1], H[a-1])

res = 0
for i range(N):
    if H[i] > t[i]:
        res += 1

print(res) 

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

t = [0]*N
for i in range(M):
   a, b = map(int, input().split())
   t[a-1] = max(t[a-1], H[b-1])
   t[b-1] = max(t[b-1], H[a-1])

res = 0
for i in range(N):
    if H[i] > t[i]:
        res += 1

print(res)
Buggy code:
n,m = map(int,input().split())
lis1 = list(map(int, input().split()))
ans = []
for i in range(n):
    ans.append(1)

for i in range(m):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    if lis1[a] > lis1[b]:
        ans[b] = 0
    elif lis1[a] < lis1[b]:
        ans[a] = 0

print(sum(ans))

Fixed code:
n,m = map(int,input().split())
lis1 = list(map(int, input().split()))
ans = [1]*n

for i in range(m):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    if lis1[a] >= lis1[b]:
        ans[b] = 0
    if lis1[a] <= lis1[b]:
        ans[a] = 0

print(sum(ans))
Buggy code:
n,m=map(int,input().split())
h=list(map(int,input().split()))
a=list([1 for _ in range(n)])

for _ in range(m):
  b,c= map(int,input().split())
  if h[b-1]<=h[c-1]:
    a[b-1]=0
  else:
    a[c-1]=0
print(sum(a))


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

for _ in range(m):
  b,c= map(int,input().split())
  if h[b-1]<h[c-1]:
    a[b-1]=0
  elif h[b-1]==h[c-1]:
    a[b-1]=0
    a[c-1]=0
  else:
    a[c-1]=0
print(sum(a))
Buggy code:
n,m = map(int,input().split())
height = list(map(int,input().split()))
lst = [0]*n
for j in range(m):
    x,y = map(int,input().split())
if height[x-1] >= height[y-1]:
    lst[x-1] = 1
if height[x-1] <= height[y-1]:
    lst[y-1] = 1
    print(lst.count(0))

Fixed code:
n,m = map(int,input().split())
height = list(map(int,input().split()))
lst = [0]*n
for j in range(m):
    x,y = map(int,input().split())
    if height[x-1] >= height[y-1]:
        lst[y-1] = 1
    if height[x-1] <= height[y-1]:
        lst[x-1] = 1
print(lst.count(0))