Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = int(input())
re = 0
for i in range(n):
    a = list(input().split())
    if a[0] == '1':
        re = 1 if re==0 else 0
    else:
        if a[1] == '1':
            s = a[2]+s if re==0 else s+a[2]
        else:
            s = a[2]+s if re==1 else s+a[2]
if re == 1:
    s = s[::-1]
print(s)

Fixed submission:
from collections import deque
s = deque(input())
n = int(input())
re = 0
st = ''
en = ''
for i in range(n):
    a = list(input().split())
    if a[0]=='1':
        re = 1 if re==0 else 0
    else:
        if a[1]=='1':
            if re==0:
                s.appendleft(a[2])
            else:
                s.append(a[2])
        else:
            if re==0:
                s.append(a[2])
            else:
                s.appendleft(a[2])
if re==1:
    s.reverse()
res = list(s)
print(''.join(res))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
s = deque(input())
n = int(input())
for _ in range(n):
    a = input()
    if len(a) != 1:
        b = list(a.split())
        if b[1] == '2':
            s.append(b[2])
        else:
            s.appendleft(b[2])
    else:
        s.reverse()
else:
    print(''.join(s))
            


        

Fixed submission:
from collections import deque
s = deque(input())
n = int(input())
re = 0
st = ''
en = ''
for i in range(n):
    a = list(input().split())
    if a[0]=='1':
        re = 1 if re==0 else 0
    else:
        if a[1]=='1':
            if re==0:
                s.appendleft(a[2])
            else:
                s.append(a[2])
        else:
            if re==0:
                s.append(a[2])
            else:
                s.appendleft(a[2])
if re==1:
    s.reverse()
res = list(s)
print(''.join(res))
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
W = sorted(list(map(int,input().split())),reverse=True)
if N<=K:
    print(0)
for i in range(K):
    W[i] = 0
print(sum(W))

Fixed submission:
N,K = map(int,input().split())
W = sorted(list(map(int,input().split())),reverse=True)
if N<=K:
    print(0)
else:
    for i in range(K):
        W[i] = 0
    print(sum(W))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int,input().split()))
pp = list()
pp.append(p[0])
cnt=1
for i in range(1,n):
    min_pp = min(pp)
    if p[i] <= min_pp:
        cnt +=1
    pp.append(p[i])
print(cnt)

Fixed submission:
n = int(input())
p = list(map(int,input().split()))
min_p = p[0]
cnt=1
for i in range(1,n):
    if p[i] <= min_p:
        min_p = p[i]
        cnt +=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(input())
cnt =0
for i in range(n-2):
  if S[i] =="A":
    if S[i+1] =="B":
      if S[i+2] == "C":
        cnt +=1
print(cnt)

Fixed submission:
N = int(input())
S = list(input())
cnt =0
for i in range(N-2):
  if S[i] =="A":
    if S[i+1] =="B":
      if S[i+2] == "C":
        cnt +=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
A,B,K=input().split(" ")
if K<=A:
  A -= K
  print(str(A)+" "+str(B))
else:
  A = 0
  B -= K - A
  print(str(A)+" "+str(B))

Fixed submission:
A,B,K = input().split(" ")
A = int(A)
B = int(B)
K = int(K)

if K>=A:
  K -=A
  A = 0
  if K>=B:
    B = 0
  else:
    B -=K
else:
  A -=K
print(A,B)

Buggy python submission (verdict: Runtime Error):
A,B,K=input().split(" ")
if K<=A:
  A -= K
  print(str(A),str(B))
else:
  A = 0
  B -= K - A
  print(str(A),str(B))
  

Fixed submission:
A,B,K = input().split(" ")
A = int(A)
B = int(B)
K = int(K)

if K>=A:
  K -=A
  A = 0
  if K>=B:
    B = 0
  else:
    B -=K
else:
  A -=K
print(A,B)
Buggy python submission (verdict: Runtime Error):
X = input()
X = int(X)

while True:
  for x in range(2, n):
    if n % p == 0:
      break
  else:
    print(x)
    break
  x +=1

Fixed submission:
x = int(input())
while True:
    for i in range(2,x):
        if x%i==0:
            break
    else:
        print(x)
        break
    x +=1
