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

class BIT:
    '''
    0-indexed
    '''
    def __init__(self, N):
        self.size = N
        self.tree = [0] * (N + 1)
        self.depth = n.bit_length()
     
    def clear(self):
        self.tree = [0] * (self.size + 1)

    def _bitsum(self, i):
        ret = 0
        while i:
            ret += self.tree[i]
            i ^= i & -i
        return ret

    def bitsum(self, l, r=None): # [l, r)
        if r is None:
            return self._bitsum(l)
        else:
            return self._bitsum(r) - self._bitsum(l)

    def bitadd(self, i, x):
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
        return

n = int(input())
m = (n * (n - 1) // 2) // 2 + 1
a = list(map(int, input().split()))
bit = BIT(n+10)

def check(X):
  b = [0] + [(y>=X)*2 - 1 for y in a]
  for i in range(n):
    b[i+1] += b[i]
  c = min(b)
  b = [x-c for x in b] 
  bit.clear()
  ans = 0
  for x in b:
    ans += bit.bitsum(x+1)
    bit.bitadd(x, 1)
  return ans >= m

t = [max(a) + 1, min(a) - 1]
while t[0] - t[1] > 1:
  mid = (t[0] + t[1]) // 2
  t[check(mid)] = mid
print(t[1])

### FIXED CODE ###

class BIT:
    '''
    0-indexed
    '''
    def __init__(self, N):
        self.size = N
        self.tree = [0] * (N + 1)
        self.depth = n.bit_length()

    def _bitsum(self, i):
        ret = 0
        while i:
            ret += self.tree[i]
            i ^= i & -i
        return ret

    def bitsum(self, l, r=None): # [l, r)
        if r is None:
            return self._bitsum(l)
        else:
            return self._bitsum(r) - self._bitsum(l)

    def bitadd(self, i, x):
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
        return

n = int(input())
m = n * (n + 1) // 4
a = list(map(int, input().split()))
d = dict()
_a = sorted(set(a + [0]))
for i, x in enumerate(_a):
  d[x] = i
a = [d[x] for x in a]


def check(X):
  b = [0] + [(y>=X)*2 - 1 for y in a]
  for i in range(n):
    b[i+1] += b[i]
  c = min(b)
  b = [x-c for x in b] 
  bit = BIT(max(b) + 2)
  ans = 0
  for x in b:
    ans += bit.bitsum(x + 1)
    bit.bitadd(x, 1)
  return ans >= m

t = [len(_a), 0]
while t[0] - t[1] > 1:
  mid = (t[0] + t[1]) // 2
  t[check(mid)] = mid
print(_a[t[1]])
### BUGGY CODE ###

import sys
#大きすぎるとダメ
sys.setrecursionlimit(2510)
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
inf=1000000000000000
d=[[inf]*w for i in range(h)]


def dfs(i,j):
    global h,w,s
    nex=[(0,-1),(0,1),(-1,0),(1,0)]
    for k in range(4):
        l,m=i+nex[k][0],j+nex[k][1]
        if 0<=i+nex[k][0]<h and 0<=j+nex[k][1]<w:
            if s[l][m]=="." and d[l][m]>d[i][j]+1:
                d[l][m]=d[i][j]+1
                dfs(l,m)
d[0][0]=0
dfs(0,0)
ans=0
for i in range(h):
    for j in range(w):
        if s[i][j]==".":
            ans+=1
if d[h-1][w-1]==inf:
    print(-1)
else:
    print(ans-d[h-1][w-1]-1)




### FIXED CODE ###

#一個だけRE、わからねえ
#解答見る
import sys
sys.setrecursionlimit(1005)
h,w=map(int,input().split())

def go_next(I,J,n):
    n+=1
    global dp,w,h
    if n>1000:
        return
    if 0<=I<h-1:
        if x[I+1][J]=="." and dp[I+1][J]>dp[I][J]+1:
            dp[I+1][J]=dp[I][J]+1
            go_next(I+1,J,n)
    if 0<I<=h-1:
        if x[I-1][J]=="." and dp[I-1][J]>dp[I][J]+1:
            dp[I-1][J]=dp[I][J]+1
            go_next(I-1,J,n)
    if 0<=J<w-1:
        if x[I][J+1]=="." and dp[I][J+1]>dp[I][J]+1:
            dp[I][J+1]=dp[I][J]+1
            go_next(I,J+1,n)
    if 0<J<=w-1:
        if x[I][J-1]=="." and dp[I][J-1]>dp[I][J]+1:
            dp[I][J-1]=dp[I][J]+1
            go_next(I,J-1,n)

x=[]
for i in range(h):
    x.append(list(input()))
#print(x)
c=0
for i in range(h):
    for j in range(w):
        if x[i][j]==".":
            c+=1
dp=[[10000000000 for i in range(w)]for j in range(h)]
dp[0][0]=1
go_next(0,0,0)
if dp[h-1][w-1]==10000000000:
    print(-1)
else:
    print(c-dp[h-1][w-1])
### BUGGY CODE ###

import numpy as np

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

A = []
B = []

for i in range(H):
    A.append(list(map(int, input().split())))

for i in range(H):
    B.append(list(map(int, input().split())))

dp = False * np.ones([H, W, 80**2+1], dtype=bool)
dp[0][0][abs(A[0][0] - B[0][0])] = True

for i in range(H):
    for j in range(W):
        diff = A[i][j] - B[i][j]
        if i > 0:
            idx = np.where(dp[i - 1][j][:])[0]
            dp[i][j][np.clip(np.abs(idx - diff), 0, 80**2)] = True
            dp[i][j][np.clip(np.abs(idx + diff), 0, 80**2)] = True

        if j > 0:
            idx = np.where(dp[i][j - 1][:])[0]
            dp[i][j][np.clip(np.abs(idx - diff), 0, 80**2)] = True
            dp[i][j][np.clip(np.abs(idx + diff), 0, 80**2)] = True

print(dp[H - 1][W - 1][:].nonzero()[0].min())


### FIXED CODE ###

import numpy as np

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

A = []
B = []

max_bias = 80
bias = max_bias * (H + W - 1) + 1

for i in range(H):
    A.append(list(map(int, input().split())))

for i in range(H):
    B.append(list(map(int, input().split())))

A = np.array(A, dtype=np.int)
B = np.array(B, dtype=np.int)
D = np.abs(A - B)

dp = np.zeros([H, W, bias * 2 + 1], dtype=bool)
dp[0][0][bias - D[0][0]] = True
dp[0][0][bias + D[0][0]] = True

for i in range(H):
    for j in range(W):
        diff = D[i][j]
        
        if i > 0:
            dp[i, j, diff:] |= dp[i - 1, j, :bias * 2 + 1 - diff]
            dp[i, j, : bias * 2 + 1 - diff] |= dp[i - 1, j, diff:]

        if j > 0:
            dp[i, j, diff:] |= dp[i, j - 1, :bias * 2 + 1 - diff]
            dp[i, j, : bias * 2 + 1 - diff] |= dp[i, j - 1, diff:]

idx = dp[H - 1][W - 1][:].nonzero()[0]
print(np.abs(idx - bias).min())
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000000)
a=['dream','dreamer','erase','eraser']
def check(c):
    rt=False
    size=len(c)
    if c=='':
        return True
    for i in a:
        if size>=len(i) and c[:len(i)]==i:
            rt=check(c[len(i):]) or rt
    return rt

