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

from bisect import bisect_left
a, b, q = map(int, input().split())
S = [int(input()) for i in range(a)]
T = [int(input()) for i in range(b)]
for _ in range(q):
    x = int(input())
    i = bisect_left(S, x)
    j = bisect_left(T, x)
    if i == 0:
        s = [S[0]]
    elif i == len(S):
        s = [S[-1]]
    else:
        s =[S[i - 1], S[i]]
    if j == 0:
        t = [T[0]]
    elif j == len(T):
        t = [T[-1]]
    else:
        t =[T[j - 1], T[j]]
    ans = []
    for i in range(len(s)):
        for j in range(len(t)):
            ans.append(abs(x - s[i]) + abs(s[i] - t[j]))
    for j in range(len(t)):
        for i in range(len(s)):
            ans.append(abs(x - t[j]) + abs(t[j] - s[i]))
    print(min(ans))

### FIXED CODE ###

from bisect import bisect_left
a, b, q = map(int, input().split())
INF = 10 ** 12
S = [int(input()) for i in range(a)]
S.append(INF)
T = [int(input()) for i in range(b)]
T.append(INF)
for _ in range(q):
    x = int(input())
    i = bisect_left(S, x)
    j = bisect_left(T, x)
    ans = []
    for y in [S[i-1],S[i]]:
        for z in [T[j - 1], T[j]]:
            ans.append(abs(x - y) + abs(y - z))
            ans.append(abs(x - z) + abs(z - y))
    print(min(ans))
### BUGGY CODE ###

import numpy as np 
import collections

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

for i in range(n):
    _a = np.delete(a, i)
    c_dict = collections.Counter(_a)
    total = 0
    for v in c_dict.values():
        if v >= 2:
            total += v * (v - 1) / 2
    print(int(total))

### FIXED CODE ###

import collections

def solve(N, A):
    c_dict = collections.Counter(A)
    originals = [0 for i in range(N + 1)]
    minus = [0 for i in range(N + 1)]
    
    for (k, v) in c_dict.items():
        originals[k] = v * (v - 1) // 2
        minus[k] = ((v * (v - 1)) - (v - 1) * (v - 2)) // 2
        
    total = sum(originals)
    
    ans = []
    for a in A:
        ans.append(str(total - minus[a]))
    return '\n'.join(ans)
    
if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    print(solve(N, A))
### BUGGY CODE ###

n,m = (int(i) for i in input().split()) 
a = [int(i) for i in input().split()] 
e = [[int(i) for i in input().split()] for i in range(m)]

for i, l in enumerate(e):
  a.sort()
  for j in range(l[0]):
    if (a[j] < l[1]):
	    a[j] = l[1]
    else:
      break
print(sum(a))

### FIXED CODE ###

n,m = (int(i) for i in input().split()) 
a = [int(i) for i in input().split()] 
e = [[int(i) for i in input().split()] for i in range(m)]

a.sort()
e.sort(key=lambda x: x[1], reverse=True)
c = 0
arr = []
for i, el in enumerate(e):
  for j in range(el[0]):
    #print(c,n)
    if (c < n):
        arr.append(el[1])
        c += 1
    else:
        break
  if (c >= n):
    break
retval = 0
#print(arr)
for i in range(c):
  if (a[i] < arr[i]):
    a[i] = arr[i]
    #print(a[i],arr[i])
  else:
    break
  #print(a)
print(sum(a))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**8)

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

dp = [float("inf")] * n #dpテーブル
#dp[i]メモ化テーブル
#まずは使わない

def rec(i):#再帰による全探索
    if i == 0:
        return 0
    elif i == 1:
        return abs(h[0]-h[1])
    else:
        return min(rec(i-1)+abs(h[i]-h[i-1]),rec(i-2)+abs(h[i]-h[i-2]))

print(rec(n-1))


### FIXED CODE ###

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

dp = [float("inf")] * n #dpテーブル
#dp[i]:=i番目の足場まで来るのに必要な最小コスト

#初期条件
dp[0]=0
dp[1]=abs(h[1]-h[0])

for i in range(2,n):
    dp[i] = min(dp[i-1] + abs(h[i-1]-h[i]) ,dp[i-2] + abs(h[i-2]-h[i]))

print(dp[n-1])
### BUGGY CODE ###

def is_even(a):
    return [ai%2 == 0 for ai in a]

N = int(raw_input())
a = [int(s) for s in raw_input().split()]

