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

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

for _ in range(M):
    max_i = A.index(max(A))
    A[max_i] >>= 1

print(sum(A))

### FIXED CODE ###

import heapq

N, M = map(int, input().split())
A = list(map(lambda x: int(x)*(-1), input().split()))

heapq.heapify(A)

for _ in range(M):
  v = heapq.heappop(A) * (-1)
  heapq.heappush(A, -(v >> 1))

print(-sum(A))
### BUGGY CODE ###

from collections import deque


def get_arounds(point, grid, max_x, max_y):
    x = point[0]
    y = point[1]
    arounds = [(x + dx, y + dy) for dx, dy in ((0, -1), (1, 0), (0, 1), (-1, 0))]
    return list(filter(lambda a: 0 <= a[0] < max_x and
                                 0 <= a[1] < max_y and
                                 grid[a[0]][a[1]], arounds))


H, W = tuple(map(int, input().split()))

grid = []
for i in range(0, H):
    grid.append(list(map(lambda x: True if x == '.' else False, list(input()))))

black = sum(map(lambda l: l.count(False), grid))

p_grid = {(0, 0): 0, (H - 1, W - 1): -1}
queue = deque([(0, 0)])
while not len(queue) == 0:
    here = queue.popleft()
    if here == (H - 1, W - 1):
        break;
    grid[here[0]][here[1]] = False
    arounds = get_arounds(here, grid, H, W)
    for a in arounds:
        p_grid[a] = p_grid[here] + 1
    queue.extend(arounds)

if p_grid[H-1, W-1] == -1:
    print('-1')
else:
    print(H * W - (p_grid[H-1, W-1] + 1) - black)


### FIXED CODE ###

from collections import deque


def get_arounds(point, grid, max_x, max_y):
    x = point[0]
    y = point[1]
    arounds = [(x + dx, y + dy) for dx, dy in ((0, -1), (1, 0), (0, 1), (-1, 0))]
    return list(filter(lambda a: 0 <= a[0] < max_x and
                                 0 <= a[1] < max_y and
                                 grid[a[0]][a[1]], arounds))


H, W = tuple(map(int, input().split()))

grid = []
for i in range(0, H):
    grid.append(list(map(lambda x: True if x == '.' else False, list(input()))))

black = sum(map(lambda l: l.count(False), grid))

grid[0][0] = False
p_grid = {(0, 0): 0}
queue = deque([(0, 0)])
while not len(queue) == 0:
    here = queue.popleft()
    if here == (H - 1, W - 1):
        break;
    arounds = get_arounds(here, grid, H, W)
    for a in arounds:
        grid[a[0]][a[1]] = False
        p_grid[a] = p_grid[here] + 1
    if not arounds:
        continue
    queue.extend(arounds)

if (H-1, W-1) in p_grid:
    print(H * W - (p_grid[H-1, W-1] + 1) - black)
else:
    print(-1)
### BUGGY CODE ###

def kuriage(cnt,P,ind,C,G):
    if cnt[ind] < P[ind]:
        if point(cnt,P,C,G) + (P[ind] - cnt[ind]) * (ind+1) * 100 + C[i] < G:
            cnt[ind:ind+1] = P[ind:ind+1]
        else:
            cnt[ind] = cnt[ind] + 1
        return cnt
    else:#cnt[ind] == P[ind]
        cnt[ind] = 0
        return kuriage(cnt, P, ind+1, C, G)

def point_over(cnt,P,C,G):
    point = 0
    for i in range(len(P)):
        point += cnt[i]*100*(i+1)
        if cnt[i] == P[i]:
            point += C[i]

        if point >= G:
            return True

    if point < G:
        return False

def point(cnt,P,C,G):
    point = 0
    for i in range(len(P)):
        point += cnt[i]*100*(i+1)
        if cnt[i] == P[i]:
            point += C[i]

    return point

D,G = map(int, input().split())
P = []
C = []

for i in range(D):
    p,c = map(int,input().split())
    P.append(p)
    C.append(c)

cnt = [0 for _ in range(D)]

ans = sum(P)
while cnt != P:
    ind = 0
    cnt = kuriage(cnt,P,ind,C,G)
#    print(cnt,sum(cnt),point(cnt,P,C,G)-25000)

    if point_over(cnt,P,C,G) and ans > sum(cnt):
        ans = min(ans, sum(cnt))

