qyliang/CodeNanoFix huggingface dataset:
Buggy code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
ma = [0]*(n)
for i in range(n):
  a,b = map(lambda x: int(x)-1,input().split())
  ma[a] = max(ma[a], h[b])
  ma[b] = max(h[a], ma[b])
ans = 0
for i in range(n):
  if h[i]>ma[i]:
    ans+=1
print(ans)

Fixed code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
ma = [0]*(n)
for i in range(m):
  a,b = map(lambda x: int(x)-1,input().split())
  ma[a] = max(ma[a], h[b])
  ma[b] = max(h[a], ma[b])
ans = 0
for i in range(n):
  if h[i]>ma[i]:
    ans+=1
print(ans)
Buggy code:
i = input()
i = i.split(' ')
l = []
while len(l)<int(i[0]):
  l += [0]

lim = int(i[1])

i = input()
i = i.split(' ')
for j in list(range(len(l))):
    i[j]=int(i[j])
print(i)

count=0
while count<lim:
    count += 1
    k = input()
    k = k.split(' ')
    if i[int(k[0])-1]==i[int(k[1])-1]:
        l[int(k[1])-1] = 1
        l[int(k[0])-1] = 1
    elif i[int(k[0])-1]>i[int(k[1])-1]:
        l[int(k[1])-1] = 1
    else:
        l[int(k[0])-1] = 1

count = 0
for j in l:
    if j==0:
        count += 1
print(count)
  


Fixed code:
i = input()
i = i.split(' ')
l = []
while len(l)<int(i[0]):
  l += [0]

lim = int(i[1])

i = input()
i = i.split(' ')
for j in list(range(len(l))):
    i[j]=int(i[j])


count=0
while count<lim:
    count += 1
    k = input()
    k = k.split(' ')
    if i[int(k[0])-1]==i[int(k[1])-1]:
        l[int(k[1])-1] = 1
        l[int(k[0])-1] = 1
    elif i[int(k[0])-1]>i[int(k[1])-1]:
        l[int(k[1])-1] = 1
    else:
        l[int(k[0])-1] = 1

count = 0
for j in l:
    if j==0:
        count += 1
print(count)
Buggy 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 int(H_tree[A])>=int(H_tree[B]):
    GOOD_Tree[A] = 0
  if int(H_tree[A])<=int(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 = 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(" ")))
    a,b = a-1,b-1

    if h[a] < h[b]:
        ans[a] = 0
    elif h[b] < h[a]:
        ans[b] = 0
    else:
        ans[a] = 0
        ans[b] = 0

print(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(" ")))
    a,b = a-1,b-1

    if h[a] < h[b]:
        ans[a] = 0
    elif h[b] < h[a]:
        ans[b] = 0
    else:
        ans[a] = 0
        ans[b] = 0

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

Fixed code:
n,m=map(int,input().split(" "))
h=list(map(int,input().split(" ")))
g=[1]*n
for i in range(m):
  r=list(map(int,input().split(" ")))
  if h[r[0]-1]<=h[r[1]-1]:
    g[r[0]-1]*=0
  if h[r[0]-1]>=h[r[1]-1]:
    g[r[1]-1]*=0
    
print(sum(g))
Buggy code:
def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    S = [list(map(int, input(_).split())) for _ in range(M)]
    LIST = [1] * N
    for A, B in S:
        if H[A-1] > H[B-1]: LIST[B-1] = 0
        elif H[A-1] < H[B-1]: LIST[A-1] = 0
        elif H[A-1] == H[B-1]:
            LIST[B - 1] = 0
            LIST[A - 1] = 0
    print(sum(LIST))


main()

Fixed code:
def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
#    S = [list(map(int, input(_).split())) for _ in range(M)]
    #LIST = [1] * N
    LIST = [ 1 for _ in range(N)]
    for _ in range(M):
        A, B = map(int, input().split())
        if H[A-1] >= H[B-1]: LIST[B-1] = 0
        if H[A-1] <= H[B-1]: LIST[A-1] = 0
    print(sum(LIST))

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

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
    elif h[b-1]>h[a-1]:
        ans[a-1] = 0
    else:
        #print("a")
        ans[a-1] = 0
        ans[b-1] = 0
