qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N, M = list(map(int, input().split()))
H_list = list(map(int, input().split()))
road_list = []

for _ in range(M):
    road_list.append([])
for i in range(M):
    a, b = list(map(int, input().split()))
    H_a, H_b = [H_list[a - 1], H_list[b - 1]]
    if H_a <= H_b:
        road_list[a - 1].append(a)
    elif H_b <= H_a:
        road_list[b - 1].append(b)

ans = 0
for road in road_list:
    if len(road) == 0:
        ans += 1
print(ans)

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

road_list = []
for _ in range(N):
    road_list.append([])
    
for i in range(M):
    a, b = list(map(int, input().split()))
    
    H_a, H_b = [H_list[a - 1], H_list[b - 1]]
    
    if H_a <= H_b:
        road_list[a - 1].append(b)

    if H_b <= H_a:
        road_list[b - 1].append(a)

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

for i in range(n):
    if h[i] > max(l[i]):
        cnt +=1
    elif l[i] == []:
        cnt+=1

print(cnt)

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

for i in range(n):
    if l[i] == []:
        cnt+=1

    elif h[i] > max(l[i]):
        cnt +=1
    

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

ab = [list(map(int,input().split())) for _ in range(m)]


point = [0]*n
app = [0]*n
cnt = []

for i in ab:
    app[i[0]-1] += 1
    app[i[1]-1] += 1
    if h[i[0]-1] > h[i[1]-1]:
        point[i[0]-1] += 1
    elif h[i[0]-1] < h[i[1]-1]:
        point[i[1]-1] += 1
for i in range(n):
    if app[i] == point[i]:
        cnt.append(i+1)
print(cnt)

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

ab = [list(map(int,input().split())) for _ in range(m)]


point = [0]*n
app = [0]*n
cnt = []

for i in ab:
    app[i[0]-1] += 1
    app[i[1]-1] += 1
    if h[i[0]-1] > h[i[1]-1]:
        point[i[0]-1] += 1
    elif h[i[0]-1] < h[i[1]-1]:
        point[i[1]-1] += 1
for i in range(n):
    if app[i] == point[i]:
        cnt.append(i+1)
print(len(cnt))
Buggy code:
n, m=map(int, input().split())
h=list(map(int,input().split()))
l = [[] for _ in range(n)]
#print(l)
#print(h)
for i in range(m):
  a, b=map(int, input().split())
  l[a-1].append(b)
  l[b-1].append(a)
ans=0
print(l)
for x in range(n):
  for y in range(len(l[x])):
    if h[x]<=h[l[x][y]-1]:
      break
  else:
    print(x)
    ans+=1
    continue
  
    
    

  
                 
       

Fixed code:
n, m=map(int, input().split())
h=list(map(int,input().split()))
l = [[] for _ in range(n)]
#print(l)
#print(h)
for i in range(m):
  a, b=map(int, input().split())
  l[a-1].append(b)
  l[b-1].append(a)
ans=0
for x in range(n):
  for y in range(len(l[x])):
    if h[x]<=h[l[x][y]-1]:
      break
  else:
    ans+=1
    continue
print(ans)
Buggy code:
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))

G = []*N

for i in range(M):
    A, B = list(map(int, input().split()))
    G[A - 1].append(B-1)
    G[B-1].append(A-1)

ans = 0

for i in range(N):
    self_h = H[i]

    self_max_flag = True

    for to in range(G[i]):
        if (self_h <= H[to]):
            self_max_flag = False
        
    if (self_max_flag):
        ans += 1

print(ans)

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

G = [[] for i in range(N)]

for i in range(M):
    A, B = list(map(int, input().split()))
    G[A - 1].append(B - 1)
    G[B - 1].append(A - 1)

ans = 0

for i in range(N):
    self_h = H[i]

    self_max_flag = True

    for to in G[i]:
        if (self_h <= H[to]):
            self_max_flag = False
        
    if (self_max_flag):
        ans += 1

print(ans)
Buggy code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
A = [0 for k in range(M)]
B = [0 for k in range(M)]

for k in range(M):
    A[k], B[k] = map(int, input().split())
    A[k] -= 1
    B[k] -=1
