Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

K, S = map(int, input().split())

count = 0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x+y+z==S:
                count += 1

print(count)


### FIXED CODE ###

K, S = map(int, input().split())

count = 0
for x in range(K+1):
    for y in range(K+1):
        if 0 <= S-x-y <= K:
            count += 1

print(count)
### BUGGY CODE ###

N = input()
l = list(map(int,input().split()))
answer =[]
for i in range(len(l)):
    for j in range(i+1, len(l)):
        if l[i] == l[j]:
            answer.append("NO")
        else:
            answer.append("YES")
if "NO" in answer:
  print("NO")
else:
  print("YES")

### FIXED CODE ###

N=input()
l=list(map(int,input().split()))
if len(l)!=len(set(l)):
  print("NO")
else:
  print("YES")
### BUGGY CODE ###

from math import *

def gcd(x, y):
    while y != 0:
        (x, y) = (y, x % y)
    return x

n = int(input())
a = [int(x) for x in input().split()]

s = 1

for i in range(n):
    x = a[i]
    for z in range(2,int(sqrt(a[i])+1)):
        t = 1
        while(x%z==0):
            t *= z
            x /= z
        while(s%t != 0):
            s *= z
    if(x > 1 and s%x!=0):
        s *= x

k = 0
for i in a:
    k += s//i
    k %= (1000000000+7)

print(k%(1000000000+7))


### FIXED CODE ###

from math import *

def gcd(x, y):
    while y != 0:
        (x, y) = (y, x % y)
    return x

def lcm(x,y):
    return x*y//gcd(x,y)
n = int(input())
a = [int(x) for x in input().split()]

mod = 1000000000+7

k = 1
for x in a:
    k = lcm(k,x)

ans = 0

for x in a:
    ans += k//x

print(ans%mod)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
h,w = map(int, input().split())
sf = [input() for _ in range(h)]

def check(c1,c2):
    st = [(c1[0],c1[1],"#")]
    visited = [[False for _ in range(w)] for _ in range(h)]
    while len(st)>0:
        s = st.pop()
        visited[s[0]][s[1]] = True
        if s[0]==c2[0] and s[1]==c2[1]:
            return True
        for d in [[1,0],[0,1],[-1,0],[0,-1]]:
            dh = s[0]+d[0]
            dw = s[1]+d[1]
            if h>dh>=0 and w>dw>=0:
                if s[2]=="#" and sf[dh][dw]=="." and not visited[dh][dw]:
                    st.append((dh,dw,"."))
                elif s[2]=="." and sf[dh][dw]=="#" and not visited[dh][dw]:
                    st.append((dh,dw,"#"))
    return False

def candidate(hi,wi):
    for d in [[1,0],[0,1],[-1,0],[0,-1]]:
        dh = hi+d[0]
        dw = wi+d[1]
        if h>dh>=0 and w>dw>=0 and sf[hi][wi]!=sf[dh][dw]:
            return True
    return False

res = 0
for hi1 in range(h):
    for wi1 in range(w):
        if not candidate(hi1,wi1):
            continue
        if sf[hi1][wi1]==".":
            continue
        for hi2 in range(h):
            for wi2 in range(w):
                if hi1==hi2 and wi1==wi2:
                    continue
                if not candidate(hi2,wi2):
                    continue
                if sf[hi2][wi2]=="#":
                    continue

                # print("check",(hi1,wi1), (hi2,wi2))
                if check((hi1,wi1),(hi2,wi2)):
                    # print((hi1,wi1), (hi2,wi2))
                    res += 1

print(res)


### FIXED CODE ###

# -*- coding: utf-8 -*-
h,w = map(int, input().split())
sf = [input() for _ in range(h)]

def candidate(hi,wi):
    for d in [[1,0],[0,1],[-1,0],[0,-1]]:
        dh = hi+d[0]
        dw = wi+d[1]
        if h>dh>=0 and w>dw>=0 and sf[hi][wi]!=sf[dh][dw]:
            return True
    return False

csf = [[False for _ in range(w)] for _ in range(h)]
for hi in range(h):
    for wi in range(w):
        csf[hi][wi] = candidate(hi,wi)