print('YES' if check(input()) else 'NO')

### FIXED CODE ###

a=['dream','dreamer','erase','eraser']
def check(c):
    if c=='':
        return True
    size=len(c)
    n=len(c)
    while n>0:
        tmp=n
        for i in a:
            #print(-n-len(i),-n)
            if size>=len(i) and c[n-len(i):n]==i:
                n-=len(i)
        if tmp==n:
            return False
    return True

print('YES' if check(input()) else 'NO')
### BUGGY CODE ###

from sys import stdin
from collections import defaultdict
from collections import deque

N,M = list(map(int,stdin.readline().split()))
Cs = [tuple(map(int,stdin.readline().split())) for _ in range(M)]
S,T = list(map(int,stdin.readline().split()))

INF = 10 ** 15
# visit = [False] * ( (N + 1) * 3 )
dist  = [-1] * ( (N) * 3 + 1 )
graph_connection = defaultdict(lambda :[])
graph_cost = defaultdict(lambda :defaultdict(lambda :INF))
#
# def dfs(v,dist_before):
#
#     dist[v] = dist_before + 1
#     next_vertexs = graph_connection[v]
#     for next_v  in next_vertexs :
#         if dist[next_v] == -1:
#             dfs(next_v,dist[v])
#     return 0
#

for cost in  Cs:
    a,b= cost
    for i in range(0,3):
        from_v = a + (i) * N
        to_v = b + (i + 1) % 3 * N
        graph_connection[from_v].append(to_v )

        # from_v = b + (i) * N
        # to_v = a + (i + 1) % 3 * N
        # graph_connection[from_v].append(to_v )