good = [1 for k in range(N)]
C = A.append(B)
for k in A:
    if good[k] ==1:

        for j in range(M):
            if k == A[j] and H[k]<=H[B[j]]:
                good[k] = 0
            if k == A[j] and H[k]>=H[B[j]]:
                good[B[j]] = 0
            if k == B[j] and H[k]<=H[A[j]]:
                good[k] = 0
            if k == B[j] and H[k]>=H[A[j]]:
                good[A[j]] = 0
for k in B:
    if good[k] ==1:

        for j in range(M):
            if k == A[j] and H[k]<=H[B[j]]:
                good[k] = 0
            if k == A[j] and H[k]>=H[B[j]]:
                good[B[j]] = 0
            if k == B[j] and H[k]<=H[A[j]]:
                good[k] = 0
            if k == B[j] and H[k]>=H[A[j]]:
                good[A[j]] = 0        
        

print(sum(good))
        

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

for k in range(M):
    A[k], B[k] = map(int, input().split())
    A[k] -= 1
    B[k] -= 1
good = [1 for k in range(N)]

for k in range(M):
    if H[A[k]] <= H[B[k]]:
        good[A[k]] = 0
    if H[A[k]] >= H[B[k]]:
        good[B[k]] = 0   
        '''
for k in range(N):
    if good[k] ==1:
        if k in A:
            for j in range(M):
                if k == A[j] and H[k]<=H[B[j]]:
                    good[k] = 0
                if k == A[j] and H[k]>=H[B[j]]:
                    good[B[j]] = 0
        if k in B:
            for j in range(M):
                if k == B[j] and H[k]<=H[A[j]]:
                    good[k] = 0
                if k == B[j] and H[k]>=H[A[j]]:
                    good[A[j]] = 0
'''
print(sum(good))
Buggy code:
N,M=map(int,input().split())
H=list(map(int,input().split()))

ans_list=[1]*N

for i in range(M):
    a,b=map(int,input().split())
    if H[a-1]<H[b-1]:
        ans_list[a]=0
    if H[a-1]>H[b-1]:
        ans_list[b]=0
    if H[a-1]==H[b-1]:
        ans_list[a]=0
        ans_list[b]=0
print(sum(ans_list))

Fixed code:


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

ans_list=[1]*N

for i in range(M):
    a,b=map(int,input().split())
    if H[a-1]<H[b-1]:
        ans_list[a-1]=0
    if H[a-1]>H[b-1]:
        ans_list[b-1]=0
    if H[a-1]==H[b-1]:
        ans_list[a-1]=0
        ans_list[b-1]=0
print(sum(ans_list))
Buggy code:
N, M = map(int, input().split())
H = [int(h) for h in input().split()]
flag = [1 for i in range(N)]
for i in range(M):
  a, b = map(int, input().split())
  if H[a-1] < H[b-1]:
    flag[a-1] = 0
  elif H[a-1] > H[b-1]:
    flag[b-1] = 0
print(sum(flag))

Fixed code:
N, M = map(int, input().split())
H = [int(h) for h in input().split()]
flag = [1 for i in range(N)]
for i in range(M):
  a, b = map(int, input().split())
  if H[a-1] <= H[b-1]:
    flag[a-1] = 0
  if H[a-1] >= H[b-1]:
    flag[b-1] = 0
print(sum(flag))
Buggy code:
#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
import math
import itertools
from collections import defaultdict
from collections import Counter
import numpy as np

import heapq

def bfs(c,nu,di,node,val):
    c[nu]=True
    di[val[nu]]+=1
    for each in node[nu]:
        if c[each]:
            continue
        di=bfs(c,each,di,node,val)
    return di





n,k=list(map(int,input().split()))
h=list(map(int,input().split()))
node=[i for i in h]
for _ in range(k):
    i,v=list(map(int,input().split()))
    i-=1
    v-=1
    """
    if node[i]>node[v]:
        node[v]=node[i]
    elif node[i]<node[v]:
        node[i]=node[v]
    """
    node[i]=max(node[i],h[v])
    node[v]=max(node[v],h[i])


check=[False for _ in range(n)]
ans=0
for i in range(n):
    if node[i]==h[i]:
        ans+=1
print(ans)
    


