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

# coding: utf-8

from bisect import bisect_left


def leq_search(xs, x, s, t):
    # x以下で最大のindex
    if t-s <= 5:
        res = 0
        for i in range(s, t):
            if xs[i] <= x:
                res = i
        return res

    return max(leq_search(xs, x, s, (s+t)//2), leq_search(xs, x, (s+t)//2, t))



def main():
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    S = [None] * (N+1)
    S[0] = 0
    for i in range(1, N+1):
        S[i] = S[i-1] + A[i-1]

    T = [None] * (M+1)
    T[0] = 0
    for i in range(1, M+1):
        T[i] = T[i-1] + B[i-1]

    n_read = 0
    for i in range(N+1):
        # print(i)
        if S[i] > K:
            break
        n = leq_search(T, K-S[i], 0, M+1)
        # print(n, T, K-S[i])
        if n_read < n + i:
            n_read = n + i
    
    return n_read


print(main())


### FIXED CODE ###

# coding: utf-8

from bisect import bisect_left


def leq_search(xs, x, s, t):
    # x以下で最大のindex
    if t-s <= 5:
        res = 0
        for i in range(s, t):
            if xs[i] <= x:
                res = i
        return res

    i = (s+t)//2
    if xs[i] <= x:
        return leq_search(xs, x, i, t)
    else:
        return leq_search(xs, x, s, i)


def main():
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    S = [None] * (N+1)
    S[0] = 0
    for i in range(1, N+1):
        S[i] = S[i-1] + A[i-1]

    T = [None] * (M+1)
    T[0] = 0
    for i in range(1, M+1):
        T[i] = T[i-1] + B[i-1]

    n_read = 0
    for i in range(N+1):
        # print(i)
        if S[i] > K:
            break
        n = leq_search(T, K-S[i], 0, M+1)
        # print(n, T, K-S[i])
        if n_read < n + i:
            n_read = n + i
    
    return n_read


print(main())
### BUGGY CODE ###

def division(x,y):
    if y == 0:
        return x
    return  division(y, x%y)

def checker(x):
    if x < 2:
        return False
    for i in range(2,x//2+1):
        v = division(x,i)
        if v > 1 :
            return False
    return True

cnt=0
q=int(input())
for i in range(q):
    o=checker(int(input()))
    if o:
        cnt+=1
print(cnt)

### FIXED CODE ###

def checker(x):
    if x == 2:
        return True
    if x < 2 or x % 2 == 0 :
        return False
    for i in range(2,int(x**0.5)+1):
        if x % i == 0 :
            return False
    return True

cnt=0
q=int(input())
for _ in range(q):
    v=int(input())
    if checker(v):
        cnt += 1
print(cnt)
### BUGGY CODE ###

import copy
N=int(input())
a=list(map(int,input().split()))

for i in range(N):
    A=copy.deepcopy(a)
    A.pop(i)
    A.insert(0,0)
    A.append(0)
    A.append(0)
    B=copy.deepcopy(A)
    B.insert(0,0)
    A_B=[abs(x-y) for (x,y) in zip(A,B)]
    print(sum(A_B))

### FIXED CODE ###

import numpy as np
N=int(input())
A=list(map(int,input().split()))

A.insert(0,0)
A.append(0)
A=np.array(A)
S=np.sum(np.abs(np.diff(A)))

for i in range(1,N+1):
    S_i=S+abs(A[i-1]-A[i+1])-(abs(A[i-1]-A[i])+abs(A[i]-A[i+1]))
    print(S_i)
### BUGGY CODE ###

def triangleChecker(a, b, c):
    if a >= b + c :
        return False
    else:
        if b >= c + a:
            return False
        else :
            if c >= a + b:
                return False
            else :
                return True
            
N = int(input())
numbers = [int(i) for i in input().split()]

counter = 0

for a in range(len(numbers)-2):
    for b in range(a+1, len(numbers)-1):
        for c in range(b+1, len(numbers)):
            if triangleChecker(numbers[a], numbers[b], numbers[c]):
                # print(combi)
                counter += 1

print(counter)

### FIXED CODE ###

import bisect

N = int(input())
numbers = [int(i) for i in input().split()]
numbers = sorted(numbers)
counter = 0

for a in range(N):
    for b in range(a+1, N):
        c = bisect.bisect_left(numbers, numbers[a] + numbers[b])
        if c > b:
            counter += c - b -1
        
print(counter)
### BUGGY CODE ###

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

bits = [0] * 40

for i in range(N):
    for j in range(40):
        if A[i] >> j & 1:
            bits[j] += 1

ans = 0
for i in range(K+1):
    tmp = 0
    for j in range(40):
        bit_count = bits[j]
        if i >> j & 1:
            bit_count = N - bit_count
        tmp += pow(2, j) * bit_count
    ans = max(ans, tmp)

print(ans)


### FIXED CODE ###

MAX_DIGIT = 50
SMALL = 1
EQUAL = 0

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

dp = [[-1 for _ in range(2)] for _ in range(100)]
dp[0][0] = 0

for d in range(MAX_DIGIT):
    mask = 1 << (MAX_DIGIT - d - 1)
    # A で元々 d 桁目にビットが立っているものの個数
    num = 0
    for i in range(N):
        if A[i] & mask:
            num += 1

    # X の d 桁目を 0, 1 にしたときのコスト
    cost0 = mask * num  # 元々の 1 の個数
    cost1 = mask * (N - num)  # 元々の 0 の個数(反転するから)

    # "K 未満 -> K 未満" の遷移
    if dp[d][SMALL] != -1:
        # 0 でも 1 でも自在に大きい方
        dp[d+1][SMALL] = max(dp[d+1][SMALL], dp[d][SMALL] + max(cost0, cost1))

    # "K ぴったり -> K 未満" の遷移
    if dp[d][0] != -1:
        if K & mask:
            # K の d 桁目が 1 だったら、X の d 桁目は 0 にする
            dp[d+1][SMALL] = max(dp[d+1][SMALL], dp[d][EQUAL] + cost0)

    # "K ぴったり -> K ぴったり" の遷移
    if dp[d][EQUAL] != -1:
        if K & mask:
            dp[d+1][EQUAL] = max(dp[d+1][EQUAL], dp[d][EQUAL] + cost1)
        else:
            dp[d+1][EQUAL] = max(dp[d+1][EQUAL], dp[d][EQUAL] + cost0)


ans = max(dp[MAX_DIGIT][EQUAL], dp[MAX_DIGIT][SMALL])
print(ans)
### BUGGY CODE ###

n,m=map(int,input().split())
N=[[] for i in range(n)]
P=[]
Y=[]
for i in range(m):
    p,y=map(int,input().split())
    P.append(p)
    Y.append(y)
    N[p-1].append(y)
for i in N:
    i.sort()
for k in range(m):
    a='{0:06d}'.format(P[k])
    b='{0:06d}'.format(N[P[k]-1].index(Y[k])+1)
    print(a+b)

### FIXED CODE ###

n,m=map(int,input().split())
city=list(list(map(int,input().split()))+[i] for i in range(m))
city.sort(key=lambda x:x[1])
city.sort(key=lambda x:x[0])
for j,l in enumerate(city):
    if j!=0 and city[j-1][0]==city[j][0]:
        city[j].append(city[j-1][3]+1)
    elif j!=0 and city[j-1][0]!=city[j][0]:
        city[j].append(1)
    else:
        city[j].append(1)
city.sort(key=lambda x:x[2])
for k in range(m):
    print('{0:06d}{1:06d}'.format(city[k][0],city[k][3]))
### BUGGY CODE ###

from itertools import combinations

n = int(input())
s = input()

c = set()

for sc in combinations(s, 3):
    c.add(sc)

print(len(c))


### FIXED CODE ###

from itertools import product

n = int(input())
s = input()

ans = 0

for cmb in product(range(10), range(10), range(10)):
    idx = -1
    for i in cmb:
        idx = s.find(str(i), idx + 1)
        if idx < 0:
            break
    else:
        ans += 1

print(ans)
### BUGGY CODE ###

n = int(input())
A = list(map(int,input().split()))
ANS = 1
for i in range(n):
    ANS *= A[i]
if ANS > 10**18:
    print(-1)
else:
    print(ANS)

### FIXED CODE ###

import sys
n = int(input())
A = list(map(int,input().split()))
if A.count(0)>0:
    print(0)
else:
    ANS = 1
    for i in range(n):
        ANS *= A[i]
        if ANS > 10**18:
            print(-1)
            sys.exit()
    print(ANS)
### BUGGY CODE ###

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

Kcost = [min(row, N - 1 - row, clm, N - 1 - clm) for row in range(N) for clm in range(N)]

Sitting = [1] * (N * N)
Kcount = 0


def Kcheck(qsn, cdsn):
    if Kcost[cdsn] > Kcost[qsn] + Sitting[qsn]:
        Kcost[cdsn] = Kcost[qsn] + Sitting[qsn]
        queue.append(cdsn)


for sn in P:
    csn = sn - 1
    Kcount += Kcost[csn]
    Sitting[csn] = 0
    queue = [csn]

    while queue:
        qsn = queue.pop()
        div, mod = divmod(qsn, N)
        if mod: Kcheck(qsn, qsn - 1)
        if mod != N - 1: Kcheck(qsn, qsn + 1)
        if div: Kcheck(qsn, qsn - N)
        if div != N - 1: Kcheck(qsn, qsn + N)

print(Kcount)


### FIXED CODE ###

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

Kcost = [min(row, N - 1 - row, clm, N - 1 - clm) for row in range(N) for clm in range(N)]

Sitting = [1] * (N * N)
Kcount = 0


def Kcheck(qsn, cdsn):
    if Kcost[cdsn] > Kcost[qsn] + Sitting[qsn]:
        Kcost[cdsn] = Kcost[qsn] + Sitting[qsn]
        queue.append(cdsn)


for sn in P:
    csn = sn - 1
    Kcount += Kcost[csn]
    Sitting[csn] = 0
    queue = [csn]

    while queue:
        qsn = queue.pop()
        div, mod = divmod(qsn, N)
        if mod: Kcheck(qsn, qsn - 1)
        if mod != N - 1: Kcheck(qsn, qsn + 1)
        if div: Kcheck(qsn, qsn - N)
        if div != N - 1: Kcheck(qsn, qsn + N)

print(Kcount)
### BUGGY CODE ###

N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
div=7+10**9
ans=1
t=0
i,j=0,N-1

if A[-1]<0 and K%2==1:
    for i1 in range(N-K,N):
        ans*=A[i1]
else:
    while t<K-1:
        if A[i]*A[i+1]>A[j]*A[j-1]:
            ans*=A[i]*A[i+1]
            i+=2
            t+=2
        else:
            ans*=A[j]
            j+=-1
            t+=1
    if t==K-1:
        ans*=A[j]

print(ans%div)

### FIXED CODE ###

N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
div=7+10**9
ans=1
t=0
i,j=0,N-1

if A[-1]<0 and K%2==1:
    for i1 in range(N-K,N):
        ans*=A[i1]
        ans%=div
else:
    while t<K-1:
        if A[i]*A[i+1]>A[j]*A[j-1]:
            ans*=A[i]*A[i+1]
            ans%=div
            i+=2
            t+=2
        else:
            ans*=A[j]
            ans%=div
            j+=-1
            t+=1
    if t==K-1:
        ans*=A[j]
        ans%=div

print(ans)
### BUGGY CODE ###

from collections import Counter
from math import factorial
N = int(input())
A = list(map(int, input().split()))

count = 0
for i in range(N):
    if (i == 0):
        ap = A[1:]
    elif(i == N - 1):
        ap = A[:i]
    else:
        ap = A[:i] + A[i + 1:]
    c = Counter(ap)
    for j, v in c.items():
        if (v <= 1):
            continue
        else:
            count += factorial(v) // factorial(2) // factorial(v - 2)
    print(count)

    count = 0


### FIXED CODE ###

from collections import Counter
N = int(input())
A = list(map(int, input().split()))

allCount = 0
c = Counter(A)

for i, v in c.items():
    if (v == 1):
        continue
    else:
        allCount += v * (v - 1) // 2


if (allCount == 0):
    for i in range(N):
        print(0)
    exit()

for i in range(N):
    a = allCount
    num = c[A[i]] - 1
    if (num == 1 or num == 0):
        print(allCount - num)
        continue
    old = c[A[i]] * (c[A[i]] - 1) // 2
    count = num * (num - 1) // 2
    print(a - old + count)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
A = {a: A.count(a) for a in set(A)}
ans = 0
for k, v in A.items():
    if k > v:
        ans += v
    elif k < v:
        ans += v - k
print(ans)


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
S = {}
for a in A:
    if a in S:
        S[a] += 1
    else:
        S[a] = 1
ans = 0
for k, v in S.items():
    if k > v:
        ans += v
    elif k < v:
        ans += v - k
print(ans)
### BUGGY CODE ###

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

if P != 2 and P != 5:
    count = [0] * P
    ans = 0
    tmp = 0
    for i in range(N - 1, -1, -1):
        tmp += int(S[i]) * 10 ** (N - 1 - i)
        tmp %= P
        ans += count[tmp]
        count[tmp % P] += 1
    ans += count[0]

    # print (count)
    print (ans)

if P == 2:
    count = 0
    for index, s in enumerate(S):
        if int(s) % 2 == 0:
            count += (index + 1)
    print (count)

if P == 5: 
    count = 0
    for index, s in enumerate(S):
        if int(s) % 5 == 0:
            count += (index + 1)
    print (count)

### FIXED CODE ###

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

if P != 2 and P != 5:
    count = [0] * P
    ans = 0
    tmp = 0
    for i in range(N - 1, -1, -1):
        tmp += int(S[i]) * pow(10, (N - 1 - i), P)
        tmp %= P
        ans += count[tmp]
        count[tmp] += 1
    ans += count[0]

    # print (count)
    print (ans)

if P == 2:
    count = 0
    for index, s in enumerate(S):
        if int(s) % 2 == 0:
            count += (index + 1)
    print (count)

if P == 5: 
    count = 0
    for index, s in enumerate(S):
        if int(s) % 5 == 0:
            count += (index + 1)
    print (count)
### BUGGY CODE ###

h, w, d = map(int, input().split(' '))

comp = {}
for i in range(h):
    tmp = list(map(int, input().split(' ')))
    for j in range(w):
        comp[tmp[j]] = [i, j]
        
q = int(input())
for _ in range(q):
    l, r = map(int, input().split(' '))
    cnt = 0
    tmp = []
    if l != r:
        for k in range(int((r - l) / d) + 1):
            tmp.append(comp[l + d * k])
        for i in range(len(tmp)):
            if i >= 1:
                cnt += abs(tmp[i][0] - tmp[i - 1][0]) + abs(tmp[i][1] - tmp[i - 1][1])

    print(cnt)

### FIXED CODE ###

h, w, d = map(int, input().split(' '))

comp = {}
for i in range(h):
    tmp = list(map(int, input().split(' ')))
    for j in range(w):
        comp[tmp[j]] = [i, j]

q = int(input())
lr = [map(int, input().split(' ')) for _ in range(q)]

dp = [0] * (h * w + 1)
for i in range(d + 1, h * w + 1):
    cnt = dp[i - d]
    cnt += abs(comp[i][0] - comp[i - d][0])
    cnt += abs(comp[i][1] - comp[i - d][1])    
    dp[i] = cnt
    

for l, r in lr:
    print(dp[r] - dp[l])
### BUGGY CODE ###

int_n = int(input())
list_x = list(map(int, input().split()))

#print(max(list_x))

#同じ値には、最小のインデックスを返す
#print(list_x.index(max(list_x)))

#int_plus = 0
list_x_left = list_x
list_calc_minus = list()

while len(list_x_left) != 0:
  #list_x_prosess = list_x_left[list_x_left.index(max(list_x_left)):]
  
  int_list_x_prosess_len = len(list_x_left) - list_x_left.index(max(list_x_left))
  int_max_list_x_prosess = max(list_x_left)
  list_x_left = list_x_left[:list_x_left.index(max(list_x_left))]
  
  [list_calc_minus.insert(0, int_max_list_x_prosess) for i in range(int_list_x_prosess_len)]
  
  ##  print(sum([max(list_x_prosess)-i for i in list_x_prosess]))
  #int_plus = int_plus + sum([max(list_x_prosess)-i for i in list_x_prosess])
#
  ##  print(list_x_left, list_x_prosess)
  
#print(int_plus)
#print([x - y for (x, y) in zip(list_calc_minus, list_x)])
print(sum([x - y for (x, y) in zip(list_calc_minus, list_x)]))



### FIXED CODE ###

int_n = int(input())
list_a = list(map(int, input().split()))

#print(int_n, list_a)

int_tmp_highet = 0
int_count = 0
for i in list_a:
  if i > int_tmp_highet:
    int_tmp_highet = i
  else:
    int_count = int_count + int_tmp_highet - i
  #print(int_count)

print(int_count)
### BUGGY CODE ###

N,K=map(int,input().split())
A=0
for a in range(100000000000000):
    if N%K==0:
        print(0)
        break
    if N<K:
        if abs(N-K)<N:
            print(abs(N-K))
            break
        else:
            print(N)
            break
    tugi=abs(N-K)
    N=tugi
    A=tugi
    tugi=abs(N-K)
    B=tugi
    N=tugi
    tugi=abs(N-K)
    if A==tugi:
        if B<A:
            print(B)
            break
        else:
       	    print(A)
            break

### FIXED CODE ###

N,K=map(int,input().split())
A=0
for a in range(100000000000000):
    if N>K:
        kot=N%K
        if abs(K-kot)>kot:
            print(kot)
            break
        else:
            print(abs(K-kot))
            break
    if N%K==0:
        print(0)
        break
    if N<K:
        if abs(N-K)<N:
            print(abs(N-K))
            break
        else:
            print(N)
            break
    tugi=abs(N-K)
    N=tugi
    A=tugi
    tugi=abs(N-K)
    B=tugi
    N=tugi
    tugi=abs(N-K)
    if A==tugi:
        if B<A:
            print(B)
            break
        else:
       	    print(A)
            break
### BUGGY CODE ###

h,w=map(int,input().split())
a,s=[],[["x"for i in range(w+2)]]
for i in range(h):
  t,tt=input(),[]
  for j in range(w):
    if t[j]=="#":a.append([i+1,j+1])
    tt.append(t[j])
  s.append(["x"]+tt+["x"])
s.append(["x"for i in range(w+2)])
f=1
for i in range(2000):
  b=[]
  for k in a:
    i,j=k[0],k[1]
    if s[i-1][j]==".":s[i-1][j]=f;b.append([i-1,j])
    if s[i+1][j]==".":s[i+1][j]=f;b.append([i+1,j])
    if s[i][j-1]==".":s[i][j-1]=f;b.append([i,j-1])
    if s[i][j+1]==".":s[i][j+1]=f;b.append([i,j+1])
  if b==[]:break
  f+=1
  a=b[:]
print(f-1)

### FIXED CODE ###

from collections import deque
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
d=deque()
dc=0
b=[]
for i in range(h):
  t=[]
  s=input()
  for j in range(w):
    if s[j]=="#":d.append((i,j));dc+=1;t.append(1)
    else:t.append(0)
  b.append(t)
count=0
while dc!=0:
  ld=dc
  dc=0
  for i in range(ld):
    x=d.popleft()
    if x[0]<h-1:
      if b[x[0]+1][x[1]]==0:b[x[0]+1][x[1]]=1;d.append((x[0]+1,x[1]));dc+=1
    if 0<x[0]:
      if b[x[0]-1][x[1]]==0:b[x[0]-1][x[1]]=1;d.append((x[0]-1,x[1]));dc+=1
    if x[1]<w-1:
      if b[x[0]][x[1]+1]==0:b[x[0]][x[1]+1]=1;d.append((x[0],x[1]+1));dc+=1
    if 0<x[1]:
      if b[x[0]][x[1]-1]==0:b[x[0]][x[1]-1]=1;d.append((x[0],x[1]-1));dc+=1
  count+=1
print(count-1)
### BUGGY CODE ###

def main():
  e,M=enumerate,10**9+7
  n,k,*a=map(int,open(0).read().split())
  dp=[[0]*(k+1)for _ in range(n+1)]
  dp[0][0]=1
  for i,(b,d,a)in e(zip(dp,dp[1:],a),1):
    t=0
    for j,v in e(b):
      t+=v
      if j>a:t-=b[~a+j]
      t%=M
      d[j]=t
  print(t)
main()

### FIXED CODE ###

def main():
  e,M=enumerate,10**9+7
  n,k,*a=map(int,open(0).read().split())
  dp=[[0]*(k+1)for _ in range(n+1)]
  dp[0][0]=1
  for i,(b,d,a)in e(zip(dp,dp[1:],a),1):
    t=0
    for j,v in e(b):
      t+=v
      if j>a:t-=b[~a+j]
      t%=M
      d[j]=t
  print(t)
main()
### BUGGY CODE ###

import math

def pf(n):
  s = set()
  i = 2
  while i * i <= n:
    while n % i == 0:
      s.add(i)
      n //= i
    i += 1
  if n > 1:
    s.add(n)
  return s

input()
d = None
u = set()
r = 'pairwise'
for x in map(int, input().split()):
  d = math.gcd(d or x, x)
  s = pf(x)
  if not s.isdisjoint(u):
    r = 'setwise'
  u |= s
print((r, 'not')[d > 1], 'coprime')


### FIXED CODE ###

N = 1000001
 
spf = [*range(N)]
i = 2
while i * i < N:
  if spf[i] == i:
    for j in range(i * i, N, i):
      if spf[j] == j:
        spf[j] = i
  i += 1
  
r = 'pairwise'
n = int(input())
a = [int(x) for x in input().split() if x > '1']
if len(a) > 1:
  u = set()
  i = None
  for x in a:
    s = set()
    while x > 1:
      p = spf[x]
      if p in u:
        r = 'setwise'
      s.add(p)
      x //= p
    u |= s
    if len(a) == n:
      if i is None: i = s
      else: i &= s
  if i:
    r = 'not'
print(r, 'coprime')
### BUGGY CODE ###

import time as time

s = time.time()

lines =  input().split()
n = int(lines[0])
m = int(lines[1])
#n,m = map(int,input().split())

py = []
od = [[]*1 for i in range(n)]

#print ("create list: " + str(time.time() - s) )

#s = time.time()
for i in range(0,m):

    lines =  input().split()
    p = int(lines[0])
    y = int(lines[1])
    py.append([p,y])
       
    odlen = len(od[p-1])
    if odlen >= 1 :

        low = 0
        high = odlen - 1
        mid = odlen >> 1

        while low <= high:
            mid = (low + high) >> 1
            guess = od[p-1][mid]
            if guess == y:
                break
            if guess > y :
                high = mid - 1
            else:
                low  = mid + 1
        od[p-1].insert(low,y)

    else:
        od[p-1].append(y)

#print ("sort: " + str(time.time() - s) )

#s = time.time()
for i in range(0,m):
    py0 = py[i][0]
    r = od[py0-1].index(py[i][1])

    tmp = py0
    digit = 0
    while tmp > 0 :        
        digit += 1
        tmp = tmp // 10
    
    l = 6-digit
    for j in range(l):
        print('0',end="")
    print(py0,end="")

    tmp = r + 1
    digit = 0
    while tmp > 0 :        
        digit += 1
        tmp = r // 10

    l = 6-digit
    for j in range(l):
        print('0',end="")
    print(r+1)

#print ("index: " + str(time.time() - s) )

### FIXED CODE ###

import sys as sys

lines =  input().split()
n = int(lines[0])
m = int(lines[1])

py = []
od = {}

#lines = sys.stdin.readlines()

for i in range(0,m):


    #l =  lines[i].split()
    l = input().split()
    p = int(l[0])
    y = int(l[1])
    
    if p in od :
        od[p].append([i,y])
    else:
        od[p] = [[i,y]]

a = []
for p in od.keys():
    od[p].sort(key=lambda x:x[1])
    r = 1

    for o in od[p]:
        cs = ""

        tmp = p
        digit = 0
        while tmp > 0 :        
            digit += 1
            tmp = tmp // 10
        
        l = 6-digit
        for j in range(l):
            cs += '0'
        cs += str(p)

        tmp = r 
        digit = 0
        while tmp > 0 :        
            digit += 1
            tmp = tmp // 10

        l = 6-digit
        for j in range(l):
            cs += '0'
        cs += str(r)        

        a.append([o[0],cs])
        r += 1

a.sort(key=lambda x:x[0])
for aa in a:
    print(aa[1])
### BUGGY CODE ###

n,m = map(int, input().split())
l = [0] * n

ac = 0
wa = 0
ac_done = []

for _ in range(m):
    p, s = input().split()
    p = int(p)
    if p in ac_done:
        continue
    else:
        if s == 'AC':
            ac += 1
            wa += l[p-1]
            ac_done.append(p)
        else:
            l[p-1] = 1 + l[p-1]

print(ac,wa)

### FIXED CODE ###

n,m = map(int, input().split())
l = [0] * n

ac = 0
wa = 0
ac_done = [False] * n

for _ in range(m):
    p, s = input().split()
    p = int(p)
    if ac_done[p-1]:
        continue
    else:
        if s == 'AC':
            ac += 1
            wa += l[p-1]
            ac_done[p-1] = True
        else:
            l[p-1] += 1 

print(ac,wa)
### BUGGY CODE ###

import numpy as np

x = input().split(' ')
n = int(x[0])
m = int(x[1])

x = input().split(' ')
heights = []
for i in range(n):
  heights.append(int(x[i]))
  
ways = []

for i in range(m):
  x = input().split(' ')
  ways.append([int(x[0]), int(x[1])])
  
#こっから接続辞書を作る
ways_dict = {}

for way in ways:
  if way[0] < way[1]:
    if ways_dict.get(way[0]):
      if way[1] not in ways_dict[way[0]]:
      	ways_dict[way[0]].append(way[1])
    else:
      ways_dict[way[0]] = [way[1]]
      
  else:
    if ways_dict.get(way[1]):
      if way[0] not in ways_dict[way[1]]:
      	ways_dict[way[1]].append(way[0])
    else:
      ways_dict[way[1]] = [way[0]]

bool_array = [1]*n


for idx in range(1, n+1):
  #if bool_array[idx-1] == 0:
  #  continue
  if ways_dict.get(idx) is None:
    continue
    
  current_h = heights[idx-1]
  
  
  for way in ways_dict[idx]:

    if heights[way-1] > current_h:
      bool_array[idx-1] = 0
    elif heights[way-1] == current_h:
      bool_array[idx-1] = 0
      bool_array[way-1] = 0
    else:
      bool_array[way-1] = 0
      
print(np.array(bool_array).sum())

### FIXED CODE ###

import numpy as np

x = input().split(' ')
n = int(x[0])
m = int(x[1])

x = input().split(' ')
heights = {}
for i in range(n):
  heights[i] = int(x[i])




ways = []

for i in range(m):
  x = input().split(' ')
  ways.append([int(x[0])-1, int(x[1])-1])
  
#こっから接続辞書を作る
ways_dict = {}

bool_array = [1]*n

for way in ways:
  if heights[way[0]] > heights[way[1]]:
      bool_array[way[1]] = 0
  elif  heights[way[0]] == heights[way[1]]:
    bool_array[way[0]] = 0
    bool_array[way[1]] = 0
  else:
    bool_array[way[0]] = 0




for higher_idx, ways in ways_dict.items():
  for way in ways_dict[higher_idx]:
    bool_array[way] = 0
      
print(np.array(bool_array).sum())