print(ans.count(1))
Buggy code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n, m = LI()
    h = LI()
    ab = LIR_(m)
    ans = [1] * n
    for a, b in ab:
        if h[a] < h[b]:
            ans[a] = 0
        if h[b] < h[a]:
            ans[b] = 0
    print(sum(ans))
    return


#main
if __name__ == '__main__':
    solve()


Fixed code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n, m = LI()
    h = LI()
    ab = LIR_(m)
    ans = [1] * n
    for a, b in ab:
        if h[a] < h[b]:
            ans[a] = 0
        if h[b] < h[a]:
            ans[b] = 0
        if h[b] == h[a]:
            ans[a] = 0
            ans[b] = 0
    print(sum(ans))
    return


#main
if __name__ == '__main__':
    solve()
Buggy code:
n, m = map(int, input().split())
H = list(map(int, input().split()))
A = [0]*n
for i in range(m):
    a, b = map(int, input().split())
    A[a-1] = max(A[a-1], H[b-1])
    A[b-1] = max(A[b-1], H[a-1])
ans = 0
for i in range(n):
    if H[i] > A[i]:
        ans += 1
print(H)
print(A)
print(ans)

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

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

print(x)


Fixed code:
n,m=map(int,input().split())
H=list(map(int,input().split()))
c=[0]*n
for i in range(m):
    a,b=map(int,input().split())
    if H[a-1]<H[b-1]:
        c[a-1]+=1
    elif H[b-1]<H[a-1]:
        c[b-1]+=1
    else:
        c[b-1]+=1
        c[a-1]+=1
x=0
for y in c:
    if y==0:
        x+=1

print(x)
Buggy code:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    N, M = lr()
    H = lr()
    road = [-1]*N
    for i in range(M):
        a, b = lr()
        mab = max(H[a-1], H[b-1])
        road[a-1] = max(mab, road[a-1])
        road[b-1] = max(mab, road[b-1])
    ans = 0
    for i in range(N):
        if road[i] == H[i] or road[i] == -1:
            ans += 1
    print(ans)
resolve()

Fixed code:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    N, M = lr()
    H = lr()
    road = [-1]*N
    for i in range(M):
        a, b = lr()
        mab = max(H[a-1], H[b-1])
        if H[a-1] == H[b-1]:
            road[a-1] = float('inf')
            road[b-1] = float('inf')
        else:
            road[a-1] = max(mab, road[a-1])
            road[b-1] = max(mab, road[b-1])
    ans = 0
    for i in range(N):
        if road[i] == H[i] or road[i] == -1:
            ans += 1
    print(ans)
resolve()
Buggy code:
n,m=map(int,input().split())
height=list(map(int,input().split()))
hoge=[1 for i in range(n)]
for i in  range(m):
  a,b=map(int,input().split())
  if(height[a-1]>height[b-1]):
    hoge[a-1]=0
  elif(height[a-1]<height[b-1]):
    hoge[b-1]=0
print(sum(hoge))


Fixed code:
n,m=map(int,input().split())
height=list(map(int,input().split()))
hoge=[1 for i in range(n)]
#print(hoge)
for i in  range(m):
  a,b=map(int,input().split())
  #print(a,b,height[a-1],height[b-1])
  if(height[a-1]>height[b-1]):
    hoge[b-1]=0
  elif(height[a-1]<height[b-1]):
    hoge[a-1]=0
  else:
    hoge[a-1],hoge[b-1]=0,0
    
print(sum(hoge))
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())
  g[a-1].append(b-1); g[b-1].append(a-1)

ans = 0
for i in range(N):
  neighbors = g[i]
  h = H[i]
  res = True
  for node in neighbors:
    res *= h > H[node]
  if(res):
    print(i+1)
  ans += res

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())
  g[a-1].append(b-1); g[b-1].append(a-1)

ans = 0
for i in range(N):
  neighbors = g[i]
  h = H[i]
  res = True
  for node in neighbors:
    res *= h > H[node]
  ans += res

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

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

print(l)
  
c = 0
for j in range(n):
  if len(l[j]) == 0:
    c += 1
  else:
    m = 0
    for k in l[j]:
      if h[j] <= h[k]:
        m = 1
        break
    if m == 0:

      c += 1
      