res = 0
used = [[False for _ in range(w)] for _ in range(h)]
for hi in range(h):
    for wi in range(w):
        if used[hi][wi]:
            continue
        st = [(hi,wi,sf[hi][wi])]
        nb = 0
        nw = 0
        # print("===")
        while len(st)>0:
            s = st.pop()
            # print(s)
            if csf[s[0]][s[1]] and not used[s[0]][s[1]]:
                used[s[0]][s[1]] = True
                if s[2] == "#":
                    nb += 1
                else:
                    nw += 1
                for d in [[1,0],[0,1],[-1,0],[0,-1]]:
                    dh = s[0]+d[0]
                    dw = s[1]+d[1]
                    if h>dh>=0 and w>dw>=0 and csf[dh][dw] and not used[dh][dw] and sf[s[0]][s[1]]!=sf[dh][dw]:
                        st.append((dh,dw,sf[dh][dw]))
        res += nb*nw
print(res)
### BUGGY CODE ###

class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m = map(int, input().split())
p = list(map(int, input().split()))
union_find = UnionFind(n)
for _ in range(m):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    union_find.union(x, y)
res = 0
for root in union_find.roots():
    idx_set = set(union_find.members(root))
    ps_set = set([p[i]-1 for i in union_find.members(root)])
    res += len(idx_set-ps_set)
print(n-res)







### FIXED CODE ###

class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m = map(int, input().split())
p = list(map(int, input().split()))
union_find = UnionFind(n)
for _ in range(m):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    union_find.union(x, y)
res = 0
groups = {}
for i in range(n):
    x = union_find.find(i)
    if x not in groups:
        groups[x] = []
    groups[x].append(i)

for k, v in groups.items():
    idx_set = set(v)
    ps_set = set([p[i]-1 for i in v])
    res += len(idx_set-ps_set)
print(n-res)
### BUGGY CODE ###

#bit全探索する
INF = 5000

def dp(n, medichine, Ma, Mb):
    INF =  5000
    if n == 0: #終端
        List = [[0, 0, 0], medichine[n]]
        if medichine[n][0] * Mb == medichine[n][1] * Ma:
            cost = medichine[n][2]
        else:
            cost = INF
    else: #n-1をもとにnについて計算
        previous = dp(n-1, medichine, Ma, Mb)
        List = previous[0].copy()
        cost = previous[1]
        if medichine[n][2] < cost:
            for x in previous[0]:
                C = x[2] + medichine[n][2]
                if C > cost:
                    continue
                A = x[0] + medichine[n][0]
                B = x[1] + medichine[n][1]
                List.append([A, B, C])
                if A * Mb == B * Ma:
                    cost = C         
    return List, cost



N, Ma, Mb = map(int, input().split())
medichine = []
for i in range(N):
    Lst = [int(x) for x in input().split()]
    medichine.append(Lst)
ans = dp(N-1, medichine, Ma, Mb)
cost = ans[1]
if cost != INF:
    print(cost)
else:
    print(-1)

### FIXED CODE ###

import collections
import copy
INF = 10000

#入力
N, Ma, Mb = map(int, input().split())
medichine = [tuple(map(int, input().split())) for _ in range(N)]

dp = {}
#dp初期化
dp = collections.defaultdict(lambda:INF)
dp[0,0] = 0

for a, b, c in medichine:
    dp_ = copy.copy(dp)
    for ca,cb in dp.keys():
        dp_[ca+a, cb+b] = min(dp_[ca+a, cb+b], dp[ca,cb]+c)
    dp = dp_    

ans = INF
for ca,cb in dp.keys():
    if ca == cb == 0: continue
    if ca*Mb == cb*Ma:
        ans = min(ans, dp[ca,cb])
        
print(-1 if ans == INF else ans)
### BUGGY CODE ###

