qyliang/CodeNanoFix huggingface dataset:
Buggy code:
list1=list(map(int,input().strip().split()))[:2]
n,m=list1[0],list1[1]
arr=list(map(int,input().strip().split()))[:n]
dict1={}
for i in range(m):
	l=list(map(int,input().strip().split()))[:2]
	key,val=l[0],l[1]
	if key in dict1:
		dict1[key].append(val)
	else:
		dict1[key]=[]
		dict1[key].append(val)
	if val in dict1:
		dict1[val].append(key)
	else:
		dict1[val]=[]
		dict1[val].append(key)
print(dict1)
count=0
for i in range(1,n+1):
	flag=0
	if i in dict1:
		l=arr[i-1]
		for j in dict1[i]:
			if(l <= arr[j-1]):
				flag=1
				break
	if(flag==0):
		count+=1
print(count)

Fixed code:
list1=list(map(int,input().strip().split()))[:2]
n,m=list1[0],list1[1]
arr=list(map(int,input().strip().split()))[:n]
dict1={}
for i in range(m):
	l=list(map(int,input().strip().split()))[:2]
	key,val=l[0],l[1]
	if key in dict1:
		dict1[key].append(val)
	else:
		dict1[key]=[]
		dict1[key].append(val)
	if val in dict1:
		dict1[val].append(key)
	else:
		dict1[val]=[]
		dict1[val].append(key)
count=0
for i in range(1,n+1):
	flag=0
	if i in dict1:
		l=arr[i-1]
		for j in dict1[i]:
			if(l <= arr[j-1]):
				flag=1
				break
	if(flag==0):
		count+=1