print(ans)


### FIXED CODE ###

import numpy as np

D,G = map(int, input().split())
P = []
C = []

for i in range(D):
    p,c = map(int,input().split())
    P.append(p)
    C.append(c)

cnt = np.zeros(D,dtype=int)
P = np.array(P)
C = np.array(C)

ans = sum(P)
cnt_tar = 0

ind_list = np.arange(D)

for bit_seed in range(2**D):

    s_bit = (format(bit_seed, '#016b'))[::-1]
    bit_list = np.array(list(s_bit[:D]),dtype=int)

    cnt = P*bit_list
    num_base = np.sum(cnt)

    point_base_array = (P * (ind_list+1) * 100 + C) * bit_list
    point_base = np.sum(point_base_array)
#    print(point_base_array)

    if point_base >= G:
        num = num_base
        ans = min(ans,num)
    elif num_base > ans:
        continue
    else:
        for i,bit in enumerate(bit_list):
            if bit == 0:
                tar = i

        point_max = point_base + P[tar]*(tar+1)*100 + C[tar]
        if point_max >= G:

            tar_min = (G-point_base) // ((tar+1)*100)
            point = point_base + P[tar]*(tar+1)*100*tar_min

            if point < G:
                tar_min += 1

            if tar_min < P[tar]:
                num = num_base + tar_min
            else:
                num = num_base + P[tar]
            ans = min(ans,num)

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

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

ans = [0 for i in range(n)]
for s in range(n) :
  for g in range(s,n) :
    if s == g :
      continue
    dis = min(abs(g-s),abs(abs(x-s)+1+abs(y-g)),abs(abs(y-s)+1+abs(x-g)))
    ans[dis] += 1
    
for i in range(1,n) :
  print(ans[i])

### FIXED CODE ###

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

ans = [0 for i in range(n)]
for s in range(n) :
  for g in range(s,n) :
    if s == g :
      continue
    dis = min(abs(g-s),abs(abs(x-s)+1+abs(y-g)),abs(abs(y-s)+1+abs(x-g)))
    ans[dis] += 1
    
for i in range(1,n) :
  print(ans[i])
### BUGGY CODE ###

N,D,A = map(int,input().split())
d = {}
E = []
for i in range(N):
    x,h = map(int,input().split())
    d[x] = h
    E.append(x)
E.sort()
ans = 0
import bisect
while E:
    x = E.pop(0)
    y = bisect.bisect_right(E,x+2*D)
    z = (d[x]+A-1)//A
    ans += z
    for j in range(y):
        d[E[y-j-1]] -= z*A
        if d[E[y-j-1]] <= 0:
            E.pop(y-j-1)
print(ans)

### FIXED CODE ###

N,D,A = map(int,input().split())
attack_number = {}
Enemy = []
import math
for i in range(N):
    x,h = map(int,input().split())
    n = math.ceil(h/A)
    attack_number[x] = n
    Enemy.append(x)
Enemy.sort()
bomb_number = [0 for i in range(N+1)]
F = {}
import bisect
for i in range(N):
    x = Enemy[i]
    y = bisect.bisect_right(Enemy,x+2*D)
    F[i] = y
ans = 0
for i in range(N):
    if i > 0:
        bomb_number[i] += bomb_number[i-1]
    x = attack_number[Enemy[i]] - bomb_number[i]
    if x <= 0:
        continue
    y = F[i]
    bomb_number[i] += x
    bomb_number[y] -= x
    ans += x
print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a
#リストの最小公倍数
def lcm(a):    
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

N = ir()
A = lr()
A.sort(reverse=True)
if N == 1:
    print(1)
    exit()