# dist[S] = 0


que = deque()
#(from_v,to_v)
que.append((S,S))

while len(que) != 0:
    from_v, to_v = que.popleft()
    dist[to_v] = dist[from_v] + 1
    if to_v == T:
        break
    for next_v in graph_connection[to_v]:
        if dist[next_v] == -1:
            que.append((to_v,next_v))
if dist[T] < 0:
    print(dist[T] )
else:
    print(dist[T]//3)


### FIXED CODE ###

from sys import stdin
from collections import defaultdict
from collections import deque

N,M = list(map(int,stdin.readline().split()))
Cs = [tuple(map(int,stdin.readline().split())) for _ in range(M)]
S,T = list(map(int,stdin.readline().split()))

INF = 10 ** 15
# visit = [False] * ( (N + 1) * 3 )
dist  = [-1] * ( (N) * 3 + 1 )
graph_connection = defaultdict(lambda :[])
graph_cost = defaultdict(lambda :defaultdict(lambda :INF))
#
# def dfs(v,dist_before):
#
#     dist[v] = dist_before + 1
#     next_vertexs = graph_connection[v]
#     for next_v  in next_vertexs :
#         if dist[next_v] == -1:
#             dfs(next_v,dist[v])
#     return 0
#

for cost in  Cs:
    a,b= cost
    for i in range(0,3):
        from_v = a + (i) * N
        to_v = b + (i + 1) % 3 * N
        graph_connection[from_v].append(to_v )

        # from_v = b + (i) * N
        # to_v = a + (i + 1) % 3 * N
        # graph_connection[from_v].append(to_v )

# dist[S] = 0


que = deque()
#(from_v,to_v)
dist[S] = 0
que.append(S)
while len(que) != 0:
    from_v = que.popleft()
    nexts = graph_connection[from_v]
    for next_v in nexts:
        if dist[next_v] == -1:
            dist[next_v] = dist[from_v] + 1
            que.append(next_v)

if dist[T] < 0:
    print(dist[T] )
else:
    print(dist[T]//3)
### BUGGY CODE ###

from statistics import median
from operator import itemgetter
N = int(input())
x = list(map(int, input().split()))
y = [x for x in range(N)]
z = list(zip(x, y))
z.sort()
x_, y = zip(*z)
val = N//2

for i in range(N):
    if list(y).index(i) < val:
        print(x_[val])
    else:
        print(x_[val-1])



### FIXED CODE ###

from statistics import median
from operator import itemgetter
N = int(input())
x = list(map(int, input().split()))
x_ = sorted(x)
m0 = median(x_[1:])
m1 = median(x_[:-1])
for i in x:
    if m1 >= i:
        print(m0)
    else:
        print(m1)
### BUGGY CODE ###

n = int(input())
s = input()
s = [s[i:i+1] for i in range(n)]
cost = [0 for _ in range(n + 1)]
lin = 0
rin = n
for i in range(n + 1):
	cost[i] = s[0:i].count('W') + s[i + 1:n].count('E')
print(min(cost))

### FIXED CODE ###

n = int(input())
s = input()
s = [s[i:i+1] for i in range(n)]
lcost = [0 for _ in range(n)]
rcost = [0 for _ in range(n)]
if s[0] == 'W':
  lcost[0] = 1
if s[-1] == 'E':
  rcost[-1] = 1
for i in range(1, n):
  if s[i] == 'W':
    lcost[i] = lcost[i - 1] + 1
  else:
    lcost[i] = lcost[i - 1]
for i in range(2, n + 1):
  if s[-i] == 'E':
    rcost[-i] = rcost[-i + 1] + 1
  else:
    rcost[-i] = rcost[-i + 1]
mincost = min(lcost[-1], rcost[0])
#print(lcost)
#print(rcost)
for i in range(1, n - 1):
  hoge = lcost[i - 1] + rcost[i + 1]
  if hoge < mincost:
    mincost = hoge
print(mincost)
### BUGGY CODE ###

def main():
    import re

    n, q, s, *lr = open(0).read().split()
    *l, =  map(int, lr[::2])
    *r, = map(int, lr[1::2])
    n = int(n)
    memo = [[None for _ in range(n + 1)] for _ in range(n + 1)]
    for i, j in zip(l, r):
        if memo[i][j] is not None:
            print(memo[i][j])
        else:
            m = re.findall('AC', s[i - 1:j])
            memo[i][j] = len(m)
            print(len(m))


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    from itertools import accumulate

    n, q, s, *lr = open(0).read().split()
    n = int(n)
    *l, = map(int, lr[::2])
    *r, = map(int, lr[1::2])
    c = [1 if s[i] == 'C' and s[i - 1] == 'A' else 0 for i in range(n)]
    a = list(accumulate(c))
    ans = ''
    for i,j in zip(l,r):
        ans += str(a[j-1]-a[i-1]) + '\n'
    print(ans)

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

s = " " + input()
t = " " + input()

dp = [[[] for _ in range(len(t))] for _ in range(len(s))]

import copy
for i in range(1, len(s)):
    for j in range(1, len(t)):
        if len(dp[i-1][j]) > len(dp[i][j-1]):
            dp[i][j] = copy.copy(dp[i-1][j])
        else:
            dp[i][j] = copy.copy(dp[i][j-1])
        if s[i] == t[j]:
            tp = dp[i - 1][j - 1]
            tp.append(s[i])
            if len(tp) > len(dp[i][j]):
                dp[i][j] = tp
print("".join(dp[len(s) - 1][len(t) - 1]))

### FIXED CODE ###

s = " " + input()
t = " " + input()

dp = [[0 for _ in range(len(t))] for _ in range(len(s))]

for i in range(1, len(s)):
    for j in range(1, len(t)):
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1] + (1 if s[i] == t[j] else 0))