print(count)
Buggy code:
h = [int(x) for x in 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
	if h[b-1] >= h[a-1]:
		l[a-1] = 0
print(sum(l))

Fixed code:
n, m = map(int, input().split())
h = [int(x) for x in 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
	if h[b-1] >= h[a-1]:
		l[a-1] = 0
print(sum(l))
Buggy code:
import sys
import numpy as np
from math import ceil as C, floor as F, sqrt
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
 
ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

_, e = I()
hs = Is()

obs = sorted([(i, h) for i, h in enumerate(hs, 1)], key=lambda x:x[1], reverse=True)
seen = D(bool)

roads = D(set)
for _ in range(e):
  a, b = I()
  roads[a].add(b)
  roads[b].add(a)
  
ans = 0
for ob in obs:
  if not seen[ob[0]]:
    if all(ob[1] > hs[r] for r in roads[ob[0]]):
      ans += 1
    seen[ob[0]] = True
    for r in roads[ob[0]]:
      seen[r] = True
      
print(ans)

Fixed code:
import sys
import numpy as np
from math import ceil as C, floor as F, sqrt
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
 
ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

_, e = I()
hs = Is()

obs = sorted([(i, h) for i, h in enumerate(hs, 1)], key=lambda x:x[1], reverse=True)
seen = D(bool)

roads = D(set)
for _ in range(e):
  a, b = I()
  roads[a].add(b)
  roads[b].add(a)
  
ans = 0
for ob in obs:
  if not seen[ob[0]]:
    if all(ob[1] > hs[r-1] for r in roads[ob[0]]):
      ans += 1
    seen[ob[0]] = True
    for r in roads[ob[0]]:
      seen[r] = True
      
print(ans)
Buggy code:
n,m=map(int,input().split())
h=list(map(int,input().split()))
road=[list(map(int,input().split())) for i in range(m)]

dp=[1 for i in range(n)]
for i in range(m):
    if h[road[i][0]-1]>h[road[i][1]-1]:
        dp[road[i][1]-1]*=0
    else:
        dp[road[i][0]-1]*=0
ans=0
for i in range(n):
    if dp[i]>0:
        ans+=1
print(ans)

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

dp=[1 for i in range(n)]
for i in range(m):
    if h[road[i][0]-1]>=h[road[i][1]-1]:
        dp[road[i][1]-1]=0
    if h[road[i][0]-1]<=h[road[i][1]-1]:
        dp[road[i][0]-1]=0
ans=0
for i in range(n):
    if dp[i]>0:
        ans+=1
print(ans)
Buggy code:
def i():
    return int(input())
def i2():
    return map(int,input().split())
def s():
    return str(input())
def l():
    return list(input())
def intl():
    return list(int(k) for k in input().split())

n,m=i2()
h=intl()
cnt=0
score=0
l=[[] for i in range(n)]
for j in range(m):
	a,b=i2()
	l[a-1].append(b-1)
	l[b-1].append(a-1)
for j in range(n):
	for k in l[j]:
		if h[j]>k:
			cnt+=1
			if cnt==len(l[j]):
				score+=1
	cnt=0
for i in range(m):
	if len(l[i])==0:
		score+=1
print(score)


Fixed code:
def i():
    return int(input())
def i2():
    return map(int,input().split())
def s():
    return str(input())
def l():
    return list(input())
def intl():
    return list(int(k) for k in input().split())

n,m=i2()
h=intl()
cnt=0
score=0
l=[[] for i in range(n)]
for j in range(m):
	a,b=i2()
	l[a-1].append(b-1)
	l[b-1].append(a-1)
for j in range(n):
	for k in l[j]:
		if h[j]>h[k]:
			cnt+=1
			if cnt==len(l[j]):
				score+=1
	cnt=0
for i in range(n):
	if len(l[i])==0:
		score+=1
print(score)
Buggy code:
n, m = map(int, input().split())
h = list(input().split())
l = [0] * n

for i in range(0, int(m)):
    a, b = map(int, input().split())
    a_int = int(h[int(a)-1])
    b_int = int(h[int(b)-1])

    if (a_int < b_int):
        l[b_int - 1] = 1
       
cnt = 0
for k in range(0, len(l)):
    if(l[k]==1):
        cnt+=1

print(cnt)

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

for i in range(0, int(m)):
    a, b = map(int, input().split())
    a_int = int(h[int(a)-1])
    b_int = int(h[int(b)-1])

    if (a_int < b_int):
        l[a - 1] = 0
    
    if (a_int > b_int):
        l[b - 1] = 0
    
    if (l[a-1] == 1):
        if (a_int == b_int):
            l[a - 1] = 0
            l[b - 1] = 0
    elif (l[b-1] == 1):
        if (a_int == b_int):
            l[a - 1] = 0
            l[b - 1] = 0 
       
cnt = 0
for k in range(0, len(l)):
    if(l[k]==1):
        cnt+=1

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

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

ans = [1]*N

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

print(sum(ans))

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

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

ans = [1] * N

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

print(sum(ans))
Buggy code:
N,M = [int(x) for x in input().split()]
P = dict([(i,True) for i in range(1,N+1)])
H = [0] + [int(x) for x in input().split()]
for m in range(M):
    A,B = [int(x) for x in input().split()]
    if H[A] >= H[B]:
        P[B] = False
    if H[B] >= H[A]:
        P[A] = False

print(P)
print(sum(list(P.values())))

Fixed code:
N,M = [int(x) for x in input().split()]
P = dict([(i,True) for i in range(1,N+1)])
H = [0] + [int(x) for x in input().split()]
for m in range(M):
    A,B = [int(x) for x in input().split()]
    if H[A] >= H[B]:
        P[B] = False
    if H[B] >= H[A]:
        P[A] = False

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

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

for i in range(m):
    road[i] = list(map(int, input().split()))

for j in range(m):
    if H[road[j][0]-1] <= H[road[j][1]-1]:
        ans[road[j][0]-1] = 1

total = sum(ans)
print(n-total)

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

for i in range(m):
    road[i] = list(map(int, input().split()))

for j in range(m):
    if H[road[j][0]-1] < H[road[j][1]-1]:
        ans[road[j][0]-1] = 1
    elif H[road[j][0]-1] > H[road[j][1]-1]:
        ans[road[j][1]-1] = 1
    elif H[road[j][0]-1] == H[road[j][1]-1]:
        ans[road[j][0]-1] = 1
        ans[road[j][1]-1] = 1

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

print(h2.count(0))

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

print(h2.count(0))
Buggy code:
n,m=list(map(int,input().split()))
h=list(map(int,input().split()))
b=[[]for i in range(n)]
for i in range(m):
  a=list(map(lambda x:int(x)-1,input().split()))
  b[a[0]].append(a[1])
  b[a[1]].append(a[0])
s=0
for i in range(n):
  f=1
  for j in b[i]:
    if h[i]<=h[j]:
      f=0
      break
  if f:
    s+=1

Fixed code:
n,m=list(map(int,input().split()))
h=list(map(int,input().split()))
b=[[]for i in range(n)]
for i in range(m):
  a=list(map(lambda x:int(x)-1,input().split()))
  b[a[0]].append(a[1])
  b[a[1]].append(a[0])
s=0
for i in range(n):
  f=1
  for j in b[i]:
    if h[i]<=h[j]:
      f=0
      break
  if f:
    s+=1
print(s)
Buggy code:
n, m = map(int, input().split())
list_height = list(map(int, input().split()))
list_way = []
list_goodpoint = [1]*n
for i in range(m):
  list_way.append(list(map(int, input().split())))

for way in list_way:
  if way[0] == way[1]:
    list_goodpoint[way[0]-1] = 0
    list_goodpoint[way[1]-1] = 0
  if way[0] > way[1]:
    list_goodpoint[way[1]-1] = 0
  if way[0] < way[1]:
    list_goodpoint[way[0]-1] = 0
print(sum(list_goodpoint))

Fixed code:
n, m = map(int, input().split())
list_height = list(map(int, input().split()))
list_way = []
list_goodpoint = [1]*n
for i in range(m):
  list_way.append(list(map(int, input().split())))

for way in list_way:
  if list_height[way[0]-1] == list_height[way[1]-1]:
    list_goodpoint[way[0]-1] = 0
    list_goodpoint[way[1]-1] = 0
  if list_height[way[0]-1] > list_height[way[1]-1]:
    list_goodpoint[way[1]-1] = 0
  if list_height[way[0]-1] < list_height[way[1]-1]:
    list_goodpoint[way[0]-1] = 0
print(sum(list_goodpoint))
Buggy 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[a - 1] = 0
    elif h[b - 1] <= h[a - 1]:
        l[b - 1] = 0
        
print(sum(l))

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[a - 1] = 0
    if h[b - 1] <= h[a - 1]:
        l[b - 1] = 0

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

gooddict={i:1 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]:  
    gooddict[a]=0
  if h[a-1]>=h[b-1]:
    gooddict[b]=0

count=0
for i in range(1,n+1):
  if gooddict[i]==1:
    count+=1
print(count)
print(gooddict)

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

gooddict={i:1 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]:  
    gooddict[a]=0
  if h[a-1]>=h[b-1]:
    gooddict[b]=0

count=0
for i in range(1,n+1):
  if gooddict[i]==1:
    count+=1
print(count)
Buggy code:
h=list(map(int,input().split()))
x=[[] for _ in range(n+1)]
for i in range(m):
  a,b=map(int,input().split())
  x[a].append(h[b-1])
  x[b].append(h[a-1])
count=0
for j in range(1,n+1):
  if x[j]==[]:
    count+=1
  else:
    if h[j-1]>max(x[j]):
      count+=1
print(count)
  

Fixed code:
n,m=map(int,input().split())
h=list(map(int,input().split()))
x=[[] for _ in range(n+1)]
for i in range(m):
  a,b=map(int,input().split())
  x[a].append(h[b-1])
  x[b].append(h[a-1])
count=0
for j in range(1,n+1):
  if x[j]==[]:
    count+=1
  else:
    if h[j-1]>max(x[j]):
      count+=1
print(count)
Buggy code:
n,m = map(int, input().split())
h_list = list(map(int, input().split()))
for i in range(m):
    a, b = map(int, input().split())
    if h_list[a-1] < h_list[b-1]:
        h_list[a-1] = 0
    elif h_list[a-1] > h_list[b-1]:
        h_list[b-1] = 0
    else:
        h_list[a-1] = 0
        h_list[b-1] = 0
print(n - h_list.count(0))

Fixed code:
n,m = map(int, input().split())
h_list = list(map(int, input().split()))
newlist = list(h_list)
for i in range(m):
    a, b = map(int, input().split())
    if h_list[a-1] < h_list[b-1]:
        newlist[a-1] = 0
    elif h_list[a-1] > h_list[b-1]:
        newlist[b-1] = 0
    else:
        newlist[a-1] = 0
        newlist[b-1] = 0
print(len(h_list) - newlist.count(0))
Buggy code:
# -*- coding: utf-8 -*-
def main():
    N,M = map(int, input().split())
    H = list(map(int, input().split()))
    ans = []
    for _ in range(N):
        ans.append(1)
    for i in range(M):
        A,B = map(int, input().split())
        if H[A-1] < H[B-1]:
            ans[A-1] = -1
        elif H[A-1] > H[B-1]:
            ans[B-1] = 0
        else:
            ans[B-1] = 0
            ans[A-1] = 0
    print(sum(ans))

if __name__ == '__main__':
    main()

Fixed code:
# -*- coding: utf-8 -*-
def main():
    N,M = map(int, input().split())
    H = list(map(int, input().split()))
    #print(H)
    ans = []
    ansn = 0
    for _ in range(N):
        ans.append(0)
    for i in range(M):
        A,B = map(int, input().split())
        if H[A-1] < H[B-1]:
            ans[A-1] = -1
        elif H[A-1] > H[B-1]:
            ans[B-1] = -1
        else:
            ans[B-1] = -1
            ans[A-1] = -1
    for j in ans:
        if j == 0:
            ansn += 1
    #print(ansn, ans)
    print(ansn)

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

J=[0]*N
for i in range(M):
    if H[AB[i][0]-1]<H[AB[i][1]-1]:
        J[AB[i][0]]+=1
    else:
        J[AB[i][1]]+=1
c=0
for i in J:
    if i == 0:
        c+=1

print(c)


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

J=[0]*N
for i in range(M):
    if H[AB[i][0]-1]<H[AB[i][1]-1]:
        J[AB[i][0]-1]+=1
    elif H[AB[i][0]-1]==H[AB[i][1]-1]:
        J[AB[i][0]-1]+=1
        J[AB[i][1]-1]+=1    
    else:
        J[AB[i][1]-1]+=1
c=0
for i in J:
    if i == 0:
        c+=1

print(c)
Buggy code:
N, M = [int(x) for x in input().split(" ")]
H = [int(x) for x in input().split(" ")]
lines = [[] for i in range(N)]

for _ in range(M):
    a, b = [int(x) for x in input().split(" ")]
    lines[a-1].append(b-1)
    lines[b-1].append(a-1)

good_observatory_num = 0
for n in range(N):
    if len(lines[n]) == 0:
        good_observatory_num += 1
    else:
        is_good = True
        for oh in lines[n]:
            if oh >= H[n]:
                is_good = False
        
        if is_good:
            good_observatory_num += 1

print(good_observatory_num)

Fixed code:
N, M = [int(x) for x in input().split(" ")]
H = [int(x) for x in input().split(" ")]
lines = [[] for i in range(N)]

for _ in range(M):
    a, b = [int(x) for x in input().split(" ")]
    lines[a-1].append(b-1)
    lines[b-1].append(a-1)

judged = []
for n in range(N):
    if len(lines[n]) == 0:
        judged.append(True)
    else:
        is_good = True
        for oh in lines[n]:
            if H[oh] >= H[n]:
                is_good = False
        judged.append(is_good)
        

print(sum(judged))
Buggy code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]
ans = [1]*n
for i in range(m):
    if h[ab[i][0]-1] == h[ab[i][1]-1]:
        ans[ab[i][0]-1] = 0
        ans[ab[i][1]-1] = 0
    elif h[ab[i][0]-1] > h[ab[i][1]]:
        ans[ab[i][1]-1] = 0
    else:
        ans[ab[i][0]-1] = 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 _ in range(m)]