MOD = 10 ** 9 + 7
l = []
first = A[0]
l = [x//gcd(x, first) for x in A[1:]]
x = lcm(l) #B[0]
answer = x%MOD

for i in range(1, N):
    answer += (first * x // A[i]) % MOD

print(answer%MOD)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a
#リストの最小公倍数
def lcm(a):    
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

N = ir()
A = lr()
A.sort()
if N == 1:
    print(1)
    exit()
MOD = 10 ** 9 + 7
l = []
first = A[0]
l = [x//gcd(x, first) for x in A[1:]]
x = lcm(l) #B[0]
answer = x%MOD

for i in range(1, N):
    answer += first * x // A[i]

print(answer%MOD)
### BUGGY CODE ###

h,w = map(int, input().split())
Data = [[[0,0,0,0] for i in range(w)] for j in range(h)]
S = [input() for i in range(h)]
for i in range(h):
    for j in range(w):
        if S[i][j] == ".":
            if j > 0:
                Data[i][j][0] = Data[i][j-1][0] + 1
            else:
                Data[i][j][0] = 1
    for j in range(w-1,-1,-1):
        if S[i][j] == ".":
            if j < w-1:
                Data[i][j][1] = Data[i][j+1][1] + 1
            else:
                Data[i][j][1] = 1
for i in range(w):
    for j in range(h):
        if S[j][i] == ".":
            if j > 0:
                Data[j][i][2] = Data[j-1][i][2] + 1
            else:
                Data[j][i][2] = 1
    for j in range(h-1,-1,-1):
        if S[j][i] == ".":
            if j < h-1:
                Data[j][i][3] = Data[j+1][i][3] + 1
            else:
                Data[j][i][3] = 1
ans = 0
for i in range(h):
    for j in range(w):
       ans = max(sum(Data[i][j])-3,ans)
print(ans)

### FIXED CODE ###

h,w = map(int, input().split())
S = [input() for i in range(h)]
U = [[0]*w for i in range(h)]
D = [[0]*w for i in range(h)]
L = [[0]*w for i in range(h)]
R = [[0]*w for i in range(h)]

for i in range(h):
    for j in range(w):
        if S[i][j] == ".":
            if j > 0:
                L[i][j] = L[i][j-1] + 1
            else:
                L[i][j] = 1
    for j in range(w-1,-1,-1):
        if S[i][j] == ".":
            if j < w-1:
                R[i][j] = R[i][j+1] + 1
            else:
                R[i][j] = 1
for i in range(w):
    for j in range(h):
        if S[j][i] == ".":
            if j > 0:
                D[j][i] = D[j-1][i] + 1
            else:
                D[j][i] = 1
    for j in range(h-1,-1,-1):
        if S[j][i] == ".":
            if j < h-1:
                U[j][i] = U[j+1][i] + 1
            else:
                U[j][i] = 1
ans = 0
for i in range(h):
    for j in range(w):
       ans = max(L[i][j]+R[i][j]+U[i][j]+D[i][j]-3,ans)
print(ans)
### BUGGY CODE ###

from _collections import deque

h, w = map(int, input().split())
ls = []
for _ in range(h):
    ls1 = []
    s = input()
    for i in range(w):
        if s[i] == '.':
            ls1.append(0)
        else:
            ls1.append(1)
    ls.append(ls1)

def trans(a, b):
    return a * w + b

ls2 = [[] for _ in range(h * w)]

for i in range(h):
    for j in range(w):
        # check ij
        if ls[i][j] == 1:
            continue
        if 0 <= i < h and 0 <= j - 1 < w and ls[i][j - 1] == 0:
            ls2[trans(i, j)].append(trans(i, j - 1))
            #print(ls2)
        if 0 <= i + 1 < h and 0 <= j < w and ls[i + 1][j] == 0:
            ls2[trans(i, j)].append(trans(i + 1, j))
            #print(ls2)
        if 0 <= i - 1 < h and 0 <= j < w and ls[i - 1][j] == 0:
            ls2[trans(i, j)].append(trans(i - 1, j))
            #print(ls2)
        if 0 <= i < h and 0 <= j + 1 < w and ls[i][j + 1] == 0:
            ls2[trans(i, j)].append(trans(i, j + 1))

def route(i, j):
    if i == j:
        return 0
    count = 1
    ss = deque(ls2[i])
    next = deque()
    now = i
    explored = set([i])
    while True:
        #print(now, i, j)
        if not ss:
            count +=1
            ss = next
            next = deque()
        now =ss.popleft()
        if now in explored:
            continue
        if now == j:
            #print(count)
            return count
        else:
            explored.add(now)
            next.extend(ls2[now])

ls3 = [0] * (h * w)

for i in range(h * w):
    if ls2[i] == []:
        continue
    count = 0
    for j in range(h * w):
        if ls2[j] == []:
            continue
        else:
            count = max( count, route(i, j))
    ls3[i] = count

print(max(ls3))

### FIXED CODE ###

from collections import deque

def main():
    h, w = map(int, input().split())
    ls = [input() for _ in range(h)]

    def trans(a, b):
        return a * w + b

    ls2 = [[] for _ in range(h * w)]

    for i in range(h):
        for j in range(w):
            # check ij
            if ls[i][j] == '#':
                continue
            if i >= 1 and ls[i-1][j] != '#':
                ls2[trans(i, j)].append(trans(i-1, j))
            if i <= h-2 and ls[i+1][j] != '#':
                ls2[trans(i, j)].append(trans(i + 1, j))
            if j <= w-2 and ls[i][j+1] != '#':
                ls2[trans(i, j)].append(trans(i, j + 1))
            if j >= 1 and ls[i][j-1] != '#':
                ls2[trans(i, j)].append(trans(i, j - 1))


    #print(ls2)


    def route(i):
        count = 1
        ss = deque(ls2[i])
        next = deque()
        explored = {i}
        while ss or next:
            if not ss:
                count +=1
                ss = next
                next = deque()
            now =ss.popleft()
            if now in explored:
                continue
            else:
                explored.add(now)
                next.extend(ls2[now])
        return count-1
    ans = 0
    for i in range(h * w - 1):
        if ls2[i] == []:
            continue
        ans = max(ans, route(i))

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

import os
import os
import sys
from collections import deque, defaultdict

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N, K = list(map(int, sys.stdin.buffer.readline().split()))
A = list(map(int, sys.stdin.buffer.readline().split()))

A = np.array(A, dtype=int) % K

if K == 1:
    print(0)
    exit()
if K == 2:
    ans = (A % 2 == 1).sum()
    print(ans)
    exit()

def test():
    ans = 0
    for i, a in enumerate(A):
        if a % K == 1:
            ans += 1
        j = 1
        while i - j >= 0 and j + 1 < K:
            if (sum(A[i - j: i]) + a) % K == j + 1:
                ans += 1
            j += 1
    print(ans)


# 和-長さ を覚える
counts = defaultdict(int)
hist = deque()
offset = 0
ans = 0
for i, a in enumerate(A):
    if a % K == 1:
        ans += 1
    ans += counts[(K - a + 1 - offset) % K]
    offset += a - 1
    offset %= K
    counts[(a - 1 - offset) % K] += 1
    if len(hist) >= K - 2:
        counts[hist.popleft()] -= 1
    hist.append((a - 1 - offset) % K)
    # print(ans, counts, offset)
print(ans)
# test()


### FIXED CODE ###

import os
import sys
from collections import defaultdict

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N, K = list(map(int, sys.stdin.buffer.readline().split()))
A = list(map(int, sys.stdin.buffer.readline().split()))

if K == 1:
    print(0)
    exit()
if K == 2:
    ans = sum([1 for a in A if a % 2 == 1], 0)
    # ans = (A % 2 == 1).sum()
    print(ans)
    exit()


def test():
    ans = 0
    for i, a in enumerate(A):
        if a % K == 1:
            ans += 1
        j = 1
        while i - j >= 0 and j + 1 < K:
            if (sum(A[i - j: i]) + a) % K == j + 1:
                ans += 1
            j += 1
    print(ans)


# 和-長さ を覚える
counts = defaultdict(int)
hist = [-1] * N
offset = 0
ans = 0
for i, a in enumerate(A):
    a %= K
    if a == 1:
        ans += 1
    ans += counts[(K - a + 1 - offset) % K]
    offset += a - 1
    offset %= K
    counts[(a - 1 - offset) % K] += 1

    if i - K + 2 >= 0:
        counts[hist[i - K + 2]] -= 1
    hist[i] = (a - 1 - offset) % K
print(ans)
### BUGGY CODE ###

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

P = 1

for i in range(N):
    P = P * A[i]
    
if P <= 1e18:
    print(P)
else:
    print(-1)

### FIXED CODE ###

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

P = 1
flag = 0

for i in range(N):
    P = P * newA[i]
    if P == 0:
        print(P)
        flag = 1
        break
    elif P > 1e18:
        print(-1)
        flag = 1
        break
        
if flag == 0:
    print(P)
### BUGGY CODE ###

import numpy

N = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))
T.insert(0, 0)
V.insert(0, 0)
V.append(0)

Z = [0] * (len(T))
for i in range(len(T)-1):
    Z[i+1] = Z[i] + T[i+1]
gokei_T = sum(T)
K = [[0, 0]]
for i in range(N):
    K.append([Z[i], Z[i+1]])
K.append([gokei_T, gokei_T])

ans = 0
for time in numpy.arange(0, gokei_T, 0.5):
    speed = 10**5
    for k, v in zip(K, V):
        if time <= k[0]:
            tmp = v + (k[0]-time)
        elif k[0] <= time <= k[1]:
            tmp = v
        elif k[1] <= time:
            tmp = v + (time - k[1])

        speed = min(speed, tmp)
    ans += 0.5 * speed

print(ans)

### FIXED CODE ###

"""
prd_xxx 様のコードを参考にさせていただきました。感謝です...！
https://beta.atcoder.jp/contests/abc076/submissions/1724160
"""

N = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))

