qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
edges = [list(map(int, input().split())) for _ in range(M)]



graph = [[] for _ in range(N+1)]
for edge in edges:
    graph[edge[0]].append(edge[1])
    graph[edge[1]].append(edge[0])

ans = []

for i in range(1,N+1):
    can = graph[i]
    hights = []
    for j in can:
        hights.append(H[j-1])
    h = max(hights)
    if H[i-1] > h:
        ans.append(i)

print(len(set(ans)))

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



graph = [[] for _ in range(N+1)]
for edge in edges:
    graph[edge[0]].append(edge[1])
    graph[edge[1]].append(edge[0])

ans = []

for i in range(1,N+1):
    can = graph[i]
    hights = []
    for j in can:
        hights.append(H[j-1])
    if len(hights) == 0:
        ans.append(i)
    else:
        h = max(hights)
        if H[i-1] > h:
            ans.append(i)

print(len(set(ans)))
Buggy code:
from sys import stdin
from collections import defaultdict
N,M = [int(x) for x in stdin.readline().rstrip().split()]
H = [int(x) for x in stdin.readline().rstrip().split()]
d = defaultdict(set)
for i in range(M):
    A,B = [int(x) for x in stdin.readline().rstrip().split()]
    d[A].add(B)
    d[B].add(A)
    
ans = 0
for h in range(1,N+1):
    f = True
    for i in d[h]:
        if H[i-1] > H[h-1]:
            f = False
    if f:
        ans += 1
print(ans)

Fixed code:
from sys import stdin
from collections import defaultdict
N,M = [int(x) for x in stdin.readline().rstrip().split()]
H = [int(x) for x in stdin.readline().rstrip().split()]
d = defaultdict(set)
for i in range(M):
    A,B = [int(x) for x in stdin.readline().rstrip().split()]
    d[A].add(B)
    d[B].add(A)
    
ans = 0
for h in range(1,N+1):
    f = True
    for i in d[h]:
        if H[i-1] >= H[h-1]:
            f = False
    if f:
        ans += 1
print(ans)
Buggy code:
N,M=map(int,input().split())
H=list(map(int,input().split()))

label=[-1]*N
Edge=[[] for _ in range(N)]
for i in range(M):
    A,B=map(int,input().split())
    Edge[A-1].append(B-1)
    Edge[B-1].append(A-1)

out=0
for i in range(N):
    if label[i]==-1:
        S=0
        CN=0
        stack=[i]
        while stack:
            T=stack.pop()
            label[T]=0
            for ii in Edge[i]:
                if label[ii]==-1:
                    stack.append(ii)
                    label[ii]=0
            if S<H[T]:
                S=H[T]
                CN=1
            elif S==H[T]:
                CN=0
        out+=CN
print(out)

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

label=[-1]*N
Edge=[[] for _ in range(N)]
for i in range(M):
    A,B=map(int,input().split())
    Edge[A-1].append(B-1)
    Edge[B-1].append(A-1)
out=0
for i in range(N):
    S=0
    for ii in Edge[i]:
        S=max(S,H[ii])
    if S<H[i]:
        out+=1
print(out)
# out=0
# for i in range(N):
#     if label[i]==-1:
#         S=0
#         CN=0
#         stack=[i]
#         while stack:
#             T=stack.pop()
#             label[T]=0
#             for ii in Edge[i]:
#                 if label[ii]==-1:
#                     stack.append(ii)
#                     label[ii]=0
#             if S<H[T]:
#                 S=H[T]
#                 CN=1
#             elif S==H[T]:
#                 CN=0
#         out+=CN
# print(out)
Buggy code:
temp = input()
temp = temp.split()
N = int(temp[0])
M = int(temp[1])

temp = input()
temp = temp.split()
height = [int(s) for s in temp]
bridge = [0] * N
data = [0] * N

for i in range(M):
  temp = input()
  temp = temp.split()
  A = int(temp[0])
  B = int(temp[1])
  if height[A-1] > height[B-1]:
    data[B-1] = 1
  else:
    data[A-1] = 1
    
  bridge[A-1] = 1
  bridge[B-1] = 1

count = 0
for i in range(N):
  if data[i] == 0 or bridge[i] == 0:
    count += 1
print(count)

Fixed code:
temp = input()
temp = temp.split()
N = int(temp[0])
M = int(temp[1])