time=0
N=int(input())
p=[N,0,0,0,0,0]
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
while p[5]!=N:
  time=time+1
  for i in range(E):
    if p[4]!=0:
      p[4]=p[4]-1
      p[5]=p[5]+1
  for i in range(D):
    if p[3]!=0:
      p[3]=p[3]-1
      p[4]=p[4]+1
  for i in range(C):
    if p[2]!=0:
      p[2]=p[2]-1
      p[3]=p[3]+1
  for i in range(B):
    if p[1]!=0:
      p[1]=p[1]-1
      p[2]=p[2]+1
  for i in range(A):
    if p[0]!=0:
      p[0]=p[0]-1
      p[1]=p[1]+1
print(time)

### FIXED CODE ###

import math
N=int(input())
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
print(math.ceil(N/min(A,B,C,D,E))+4)
### BUGGY CODE ###

def main():
    N, K = list(map(int, input().split()))
    field = list(map(int, input().split()))

    dpList = [0] * N
    dpList[1] = abs(field[0] - field[1])

    for i in range(2, N):
        tmpList = []
        minCost = -1

        for j in range(max(0, i-K), i):
            cost = dpList[j] + abs(field[i] - field[j])

            if(minCost == -1):
                minCost = cost
            elif minCost > cost:
                minCost = cost

        dpList[i] = minCost

    print(dpList[-1])

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    N, K = list(map(int, input().split()))
    field = list(map(int, input().split()))

    dpList = [0] * N
    dpList[1] = abs(field[0] - field[1])

    for i in range(2, N):
        tmpList = []
        minCost = -1

        minS = max(0, i - K)

        for dpJ, fJ in zip(dpList[minS:i], field[minS:i]):
            cost = dpJ + abs(field[i] - fJ)

            if(minCost == -1):
                minCost = cost
            elif minCost > cost:
                minCost = cost

        dpList[i] = minCost

    print(dpList[-1])

if __name__ == "__main__":
    main()
### BUGGY CODE ###

n = int(input())
s = []
for i in range(n):
    s.append(int(input()))
max_s = -10**9
for i in range(n-1):
    R_i = s[i]
    s[i] = 0
    R_j = max(s)
    R = R_j - R_i
    if R > max_s:
        max_s = R

print(max_s)



### FIXED CODE ###

n = int(input())
s = []
for i in range(n):
    s.append(int(input()))
max_s = -10**9
min_s = s[0]
for i in range(1, n):
    max_s = max(max_s, s[i] - min_s)
    min_s = min(min_s, s[i])

print(max_s)
### BUGGY CODE ###

N=int(input())
S=input()
mod=10**9+7

#DP[i]#最後においた数の右にある残っている個数
rest=N-1
DP=[1]*(N)

for s in S:
    NDP=[0]*(N)
    if s=="<":
        for i in range(rest+1):
            if i>=1:
                NDP[i-1]=(DP[i]+NDP[i-1])%mod

        DP=NDP
        for i in range(N-2,-1,-1):
            DP[i]=(DP[i+1]+DP[i])%mod

    else:
        DP=[DP[rest-i] for i in range(N)]#左右逆にして考える

        #print(DP)
        for i in range(rest+1):
            if i>=1:
                NDP[i-1]=(DP[i]+NDP[i-1])%mod

        DP=NDP
        for i in range(N-2,-1,-1):
            DP[i]=(DP[i+1]+DP[i])%mod


        DP=[DP[rest-1-i] for i in range(N)]

    rest-=1
    #print(DP,rest)

print(DP[0])

### FIXED CODE ###

N=int(input())
S=input()
mod=10**9+7

#DP[i]#最後においた数の右にある残っている個数
rest=N-1
DP=[1]*(N)

for s in S:
    NDP=[0]*(N)
    if s=="<":
        for i in range(rest+1):
            if i>=1:
                NDP[i-1]=(DP[i]+NDP[i-1])%mod

        DP=NDP
        for i in range(N-2,-1,-1):
            DP[i]=(DP[i+1]+DP[i])%mod

    else:
        DP=[DP[rest-i] for i in range(N)]#左右逆にして考える

        #print(DP)
        for i in range(rest+1):
            if i>=1:
                NDP[i-1]=(DP[i]+NDP[i-1])%mod

        DP=NDP
        for i in range(N-2,-1,-1):
            DP[i]=(DP[i+1]+DP[i])%mod


        DP=[DP[rest-1-i] for i in range(N)]

    rest-=1
    #print(DP,rest)