maxv = [0]
# グラフを整える準備
for v, t in zip(V, T):
    # 転換地点では低い方に合わせる
    maxv[-1] = min(maxv[-1], v)
    for ti in range(t * 2):
        maxv.append(v)

T = len(maxv)
# 前からグラフを整える
for i in range(T - 1):
    maxv[i + 1] = min(maxv[i+1], maxv[i] + 0.5)

maxv[-1] = 0
# 後ろからグラフを整える
for i in reversed(range(T-1)):
    maxv[i] = min(maxv[i], maxv[i + 1] + 0.5)

ans = 0
# 台形計算
for i in range(T-1):
    ans += (maxv[i] + maxv[i+1]) * 0.25
print(ans)
### BUGGY CODE ###

N,Q = map(int,input().split())
S = input()
tmp = ''
kesu = ''
ans = 0
for i in range(Q):
    LR = list(map(int, input().strip().split(' ')))
    ans = 0
    tmp = S[LR[0]-1:LR[1]]
    kesu = tmp.replace('AC', '')
    ans = (LR[1]-LR[0]+1-len(kesu))/2
    print(int(ans))

### FIXED CODE ###

# 答案
N,Q = map(int,input().split())
S = input()
l,r = 0,0
csum = [0]*(N+1)

# 累積和
for ctr in range(N):
    if ctr == (N-1):
        csum[ctr+1] = csum[ctr]
    elif S[ctr]=='A' and S[ctr+1]=='C':
        csum[ctr+1] = csum[ctr] + 1
    else:
        csum[ctr+1] = csum[ctr]