i = len(s) - 1
j = len(t) - 1
c = 0
ans = []
ansl = dp[-1][-1]
while (c < ansl):
    if s[i] == t[j]:
        ans.append(s[i])
        i -= 1
        j -= 1
        c += 1
    else:
        if dp[i - 1][j] > dp[i][j - 1]:
            i -= 1
        else:
            j -= 1
ans.reverse()
print("".join(ans))
### BUGGY CODE ###

N = int(input())
S = input()
ans = 0
for i in range(1000):
    lucky = str(i)
    if 0 <= i <= 9:
        lucky = "00" + lucky
    elif 10 <= i <= 99:
        lucky = "0" + lucky
    else:
        pass
    now = 0
    index = 0
    while index < N:
        if lucky[now] == S[index]:
            now += 1
        if now == 3:
            ans += 1
            break
        index += 1
print(ans)


### FIXED CODE ###

N = int(input())
S = input()
ans = 0
for i in range(1000):
    lucky = str(i)
    if 0 <= i <= 9:
        lucky = "00" + lucky
    elif 10 <= i <= 99:
        lucky = "0" + lucky
    else:
        pass
    now = 0
    index = 0
    while index < N:
        if lucky[now] == S[index]:
            now += 1
        if now == 3:
            ans += 1
            break
        index += 1
print(ans)
### BUGGY CODE ###

n,m=[int(x) for x in input().split()]
x=[int(x) for x in input().split()]
y=[int(x) for x in input().split()]
from itertools import product
mod=10**9+7
ans=0
for i,j in product(range(1,n),range(1,m)):
    ans=(ans+(x[i]-x[i-1])*(y[j]-y[j-1])*i*(n-i)*j*(m-j))%mod
print(ans)

### FIXED CODE ###

n,m=[int(x) for x in input().split()]
x=[int(x) for x in input().split()]
y=[int(x) for x in input().split()]
mod=10**9+7
ans=0
ysum=0
for j in range(1,m):
    ysum+=(y[j]-y[j-1])*j*(m-j)
for i in range(1,n):
    ans=ans+(x[i]-x[i-1])*i*(n-i)*ysum
print(ans%mod)
### BUGGY CODE ###

N,K=map(int,input().split())
A=list(map(int, input().split()))
cnt=0
for i in range(N):
    if K+i<=N:
            B=A[i:K+i]
            res=[]
            for b in B:
                tmp=0
                for i in range(1,b+1):
                    tmp+=i
                res.append(tmp/b)
    if cnt<sum(res):
        cnt=sum(res)