ans = [1]*n
for i in range(m):
    if h[ab[i][0]-1] == h[ab[i][1]-1]:
        ans[ab[i][0]-1] = 0
        ans[ab[i][1]-1] = 0
    elif h[ab[i][0]-1] > h[ab[i][1]-1]:
        ans[ab[i][1]-1] = 0
    else:
        ans[ab[i][0]-1] = 0
print(sum(ans))
Buggy code:
import math
import sys

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

lis = [0] * N  


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

    hightA = H[A-1]
    hightB = H[B-1]

    if hightA < hightB:
        if lis[B-1] == 0:
            lis[B-1] = 1
            lis[A-1] = -1
        
        elif lis[B-1] == 1 or lis[B-1] == -1:
            lis[A-1] = -1
    
    if hightB < hightA:
        if lis[A-1] == 0:
            lis[A-1] = 1
            lis[B-1] = -1
        
        elif lis[A-1] == 1 or lis[A-1] == -1:
            lis[B-1] = -1

    if hightB == hightA:
        lis[A-1] = -1
        lis[B-1] = -1

print(lis)

Fixed code:
import math
import sys

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

lis = [0] * N  


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

    hightA = H[A-1]
    hightB = H[B-1]

    if hightA < hightB:
        if lis[B-1] == 0:
            lis[B-1] = 1
            lis[A-1] = -1
        
        elif lis[B-1] == 1 or lis[B-1] == -1:
            lis[A-1] = -1
    
    if hightB < hightA:
        if lis[A-1] == 0:
            lis[A-1] = 1
            lis[B-1] = -1
        
        elif lis[A-1] == 1 or lis[A-1] == -1:
            lis[B-1] = -1

    if hightB == hightA:
        lis[A-1] = -1
        lis[B-1] = -1