# 出力
for ctr in range(Q):
    l,r=map(int,input().split())
    print(csum[r-1] - csum[l-1])
### BUGGY CODE ###

[N,L] = [int(x) for x in input().split()]
A = {}
B = [0]*N
ANS = {}
count = 0
for i,x in enumerate(input().split()):
    i = int(i)
    x = int(x)
    B[i] = x
    if x in A : A[x] += [i]
    else : A[x] = [i]
for i in range(10**9) :
    try:
        for j in A[i] :
            for k in range(L) :
                if j + k not in ANS :
                    ANS[j+k] = i
                    count += 1
        if count > N * 0.9997 : break
    except KeyError:
        continue

for i in range(L):
    if i not in ANS : ANS[i] = min(B[:i+1])
for i in range(L,N):
    if i not in ANS : ANS[i] = min(B[i+1-L:i+1])
for i in range(L-1,N-1) : print(ANS[i], end=" ")
print(ANS[N-1])

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
### BUGGY CODE ###

X, Y, A, B, C = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

A = A[0:X]
B = B[0:Y]

arr = A+B

for c in C:
  _min = min(arr)
  if c >= _min:
    arr[arr.index(_min)] = c

print(sum(arr))

### FIXED CODE ###

import numpy as np
X, Y, A, B, C = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

A = A[0:X]
B = B[0:Y]
D = A+B+C

D.sort(reverse=True)

D = D[0:X+Y]
print(sum(D))
### BUGGY CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))

cost=[0]*n
for i in range(1,n):
  cost[i]=min( [cost[i-j]+abs(h[i]-h[i-j]) for j in range(1,min(i+1,k+1))] )
print(cost[-1])

### FIXED CODE ###

