Problem: There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i. There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j.  Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road. Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road.  How many good observatories are there?

Submission attempts (in order):
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
    else if(s[a] == s[b]):
      cs[a]=-1
      cs[b]=-1
    else:
      cs[b]=-1
  print(cs.count(-1))
      
if __name__ == '__main__':
  main()

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

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



#include <map>
#include <cstdlib>
#include <algorithm>
using namespace std;
 
int main() {
  int n,m;
  int cnt=0;
  cin >> n >> m;
  
  vector<int> v,x;

  int a,b;
  for(int i = 0; i < n; ++i) {
    cin >> a;
    v.push_back(a);
  }
  x = v;
  
  for(int i = 0; i < m; ++i) {
    cin >> a >> b;
    a--;
    b--;
    if(v[a] < v[b]) x[a] = -1;
    else if(v[a] == v[b]) {
      x[a] = -1;
      x[b] = -1;
    }else x[b] = -1;
  }

  cout << v.size() - count(x.begin(), x.end(), -1) << "\n";
  return 0;
}



#include <map>
#include <cstdlib>
#include <algorithm>
using namespace std;
 
int main() {
  int n,m;
  int cnt=0;
  cin >> n >> m;
  
  vector<int> v,x;
 
  int a,b;
  for(int i = 0; i < n; ++i) {
    cin >> a;
    v.push_back(a);
  }
  x = v;
  
  for(int i = 0; i < m; ++i) {
    cin >> a >> b;
    a--;
    b--;
    if(v[a] < v[b]) {
      x[a] = -1;
    }
    else if(v[a] == v[b]) {
      x[a] = -1;
      x[b] = -1;
    }else if(x[b] < x[a]) {
      x[b] = -1;
    }
  }
 
  cout << v.size() - count(x.begin(), x.end(), -1) << "\n";
  return 0;
}

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'
    else if(s[a] == s[b]):
      cs[a]='1'
      cs[b]='1'
    else:
      cs[b]='1'
  print(cs.count('1'))
      
if __name__ == '__main__':
  main()

def main():
  n,m = map(int,input().split())
  s = list(map(int,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
    else if(s[a] == s[b]):
      cs[a]=-1
      cs[b]=-1
    else:
      cs[b]=-1
  print(cs.count(-1))
      
if __name__ == '__main__':
  main()

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(cs)
  print()
  print(len(cs)-cs.count(-1))
      
if __name__ == '__main__':
  main()

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

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Accepted