ans = 0
for i in lis:
  if i == 0 or i == 1:
    ans = ans + 1

print(ans)
Buggy code:
n,m = map(int,input().split())
hlist = list(map(int,input().split()))
ten = []
append = ten.append
for i in range(n):
    append(1)
#print(ten)
for i in range(m):
    a,b = map(int,input().split())
    if hlist[a-1] > hlist[b-1]:
        ten[b-1] = 0
    elif hlist[b-1] > hlist[a-1]:
        ten[a-1] = 0

print(sum(ten))  

Fixed code:
n,m = map(int,input().split())
hlist = list(map(int,input().split()))
ten = []
append = ten.append
for i in range(n):
    append(1)
#print(ten)
for i in range(m):
    a,b = map(int,input().split())
    if hlist[a-1] > hlist[b-1]:
        ten[b-1] = 0
    elif hlist[b-1] > hlist[a-1]:
        ten[a-1] = 0
    elif hlist[b-1] == hlist[a-1]:
        ten[a-1] = 0
        ten[b-1] = 0


print(sum(ten))
Buggy code:
N,M=map(int, input().split())
yoi = []
for i in range(N):
  yoi.append(True)
H=list(map(int, input().split()))
for i in ranage(M):
  A,B=map(int, input().split())
  if H[A-1]<=H[B-1]: yoi[A-1]=False
  if H[B-1]<=H[A-1]: yoi[B-1]=False 
