Problem p02689 (python)

Fixed submission:
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 submission (verdict: Runtime Error):
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()

Buggy submission (verdict: Runtime Error):
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()

Buggy submission (verdict: Runtime Error):
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 submission (verdict: Runtime Error):
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))

Buggy submission (verdict: Runtime Error):
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()

Buggy submission (verdict: Runtime Error):
#include <iostream>
#include <vector>
#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;
}

Buggy submission (verdict: Runtime Error):
#include <iostream>
#include <vector>
#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;
}