Fixed code:
#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
import math
import itertools
from collections import defaultdict
from collections import Counter
import numpy as np

import heapq

def bfs(c,nu,di,node,val):
    c[nu]=True
    di[val[nu]]+=1
    for each in node[nu]:
        if c[each]:
            continue
        di=bfs(c,each,di,node,val)
    return di





n,k=list(map(int,input().split()))
h=list(map(int,input().split()))
#node=[i for i in h]
node=[defaultdict(int) for _ in range(n) ]
for _ in range(k):
    i,v=list(map(int,input().split()))
    i-=1
    v-=1
    """
    if node[i]>node[v]:
        node[v]=node[i]
    elif node[i]<node[v]:
        node[i]=node[v]
    """
    #node[i]=max(node[i],h[v])
    #node[v]=max(node[v],h[i])
    #node[i].append(v)
    #node[v].append(i)
    node[i][h[v]]+=1
    node[v][h[i]]+=1

#print(node)
check=[False for _ in range(n)]
ans=0
for i in range(n):
    t=node[i]
    if len(t)==0:
        ans+=1
        continue
    if max(t.keys())<h[i]:
        #print(i)
        ans+=1
print(ans)
Buggy code:
n,m=map(int,input().split())
h=[0]+list(map(int, input().split()))
roads=[[] for _ in range(n+1)]
cnt=0
for i in range(m):
    a,b=map(int,input().split())
    roads[a].append(b)
    roads[b].append(a)
 
for i in range(1,n+1):
    for j in roads[i]:
        if h[i]<=h[j]:
            break
    else:
         cnt+=1
    