counter = 0
any_even = is_even(a)

while sum(any_even) > 0:
    even_min_idx, eve_min = min([(i, a[i]) for i in range(N) if any_even[i]])

    for i in range(N):
        if a[i] % 2 == 1:
            a[i] = 3*a[i]
        elif i == even_min_idx:
            a[i] /= 2
        else:
            a[i] *= 3
    counter += 1
    any_even = is_even(a)

print counter

### FIXED CODE ###

def is_even(a):
    return [ai%2 == 0 for ai in a]

def extract_2(ai):
    n = 0
    while ai % 2 == 0:
        ai /= 2
        n += 1
    return n

N = int(raw_input())
a = [int(s) for s in raw_input().split()]

any_even = is_even(a)

evens = [extract_2(a[i]) for i in range(N) if any_even[i]]
print sum(evens)
### BUGGY CODE ###

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

al = list(map(int,input().split()))
al = sorted(al)


cbl = []
for _ in range(m):
    b,c = map(int,input().split())
    cbl.append((c,b))

cbl = sorted(cbl)
for c,b in cbl:
    target = bisect.bisect_left(al, c)
    num = min(bisect.bisect_left(al, c), b)
    al = al[num:target] + [c] * num + al[target:]
print(sum(al))
    

### FIXED CODE ###

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

al = list(map(int,input().split()))
al = sorted(al)


cbl = []
for _ in range(m):
    b,c = map(int,input().split())
    cbl.append((c,b))

sumal = [0]
suma = 0
for a in al:
    suma += a
    sumal.append(suma)
    
cbl = sorted(cbl, reverse=True)

topn = [0 for i in range(n)]
pos = 0
for c,b in cbl:
    for _ in range(b):
        topn[pos] = c
        pos += 1
        if pos == n:
            break
    else:
        continue
    break

sumtopn = [0]
sumtop = 0
for t in topn:
    sumtop += t
    sumtopn.append(sumtop)
ans = 0
for i in range(n+1):
    left = sumal[-1] - sumal[i]
    right = sumtopn[i]
    tmp = left + right
    if tmp > ans:
        ans = tmp
        
print(ans)
### BUGGY CODE ###

def main():
	import sys
	input = sys.stdin.readline
	N = int(input())
	A = [int(input()) for _ in range(N)]
	maxNum = max(A)
	maxIndex = [i for i, x in enumerate(A) if x == max(A)]
	if len(maxIndex) > 1:
		for _ in range(N):
			print(maxNum)
	elif maxIndex[0] == 0:
		print(max(A[1:]))
		for i in range(1, N-1):
			if i != maxIndex[0]:
				print(maxNum)
			else:
				prev = max(max(A[:i]), max(A[i+1:]))
				print(prev)
		print(maxNum)
	elif maxIndex[0] == N-1:
		print(maxNum)
		for i in range(1, N-1):
			if i != maxIndex[0]:
				print(maxNum)
			else:
				prev = max(max(A[:i]), max(A[i+1:]))
				print(prev)
		print(max(A[:N-1]))
	else:
		for i in range(N):
			if i != maxIndex[0]:
				print(maxNum)
			else:
				prev = max(max(A[:i]), max(A[i+1:]))
				print(prev)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
	import sys
	import numpy as np
	input = sys.stdin.readline
	N = int(input())
	A = [int(input()) for _ in range(N)]
	A = np.array(A)
	maxNum = np.max(A)
	maxIndex = np.where(A == A.max())[0]
	if len(maxIndex) > 1:
		for _ in range(N):
			print(maxNum)
	elif maxIndex[0] == 0:
		print(np.max(A[1:]))
		for i in range(1, N):
			print(maxNum)
	elif maxIndex[0] == N-1:
		for i in range(N-1):
			print(maxNum)
		print(np.max(A[:N-1]))
	else:
		for i in range(maxIndex[0]):
			print(maxNum)
		prev = max(np.max(A[:maxIndex[0]]), np.max(A[maxIndex[0]+1:]))
		print(prev)
		for i in range(maxIndex[0]+1, N):
			print(maxNum)



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

import sys
readline = sys.stdin.readline