temp = input()
temp = temp.split()
height = [int(s) for s in temp]
bridge = [0] * N
data = [0] * N

for i in range(M):
  temp = input()
  temp = temp.split()
  A = int(temp[0])
  B = int(temp[1])
  if height[A-1] > height[B-1]:
    data[B-1] = 1
  elif height[A-1] < height[B-1]:
    data[A-1] = 1
  else:
    data[A-1] = data[B-1] = 1
    
  bridge[A-1] = 1
  bridge[B-1] = 1

count = 0
for i in range(N):
  if data[i] == 0 or bridge[i] == 0:
    count += 1
print(count)
Buggy code:
import copy
n,m=map(int,input().split())
h=list(map(int,input().split()))
H = copy.deepcopy(h)
for _ in range(m):
    a,b=map(int,input().split())
    if H[b-1] - H[a-1] >= 0:
        h[a-1] = 0
    else:h[b-1] = 0
print(n-h.count(0))

Fixed code:
import copy
n,m=map(int,input().split())
h=list(map(int,input().split()))
H = copy.deepcopy(h)
for _ in range(m):
    a,b=map(int,input().split())
    if H[b-1] - H[a-1] > 0:
        h[a-1] = 0
    elif H[b-1] - H[a-1] == 0:
        h[a-1] = 0
        h[b-1] = 0
    else:
        h[b-1] = 0
print(n-h.count(0))
Buggy code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
maxh = []
for height in h:
    maxh.append(height)
for i in range(m):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    maxh[a] = max(maxh[a], h[b])
    maxh[b] = max(maxh[b], h[a])
g = 0
for height, maxheight in zip(h, maxh):
    if height == maxheight:
        g += 1
print(g)

Fixed code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
maxh = []
for height in h:
    maxh.append(0)
for i in range(m):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    maxh[a] = max(maxh[a], h[b])
    maxh[b] = max(maxh[b], h[a])
g = 0
for height, maxheight in zip(h, maxh):
    if height > maxheight:
        g += 1
print(g)
Buggy code:
# -*- coding: utf-8 -*-

N,M = map(int, input().split())
h_l = list(map(int, input().split()))

all_l = list(range(1,N+1))
lose_l = []
while M > 0:
    a,b = map(int, input().split())
    if h_l[a-1] > h_l[b-1]:
        lose_l.append(b)
    if h_l[a-1] < h_l[b-1]:
        lose_l.append(a)
    else:
        pass
    M -= 1

result = list(set(all_l) - set(lose_l))
print(len(result))

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

N,M = map(int, input().split())
h_l = list(map(int, input().split()))

all_l = list(range(1,N+1))
lose_l = []
while M > 0:
    a,b = map(int, input().split())
    if h_l[a-1] > h_l[b-1]:
        lose_l.append(b)
    elif h_l[a-1] < h_l[b-1]:
        lose_l.append(a)
    else:
        lose_l.append(b)
        lose_l.append(a)
    M -= 1

result = list(set(all_l) - set(lose_l))
print(len(result))
Buggy code:
def main():
    nm = list(map(int, input().split()))
    h = list(map(int, input().split()))
    ab = [None]*nm[1]
    for i in range(nm[1]):
        ab[i] = list(map(int, input().split()))

    memo = [0]*nm[0]
    for i in range(nm[1]):
        a = ab[i][0]-1
        b = ab[i][1]-1
        if h[a] > h[b]:
            memo[b] = 1
        elif h[a] < h[b]:
            memo[a] = 1
    
    print(memo.count(0))

if __name__ == '__main__':
    main()

Fixed code:
def main():
    nm = list(map(int, input().split()))
    h = list(map(int, input().split()))
    ab = [None]*nm[1]
    for i in range(nm[1]):
        ab[i] = list(map(int, input().split()))

    memo = [0]*nm[0]
    for i in range(nm[1]):
        a = ab[i][0]-1
        b = ab[i][1]-1
        if h[a] > h[b]:
            memo[b] = 1
        elif h[a] < h[b]:
            memo[a] = 1
        else:
            memo[a] = 1
            memo[b] = 1
    
    print(memo.count(0))

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

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

dp=[True]*N

for i in A:
  if H[i[0]-1]<H[i[1]-1]:
    dp[i[1]-1]=True
    dp[i[0]-1]=False
  elif H[i[0]-1]>H[i[1]-1]:
    dp[i[1]-1]=False
    dp[i[0]-1]=True
  elif H[i[0]-1]==H[i[1]-1]:
    dp[i[1]-1]=True
    dp[i[0]-1]=True