print(cnt

Fixed code:
n,m=map(int,input().split())
h=[0]+list(map(int, input().split()))
roads=[[] for _ in range(n+1)]
cnt=0
for i in range(m):
    a,b=map(int,input().split())
    roads[a].append(b)
    roads[b].append(a)

for i in range(1,n+1):
    for j in roads[i]:
        if h[i]<=h[j]:
            break
    else:
         cnt+=1
    
print(cnt)
Buggy code:
#template
def inputlist(): return [int(k) for k in input().split()]
#template
N,M = inputlist()
H = inputlist()
graph = [[] for _ in range(N)]
print(graph)

for i in range(M):
    A,B = inputlist()
    A -=1
    B -=1
    graph[A].append(B)
    graph[B].append(A)
ans = 0
for i in range(N):
    h = H[i]
    k = 0
    for j in graph[i]:
        k = max(k,H[j])
    if h > k:
        ans +=1
print(ans)


Fixed code:
#template
def inputlist(): return [int(k) for k in input().split()]
#template
N,M = inputlist()
H = inputlist()
graph = [[] for _ in range(N)]

for i in range(M):
    A,B = inputlist()
    A -=1
    B -=1
    graph[A].append(B)
    graph[B].append(A)
ans = 0
for i in range(N):
    h = H[i]
    k = 0
    for j in graph[i]:
        k = max(k,H[j])
    if h > k:
        ans +=1
print(ans)
Buggy code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
d = [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    a,b = a-1,b-1
    d[a].append(b)
    d[b].append(a)

cnt = 0
for i in range(n):
    H = h[i]
    max1 = 0
    for j in d[i]:
        max1 = max(max1,h[j])
    if max1 > H:
        cnt +=1        
print(cnt)

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

cnt = 0
for i in range(n):
    H = h[i]
    max1 = 0
    for j in d[i]:
        max1 = max(max1,h[j])
    if H > max1:
        cnt +=1        
print(cnt)
Buggy code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
P = [list(map(int,input().split())) for i in range(M)]

Tallest = [1]*N

for i in range (0,M):
	if H[int(P[i][0])-1] > H[int(P[i][1])-1]:
		Tallest[P[i][1]-1]=0	
	elif H[int(P[i][0])-1] == H[int(P[i][1])-1]:
		Tallest[P[i][0]-1]=0
		Tallest[P[i][0]-1]=0
	elif H[int(P[i][0])-1] < H[int(P[i][1])-1]:
		Tallest[P[i][0]-1]=0

print(sum(Tallest))

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

Tallest = [1]*N

for i in range (0,M):
	if H[int(P[i][0])-1] > H[int(P[i][1])-1]:
		Tallest[P[i][1]-1]=0	
	elif H[int(P[i][0])-1] == H[int(P[i][1])-1]:
		Tallest[P[i][0]-1]=0
		Tallest[P[i][1]-1]=0
	else:
		Tallest[P[i][0]-1]=0

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

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

N_addj = [[] for i in range(N)]

for i in range(M):
    AB = list(map(int, input().split()))
    N_addj[AB[0]-1].append(AB[1]-1)
    N_addj[AB[1]-1].append(AB[0]-1)


N_memo = [0] * N

num = 0


arr = []

print(H)


for i in range(N):
    flag = True
    for j in N_addj[i]:
        if(H[i] <= H[j]):
            flag = False
            break
    if(flag):
        num = num + 1

print(num)


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

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

N_addj = [[] for i in range(N)]

for i in range(M):
    AB = list(map(int, input().split()))
    N_addj[AB[0]-1].append(AB[1]-1)
    N_addj[AB[1]-1].append(AB[0]-1)


N_memo = [0] * N

num = 0


arr = []


for i in range(N):
    flag = True
    for j in N_addj[i]:
        if(H[i] <= H[j]):
            flag = False
            break
    if(flag):
        num = num + 1

print(num)
Buggy code:
n, m = list(map(int, input().split()))
h_list = list(map(int, input().split()))
hh_list = [1] * n

for mm in range(m):
    a, b = list(map(int, input().split()))
    if h_list[a-1] - h_list[b-1] < 0:
        hh_list[a-1] = 0

counter = 0
for hh in hh_list:
    if hh >= 1:
        counter += 1
print(counter)

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

for mm in range(m):
    a, b = list(map(int, input().split()))
    if h_list[a-1] - h_list[b-1] < 0:
        hh_list[a-1] = 0
    if h_list[b-1] - h_list[a-1] < 0:
        hh_list[b-1] = 0
    if h_list[a-1] == h_list[b-1]:
        hh_list[a-1] = 0
        hh_list[b-1] = 0

counter = 0
for hh in hh_list:
    if hh >= 1:
        counter += 1
print(counter)
Buggy code:
n,m = map(int,input().split())
h = list(map(int,input().split()))

g = [[] for _ in range(n)]
for _ in range(m):
  a,b = map(int,input().split())
  g[a-1].append(b-1)
  g[b-1].append(a-1)
print(g)

cnt = n
for i in range(n):
  for j in g[i]:
    if h[i] <= h[j]:
      cnt -= 1
      break
print(cnt)

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

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

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

print(sum(final))

Fixed code:
n,m=map(int,input().split())
h=list(map(int,input().split()))
final=[1]*n
for i in range(m):
  a,b=map(int,input().split())
  if h[a-1]<h[b-1]:
         final[a-1]=0
  elif h[a-1]>h[b-1]:
         final[b-1]=0
  else:
         final[a-1]=0
         final[b-1]=0

print(sum(final))
Buggy code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
g = [[] for _ in range(n+1)]
for i in range(m):
    a, b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)

cnt = 0
for i in range(1, n+1):
    if len(g[i]) == 0:
        continue
    for j in g[i]:
        print(i, j)
        print(h[j-1], h[i-1])
        if h[j-1] >= h[i-1]:
            break
    else:
        cnt += 1

print(cnt)

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

cnt = 0
for i in range(1, n+1):
    for j in g[i]:
        if h[j-1] >= h[i-1]:
            break
    else:
        cnt += 1

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


Fixed code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
t = [True for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    if h[a-1] <= h[b-1]:
        t[a-1] = False
    if h[a-1] >= h[b-1]:
        t[b-1] = False
count = 0
for i in t:
    if i:
        count+=1
print(count)
Buggy code:
N,M=int(input())
L=list(map(int,input().split()))
B=[1]*N
for i in range(M):
  a,b=map(int,input().split())
  if L[a-1]<L[b-1]:
    B[a-1]==0
  elif L[a-1]==L[b-1]:
    B[a-1]=0
    B[b-1]=0
  else:
    B[b-1]=0
print(sum(B))
  

Fixed code:
N,M=map(int,input().split())
L=list(map(int,input().split()))
B=[1]*N
for i in range(M):
  a,b=map(int,input().split())
  if L[a-1]<L[b-1]:
    B[a-1]=0
  elif L[a-1]==L[b-1]:
    B[a-1]=0
    B[b-1]=0
  else:
    B[b-1]=0
print(sum(B))
Buggy code:
def main():
  n,m = map(int,input().split())
  s = [int(n) for n in input().split()]
  cs = s
  for i in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    if(s[a] < s[b]):
      cs[a] = -1
    elif(s[a] == s[b]):
      cs[a] = -1
      cs[b] = -1
    elif(s[b] < s[a]):
      cs[b] = -1
  print(len(cs)-cs.count(-1))
      
if __name__ == '__main__':
  main()

Fixed code:
import copy

def main():
  n,m = map(int,input().split())
  s = [int(n) for n in input().split()]
  cs = copy.copy(s)
  for i in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    if(s[a] < s[b]):
      cs[a] = -1
    elif(s[a] == s[b]):
      cs[a] = -1
      cs[b] = -1
    elif(s[b] < s[a]):
      cs[b] = -1
  print(len(cs)-cs.count(-1))
      
if __name__ == '__main__':
  main()
Buggy code:
N, M =map(int, input().split())
H_tree =[int(n) for n in input().split()]
GOOD_Tree = [1 for n in range(N)]
 
for i in range(M):
  A, B = map(int, input().split())
  if H_tree[A]<=H_tree[B]:GOOD_Tree[A] = 0
  if H_tree[A]>=H_tree[B]:GOOD_Tree[B] = 0
print(sum(GOOD_Tree))

Fixed code:
N, M =map(int, input().split())
H_tree = [0] + [int(n) for n in input().split()]
GOOD_Tree = [0] + [1 for n in range(N)]
 
for i in range(M):
  A, B = map(int, input().split())
  if H_tree[A]<=H_tree[B]:GOOD_Tree[A] = 0
  if H_tree[A]>=H_tree[B]:GOOD_Tree[B] = 0
print(sum(GOOD_Tree))
Buggy code:
n, m = map(int, input().split())
h = [int(i) for i in input().split()]
load = [list(map(int, input().split())) for _ in range(m)]
result = {i: 1 for i in range(n)}

for l in load:
    a, b = l[0] - 1, l[1] - 1
    if h[a] < h[b]:
        result[a] = 0
    elif h[a] > h[b]:
        result[b] = 0
    elif h[a] == h[b]:
        result[a] = 0
        result[b] = 1

print(sum(result.values()))

Fixed code:
n, m = map(int, input().split())
h = [int(i) for i in input().split()]
load = [list(map(int, input().split())) for _ in range(m)]
result = {i: 1 for i in range(n)}

for l in load:
    a, b = l[0] - 1, l[1] - 1
    if h[a] < h[b]:
        result[a] = 0
    elif h[a] > h[b]:
        result[b] = 0
    elif h[a] == h[b]:
        result[a] = 0
        result[b] = 0

print(sum(result.values()))
Buggy code:
N,M=map(int,input().split())
H=list(map(int,input().split()))
good=[True]*N
for i in range(M):
    A,B=map(int,input().split())
    if H[A-1]>H[B-1]:
        print("A")
        good[B-1]=False
    elif H[B-1]>H[A-1]:
        good[A-1]=False
    else:
        good[A-1],good[B-1]=False,False
ans=0
for i in good:
    if i==True:
        ans+=1
print(good)

Fixed code:
N,M=map(int,input().split())
H=list(map(int,input().split()))
good=[True]*N
for i in range(M):
    A,B=map(int,input().split())
    if H[A-1]>H[B-1]:
        good[B-1]=False
    elif H[B-1]>H[A-1]:
        good[A-1]=False
    else:
        good[A-1],good[B-1]=False,False
ans=0
for i in good:
    if i==True:
        ans+=1
print(ans)
Buggy code:
n,m=map(int, input().split())
h=list(map(int, input().split()))
root=[list(map(int,input().split()))  for _ in range(m)]

ans=0
lis=[1 for _ in range(n)]

for i in range(len(root)):
    a=root[i][0]
    b=root[i][1]
    if h[a-1] > h[b-1]:
        lis[b-1]=0
    elif h[a-1]< h[b-1]:
        lis[a-1]=0
    else:
        lis[a-1],lis[b-1]=0

ans=sum(lis)
print(ans)

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

ans=0
lis=[1 for _ in range(n)]

for i in range(len(root)):
    a=root[i][0]
    b=root[i][1]
    if h[a-1] > h[b-1]:
        lis[b-1]=0
    elif h[a-1]< h[b-1]:
        lis[a-1]=0
    else:
        lis[a-1]=0
        lis[b-1]=0

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

print(sum(d))

Fixed code:

n,m = list(map(int,input().split()))
h = list(map(int,input().split()))
d = [1] * n
for i in range(m):
  a,b = list(map(int,input().split()))
  a -= 1
  b -= 1
  if h[a] > h[b]:
    d[b] = 0
  elif h[b] > h[a]:
    d[a] = 0
  else:
    d[a] = 0
    d[b] = 0

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

x = [set() for _ in range(n)]
for a, b in ab:
    x[a-1].add(b-1)
    x[b-1].add(a-1)
print(x)    
ans = 0
for i, xx in enumerate(x):
    for xxx in xx:
        if h[i] <= h[xxx]:
            break
    else:
        ans += 1
        
print(ans)

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

x = [set() for _ in range(n)]
for a, b in ab:
    x[a-1].add(b-1)
    x[b-1].add(a-1)
    
ans = 0
for i, xx in enumerate(x):
    for xxx in xx:
        if h[i] <= h[xxx]:
            break
    else:
        ans += 1
        
print(ans)
Buggy code:
N,M=map(int, input().split())
peaks=list(map(int, input().split()))
flag=[1]*N
a=0
b=0
for i in range(M):
  a,b=map(int,input().split())
  a-=1
  b-=1
  if peaks[a]<=peaks[b]:
     flag[a]=0
  if peaks[a]>=peaks[b]:
     flag[a]=0
ans=0
for i in flag:
  ans+=flag[i]
print(ans)

Fixed code:
N,M=map(int, input().split())
peaks=list(map(int, input().split()))
flag=[1]*N
a=0
b=0
for i in range(M):
  a,b=map(int,input().split())
  a-=1
  b-=1
  if peaks[a]<=peaks[b]:
     flag[a]=0
  if peaks[a]>=peaks[b]:
     flag[b]=0
ans=0
for i in flag:
  ans+=i
print(ans)
Buggy code:
N, M = map(int,input().split())
H = list(map(int,input().split()))
count = 0
for _ in range(M):
    A, B = map(int,input().split())
    if H[B-1] < H[A-1]:
        count +=1
    if H[B-1] > H[A-1]:
        count +=1
print(count)

Fixed code:
N, M = map(int,input().split())
H = list(map(int,input().split()))
ans = [0]*N
for _ in range(M):
    A, B = map(int,input().split())
    if H[A-1] >= H[B-1]:
        ans[B-1] = 1
    if H[A-1] <= H[B-1]:
        ans[A-1] = 1
print(ans.count(0))
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])

ct=0
for j in range(N):
    if H[j]>[j]:
        ct+=1
print(ct)


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])

ct=0
for j in range(N):
    if h[j]>t[j]:
        ct+=1
print(ct)
Buggy code:
n,m = list(map(int, input().split()))
i = list(map(int, input().split()))
k=i
ans=0
for j in range(m):
    a,b = list(map(int, input().split()))
    if i[a-1]==i[b-1]:
        k[a-1]=0
        k[b-1]=0
    else:
        if i[b-1]>i[a-1]:
            k[a-1]=0
        else:
            k[b-1]=0
            
for w in range(n):
    if k[w]!=0:
        ans+=1
print(ans)
print(k)

Fixed code:
n,m = list(map(int, input().split()))
i = list(map(int, input().split()))
k=[0]*n
ans=0
for j in range(m):
   
    a,b = list(map(int, input().split()))
    a-=1
    b-=1
    if i[a]==i[b]:
        k[a]+=1
        k[b]+=1
        
    else:
        if i[b]>i[a]:
            k[a]+=1
        else:
            k[b]+=1
            
for w in range(n):
    if k[w]==0:
        ans+=1
print(ans)