def main():

	#s = tuple(input())
	s = input()
	length = len(s)

	dp = [[0]*13 for _ in range(length)]
	MOD = 10**9+7
	if s[-1] == '?':
		for i in range(10):
			dp[0][i] = 1
	else:
		dp[0][int(s[-1])] = 1

	for i in range(1,length):
		if s[-i-1] != '?':
			num = (int(s[-i-1]) * (10**i)) % 13
			for j in range(13):
				dp[i][(num+j)%13] = dp[i-1][j]
				dp[i][(num+j)%13] %= MOD
		else:
			num = (10**i) % 13
			for j in range(10):
				for k in range(13):
					dp[i][(num*j+k)%13] += dp[i-1][k]
					dp[i][(num*j+k)%13] %= MOD

	print(dp[-1][5] % MOD)

if __name__ == '__main__':
	main()


### FIXED CODE ###

INF = 10 ** 9 + 7

S = input()
# dp[i][j]はうしろからi桁を13で割った余りがjであるものの個数
dp = [[0] * 13 for _ in range(len(S) + 1)]
dp[0][0] = 1
mul = 1

for i in range(len(S)):
    x = S[-(i + 1)]
    if x == "?":
        for k in range(10):
            for j in range(13):
                dp[i + 1][(mul * k + j) % 13] += dp[i][j]
                dp[i + 1][(mul * k + j) % 13] %= INF
    else:
        k = int(x)
        for j in range(13):
            dp[i + 1][(mul * k + j) % 13] += dp[i][j]
            dp[i + 1][(mul * k + j) % 13] %= INF
    mul = mul * 10 % 13  # 計算量削減のためここで13で割っている

print(dp[len(S)][5])
### BUGGY CODE ###

def main():
    import sys
    input = sys.stdin.readline
    N = int(input())

    A = [tuple(map(int, input().split())) for _ in range(N)]

    # check = [[True] + [False] * (N - 2) for _ in range(N)] #True準備完了、False試合不可
    check = [0] * N #i番目の次の相手のindex

    ans = 0
    i = 0
    tmp = 0
    count = 0
    chance = [i for i in range(N)]
    flag  = [True] * N #試合をしたかどうかチェック
    while tmp < 2 * N + 2 and len(chance) != 0:
        ans += 1
        flag  = [True] * N #試合をしたかどうかチェック
        tmp_lst = []
        # print ('chance', chance)
        for i in chance:
            if check[i] >= N - 1 or flag[i] == False:
                tmp += 1
                continue
            b = A[i][check[i]] - 1
            # print (b)
            if A[b][check[b]] - 1 == i and flag[b]: #試合できる時
                check[i] += 1
                check[b] += 1
                flag[i] = False
                flag[b] = False
                tmp = 0
                count += 1
                tmp_lst.append(i)
                tmp_lst.append(b)
                if count == (N * (N - 1))//2:
                    print (ans)
                    exit()
        chance = tmp_lst
    print (-1)
    return 
            
if __name__ == '__main__':
    main()


### FIXED CODE ###

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

N = int(input())
A = [list(reversed(list(map(lambda x: int(x) - 1, input().split())))) for _ in range(N)]
B = {i: row for i, row in enumerate(A)}

# print (A)
# print (B)

end = 0

for k in range(8000):
    used = set()
    dels = []
    for i, q in B.items():
        if not q:
            continue
        if i in used:
            continue
        j = q[-1]
        if j in used:
            continue
        if A[j][-1] == i:
            A[j].pop()
            A[i].pop()
            used.add(i)
            used.add(j)
            if not A[i]:
                end += 1
                dels.append(i)
            if not A[j]:
                end += 1
                dels.append(j)
    if not used:
        print (-1)
        exit()
    
    if end == N:
        print (k + 1)
        exit()
    
    for i in dels:
        del B[i]
        