print(c)
  

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

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

c = 0
for j in range(n):
  if len(l[j]) == 0:
    c += 1
  else:
    m = 0
    for k in l[j]:
      if h[j] <= h[k]:
        m = 1
        break
    if m == 0:

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

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

print(ans.count(1))

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(ans.count(1))
Buggy code:
"""
~~ author : dokueki
~~ created : 10~05~2020
"""

import sys
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)-1
sys.setrecursionlimit(10**7)
mod = 1000000007


def IOE():
    sys.stdin = open("input.txt", "r")
    sys.stdout = open("output.txt", "w")


def main():
    n, m = map(int, sys.stdin.readline().split())
    h = list(map(int, sys.stdin.readline().split()))
    ans = [True]*n
    for i in range(m):
        a, b = map(int, sys.stdin.readline().split())
        a -= 1
        b -= 1
        if h[a] <= h[b]:
            ans[a] = False
        else:
            ans[b] = False
    print(sum(ans))


if __name__ == "__main__":
    try:
        IOE()
    except:
        pass
    main()


Fixed code:
"""
~~ author : dokueki
~~ created : 10~05~2020
"""

import sys
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)-1
sys.setrecursionlimit(10**7)
mod = 1000000007


def IOE():
    sys.stdin = open("input.txt", "r")
    sys.stdout = open("output.txt", "w")


def main():
    n, m = map(int, sys.stdin.readline().split())
    h = list(map(int, sys.stdin.readline().split()))
    ans = [True]*n
    for i in range(m):
        a, b = map(int, sys.stdin.readline().split())
        a -= 1
        b -= 1
        if h[a] < h[b]:
            ans[a] = False
        elif h[a] > h[b]:
            ans[b] = False
        else:
            ans[a], ans[b] = False, False
    print(sum(ans))


if __name__ == "__main__":
    try:
        IOE()
    except:
        pass
    main()
Buggy code:
## C
N, M = map( int, input().split() )
H = [0] + list(map(int, input().split()) )
X = [[] for x in range(N+1)]
for i in range(M):
    A, B = map(int, input().split())
    X[A].append(H[B])
    X[B].append(H[A])
rt = 0
for i in range(1, N+1):
    if H[i] > max(X[i]):
        rt += 1
print(rt)

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

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

count = 0
for j in range(n):
    if target[j] == win[j]:
        count += 1

print(count)

Fixed code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
target = [0 for _ in range(n)]
win = [0 for _ in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    target[a-1] += 1
    target[b-1] += 1
    if h[a-1] > h[b-1]:
        win[a-1] += 1
    elif h[b-1] > h[a-1]:
        win[b-1] += 1

count = 0
for j in range(n):
    if target[j] == win[j]:
        count += 1

print(count)
Buggy code:
#ABC166d
N, M = map(int,input().split())
H = list(map(int, input().split()))
count=[0]*M
A = [0]*M
B = [0]*M

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

ans = [1]*N

for i in range(N):
    if H[A[i]-1] == H[B[i]-1]:
        ans[A[i]-1] = 0
        ans[B[i]-1] = 0
    elif H[A[i]-1] > H[B[i]-1]:
        ans[B[i]-1] = 0
    elif H[A[i]-1] < H[B[i]-1]:
        ans[A[i]-1] = 0
print(sum(ans))


Fixed code:
#ABC166d
N, M = map(int,input().split())
H = list(map(int, input().split()))
count=[0]*M
A = [0]*M
B = [0]*M

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

ans = [1]*N

for i in range(M):
    if H[A[i]-1] == H[B[i]-1]:
        ans[A[i]-1] = 0
        ans[B[i]-1] = 0
    elif H[A[i]-1] > H[B[i]-1]:
        ans[B[i]-1] = 0
    elif H[A[i]-1] < H[B[i]-1]:
        ans[A[i]-1] = 0
print(sum(ans))
Buggy code:
n,m = map(int,input().split())
h = [int(x) for x in input().split()]
a = [0] * m
b = [0] * m
for i in range(m):
    a[i],b[i] = map(int,input().split())
ind = []
for i in range(m):
    if h[a[i]-1] < h[b[i]-1]:
        ind.append(a[i])
    elif h[a[i]-1] == h[b[i]-1]:
        ind.append(a[i])
        ind.append(b[i])
    else:
        ind.append(b[i])
ind2 = [0] * n
for i in range(n):
    ind2[ind[i]-1] += 1
ans = 0
for i in range(n):
    if ind2[i] == 0:
        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
for i in range(m):
    a[i],b[i] = map(int,input().split())
ind = []
for i in range(m):
    if h[a[i]-1] < h[b[i]-1]:
        ind.append(a[i])
    elif h[a[i]-1] == h[b[i]-1]:
        ind.append(a[i])
        ind.append(b[i])
    else:
        ind.append(b[i])
ind2 = [0] * n
for i in range(len(ind)):
    ind2[ind[i]-1] += 1
ans = 0
for i in range(n):
    if ind2[i] == 0:
        ans += 1
print(ans)
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[A-1] +=1
    elif h[B-1] < h[A-1]:
      l[B-1] +=1
print(n-l.count(0))


Fixed code:
n, m = map(int, input().split()) 
h = list(map(int, input().split()))
l = [0]*n
for i in range(m):
    A, B= map(int, input().split())
    if h[A-1] < h[B-1]:
      l[A-1] +=1
    elif h[B-1] < h[A-1]:
      l[B-1] +=1
    else:
      l[A-1] +=1
      l[B-1] +=1
print(l.count(0))
Buggy code:
#!python3

# input
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]