print(cnt)

### FIXED CODE ###

N,K=map(int, input().split())
S=list(map(int, input().split()))
s=sum(S[:K])
dp=[0]*(N-K+1)
dp[0]=s
for i in range(1,N-K+1):
    s=s-S[i-1]+S[i+K-1]
    if s>dp[i-1]:
        dp[i]=s
print((max(dp)+K)/2)
### BUGGY CODE ###

class Dict(object):

    m1 = 1046527
    m2 = m1 - 1

    def __init__(self):
        self._dict = [""] * self.m1

    def insert(self, k):
        i = 0

        while True:
            ix = self._h(k, i)
            if self._dict[ix] == "":
                self._dict[ix] = k
                return
            else:
                i += 1

    def find(self, k):
        i = 0

        while True:
            ix = self._h(k, i)
            if self._dict[ix] == k:
                return True
            elif self._dict[ix] == "":
                return False
            else:
                i += 1

        return False

    def _h(self, k, i):
        return (self._h1(k) + i * self._h2(k)) % self.m1

    def _h1(self, k):
        return k % self.m1

    def _h2(self, k):
        return k % self.m2 + 1


def to_int(s):
    ret = 0
    i = 1
    for j in range(len(s)):
        e = s[len(s) - j - 1]

        if e == 'A':
            ret += 1 * i
        elif e == 'C':
            ret += 2 * i
        elif e == 'G':
            ret += 3 * i
        elif e == 'T':
            ret += 4 * i
        i *= 5

    return ret


if __name__ == '__main__':
    n = int(input())

    d = Dict()

    for _ in range(n):
        cmd, val = input().split()

        if cmd[0] == "i":
            d.insert(to_int(val))
        else:
            ans = "yes" if d.find(to_int(val)) else "no"
            print(ans)

### FIXED CODE ###

M = 1046527
L = 14
H = [""] * M
 
def getChar(ch):
    if ch == 'A':
        return 1
    elif ch == 'C':
        return 2
    elif ch == 'G':
        return 3
    elif ch == 'T':
        return 4
    else:
        return 0
 
def getKey(strings):
    Sum = 0
    p = 1
    for i in xrange(len(strings)):
        Sum += p * getChar(strings[i])
        p *= 5
 
    return Sum
 
def h1(key):
    return key % M
 
def h2(key):
    return 1 + (key % (M-1))
 
def find(strings):
    key = getKey(strings)
    i = 0
    while True:
        h = (h1(key) + i * h2(key)) % M
        if H[h] == strings:
            return 1
        elif len(H[h]) == 0:
            return 0
        else:
            i += 1
    return 0
 
def insert(strings):
    key = getKey(strings)
    i = 0
    while True:
        h = (h1(key) + i * h2(key)) % M
        if H[h] == strings:
            return 1
        elif len(H[h]) == 0:
            H[h] = strings
            return 0
        else:
            i += 1
    return 0
 
def main():
    n = input()
    for i in xrange(n):
        com = raw_input().split()
        if com[0][0] == 'i':
            insert(com[1])
        else:
            if find(com[1]):
                print 'yes'
            else:
                print 'no'
    return 0
 
main()
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))


L=[str(a.index(i)+1) for i in range(1,n+1)]
print(" ".join(L))


### FIXED CODE ###

from operator import itemgetter
n=int(input())
a=list(map(int,input().split()))

print(*[t[0] +1 for t in sorted(enumerate(a),key=itemgetter(1))])
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
import itertools


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    c = itertools.combinations_with_replacement(range(1, N + 1), 2)
    cnt = 0
    for i in c:
        x = i[0]
        y = i[1]
        if y - A[y - 1] == x + A[x - 1]:
            cnt += 1
    print(cnt)
    return

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
# import itertools
import collections


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N = int(input())
    A = [int(x) for x in input().split()]

    # # TLE
    # c = itertools.combinations_with_replacement(range(1, N + 1), 2)
    # cnt = 0
    # for i in c:
    #     x = i[0]
    #     y = i[1]
    #     if x + A[x - 1] == y - A[y - 1]:
    #         cnt += 1
    # print(cnt)

    L = []  # 左辺
    R = []  # 右辺
    for i in range(N):
        x = y = i + 1
        L.append(x + A[i])
        R.append(y - A[i])
    cl = collections.Counter(L)
    cr = collections.Counter(R)
    ans = 0
    for i in range(N):
        if i in cl and i in cr:
            ans += cl[i] * cr[i]
    print(ans)
    return

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