print(DP[0])
### BUGGY CODE ###

K, S = map(int, input().split())
ans = 0 
for X in range(K + 1):
    for Y in range(K + 1):
        if X + Y > S:
            continue
        for Z in range(K + 1):
            if X + Y + Z == S:
                ans += 1
print(ans)

### FIXED CODE ###

K, S = map(int, input().split())
ans = 0 
for X in range(K+1):
    for Y in range(K+1):
        Z = S - X - Y
        if 0 <= Z and Z <= K:
            ans += 1
        
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import numpy as np

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

l = []
r = []
for i in range(m):
    ll, rr = map(int, input().split())
    l.append(ll)
    r.append(rr)

ans = 0

for i in range(1, n+1):
    for j in range(m):
        if l[j] > i or r[j] < i:
            break
        elif j == m-1:
            ans += 1

print(ans)

### FIXED CODE ###

# -*- coding: utf-8 -*-
# import numpy as np

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

l_min = 1
r_max = n+1

for i in range(m):
    l, r = map(int, input().split())
    l_min = max(l_min, l)
    r_max = min(r_max, r)

ans = r_max - l_min + 1
if ans > 0:
    print(ans)
else:
    print(0)
### BUGGY CODE ###

n = int(input())
for i in range(n):
  if (i+1) < 6:
    print(0)
  else:
    count=0
    for j in range(100):
      for k in range(100):
        c= ((j+1)+(k+1))**2-4*((j+1)**2+(k+1)**2+(j+1)*(k+1)-(i+1))
        
        if c > 0:
          z = -(j+k+2)+c**(1/2)
        if z.is_integer() and z%2 == 0 and z>0:
          count +=1
    print(count) 
     

### FIXED CODE ###

n = int(input())
ans = [0 for i in range(n)]


for i in range(100):
  for j in range(100):
    for k in range(100):
      a = (i+1)*(i+1) +(j+1)*(j+1) + (k+1)*(k+1) + (i+1)*(j+1) +(j+1)*(k+1) + (k+1)*(i+1)
      if a <= n:
        ans[a-1]+=1
for i in ans:
  print(i)
### BUGGY CODE ###

import heapq
N,M = map(int,input().split())
A = list(map(int,input().split()))
B = []
C = []
for _ in range(M):
    L_,R_ = map(int,input().split())
    B.append(L_)
    C.append(R_)
heapq.heapify(A)
for i in range(M):
    for j in range(B[i]):
        tmp = heapq.heappop(A)
        if tmp >= C[i]:
            heapq.heappush(A,tmp)
            break
        heapq.heappush(A,C[i])
print(sum(A))


### FIXED CODE ###

import heapq
N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for _ in range(M)]
BC = sorted(BC,key = lambda x:x[1],reverse=True)


heapq.heapify(A)
for i in range(M):
    for j in range(BC[i][0]):
        tmp = heapq.heappop(A)
        if tmp >= BC[i][1]:
            heapq.heappush(A,tmp)
            break
        heapq.heappush(A,BC[i][1])
print(sum(A))
### BUGGY CODE ###

from functools import lru_cache

N, K = map(int, input().split())
P = list(map(int, input().split()))


@lru_cache(maxsize=None)
def calc_exp(n: int):
    return sum(range(1, n + 1)) / n


len_sum = -1
max_len = None
for i in range(len(P)):
    if len(P[i:i + K]) == K:
        l = sum(P[i:i + K])
        if l > len_sum:
            max_len = P[i:i + K]
            len_sum = sum(max_len)

print(sum(map(calc_exp, max_len)))


### FIXED CODE ###

N, K = map(int, input().split())
P = list(map(int, input().split()))
P = list(map(lambda x: (x + 1) / 2, P))

s = sum(P[:K])
ans = [s]
for prev_a, next_a in zip(P, P[K:]):
    s -= prev_a
    s += next_a
    ans.append(s)