N,K=map(int,input().split())
listH=list(map(int,input().split()))
cost=[10**9]*N
cost[0]=0
for i in range(1,N):
  for k in range(1,K+1):
    if i-k>=0:
      cost[i]=min(abs(listH[i-k]-listH[i])+ cost[i-k],cost[i])
ans=cost[N-1]      
print(ans)
### BUGGY CODE ###

# coding: utf-8


def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    A = [None] * M
    B = [None] * M
    for i in range(M):
        A[i], B[i] = map(int, input().split())
        A[i] -= 1
        B[i] -= 1
    
    paths = {i: [] for i in range(N)}
    for i in range(M):
        if B[i] not in paths[A[i]]:
            paths[A[i]].append(B[i])
        if A[i] not in paths[B[i]]:
            paths[B[i]].append(A[i])
    
    good = [None] * N
    for i in range(N):
        if good[i] is not None:
            continue
        
        neighs = paths[i]
        for neigh in neighs:
            if H[i] <= H[neigh]:
                good[i] = False
            if H[i] >= H[neigh]:
                good[neigh] = False
        
        if good[i] is None:
            good[i] = True
    
    ans = 0
    for i in range(N):
        if good[i]:
            ans += 1
    
    return ans


print(main())


### FIXED CODE ###

# coding: utf-8


def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    A = [None] * M
    B = [None] * M
    for i in range(M):
        A[i], B[i] = map(int, input().split())
        A[i] -= 1
        B[i] -= 1
    
    paths = [[] for _ in range(N)]
    for i in range(M):
        if B[i] not in paths[A[i]]:
            paths[A[i]].append(B[i])
        if A[i] not in paths[B[i]]:
            paths[B[i]].append(A[i])
    
    good = [None] * N
    for i in range(N):
        if good[i] is not None:
            continue
        
        neighs = paths[i]
        for neigh in neighs:
            if H[i] <= H[neigh]:
                good[i] = False
            if H[i] >= H[neigh]:
                good[neigh] = False
        
        if good[i] is None:
            good[i] = True
    
    ans = 0
    for i in range(N):
        if good[i]:
            ans += 1
    
    return ans


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

N,K=list(map(int,input().split()))
dp_list=[10**10]*(N+K)
h=list(map(int,input().split()))
for _ in range(K):h.append(0)
dp_list[0]=0
for i in range(N):
    for j in range(1,K+1):
        k=i+j
        dp_list[k]=min(dp_list[k],abs(h[k]-h[i])+dp_list[i])
print(dp_list[N-1])

### FIXED CODE ###

import numpy as np
N,K=list(map(int,input().split()))
dp_list=np.full(N,10**10,dtype=int)
h=list(map(int,input().split()))
h=np.array(h)
dp_list[0]=0
for i in range(1,N):
        dp_list[i:i+K] = np.fmin(dp_list[i:i+K], dp_list[i-1] + np.abs(h[i:i+K] - h[i-1]))
print(dp_list[-1])
### BUGGY CODE ###

n, m = map(int, input().split(' '))
submits = [list(input().split(' ')) for i in range(m)]

WAs = [0] * n
ACs = []
penalty = 0
for submit in submits:
    p, s = submit
    p = int(p) - 1
    if p in ACs:
        continue
    if s == 'AC':
        penalty += WAs[p]
        ACs.append(p)
    else:
        WAs[p] += 1

print(len(ACs), penalty)


### FIXED CODE ###

import sys
input = sys.stdin.readline

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

WAs = [0] * n
correct = 0
penalty = 0
for i in range(m):
    p, s = input().strip().split(' ')
    p = int(p) - 1
    if WAs[p] == -1:
        continue
    if s == 'AC':
        penalty += WAs[p]
        correct += 1
        WAs[p] = -1
    else:
        WAs[p] += 1

print(correct, penalty)
### BUGGY CODE ###

N = int(input())
List = list(map(int,input().split()))
List.sort()
counter = 0
for i in range(N-2):
  for j in range(N-i-2):
    k = i + j + 2
    while k < N:
      if List[i+j+1] + List[i] > List[k]:
        counter += 1
        k += 1
      else:
          break
print(counter)

### FIXED CODE ###

import bisect
N = int(input())
List = list(map(int,input().split()))
List.sort()
ans = 0
for i in range(N-1):
  for j in range(i+1, N):
    ans += bisect.bisect_left(List,List[i]+List[j])-(j+1)
print(ans)