n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

import itertools
bit = list(itertools.product([0,1], repeat=n))

ans = []
for i in range(2 ** n):
    arr = list(bit[i])
    x = 0
    y = 0
    for j in range(len(arr)):
        if arr[j] == 1:
            x += v[j]
            y += c[j]
    ans.append(x-y)
print(max(ans))


### FIXED CODE ###

n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

count = 0
for i in range(n):
    if v[i] >= c[i]:
        count += v[i] - c[i]

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

import sys
from io import StringIO
import unittest

def resolve():
    n, m = map(int, input().split())

    red = set([1])
    balls = [1 for _ in range(n)]

    for _ in range(m):
        x, y = map(int, input().split())

        if x in red and balls[x - 1] >= 2:
            red = red | set([y])
        elif x in red and balls[x - 1] == 1:
            red = (red | set([y])) - set([x])

        balls[x - 1] -= 1
        balls[y - 1] += 1

        # print(red, balls)

    print(len(red))

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例1(self):
        input = """3 2
1 2
2 3"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例2(self):
        input = """3 3
1 2
2 3
2 3"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例3(self):
        input = """4 4
1 2
2 3
4 1
3 4"""
        output = """3"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

### FIXED CODE ###

import sys
from io import StringIO
import unittest

def resolve():
    n, m = map(int, input().split())

    red = [0 for _ in range(n)]
    red[0] = 1
    balls = [1 for _ in range(n)]

    for _ in range(m):
        x, y = map(int, input().split())

        if red[x - 1] == 1:
            red[y - 1] = 1

        balls[x - 1] -= 1
        balls[y - 1] += 1

        if balls[x - 1] == 0:
            red[x - 1] = 0

    print(sum(red))

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例1(self):
        input = """3 2
1 2
2 3"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例2(self):
        input = """3 3
1 2
2 3
2 3"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例3(self):
        input = """4 4
1 2
2 3
4 1
3 4"""
        output = """3"""
        self.assertIO(input, output)

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

from collections import Counter
import sys
sdin = sys.stdin.readline

n,t = map(int, sdin().split())
a = list(map(int, sdin().split()))

# iまででの最高と最低
diff_list = [] # iを含むiまでの最低
max_list = [] # iを含まないiからの最高

mini = max(a)
maxi = max(a)

# iまでの最低と最高を更新
for i in range(n-1):
    if a[i] < mini:
        mini = a[i]
    
    if a[i] == maxi:
        maxi = max(a[i+1:])
        
    diff_list.append(maxi-a[i])
    
cnt = Counter(diff_list)

# 最大値の個数
print(cnt[max(cnt.keys())])
    

### FIXED CODE ###

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


a_min = float("inf")
a_max = 0
a_diff = 0

ans = 0
a_diff = -1

for a in A:

    hasModefied = False
    if a_min > a:
        a_min = a
        a_max = a
    if a_max < a:
        a_max = a
        hasModefied = True
        
    if hasModefied:
        if a_diff == a_max-a_min:
            ans += 1
        elif a_diff < a_max-a_min:
            a_diff = a_max - a_min
            ans = 1
            
print(ans)
### BUGGY CODE ###

import numpy as np

n = int(input())
A = np.array(list(map(int, input().split())))

mod = 10**9+7

ans = 0
for i in range(n-1):
    ans += sum(A[i] * A[i+1:])
    ans %= mod
print(ans)

### FIXED CODE ###

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

mod = 10**9+7

cs = [0]
for a in A:
    cs.append(cs[-1]+a)
cs = cs[1:]

ans = 0
for i in range(n):
    ans += A[i] * (cs[-1]-cs[i])
    ans %= mod
print(ans)
### BUGGY CODE ###

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

score = [1 for _ in range(N)]
for i in range(K-1,N):
  for j in range(K):
    score[i] *= A[i-j]
  
for k in range(K-1,N-1):
  if score[k] < score[k+1]:
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

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

for i in range(K-1,N-1):
  if A[i+1-K] < A[i+1]:
    print("Yes")
  else:
    print("No")