Buggy python submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
diff = abs(a-b)

if diff%2==0:
  print(diff//2)
else :
  print(min(A - 1, N - B) + 1 + diff // 2)
  

Fixed submission:
n,a,b = map(int,input().split())
diff = abs(a-b)
 
if diff%2==0:
  print(diff//2)
else :
  print(min(a - 1, n - b) + 1 + diff // 2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
S = input()
cnt=0
for i in range(1000):
    x = str(i).zfill(3)
    j=0
    for s in S:
        if x[j]==s:
            j+=1
            if j==3:
                cnt+=1
                break
print(cnt)

Fixed submission:
n = int(input())
S = input()
cnt=0
for i in range(10):
    x=S.find(str(i),0,n-2)
    if x!=-1:
        for j in range(10):
            y=S.find(str(j),x+1,n-1)
            if y!=-1:
                for k in range(10):
                    z=S.find(str(k),y+1,n)
                    if z!=-1:
                        cnt+=1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
S = input()
cnt=0
for i in range(1000):
    x = str(i).zfill(3)
    k=0
    j=0
    while j<3 and k<n:
        if x[j] in S[k]:
            if j==2:
                cnt+=1
                break
            else:
                j+=1
                k+=1
        else:
            k+=1
print(cnt)

Fixed submission:
n = int(input())
S = input()
cnt=0
for i in range(10):
    x=S.find(str(i),0,n-2)
    if x!=-1:
        for j in range(10):
            y=S.find(str(j),x+1,n-1)
            if y!=-1:
                for k in range(10):
                    z=S.find(str(k),y+1,n)
                    if z!=-1:
                        cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
import math
a,b,x = map(int,input().split())
tan = a**3/(2*(a**2*b-x))
if tan<=(a/b):
    tan = 2*x/(b**2*a)
rad = math.atan(tan)
deg= 90- (rad * 180/math.pi)
print(deg)

Fixed submission:
import math
import sys
a,b,x = map(int,input().split())
if a*a*b == x:
    print(0)
    sys.exit()
tan = a**3/(2*(a**2*b-x))
if tan<=(a/b):
    tan = 2*x/(b**2*a)
rad = math.atan(tan)
deg= 90- (rad * 180/math.pi)
print(deg)

Buggy python submission (verdict: Runtime Error):
import math
a,b,x = map(int,input().split())
tan = a**3/(2*(a**2*b-x))
if tan<=(a/b):
    tan = 2*x/(b**2*a)
rad = math.atan(tan)
deg= 90-math.degrees(rad)
print(deg)

Fixed submission:
import math
import sys
a,b,x = map(int,input().split())
if a*a*b == x:
    print(0)
    sys.exit()
tan = a**3/(2*(a**2*b-x))
if tan<=(a/b):
    tan = 2*x/(b**2*a)
rad = math.atan(tan)
deg= 90- (rad * 180/math.pi)
print(deg)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
L = list(map(int,input().split()))

def tri_judge(a,b,c):
    if a<b+c and b<c+a and c<a+b:
        return 1
    else:
        return 0
cnt = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        check = L[i]+L[j]
        for k in range(j+1,n):
            if check>L[k]:
                if(tri_judge(L[i],L[j],L[k])):
                    cnt += 1
print(cnt)

Fixed submission:
import bisect
N = int(input())
L = sorted(list(map(int,input().split())))
cnt = 0
for i in range(N):
    for j in range(i+1,N):
        cnt += bisect.bisect_left(L,L[i]+L[j])-(j+1)
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))

res = list()
for rank in range(1,n+1):
    for i,v in enumerate(a):
        if v == rank:
            res.append(i+1)

res2 = [str(k) for k in res]
res2 = " ".join(res2)
print(res2)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = [0] * N
for i, a in enumerate(A):
    ans[a-1] = i+1
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
a = list(map(int,input().split()))
while m>0:
    a[a.index(max(a))] //=2
    m-=1
print(sum(a))

Fixed submission:
import heapq
n,m = map(int,input().split())
a = list(map(int,input().split()))
a = list(map(lambda x:x*(-1),a))
heapq.heapify(a)
while m>0:
    ma = heapq.heappop(a)*(-1)
    ma //=2
    heapq.heappush(a,ma*(-1))
    m-=1
print(sum(a)*(-1))

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)
while a[0]>0 and m>0:
    a[0]=a[0]//2
    a.sort(reverse=True)
    m-=1
print(sum(a))

Fixed submission:
import heapq
n,m = map(int,input().split())
a = list(map(int,input().split()))
a = list(map(lambda x:x*(-1),a))
heapq.heapify(a)
while m>0:
    ma = heapq.heappop(a)*(-1)
    ma //=2
    heapq.heappush(a,ma*(-1))
    m-=1
print(sum(a)*(-1))
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
A = list(map(int,input().split()))
B = A*k
lA = len(A)
lB = len(B)
mod=10**9+7
cnt1=0
for i in range(lA):
    for j in range(i+1,lA):
        if A[i] > A[j]:
            cnt1+=1
cnt2=0
for i in range(lA):
    for j in range(lA):
        if A[i] > A[j]:
            cnt2+=1
print((cnt1*k+cnt2*(k*(k-1)//2))%mod)

Fixed submission:
n,k=map(int,input().split())
A = list(map(int,input().split()))
lA = len(A)
mod=10**9+7
cnt1=0
for i in range(lA):
    for j in range(i+1,lA):
        if A[i] > A[j]:
            cnt1+=1
cnt2=0
for i in range(lA):
    for j in range(lA):
        if A[i] > A[j]:
            cnt2+=1
print((cnt1*k+cnt2*(k*(k-1)//2))%mod)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a = list(map(int,input().split()))
B = a*k
lB = len(B)
mod=10**9+7
cnt=0
for i in range(lB):
    for j in range(i+1,lB):
        if B[i] > B[j]:
            cnt+=1
print(cnt%mod)

Fixed submission:
n,k=map(int,input().split())
A = list(map(int,input().split()))
lA = len(A)
mod=10**9+7
cnt1=0
for i in range(lA):
    for j in range(i+1,lA):
        if A[i] > A[j]:
            cnt1+=1
cnt2=0
for i in range(lA):
    for j in range(lA):
        if A[i] > A[j]:
            cnt2+=1
print((cnt1*k+cnt2*(k*(k-1)//2))%mod)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
st = list()
for i in range(n):
    st.append(list(input()))
    st[i].sort()
cnt =0
for i in range(n-1):
    for j in range(i+1,n):
        if st[i] == st[j]:
            cnt +=1
print(cnt)

Fixed submission:
n = int(input())
st = dict()
cnt = 0
for i in range(n):
    stx="".join(sorted(list(input())))
    if stx not in st:
        st[stx] = 0
    else:
        st[stx] +=1
        cnt += st[stx]
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = [int(input()) for _ in range(n)]
B = A[:]
max_A = max(A)
for i in range(n):
    if A[i] == max_A:
        B[i] = 0
        print(max(B))
        B[i] = max_A
    else:
        print(max_A)

Fixed submission:
n = int(input())
A = [int(input()) for _ in range(n)]
B = A[:]
B.sort(reverse = True)
max_A = max(A)
for i in range(n):
    if A[i] == max_A:
        print(B[1])
    else:
        print(max_A)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list()
for i in range(n):
    A.append(int(input()))

for i in range(n):
    B = [x for x in A]
    B[i] = 0
    print(max(B))

Fixed submission:
n = int(input())
A = [int(input()) for _ in range(n)]
B = A[:]
B.sort(reverse = True)
max_A = max(A)
for i in range(n):
    if A[i] == max_A:
        print(B[1])
    else:
        print(max_A)
Buggy python submission (verdict: Time Limit Exceeded):
l,r = map(int,input().split())
if r-l<1:
    print(0)
else:
    res = 2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            res = min((i*j)%2019,res)
    print(res)

Fixed submission:
l,r = map(int,input().split())
if r-l>=2019:
    print(0)
else:
    res = 2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            res = min((i*j)%2019,res)
    print(res)

Buggy python submission (verdict: Time Limit Exceeded):
l,r = map(int,input().split())
if r-l<1:
    print(0)
else:
    con = list()
    for i in range(l,r):
        for j in range(i+1,r+1):
            con.append((i*j)%2019)
    print(min(con))

Fixed submission:
l,r = map(int,input().split())
if r-l>=2019:
    print(0)
else:
    res = 2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            res = min((i*j)%2019,res)
    print(res)
Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d = map(int,input().split())
def calc(n,x,y):
    cnt = n // x
    cnt += n//y
    lcm = x*y//math.gcd(x,y)
    cnt -= int(n//lcm)
    return n - cnt

print(calc(b,c,d)-calc(a-1,c,d))


Fixed submission:
import fractions
a,b,c,d = map(int,input().split())
def calc(n,x,y):
    cnt = n // x
    cnt += n//y
    lcm = x*y//fractions.gcd(x,y)
    cnt -= n//lcm
    return n - cnt

print(calc(b,c,d)-calc(a-1,c,d))

Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d = map(int,input().split())
def calc(n,x,y):
    cnt = n // x
    cnt += n//y
    lcm = x*y//math.gcd(x,y)
    cnt -= n//lcm
    return n - cnt

print(calc(b,c,d)-calc(a-1,c,d))


Fixed submission:
import fractions
a,b,c,d = map(int,input().split())
def calc(n,x,y):
    cnt = n // x
    cnt += n//y
    lcm = x*y//fractions.gcd(x,y)
    cnt -= n//lcm
    return n - cnt

print(calc(b,c,d)-calc(a-1,c,d))
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
xx = [int(input()) for _ in range(m)]
mod = 10**9+7
dp = [1]*(n+1)
for i in range(m):
    dp[int(input())] =0

for i in range(2,n+1):
    if dp[i]!=0:
        dp[i]=dp[i-1]+dp[i-2]

print(dp[n]%mod)


Fixed submission:
n,m = map(int,input().split())
mod = 10**9+7
dp = [1]*(n+1)
for i in range(m):
    dp[int(input())] =0

for i in range(2,n+1):
    if dp[i]!=0:
        dp[i]=dp[i-1]+dp[i-2]

print(dp[n]%mod)

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
xx = [int(input()) for _ in range(m)]

f = [0]*(n+3)
f[0] = 1
endf = 0
for i in range(1,n+1):
    if i in xx:
        endf += 1
        if endf ==2:
            print(0)
            break
        continue
    else :
        if endf == 1:
            endf = 0
            f[i] = f[i-2]
        else :
            endf = 0
            f[i] = f[i-1] + f[i-2]
else:
    print(f[n]%1000000007)

Fixed submission:
n,m = map(int,input().split())
mod = 10**9+7
dp = [1]*(n+1)
for i in range(m):
    dp[int(input())] =0

for i in range(2,n+1):
    if dp[i]!=0:
        dp[i]=dp[i-1]+dp[i-2]

print(dp[n]%mod)
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
a = list(map(int,input().split()))
import heapq
heapq.heapify(a)
BC=[list(map(int,input().split())) for _ in range(m)]
for i in range(m):
    while BC[i][0]>0:
        if BC[i][1] > a[0]:
            minA = heapq.heappop(a)
            heapq.heappush(a,BC[i][1])
            BC[i][0] -=1
        else:
            break
print(sum(a))

Fixed submission:
n,m = map(int,input().split())
a = list(map(int,input().split()))
import heapq
heapq.heapify(a)
BC=[list(map(int,input().split())) for _ in range(m)]
BC.sort(reverse=True,key=lambda x:x[1])
for i in range(m):
    while BC[i][0]>0:
        if BC[i][1] > a[0]:
            minA = heapq.heappop(a)
            heapq.heappush(a,BC[i][1])
            BC[i][0] -=1
        else:
            break
print(sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
a = list(map(int,input().split()))
import heapq
heapq.heapify(a)
for i in range(m):
    b,c=map(int,input().split())
    while b>0:
        if c > a[0]:
            minA = heapq.heappop(a)
            heapq.heappush(a,c)
            b -=1
        else:
            break
print(sum(a))

Fixed submission:
n,m = map(int,input().split())
a = list(map(int,input().split()))
import heapq
heapq.heapify(a)
BC=[list(map(int,input().split())) for _ in range(m)]
BC.sort(reverse=True,key=lambda x:x[1])
for i in range(m):
    while BC[i][0]>0:
        if BC[i][1] > a[0]:
            minA = heapq.heappop(a)
            heapq.heappush(a,BC[i][1])
            BC[i][0] -=1
        else:
            break
print(sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for _ in range(5)]
ch = [0]*6
ch[0] = n
cnt = 0
while ch[5]!=n:
    ch2 = [0]*5
    for i in range(5):
        ch2[i] = min(ch[i],a[i])
    for i in range(5):
        ch[i] -= ch2[i]
        ch[i+1] += ch2[i]
    cnt+=1
print(cnt)

Fixed submission:
n = int(input())
a = [int(input()) for _ in range(5)]
print(-(-n//min(a))+4)
Buggy python submission (verdict: Runtime Error):
import numpy as np
import math
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.append(x)
a.sort()
d = np.diff(a)
if n>1:
    gcd = math.gcd(d[0],d[1])
    if n>3:
        for i in range(2,n-1):
            gcd = math.gcd(gcd,d[i])
    print(gcd)
else:
    print(d[0])

Fixed submission:
import numpy as np
import fractions
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.append(x)
a.sort()
d = np.diff(a)
if n>1:
    gcd = fractions.gcd(d[0],d[1])
    if n>3:
        for i in range(2,n-1):
            gcd = fractions.gcd(gcd,d[i])
    print(gcd)
else:
    print(d[0])
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
if n==1 and m==1:
    print(1)
elif n==1 or M==1:
    print(n*m-2)
else:
    print((m-2)*(n-2))


Fixed submission:
n,m=map(int,input().split())
if n==1 and m==1:
    print(1)
elif n==1 or m==1:
    print(n*m-2)
else:
    print((m-2)*(n-2))
Buggy python submission (verdict: Time Limit Exceeded):
n,Y = map(int,input().split())
for x in range(min(-(-Y//10000)+1,n+1)):
    for y in range(min(-(-Y//5000)+1,n+1)):
        for z in range(min(-(-Y//1000)+1,n+1)):
            if x+y+z==n and x*10000+y*5000+z*1000==Y:
                print(x,y,z)
                exit()
else:
    print(-1,-1,-1)

Fixed submission:
n,Y = map(int,input().split())
for z in range(n+1):
    for y in range(n-z+1):
        if 0<=n-z-y<=2000 and (n-z-y)*10000+y*5000+z*1000==Y:
            print(n-z-y,y,z)
            exit()
else:
    print(-1,-1,-1)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
s = input()
t = input()
s2=list(itertools.permutations(s))
t2 = list(itertools.permutations(t))
s3 = [''.join(x) for x in s2]
t3 = [''.join(x) for x in t2]
for s in s3:
    for t in t3:
        if s<t:
            print('Yes')
            exit()
else:
    print('No')

Fixed submission:
s = list(input())
t = list(input())
s.sort()
s2 = ''.join(s)
t.sort(reverse=True)
t2=''.join(t)
print('Yes') if s2<t2 else print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
b = []
for i in range(n):
    b.append(a[i])
    b = b[::-1]
print(*b)

Fixed submission:
from collections import deque
n = int(input())
a = list(map(int,input().split()))
b = deque([])
for i in range(n):
    if i%2==0:
        b.appendleft(a[i])
    else:
        b.append(a[i])
else:
    if n%2==0:
        b = list(b)
        b = b[::-1]
print(*b)
Buggy python submission (verdict: Time Limit Exceeded):
n,a,b = map(int,input().split())
A = [x for x in range(a,b+1)]
minA = a*(n-1)+b
maxA = b*(n-1)+a
print(max(maxA-minA+1,0))

Fixed submission:
n,a,b = map(int,input().split())
minA = a*(n-1)+b
maxA = b*(n-1)+a
print(max(maxA-minA+1,0))
Buggy python submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import sympy
import math
mod = 10**9+7
n = int(read())
cnt = sympy.divisor_count(math.factorial(n))
print(cnt%mod)

Fixed submission:
import math
mod = 10**9+7
n = int(input())
n = math.factorial(n)
ans = 1
i = 2
while i*i<=n:
    cnt = 1
    while n % i == 0:
        cnt += 1
        n //= i
    i = i + 1
    ans = ans*cnt

if n != 1:
    ans = ans*2
print(ans%mod)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))
MAX_RSESULT = 1000000000000000000

result = 1
for ai in a:
    result *= ai
if result <= MAX_RSESULT:
    print(result)
else:
    print(-1)


Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))
MAX_RSESULT = 1000000000000000000

result = 1
a.sort(reverse=True)

if a[-1]==0:
    result = 0
else:
    for ai in a:
        result *= ai
        if result > MAX_RSESULT:
            result = -1
            break
print(result)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
h = list(map(int, input().split()))
h_cond = [True]*n
count = 0

for i in range(m):
    tmp_a, tmp_b = map(int, input().split())
    if h[tmp_a-1] < h[tmp_b-1]:
        h_cond[tmp_a-1] = False
    elif h[tmp_a-1] > h[tmp_b-1]:
        h_cond[tmp_b-1] = False
    else:
        h_cond[tmp_a - 1] = False
        h_cond[tmp_b - 1] = False

# print(h_cond)
# print(route)
for idx, hi in enumerate(route):
    if h_cond[idx]:
        count += 1

print(count)


Fixed submission:
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
h = list(map(int, input().split()))
h_cond = [True]*n
count = 0

for i in range(m):
    tmp_a, tmp_b = map(int, input().split())
    if h[tmp_a-1] < h[tmp_b-1]:
        h_cond[tmp_a-1] = False
    elif h[tmp_a-1] > h[tmp_b-1]:
        h_cond[tmp_b-1] = False
    else:
        h_cond[tmp_a - 1] = False
        h_cond[tmp_b - 1] = False

# print(h_cond)
# print(route)
for idx, hi in enumerate(h_cond):
    if h_cond[idx]:
        count += 1

print(count)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
a = [0]*k
has_k = [False]*n
count = 0

for i in range(k):
    tmp_d = int(input())
    tmp_a = list(map(int, input().split()))
    for ai in tmp_a:
        has_k[ai-1] = True

for ki in has_k:
    if ki == False:
        count += 1

print(count)


Fixed submission:
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
h = list(map(int, input().split()))
h_cond = [True]*n
count = 0

for i in range(m):
    tmp_a, tmp_b = map(int, input().split())
    if h[tmp_a-1] < h[tmp_b-1]:
        h_cond[tmp_a-1] = False
    elif h[tmp_a-1] > h[tmp_b-1]:
        h_cond[tmp_b-1] = False
    else:
        h_cond[tmp_a - 1] = False
        h_cond[tmp_b - 1] = False

# print(h_cond)
# print(route)
for idx, hi in enumerate(h_cond):
    if h_cond[idx]:
        count += 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(n):
    if p[i] <= min(p[:i+1]):
        count += 1
print(count)


Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())
p = list(map(int, input().split()))
count = 0
tmp_min = n
for pi in p:
    if pi < tmp_min:
        tmp_min = pi
    if pi <= tmp_min:
        count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
n = int(input())
l = list(map(int, input().split()))
l.sort()
total = 0
result = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            total += 1
            if l[k] < l[i] + l[j]:
                result +=1
            else:
                break
print(result)


Fixed submission:
# -*- coding: utf-8 -*-
import bisect
n = int(input())
l = list(map(int, input().split()))
l.sort()
result = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        tmp = l[i] + l[j]
        ind = bisect.bisect_left(l, tmp)
        result += (ind-j-1)
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
n = int(input())
l = list(map(int, input().split()))
l.sort()
total = 0
result = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            if l[k] < l[i] + l[j]:
                result +=1
            total += 1
print(result)


Fixed submission:
# -*- coding: utf-8 -*-
import bisect
n = int(input())
l = list(map(int, input().split()))
l.sort()
result = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        tmp = l[i] + l[j]
        ind = bisect.bisect_left(l, tmp)
        result += (ind-j-1)
print(result)