print(max(ans))
### BUGGY CODE ###

from collections import deque
import sys
input = sys.stdin.readline

f_inf = float('inf')

def push(v, d):
    if dist[v] != f_inf: return
    dist[v] = d
    que.append(v)

n, x, y = map(int, input().split())
x -= 1
y -= 1

ans = [0]*n
for sv in range(n):
    dist = [f_inf] * n
    que = deque([])
    push(sv, 0)

    while que:
        v = que.popleft()
        d = dist[v]+1
        if v-1 >= 0: push(v-1, d)
        if v+1 < n: push(v+1, d)
        if v == x: push(y, d)
        if v == y: push(x, d)

    for i in range(n):
        ans[dist[i]] += 1
        
for i in range(n):
    ans[i] = ans[i]//2

for i in range(1, n):
    print(ans[i])

### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline

f_inf = float('inf')

def push(v, d):
    if dist[v] != f_inf: return
    dist[v] = d
    que.append(v)

n, x, y = map(int, input().split())
x -= 1
y -= 1

ans = [0]*n
for sv in range(n):
    dist = [f_inf] * n
    que = deque([])
    push(sv, 0)

    while que:
        v = que.popleft()
        d = dist[v]+1
        if v-1 >= 0: push(v-1, d)
        if v+1 < n: push(v+1, d)
        if v == x: push(y, d)
        if v == y: push(x, d)

    for i in range(n):
        ans[dist[i]] += 1
        
for i in range(n):
    ans[i] = ans[i]//2

for i in range(1, n):
    print(ans[i])
### BUGGY CODE ###

S = str(input())
Q = int(input())
Qvery = [0]*Q
for i in range(Q):
    Qvery[i] = list(map(str,input().split()))
frontback = 1
for i in range(Q):
    if Qvery[i][0]=='1':
        frontback *= -1
        
    else:
        if Qvery[i][1]=='2':
            if frontback == 1:
                S = S + str(Qvery[i][2])
            else:
                S = str(Qvery[i][2]) + S
        else:
            if frontback == 1:
                S = str(Qvery[i][2]) + S
            else:
                S = S + str(Qvery[i][2])
if frontback == -1:
    S = S[::-1]
print(S)

### FIXED CODE ###

S = str(input())
Q = int(input())
Qvery = [0]*Q
for i in range(Q):
    Qvery[i] = list(map(str,input().split()))
frontback = 1
tail = ''
head = ''
for i in range(Q):
    if Qvery[i][0]=='1':
        frontback *= -1
        
    else:
        if Qvery[i][1]=='2':
            if frontback == 1:
                tail +=  str(Qvery[i][2])
            else:
                head = str(Qvery[i][2]) + head
        else:
            if frontback == 1:
                head = str(Qvery[i][2])+head
            else:
                tail += str(Qvery[i][2])
S = head + S + tail
if frontback == -1:
    S = S[::-1]
    
print(S)
### BUGGY CODE ###

import sys

def _sum_ob_divisors(n):
    L = [0] * (n + 1)
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            L[j] += j
    return sum(L)


def sum_ob_divisors(f):
    n = int(f.read())

    return _sum_ob_divisors(n)


def main():
    ans = sum_ob_divisors(sys.stdin.buffer)
    print(ans)


if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys

# import numpy as np

def _sum_ob_divisors(n):
    def f(n, x):
        y = n // x
        return y * (y + 1) * x // 2
    return sum(f(n, i) for i in range(1, n + 1))


# def _sum_ob_divisors(n):
#     L = [1] * (n + 1)
#     # L = np.ones(n + 1, dtype=np.int64)
#     for i in range(2, n + 1):
#         for j in range(i, n + 1, i):
#             L[j] += 1
#         # L[i:n + 1:i] += 1
#     # print(f'{L=}')
#     return sum(i * x for i, x in enumerate(L))


def sum_ob_divisors(f):
    n = int(f.read())

    return _sum_ob_divisors(n)


def main():
    ans = sum_ob_divisors(sys.stdin.buffer)
    print(ans)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