print(dp.count(True))

Fixed code:
N,M=list(map(int, input().split()))
H=list(map(int, input().split()))
A=[list(map(int, input().split())) for _ in range(M)]
 
dp=[True]*N

 
for i in A:
  if H[i[0]-1]<H[i[1]-1]:
    dp[i[0]-1]=False
    
  elif H[i[0]-1]>H[i[1]-1]:
    dp[i[1]-1]=False
  
  elif H[i[0]-1]==H[i[1]-1]:
    dp[i[1]-1]=False
    dp[i[0]-1]=False
  
 
print(dp.count(True))
Buggy code:
N, M = map(int, input().split())
O = list(map(int, input().split()))
B = [[0 for i in range(N)] for j in range (N)]
 
for j in range(M):
  o_1, o_2 = map(int, input().split())
  B[o_1-1].append(o_2-1)
  B[o_2-1].append(o_1-1)
  
ans = 0
for node in range(N):
  flag =1
  for l in B[node]:
    if O[node] <= O[l]:
      flag = 0
  if  flag ==1:
    ans += 1
print(ans)
      

Fixed code:
N, M = map(int, input().split())
O = list(map(int, input().split()))
B = [[] for i in range(N)]
 
for j in range(M):
  o_1, o_2 = map(int, input().split())
  B[o_1-1].append(o_2-1)
  B[o_2-1].append(o_1-1)

ans = 0
for node in range(N):
  flag =1
  for l in B[node]:
    if O[node] <= O[l]:
      flag = 0
  if  flag ==1:
    ans += 1