print (N * (N - 1) // 2)
### BUGGY CODE ###

n, k, q = map(int, input().split())
p = [k] * n
for i in range(q):
  a = int(input())
  for j in range(n):
    if j != a - 1:
      p[j] -= 1
for i in range(n):
  if p[i] <= 0:
    print('No')
  else:
    print('Yes')

### FIXED CODE ###

from collections import defaultdict
d = defaultdict(int)
n, k, q = map(int, input().split())
for i in range(q):
  d[int(input())] += 1

for i in range(n):
  p = k - q
  if i + 1 in d:
    p += d[i + 1]
  if p <= 0:
    print('No')
  else:
    print('Yes')
### BUGGY CODE ###

import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    h,w=map(int,input().split())
    A=[list(map(int,input().split())) for _ in range(h)]
    B=[list(map(int,input().split())) for _ in range(h)]
    dp=[[[] for _ in range(w)] for _ in range(h)]
    dp[-1][-1].append(A[-1][-1]-B[-1][-1])
    dp[-1][-1].append(-A[-1][-1]+B[-1][-1])

    from itertools import product
    for i,j in product(range(h-1,-1,-1),range(w-1,-1,-1)):
        p=A[i][j]-B[i][j]
        if(i+1<h):
            for x in dp[i+1][j]:
                dp[i][j].append(x+p)
                dp[i][j].append(x-p)
        if(j+1<w):
            for x in dp[i][j+1]:
                dp[i][j].append(x+p)
                dp[i][j].append(x-p)

    print(min(*(abs(x) for x in dp[0][0])))
resolve()

### FIXED CODE ###

import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    h,w=map(int,input().split())
    A=[list(map(int,input().split())) for _ in range(h)]
    B=[list(map(int,input().split())) for _ in range(h)]
    dp=[[0]*w for _ in range(h)]
    x=abs(A[0][0]-B[0][0])
    offset=12800
    dp[0][0]|=1<<(x+offset)
    dp[0][0]|=1<<(-x+offset)

    from itertools import product
    for i,j in product(range(h),range(w)):
        if(i==0 and j==0): continue
        x=abs(A[i][j]-B[i][j])
        S=0
        if(i>0): S|=dp[i-1][j]
        if(j>0): S|=dp[i][j-1]
        dp[i][j]=(S<<x)|(S>>x)

    for i in range(12800):
        if((dp[-1][-1]>>(i+offset))&1):
            print(i)
            return
resolve()
### BUGGY CODE ###

import sys

A=[[0,0,0]]
size = 0

def insert(A,x):
    global size

    fp=A[0][1]
    A.append([x,fp,0])
    A[fp][2]=len(A)-1
    A[0][1]=len(A)-1     
    size += 1    

def delete(A,x):
    global size
    p =A[0][1]
    while A[p][0]!=x:
        p=A[p][1]
        if p==0: return
    fp=A[p][1]
    bp=A[p][2]
    A[fp][2]=bp
    A[bp][1]=fp
    A[p]=[-1,-1,-1]
    size -= 1
    return

def deletefirst(A):
    global size
    if size == 0: return
    p=A[0][1]
    fp=A[p][1]
    A[0][1]=fp
    A[fp][2]=0
    A[p]=[-1,-1,-1]
    size -= 1
    return 0

def deletelast(A):
    global size
    if size == 0: return
    p=A[0][2]
    bp=A[p][2]
    A[0][2]=bp
    A[bp][1]=0
    A[p]=[-1,-1,-1]
    size -= 1
    return 0

n = int(raw_input())
for i in range(n):
    s = (raw_input().split())
    if s[0] == 'insert':
        insert(A,s[1])
    elif s[0] == 'delete':
        delete(A,s[1])
    elif s[0] == 'deleteFirst':
        deletefirst(A)
    elif s[0] == 'deleteLast':
        deletelast(A)

e = A[0][1]
while e!=0:
    print A[e][0],
    e = A[e][1]

### FIXED CODE ###

import sys,gc
    
A=[]
fp =0
bp =0

n=int(raw_input())
while n:
    s = raw_input()
    if s[0] == 'i':
        A.append(int(s[7:]))
        fp += 1
    elif s[6] == ' ':
        try:
            i = A[::-1].index(int(s[7:]))
            if i!=-1:
                del A[-i-1]
                fp -=1
        except:
            pass
    elif s[6] == 'F':
        A.pop()
        fp -=1
    elif s[6] == 'L':
        bp +=1
    n -=1

for e in A[bp:fp+1][::-1]:
    print int(e),
### BUGGY CODE ###

n = int(input())
s = input()
r = list()
for i in range(n):
    if s[i] == "R":
        r.append(i)
b = list()
for i in range(n):
    if s[i] == "B":
        b.append(i)
g = list()
for i in range(n):
    if s[i] == "G":
        g.append(i)
a = len(r) * len(b) * len(g)
for i in r:
    for j in b:
        k = abs(i - j)
        if i + k in g:
            a -= 1
        if i - k in g:
            a -= 1
        if j + k in g:
            a -= 1
        if j - k in g:
            a -= 1
        if (i + j) / 2 in g:
            a -= 1
print(a)

### FIXED CODE ###

n = int(input())
s = input()
r = set()
g = set()
b = set()
for i in range(n):
    if s[i] == "R":
        r.add(i)
    if s[i] == "G":
        g.add(i)
    if s[i] == "B":
        b.add(i)
a = len(r) * len(b) * len(g)
for i in r:
    for j in b:
        k = abs(i - j)
        if i + k in g:
            a -= 1
        if i - k in g:
            a -= 1
        if j + k in g:
            a -= 1
        if j - k in g:
            a -= 1
        if (i + j) / 2 in g:
            a -= 1
print(a)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

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

seg = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

B = {}
for a in A:
    ind = seg[a]
    if not ind in B.keys():
        B[ind] = a
    else:
        if B[ind] < a:
            B[ind] = a

I = sorted(list(B.keys()))
#print(I)
Ap = []
def search(ind, remain, ret, l, maxl):
    if ind >= len(I):
        return False, ret, l
    #print(I[ind], remain, ret)
    a = I[ind]
    p = remain // a
    r = remain % a 
    if p == 0:
        return False, ret, l
    if r == 0:
        ret.append((a, p))
        l += p
        return True, ret, l
    for q in range(p-1, -1, -1):
        nowl = l
        r += a
        oldr = ret[:]
        ok, newr, newl = search(ind+1, r, oldr, nowl, maxl)
        if ok:
            newl += q
            newr.append((a, q))
            if ind == 0:
                if newl >= maxl:
                    maxl = newl
                    Ap.append(newr)
                continue
            return True, newr, newl
    if ind == 0:
        return False, Ap, l
    return False, ret, l

def main():

    only, Ls, l = search(0, N, [], 0, 0)
    #print(Ls)
    if only:
        Q = []
        for k, v in Ls:
            Q.extend([B[k]]*v)
        Q.sort(reverse=True)
        print(''.join([str(q) for q in Q]))
    else:
        anss = []
        for L in Ls:
            P = []
            for k, v in L:
                P.append((B[k], v))
            P.sort(reverse=True)
            Q = []
            for p, v in P:
                Q.extend([p]*v)
            num = int(''.join([str(q) for q in Q]))
            anss.append(num)

        print(max(anss))

if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline

NUM = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
INF = 10**14

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

dp = [-INF]*(N+1)
dp[0] = 0
for i in range(N):
    for a in A:
        c = NUM[a]
        if i + c <= N:
            dp[i+c] = max(dp[i+c], dp[i]+1)

D = dp[N]
ind = N
ans = ''
for _ in range(D):
    for a in A:
        c = NUM[a]
        if ind - c < 0: continue
        if dp[ind] == dp[ind-c] + 1:
            ind -= c
            ans += str(a)
            break
print(ans)
### BUGGY CODE ###

from itertools import zip_longest
def get_X(ls):
    X = list()
    for xs in zip_longest(*ls):
        xs = [i for i in xs if i is not None]
        _sum = sum(xs)
        _len = len(xs)
        if _len - _sum > _sum:
            X.append(1)
        else:
            X.append(0)
    return X

def get_2_order(d, max_len=None):
    i = 1
    ls = []
    while True:
        amari = d%2**i
        ls.append(amari//2**(i-1))
        d -= amari
        if d < 2**i:
            break
        i += 1
    if max_len is not None:
        while len(ls) < max_len:
            ls.append(0)
    return ls

def get_max(X,ls):
    _sum = 0
    for i, xs in enumerate(zip_longest(*ls)):
        xs = [i for i in xs if i is not None]
        _sum += 2**i*sum([1 if x != X[i] else 0 for j,x in enumerate(xs)])
    return _sum


N, K = map(int, input().split())
A_ls = [int(i) for i in input().split()]
if len(A_ls) == 1:
    print(A_ls[0])
else:
    _max = 0
    len_K = len(get_2_order(K))
    A_ls = [get_2_order(d, len_K) for d in A_ls]
    for i in range(K):
        X = get_2_order(i, len_K)
        result = get_max(X, A_ls)
        if _max < result:
            _max = result
    print(_max)

### FIXED CODE ###

import sys
from collections import Counter
INF = 10**18
N, K = [int(i) for i in sys.stdin.readline().split()]
len_k = len(bin(K)[2:])
A_ls = [bin(int(i))[2:] for i in sys.stdin.readline().split()]
max_len = max([len(i) for i in A_ls] + [len_k])
K = bin(K)[2:].zfill(max_len)
A_ls = [A.zfill(max_len) for A in A_ls]
# i番目の解
memo_ls = [0 for i in range(max_len)]
# i番目のみの最適解を考えた時の和
memo_ls2 = [0 for i in range(max_len)]
for i in range(max_len):
    ct = Counter([A[-1-i] for A in A_ls])
    # i番目のけたとして0を選んだ時の和
    ans_0 = 2**i*ct["1"]
    ans_1 = 2**i*ct["0"]
    ct.clear()
    memo_ls[-1-i] = (ans_0, ans_1)
    memo_ls2[-1-i] = max(ans_0, ans_1)
# i-1番目までの解の最大
# memo_ls3[i][j] j : 答えが決まっている時1, いない時0
memo_ls3 = [[0 for i in range(2)] for i in range(max_len + 1)]
memo_ls3[0][1] = -INF
for i, j in enumerate(K, 1):
    if j == "0":
        memo_ls3[i][0] = memo_ls3[i-1][0] + memo_ls[i-1][0]
        memo_ls3[i][1] = memo_ls3[i-1][1] + memo_ls2[i-1]
    else:
        memo_ls3[i][0] = memo_ls3[i-1][0] + memo_ls[i-1][1]
        memo_ls3[i][1] = max(memo_ls3[i-1][1] + memo_ls2[i-1], memo_ls3[i-1][0] + memo_ls[i-1][0])
res = max(memo_ls3[-1])
print(int(res))
### BUGGY CODE ###

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

dp = [0] * N
dp[1] = abs(h[0] - h[1])

for i in range(2, N):
    dp[i] = min([dp[j] + abs(h[i] - h[j]) for j in range(i - K, i) if j >= 0])

print(dp[-1])

### FIXED CODE ###

def main():
    N, K = map(int,input().split())
    h = list(map(int,input().split()))
    
    dp = [0] * N
    dp[1] = abs(h[0] - h[1])
    
    for i in range(2, N):
        dp[i] = min(dp[j] + abs(h[i] - h[j]) for j in range(max(0, i - K), i))
    
    print(dp[-1])

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

def main():
    n = int(input())
    num_list = list(map(int, input().split()))

    count = n

    for i in range(1,n+1):
        for j in range(1,i):
            if num_list[i-1] > num_list[j-1]:
                count -= 1
                break

    print(count)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    n = int(input())
    num_list = list(map(int, input().split()))

    count = n

    min = num_list[0]

    for i in range(1,n):
        if num_list[i] > min:
            count -= 1
        if num_list[i] < min:
            min = num_list[i]

    print(count)

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

import numpy as np
a = int(raw_input())
Ali = (np.array( map(int,raw_input().split())))
Bli =(np.array(map(int,raw_input().split())))
Cli =(np.array(map(int,raw_input().split())))
Ali = np.sort(Ali)
Bli = np.sort(Bli)
Cli = np.sort(Cli)[::-1]
co=0
for B in Bli:
    ca = 0 
    for A in Ali:
        if A >= B:
            break
        else:
            ca+=1
    cb =0
    for C in Cli:
        if C <= B:
            break
        else:
            cb +=1 
    co += ca*cb
print(co)


### FIXED CODE ###

import bisect
N = int(input())
Alist = list(map(int,input().split()))
Blist = list(map(int,input().split()))
Clist = list(map(int,input().split()))
Alist.sort()
Clist.sort()
retnum = 0 
for i in Blist:
    Anum = bisect.bisect_left(Alist,i)
    Cnum =  N - bisect.bisect_right(Clist,i)
    retnum +=(Anum * Cnum)
print(retnum)
### BUGGY CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
#print([bin(val) for val in A])

A.sort()
#print(A)

def binsearch(threshold, lst):
    left, right = -1, len(lst)
    while right - left > 1:
        mid = (right + left) // 2
        if lst[mid] >= threshold:
            right = mid
        else:
            left = mid
    return right
for i in range(M):
    temp = A.pop(-1) // 2
    indx = binsearch(temp, A)
    #print(indx)
    if indx == N:
        A.append(temp)
    else:
        A.insert(indx, temp)
    #print(A)
print(sum(A))


### FIXED CODE ###

import heapq

N, M = map(int, input().split())
A = list(map(lambda x:-int(x), input().split()))
#print([bin(val) for val in A])

heapq.heapify(A)
#print(A)

for _ in range(M):
    temp = -heapq.heappop(A) // 2
    heapq.heappush(A, -temp)
    #print(A)
print(-sum(A))