def main():
    link = [[] for _ in range(N)]
    for a, b in AB:
        link[a - 1].append(b - 1)
        link[b - 1].append(a - 1)

    ans = N
    for i in range(N):
        for x in link[i]:
            if H[i] <= H[x]:
                print(i, H[i], x, H[x])
                ans -= 1
                break
    
    print(ans)


if __name__ == "__main__":
    main()


Fixed code:
#!python3

# input
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]


def main():
    link = [[] for _ in range(N)]
    for a, b in AB:
        link[a - 1].append(b - 1)
        link[b - 1].append(a - 1)

    ans = N
    for i in range(N):
        for x in link[i]:
            if H[i] <= H[x]:
                ans -= 1
                break
    
    print(ans)


if __name__ == "__main__":
    main()
Buggy code:
N, M = map(int, input().split())
H = input().split()
ans = [1] * N

print(H)
for i in range(M):
    a, b = map(int, input().split())
    AH = int(H[a - 1])
    BH = int(H[b - 1])
    if AH >= BH:
        ans[b - 1] = 0
    elif BH >= AH:
        ans[a - 1] = 0


print(ans.count(1))


Fixed code:
N, M = map(int, input().split())
H = [int(h) for h in input().split()]
ans = [1] * N


# print(H)

for i in range(M):
    a, b = map(int, input().split())
    AH = H[a - 1]
    BH = H[b - 1]
    # print(AH, BH)
    if AH >= BH:
        ans[b - 1] = 0
    if BH >= AH:
        ans[a - 1] = 0


print(ans.count(1))
Buggy code:
n,m = map(int,input().split(' '))
h = list(map(int,input().split(' ')))
ansList = [1]*n
numlist = []

for i in range(m):
    a,b = map(int, input().split())
    if h[a-1] > h[b-1]:
        #ansList[a-1] = ma
        numlist.append(b-1)
    else:
        numlist.append(a-1)
for i in list(set(numlist)):
    ansList[i] = 0
print(ansList.count(1))

print(set(numlist))
print(ansList)

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

for i in range(m):
    a,b = map(int, input().split())
    if h[a-1] > h[b-1]:
        #ansList[a-1] = ma
        numlist.append(b-1)
    elif h[a-1] == h[b-1]:
        numlist.append(a-1)
        numlist.append(b-1)
    else:
        numlist.append(a-1)
for i in list(set(numlist)):
    ansList[i] = 0
print(ansList.count(1))
Buggy code:

def solve():
  n, m = map(int, input().split())
  h = list(map(int, input().split()))
  tenbo = []
  ans = 0
  bit = [0]*n
  for i in range(m):
    tenbo.append(list(map(int, input().split())))
  hoge = [[] for i in range(n)]
  for i in range(m):
    hoge[tenbo[i][0]-1].append(tenbo[i][1]-1)
    hoge[tenbo[i][1]-1].append(tenbo[i][0]-1)
  for i in range(n):
    if len(hoge[i]) == 0:
      ans += 1
    for j in hoge[i]:
      if h[i] <= h[j]:
        bit[i] = 1
        break
  print(bit.count(1)+ans)
  return 0

 
if __name__ == "__main__":
  solve()


Fixed code:
def solve():
  n, m = map(int, input().split())
  h = list(map(int, input().split()))
  tenbo = []
  ans = 0
  bit = [0]*n
  for i in range(m):
    tenbo.append(list(map(int, input().split())))
  hoge = [[] for i in range(n)]
  for i in range(m):
    hoge[tenbo[i][0]-1].append(tenbo[i][1]-1)
    hoge[tenbo[i][1]-1].append(tenbo[i][0]-1)
  for i in range(n):
    for j in hoge[i]:
      if h[i] <= h[j]:
        bit[i] = 1
        break
  print(bit.count(0))
  return 0

 
if __name__ == "__main__":
  solve()
Buggy code:
N,M = map(int,input().split())
H = list(map(int,input().split()))

x = [True] * N

for _ in range(M):
	a,b = map(int,input().split())
	if H[a - 1] >= H[b - 1]:
		x[a - 1] = False
	if H[b - 1] >= H[a - 1]:
		x[a - 1] = False
print(len([i for i in x if i == True]))

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

x = [True] * N

for _ in range(M):
	a,b = map(int,input().split())
	if H[a - 1] >= H[b - 1]:
		x[b - 1] = False
	if H[b - 1] >= H[a - 1]:
		x[a - 1] = False
print(len([i for i in x if i == True]))
Buggy code:
N, r = map(int, input().split())
hs = list(map(int, input().split()))
g = [1]*N
for i in range(r):
    road = list(map(int, input().split()))
    if hs[road[0] - 1] > hs[road[1] - 1]:
        g[road[1] - 1] = 0
    else:
        g[road[0] - 1] = 0
print(sum(g))


Fixed code:
N, r = map(int, input().split())
hs = list(map(int, input().split()))
g = [1]*N
for i in range(r):
    road = list(map(int, input().split()))
    if hs[road[0] - 1] >= hs[road[1] - 1]:
        g[road[1] - 1] = 0
    if hs[road[0] - 1] <= hs[road[1] - 1]:
        g[road[0] - 1] = 0
print(sum(g))
Buggy code:
N,M = (int(i) for i in input().split())
table = [1 for _ in range(N)]
h = list(map(int, input().split()))
for _ in range(M):
  u,v = (int(i) for i in input().split())
  u-=1
  v-=1
  if h[u]!=h[v]:
    if h[u]>h[v]:
      table[u] = 1*table[u]
      table[v] = 0*table[v]
    else:
      table[u] = 0*table[u]
      table[v] = 1*table[v]
  else:
    h[u] = 0
    h[v] = 0

ans = sum(table)
print(ans)

Fixed code:
N,M = (int(i) for i in input().split())
table = [1 for _ in range(N)]
h = list(map(int, input().split()))
for _ in range(M):
  u,v = (int(i) for i in input().split())
  u-=1
  v-=1
  if h[u]==h[v]:
    table[u] = 0
    table[v] = 0
  else:
    if h[u]>h[v]:
      table[v] = 0
    if h[v]>h[u]:
      table[u] = 0

ans = sum(table)
print(ans)
Buggy code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
c=0
deg=[[] for i in range(n)]
for i in range(m):
  u,v=map(int,input().split())
  deg[u-1].append(v-1)
  deg[v-1].append(u-1)
for i in range(n):
  ff=0
  for j in deg[i]:
    if(a[i]>a[deg[i][j]]):
      continue
    ff=1
  if(ff==0):
    c+=1
print(c)

Fixed code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
c=0
deg=[[] for i in range(n)]
for i in range(m):
  u,v=map(int,input().split())
  deg[u-1].append(v-1)
  deg[v-1].append(u-1)
for i in range(n):
  ff=0
  for j in deg[i]:
    if(a[i]>a[j]):
      continue
    ff=1
  if(ff==0):
    c+=1
print(c)