print(ans)
Buggy code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
graph = [set() for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    graph[a - 1].add(b - 1)
    graph[b - 1].add(a - 1)

good = [-1] * N
for i in range(N):
    if good[i] != -1:
        continue
    if not graph[i]:
        print(i)
        good[i] = 1
    elif all(H[nei] < H[i] for nei in graph[i]):
        good[i] = 1
        for nei in graph[i]:
            good[nei] = 0
    else:
        good[i] = 0

print(sum(good))

Fixed code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
graph = [set() for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    graph[a - 1].add(b - 1)
    graph[b - 1].add(a - 1)

good = [-1] * N
for i in range(N):
    if good[i] != -1:
        continue
    if not graph[i]:
        good[i] = 1
    elif all(H[nei] < H[i] for nei in graph[i]):
        good[i] = 1
        for nei in graph[i]:
            good[nei] = 0
    else:
        good[i] = 0

print(sum(good))
Buggy code:
import numpy as np

n,m = map(int, input().split())
h = np.array(list(map(int, input().split())))

high = np.array([1]*n)
cnt = np.array([0]*n)

for _ in range(m):
    a,b = map(int, input().split())
    if h[a-1] < h[b-1]:
        high[a-1] *= 0
        
    
    elif h[a-1] > h[b-1]:
        high[b-1] *= 0

ans = np.count_nonzero(high==1)

print(ans)

Fixed code:
import numpy as np

n,m = map(int, input().split())
h = np.array(list(map(int, input().split())))

high = np.array([True]*n)
cnt = np.array([False]*n)

for _ in range(m):
    a,b = map(int, input().split())
    if h[a-1] < h[b-1]:
        high[a-1] = False
    
    elif h[a-1] > h[b-1]:
        high[b-1] = False
    
    else:
        high[a-1] = False
        high[b-1] = False

ans = np.count_nonzero(high==True)

print(ans)
Buggy code:
import numpy as np

n,m = map(int, input().split())
h = np.array(list(map(int, input().split())))

high = np.array([0]*n)
cnt = np.array([0]*n)

for _ in range(m):
    a,b = map(int, input().split())
    if h[a-1] > h[b-1]:
        h[a-1] += 1
    
    elif h[a-1] < h[b-1]:
        h[b-1] += 1
    cnt[a-1] += 1
    cnt[b-1] += 1

ans = np.count_nonzero(high==1) +np.count_nonzero(cnt==0)

print(ans)

Fixed code:
import numpy as np

n,m = map(int, input().split())
h = np.array(list(map(int, input().split())))

high = np.array([1]*n)
cnt = np.array([0]*n)

for _ in range(m):
    a,b = map(int, input().split())
    if h[a-1] < h[b-1]:
        high[a-1] *= 0
    
    elif h[a-1] > h[b-1]:
        high[b-1] *= 0
    
    else:
        high[a-1] *= 0
        high[b-1] *= 0

ans = np.count_nonzero(high==1)

print(ans)
Buggy code:
def main():
    n, m = (int(i) for i in input().split())
    h = [int(i) for i in input().split()]
    roads = [(int(i) for i in input().split()) for _ in range(m)]

    nbors = [[] for _ in range(n)]
    for a, b in roads:
        nbors[a-1].append(b-1)
        nbors[b-1].append(a-1)

    ngood = 0
    for o in range(n):
        if all(h[o] > h[nb] for nb in nbors[o]):
            ngood += 1

    return ngood

main()


Fixed code:
def main():
    n, m = (int(i) for i in input().split())
    h = [int(i) for i in input().split()]
    roads = [(int(i) - 1 for i in input().split()) for _ in range(m)]

    nbors = [[] for _ in range(n)]
    for a, b in roads:
        nbors[a].append(b)
        nbors[b].append(a)

    ngood = 0
    for o in range(n):
        if all(h[o] > h[nb] for nb in nbors[o]):
            ngood += 1

    print(ngood)

main()
Buggy code:
def q3():
    N, M = (int(i) for i in input().split())
    H = [int(i) for i in input().split()]
    ans = [True]*N

    for i in range(M):
        A, B = (int(i) for i in input().split())

        if H[A-1] <= H[B-1]:
            ans[A-1] = False
        if H[B-1] <= H[A-1]:
            ans[B-1] = False

    print(ans)


if __name__ == '__main__':
    q3()


Fixed code:
def q3():
    N, M = (int(i) for i in input().split())
    H = [int(i) for i in input().split()]
    ans = [True]*N

    for i in range(M):
        A, B = (int(i) for i in input().split())

        if H[A-1] <= H[B-1]:
            ans[A-1] = False
        if H[B-1] <= H[A-1]:
            ans[B-1] = False

    print(ans.count(True))


if __name__ == '__main__':
    q3()
Buggy code:
import numpy as np
N, M =  map(int, input().split())


high = list(map(int, input().split()))
good = [0 for i in range(N)]



for i in range(M):
    A, B =map(int, input().split())
    if (high[A - 1] > high[B - 1]):
        good[B - 1] += 1
    else:
        good[A - 1] += 1

        
print(good.count(0))


Fixed code:
import numpy as np
N, M =  map(int, input().split())


high = list(map(int, input().split()))
good = [0 for i in range(N)]



for i in range(M):
    A, B =map(int, input().split())
    if (high[A - 1] > high[B - 1]):
        good[B - 1] += 1
    elif (high[A - 1] == high[B - 1]):
        good[A - 1] += 1
        good[B - 1] += 1
    else:
        good[A - 1] += 1

        
print(good.count(0))
Buggy code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
preH =[]
for i in range(M):
    preH.append(list(map(int, input().split())))
ans = [True]*N

for i in range(M):
    A,B = preH[i]
   

    if(H[A-1]>=H[B-1]):
        ans[A-1] = False
    if(H[B-1]>=H[A-1]):
        ans[B-1] = False

print(ans.count(True))

Fixed code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
preH =[]
for i in range(M):
    preH.append(list(map(int, input().split())))
ans = [True]*N

for i in range(M):
    A,B = preH[i]


    if(H[A-1]<=H[B-1]):
        ans[A-1] = False
    if(H[B-1]<=H[A-1]):
        ans[B-1] = False

print(ans.count(True))
Buggy code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
adj_max = [0]*N
ans = 0
for _ in range(M):
  tmp1, tmp2 = map(int, input().split())
  adj_max[tmp1] = max(adj_max[tmp1], H[tmp2])
  adj_max[tmp2] = max(adj_max[tmp2], H[tmp1])
for num in range(N):
  if H[num] > adj_max[num]:
    ans += 1
print(ans)

Fixed code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
adj_max = [0]*N
ans = 0
for _ in range(M):
  tmp1, tmp2 = map(int, input().split())
  adj_max[tmp1-1] = max(adj_max[tmp1-1], H[tmp2-1])
  adj_max[tmp2-1] = max(adj_max[tmp2-1], H[tmp1-1])
for num in range(N):
  if H[num] > adj_max[num]:
    ans += 1
print(ans)
Buggy code:
N, M = map(int, input().split())
c = [0 for _ in range(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]:
      c[a-1] = 1
    elif H[a-1] > H[b-1]:
      c[b-1] = 1
    elif H[a-1] != H[b-1]:
      c[a-1] = 1
      c[b-1] = 1

print(c.count(1))

Fixed code:
N, M = map(int, input().split())
c = [1 for _ in range(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]:
      c[a-1] = 0
    elif H[a-1] > H[b-1]:
      c[b-1] = 0
    elif H[a-1] == H[b-1]:
      c[a-1] = 0
      c[b-1] = 0

print(c.count(1))
Buggy code:
N,M = (int(x) for x in input().split())
hight = [int(x) for x in input().split()]
tenbou = [input().split() for l in range(M)]
result = [1] * N


for i in range(M):
    x = int(tenbou[i][0]) - 1
    y = int(tenbou[i][1]) - 1
    if hight[x] >= hight[y]:
        result[y] = 0
    elif hight[y] > hight[x]:
        result[x] = 0
print(result)
print(result.count(1))

Fixed code:
N,M = (int(x) for x in input().split())
hight = [int(x) for x in input().split()]
tenbou = [input().split() for l in range(M)]
result = [1] * N


for i in range(M):
    x = int(tenbou[i][0]) - 1
    y = int(tenbou[i][1]) - 1
    if hight[x] > hight[y]:
        result[y] = 0
    elif hight[y] == hight[x]:
        result[x] = 0
        result[y] = 0
    elif hight[y] > hight[x]:
        result[x] = 0
#print(result)
print(result.count(1))
Buggy code:
N,M = map(int,input().split())
listH = list(map(int,input().split()))
LofS = [set() for i in range(N) ]
for i in range(M):
  a,b=map(int,input().split())
  LofS[a-1].add(b)
  LofS[b-1].add(a)
listMax = []
for i in range(N):
   listMax.append( max( [ listH[j-1] for j in LofS[i] ] , default=0) )
print(listMax)
count = 0
for i in range(N):
  if listH[i] > listMax[i]:
    count += 1
print(count)

Fixed code:
N,M = map(int,input().split())
listH = list(map(int,input().split()))
LofS = [set() for i in range(N) ]
for i in range(M):
  a,b=map(int,input().split())
  LofS[a-1].add(b)
  LofS[b-1].add(a)
listMax = []
for i in range(N):
   listMax.append( max( [ listH[j-1] for j in LofS[i] ] , default=0) )
count = 0
for i in range(N):
  if listH[i] > listMax[i]:
    count += 1
print(count)
Buggy code:
n,m=map(int, input().split())
h = list(map(int, input().split()))
l = [input().split() for i in range(m)]

list = [0]*n
for j in range(m):
    if l[j][0] >= l[j][1]:
        list[int(l[j][1])-1] -= 1
    else :
        list[int(l[j][0])-1] -= 1

print(list.count(0))

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

list = [0]*n
for j in range(m):
    if h[int(l[j][0])-1] > h[int(l[j][1])-1]:
        list[int(l[j][1])-1] -= 1
    elif  h[int(l[j][0])-1] < h[int(l[j][1])-1]:
        list[int(l[j][0])-1] -= 1
    else :
        list[int(l[j][0])-1] -= 1
        list[int(l[j][1])-1] -= 1

print(list.count(0))
Buggy code:
n, m = list(map(int, input().split()))
H = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(m)]

ans = [1] * (n)
route = [1] * (n)
for i in range(len(ab)):
    a, b = ab[i]
    if H[a-1] <= H[b-1]:
      ans[a-1] = 0

    elif H[b-1] <= H[a-1]:
      ans[b-1] = 0
    
print(sum(cnt))

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

ans = [1] * (n)
route = [1] * (n)
for i in range(len(ab)):
    a, b = ab[i]
    if H[a-1] <= H[b-1]:
      ans[a-1] = 0

    if H[b-1] <= H[a-1]:
      ans[b-1] = 0
    
print(sum(ans))
Buggy code:
import sys
N, M = map(int, sys.stdin.readline().rstrip().split())
h_i = [int(x) for x in sys.stdin.readline().rstrip().split()]
ab = [list(map(int, sys.stdin.readline().rstrip().split())) for _ in range(M)]

J = [1 for i in range(N)]
for li in ab:
  if h_i[li[0]] < h_i[li[1]]:
    J[li[0]] = 0
  elif h_i[li[0]] == h_i[li[1]]:
    J[li[0]] = J[li[1]] = 0
  else:
    J[li[1]] = 0
print(J)

Fixed code:
import sys
N, M = map(int, sys.stdin.readline().rstrip().split())
h_i = [int(x) for x in sys.stdin.readline().rstrip().split()]
ab = [list(map(int, sys.stdin.readline().rstrip().split())) for _ in range(M)]
 
J = [1 for i in range(N)]
#print(ab,J)

for li in ab:
  #print(li)
  if h_i[li[0]-1] < h_i[li[1]-1]:
    J[li[0]-1] = 0
  elif h_i[li[0]-1] == h_i[li[1]-1]:
    J[li[0]-1] = J[li[1]-1] = 0
  else:
    J[li[1]-1] = 0
print(J.count(1))
Buggy code:
n, m = map(int,input().split())
h = list(map(int,input().split()))
n_ans=[1]*n

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



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

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

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

print(tmp.count(0))

Fixed code:
n,m=map(int,input().split())
l=list(map(int,input().split()))
tmp=[0]*n

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

print(tmp.count(0))
Buggy code:
n,m=map(int,input().split())
H=list(map(int,input().split()))
lb=[True]*n
for r in range(m):
    a,b=input().split()
    a,b=int(a)-1,int(b)-1
    if H[a]>H[b]:
        lb[b]=False
    elif H[a]<H[b]:
        lb[a]=False
    else:
        lb[a]=False
        lb[b]=False
lb.count(True)

Fixed code:
n,m=map(int,input().split())
H=list(map(int,input().split()))
lb=[True]*n
for r in range(m):
    a,b=input().split()
    a,b=int(a)-1,int(b)-1
    if H[a]>H[b]:
        lb[b]=False
    elif H[a]<H[b]:
        lb[a]=False
    else:
        lb[a]=False
        lb[b]=False
print(lb.count(True))
Buggy code:
N,M=list(map(int,input().split()))
src=list(map(int,input().split()))
w=[]
for e in range(N):
  w.append(1)
q=[]
for m in range(M):
  q.append(list(map(int,input().split())))
#q=list(set(q))
for a,b in q:
  if src[a-1]<src[b-1]:
    w[a-1] = 0
  elif src[b-1]<src[a-1]:
    w[b-1] = 0
ans = 0
for o in w:
  if o == 1:
    ans+=1
print(ans)

Fixed code:
N,M=list(map(int,input().split()))
src=list(map(int,input().split()))
w=[]
for e in range(N):
  w.append(1)
q=[]
for m in range(M):
  q.append(list(map(int,input().split())))
#q=list(set(q))
for a,b in q:
  if src[a-1]<src[b-1]:
    w[a-1] = 0
  elif src[b-1]<src[a-1]:
    w[b-1] = 0
  elif src[b-1]==src[a-1]:
    w[a-1]=0
    w[b-1]=0
ans = 0
for o in w:
  if o == 1:
    ans+=1
print(ans)
Buggy code:
def main():
    import collections
    n, m = map(int, input().split())
    hs = list(map(int, input().split()))
    nmap = [0] * n
    cnt = 0

    for j in range(m):
        v = input().split()
        v0 = int(v[0]) - 1
        v1 = int(v[1]) - 1
        if hs[v0] < hs[v1]:
            nmap[v0] += 1
        elif hs[v0] == hs[v1]:
            nmap[v0] += 1
            nmap[v1] += 1
        # else:
        #     nmap[v1] += 1
    print(nmap)
    for i in nmap:
        if i == 0:
            cnt += 1
    return cnt


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


Fixed code:
def main():
    import collections
    n, m = map(int, input().split())
    hs = list(map(int, input().split()))
    nmap = [0] * n
    cnt = 0

    for j in range(m):
        v = input().split()
        v0 = int(v[0]) - 1
        v1 = int(v[1]) - 1
        if hs[v0] < hs[v1]:
            nmap[v0] += 1
        elif hs[v0] == hs[v1]:
            nmap[v0] += 1
            nmap[v1] += 1
        else:
            nmap[v1] += 1
    for i in nmap:
        if i == 0:
            cnt += 1
    return cnt


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