def main():
  t = int(input())
  for _ in range(t):
    a, b, c, d = map(int, input().split())
    if (a < b or d < b):
      print("No")
      continue
    if (c >= b):
      print("Yes")
      continue
  
    lst = []
    while True:
      a %= b
      if a > c:
        print("No")
        break
      if a in lst:
        print("Yes")
        break
      lst.append(a)
      a += d
main()

### FIXED CODE ###

def gcd(a, b):
    if b == 0:return a
    return gcd(b, a % b)

t = int(input())
for _ in range(t):
    a, b, c, d = map(int, input().split())
    #exception
    if a < b or d < b:
        print("No")
        continue

    if c >= b:
        print("Yes")
        continue

    g = gcd(d, b)
    print("Yes" if b - g + a % g <= c else "No")
### BUGGY CODE ###

import math
n = input()
m = int(n)

ans = 0
for i in range(m):
    for j in range(m):
        s = str(i + 1)
        t = str(j + 1)
        if s[0] == t[-1] and s[-1] == t[0]:
            ans += 1
            
            
print(ans)


### FIXED CODE ###

n = int(input())

d = [10 * [0] for _ in range(10)]

ans = 0
for i in range(1, n+1):
    s = str(i)
    if s[0] == "0" or s[-1] == "0": continue
    d[int(s[0])][int(s[-1])] += 1

for i in range(1, 10):
    for j in range(1, 10):
        ans += d[i][j] * d[j][i]
                  
print(ans)
### BUGGY CODE ###

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

def dp(cost):
    for x in range(N-1):
        for k in range(1,K+1):
            if x+k < N :
                tmp = cost[x] + abs(h[x] - h[x+k])
                cost[x+k] = min(tmp,cost[x+k])
            else:
                break
    return 0

def solve():
    cost = [float('inf')] * N
    cost[0] = 0
    dp(cost)
    print(cost[N-1])
    return 0

if __name__ == "__main__":
    solve()

### FIXED CODE ###

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

def dp(cost):
    for x in range(1,N):
        for k in range(max(x-K,0),x):
            cost[x] = min(cost[x] , cost[k] + abs( h[x] - h[k] ) )
        # cost[x] =  min( [ cost[k] + abs( h[x] - h[k] ) for k in range(max(x-K,0),x) ] ) 
    return 0

def solve():
    cost = [float('inf')] * N
    cost[0] = 0
    dp(cost)
    print(cost[N-1])
    return 0

if __name__ == "__main__":
    solve()
### BUGGY CODE ###

a,b=map(int,input().split())
h=[int(i) for i in input().split()]
ansl=[]
dic={i:0 for i in range(a)}
aans=[]
for i in range(b):
    c,d=map(int,input().split())
    if [c,d] in aans or [d,c] in aans:
      	c=c
    else:
        ch=h[c-1]
        dh=h[d-1]
        if ch==dh:
            if dic[c-1]==0:
                ansl.append(c-1)
                dic[c-1]+=1
            if dic[d-1]==0:
                ansl.append(d-1)
                dic[d-1]+=1
        else:
            if ch<dh:
                if dic[c-1]==0:
                    ansl.append(c-1)
                    dic[c-1]+=1
            else:
                if dic[d-1]==0:
                    ansl.append(d-1)
                    dic[d-1]+=1
        aans.append([c,d])
print(a-len(ansl))

### FIXED CODE ###

a,b=map(int,input().split())
h=[int(i) for i in input().split()]
ansl=[]
dic={i:0 for i in range(a)}
aans=[]
for i in range(b):
    c,d=map(int,input().split())
    if True:
        ch=h[c-1]
        dh=h[d-1]
        if ch==dh:
            if dic[c-1]==0:
                ansl.append(c-1)
                dic[c-1]+=1
            if dic[d-1]==0:
                ansl.append(d-1)
                dic[d-1]+=1
        else:
            if ch<dh:
                if dic[c-1]==0:
                    ansl.append(c-1)
                    dic[c-1]+=1
            else:
                if dic[d-1]==0:
                    ansl.append(d-1)
                    dic[d-1]+=1
        aans.append([c,d])
print(a-len(ansl))