print(len([1 for x in yoi if x==True]))

Fixed code:
N,M=map(int, input().split())
yoi = []
for i in range(N):
  yoi.append(True)
H=list(map(int, input().split()))
for i in range(M):
  A,B=map(int, input().split())
  if H[A-1]<=H[B-1]: yoi[A-1]=False
  if H[B-1]<=H[A-1]: yoi[B-1]=False 
print(len([1 for x in yoi if x==True]))
Buggy code:
N,M=map(int,input().split())
H=list(map(int,input().split()))
A,B=[0]*M,[0]*M
for i in range(M):
  A[i],B[i]=map(int,input().split())
print(A)
lst=[1]*N
for i in range(M):
  if H[A[i]-1]<H[B[i]-1]:
    lst[A[i]-1]=0
  if H[A[i]-1]>H[B[i]-1]:
    lst[B[i]-1]=0
  print(lst)
print(sum(lst))

Fixed code:
N,M=map(int,input().split())
H=list(map(int,input().split()))
A,B=[0]*M,[0]*M
for i in range(M):
  A[i],B[i]=map(int,input().split())
lst=[1]*N
for i in range(M):
  if H[A[i]-1]<=H[B[i]-1]:
    lst[A[i]-1]=0
  if H[A[i]-1]>=H[B[i]-1]:
    lst[B[i]-1]=0
print(sum(lst))
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())
  A=h[a-1]
  B=h[b-1]
  z=min(A,B)
  if z==A:
    x[a-1]=0
  else:
    x[b-1]=0
  
print(sum(x))

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())
  A=h[a-1]
  B=h[b-1]
  if A!=B:
    z=min(A,B)
    if z==A:
       x[a-1]=0
    else:
       x[b-1]=0
  else:
    x[a-1]=0
    x[b-1]=0
  
print(sum(x))
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)]

tf_array = [0]*N

for a, b in AB:
    print(a,b)
    if H[a-1] > H[b-1]:
        tf_array[b-1] += 1
    elif H[a-1] == H[b-1]:
        tf_array[a-1] += 1
        tf_array[b-1] += 1
    else:
        tf_array[a-1] += 1

print(tf_array.count(0))

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

tf_array = [0]*N

for a, b in AB:
    if H[a-1] > H[b-1]:
        tf_array[b-1] += 1
    elif H[a-1] == H[b-1]:
        tf_array[a-1] += 1
        tf_array[b-1] += 1
    else:
        tf_array[a-1] += 1

print(tf_array.count(0))
Buggy code:


n,m = map(int,input().split())

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

# a = [0] * m
# b = [0] * m

ma = [0]*n


for i in range(m):
    a, b = map(int,input().split())
    a -= 1; b -= 1
    ma[a] = max(ma[a],h[b])
    ma[b] = max(ma[b],h[a])

int ans = 0    
for i in range(n):
    ans += h[i] > ma[i]
        

print(ans)

Fixed code:


n,m = map(int,input().split())

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

# a = [0] * m
# b = [0] * m

ma = [0]*n


for i in range(m):
    a, b = map(int,input().split())
    a -= 1; b -= 1
    ma[a] = max(ma[a],h[b])
    ma[b] = max(ma[b],h[a])

ans = 0    
for i in range(n):
    if h[i] > ma[i]:
        ans += 1
        

print(ans)
Buggy code:
n,m=list(map(int, input().split()))
h=list(map(int, input().split()))
p=[]
remain = set(range(1, n+1))
for i in range(m):
    p.append(list(map(int, input().split())))
temp = []
for a,b in p:
    temp.append([b,a])
p = p + temp
for a,b in p:
    if h[a-1]<=h[b-1]:
        remain -= set(a)
print(len(remain))

Fixed code:
n,m=list(map(int, input().split()))
h=list(map(int, input().split()))
p=[]
remain = set(range(1, n+1))
for i in range(m):
    p.append(list(map(int, input().split())))
temp = []
for a,b in p:
    temp.append([b,a])
p = p + temp
delset = set()
for a,b in p:
    if h[a-1]<=h[b-1]:
        #remain = remain - set([a])
        delset.add(a)
remain = remain - delset
print(len(remain))