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

from sys import stdin
from sys import setrecursionlimit
import numpy as np

setrecursionlimit(10 ** 7)

n,k = map(int,stdin.readline().rstrip().split())
a = list(map(int,stdin.readline().rstrip().split()))
a = np.array(a,dtype=np.int64)
lamp= np.zeros(n,dtype=np.int64)

for i,j in enumerate(a):
    lamp[max(0,i-j):min(n+1,i+j+1)] += 1
    
if k == 1:
    print(*lamp)
    exit()

for _ in range(min(k-1,100)):
    b = np.zeros(n,dtype=np.int64)
    for i,j in enumerate(lamp):
        b[max(0,i-j):min(n+1,i+j+1)] += 1
    lamp = b.copy()

lamp[lamp>n] = n

print(*lamp)

### FIXED CODE ###

from itertools import accumulate
from copy import deepcopy

n,k = map(int,input().split())
a = list(map(int,input().split()))
b = [0]*(n+1)

if k > 41:
    k = 41

for _ in range(k):
    b = [0]*(n+1)
    for i,j in enumerate(a):
        b[max(0,i-j)] += 1
        b[min(n,i+j+1)] -= 1
    a = list(accumulate(b))
    for i in range(n+1):
        if a[i] >= n:
            a[i] = n

print(*a[:-1])
### BUGGY CODE ###

def solve(string):
    h, w, d, *a = map(int, string.split())
    a, q, lr = a[:h * w], a[h * w], a[h * w + 1:]
    n = h * w
    index = [a.index(i + 1) for i in range(h * w)]
    diff = [0] * d + [
        abs(i0 // w - i1 // w) + abs(i0 % w - i1 % w) for i0, i1 in zip(index, index[d:])
    ]
    costs = []
    for i in range(n):
        if i < d:
            costs.append(diff[i])
        else:
            costs.append(diff[i] + costs[i - d])
    return "\n".join([str(costs[r - 1] - costs[l - 1]) for l, r in zip(lr[::2], lr[1::2])])


if __name__ == '__main__':
    n, m, d = map(int, input().split())
    ins = '{} {} {}\n'.format(n, m, d) + '\n'.join([input() for _ in range(n)])
    n = int(input())
    print(solve(ins + '\n{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))


### FIXED CODE ###

import numpy as np

h, w, d = map(int, input().strip().split(" "))
a = [[int(i) for i in input().strip().split(" ")] for _ in range(h)]
q = int(input().strip())
lr = [input().strip().split(" ") for _ in range(q)]
rs = [None for _ in range(h * w)]
cs = [None for _ in range(h * w)]
for _r, _a in enumerate(a):
    for _c, __a in enumerate(_a):
        rs[__a - 1] = _r
        cs[__a - 1] = _c
rs_d = [rs[i::d] for i in range(d)]
cs_d = [cs[i::d] for i in range(d)]
costs = [
    np.cumsum(
        np.abs(np.array(_rs[1:]) - np.array(_rs[:-1])) +
        np.abs(np.array(_cs[1:]) - np.array(_cs[:-1]))) for _rs, _cs in zip(rs_d, cs_d)
]
for l, r in lr:
    l = int(l) - 1
    r = int(r) - 1
    if l == r:
        print(0)
    elif l < d:
        print(costs[r % d][r // d - 1])
    else:
        print(costs[r % d][r // d - 1] - costs[l % d][l // d - 1])
### BUGGY CODE ###

import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

class Graph(object):
	def __init__(self):
		self.graph = defaultdict(list)

	def __len__(self):
		return len(self.graph)

	def add_edge(self, a, b):
		self.graph[a].append(b)

def DFS(G, W, Wlist, visit, node):
	for i in G.graph[node]:
		if visit[i] != "Yes":
			visit[i] = "Yes"
			DFS(G, W, Wlist, visit, i)
			W[node] += W[i]
			Wlist[node].append(W[i])

#処理内容
def main():
	#入力
	N = int(input())
	G = Graph()
	for i in range(N - 1):
		a, b = getlist()
		a -= 1; b -= 1
		G.add_edge(a, b)
		G.add_edge(b, a)

	#DFS
	W = [1] * N
	Wlist = [[] for i in range(N)]
	visit = ["No"] * N
	visit[0] = "Yes"
	DFS(G, W, Wlist, visit, 0)
	# print(W)
	# print(Wlist)
	for i in range(N):
		Wlist[i].append(N - W[i])

	# print(Wlist)
	pow2 = pow(2, N - 1, con)
	ans_up = N * (pow2 - 1)
	for i in range(N):
		for j in Wlist[i]:
			ans_up -= pow(2, j, con) - 1
			ans_up %= con

	# print(ans_up)

	ans = ans_up * pow(pow2 * 2, con - 2, con)
	print(ans % con)

if __name__ == '__main__':
	main()

### FIXED CODE ###

import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
from collections import deque
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

class Graph(object):
	def __init__(self):
		self.graph = defaultdict(list)

	def __len__(self):
		return len(self.graph)

	def add_edge(self, a, b):
		self.graph[a].append(b)

def DFS(G, W, Wlist, visit, node):
	for i in G.graph[node]:
		if visit[i] == 0:
			visit[i] = 1
			DFS(G, W, Wlist, visit, i)
			W[node] += W[i]
			Wlist.append(W[i])

class BFS(object):
	def __init__(self, graph, s, N):
		self.g = graph.graph
		self.Q = deque(); self.Q.append(s)
		self.dist = [INF] * N; self.dist[s] = 0
		self.prev = [None] * N; self.prev[s] = -1
		self.order = []
		while self.Q:
			v = self.Q.popleft()
			self.order.append(v)
			for i in self.g[v]:
				if self.dist[i] == INF:
					self.dist[i] = self.dist[v] + 1
					self.prev[i] = v
					self.Q.append(i)


#処理内容
def main():
	#入力
	N = int(input())
	G = Graph()
	Nedge = [0] * N
	for i in range(N - 1):
		a, b = getlist()
		a -= 1; b -= 1
		G.add_edge(a, b)
		G.add_edge(b, a)
		Nedge[a] += 1; Nedge[b] += 1

	W = [1] * N
	#葉の場合の処理
	# for i in range(N):
	# 	if Nedge[i] == 1:
	# 		W[i] = 1

	BF = BFS(G, 0, N)

	for i in range(N - 1, 0, -1):
		v = BF.order[i]
		W[BF.prev[v]] += W[v]

	Wlist = []
	for i in range(N):
		for j in G.graph[i]:
			if j != BF.prev[i]:
				Wlist.append(W[j])
	for i in range(N):
		Wlist.append(N - W[i])

	pow2 = pow(2, N - 1, con)
	ans_up = N * (pow2 - 1)
	for i in Wlist:
		ans_up -= pow(2, i, con) - 1
		ans_up %= con

	ans = ans_up * pow(pow2 * 2, con - 2, con)
	print(ans % con)

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

N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
X = N + M
sum_n = 0
sum_m = 0
ans = 0
flag = False
for i in reversed(range(1,X+1)):
    if(flag):
        break
    for j in range(i+1):
        n = j
        m = i - j
        if(n <= N and m <= M):
            sum_n = sum(A[0:n])
            sum_m = sum(B[0:m])
            if((sum_m + sum_n) <= K):
                ans=i
                flag =True
                break
            sum_m = 0
            sum_n = 0
print(ans)

### FIXED CODE ###

N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a,b = [0],[0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])

ans,j = 0,M
for i in range(N+1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans,i+j)
print(ans)
### BUGGY CODE ###

N,M = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(lambda x: x//2,A))

def gcd(n,m):
    while n:
        m,n = [n,m%n]
    return m

su = 1
for b in B:
    su = su * b // gcd(su,b)

for b in B:
    if (su // b) % 2 == 0:
        print(0)
        exit()

print(M//su - M//(su*2))

### FIXED CODE ###

def a():
    N,M = map(int,input().split())
    B = list(map(lambda x: int(x)//2,input().split()))

    def gcd(n,m):
        while n:
            m,n = [n,m%n]
        return m

    su = 1
    for b in B:
        su *= b // gcd(su,b)
        if su > M:
            return 0

    for _ in filter(lambda x:(su//x)%2==0,B):
        return 0

    return M//su - M//(su*2)

print(a())
### BUGGY CODE ###

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

area = []
for i in range(K):
    L, R = map(int, input().split())
    area.append((L, R))

area.sort()
d = [0] * N


def func(pos):
    for a in area:
        for i in range(a[0], a[1]+1):
            if pos - i > -1:
                d[pos] += d[pos-i] % 998244353
            else:
                return


d[0] = 1
for i in range(1, N):
    func(i)

print(d[N-1] % 998244353)


### FIXED CODE ###

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

area = []
for i in range(K):
    L, R = map(int, input().split())
    area.append((L, R))

area.sort()
d = [0] * N
a = [0] * N


def func(pos):
    for l, r in area:
        if pos + l - 1 < N:
            a[pos + l-1] += d[pos]
        if pos + r < N:
            a[pos + r] -= d[pos]
    d[pos+1] = (d[pos] + a[pos]) % 998244353


d[0] = 1
a[0] = -1
for i in range(0, N-1):
    func(i)

print(d[N-1] % 998244353)
### BUGGY CODE ###

import sys
# input = sys.stdin.readline
S = list(input())
p = 10 ** 9 + 7
# p = 10 ** 18

A = AB = ABC = 0
Q = 0
for i, Si in enumerate(S):
    # print("#", A, AB, ABC)
    if Si == 'A':
        A = (A + 1 * (3 ** Q)) % p
    elif Si == 'B':
        AB = (AB + A) % p
    elif Si == 'C':
        ABC = (ABC + AB) % p
    else:
        ABC = (3 * ABC + AB) % p
        AB = (3 * AB + A) % p
        #A = (3 * A + 1 * (3 ** Q)) % p
        A = (3 * A + 1 * (pow(3,Q,p))) % p
        Q += 1

print(ABC)


### FIXED CODE ###

S=input()
N=len(S)
mod=pow(10,9)+7
dpa=[0]*N
dpl=[0]*N
dpc=[0]*N
dpr=[0]*N
for i in range(1,N):
    if S[i-1]=='A':
        dpa[i]=dpa[i-1]+1
        dpl[i]=dpl[i-1]
    elif S[i-1]=='?':
        dpa[i]=dpa[i-1]
        dpl[i]=dpl[i-1]+1
    else:
        dpa[i]=dpa[i-1]
        dpl[i]=dpl[i-1]
for i in range(N-2,-1,-1):
    if S[i+1]=='C': 
        dpc[i]=dpc[i+1]+1
        dpr[i]=dpr[i+1]
    elif S[i+1]=='?': 
        dpc[i]=dpc[i+1]
        dpr[i]=dpr[i+1]+1
    else: 
        dpc[i]=dpc[i+1]
        dpr[i]=dpr[i+1]
ans=0 
for i in range(1,N-1):
    if S[i]=='?' or S[i]=='B':
        x=pow(3,dpl[i],mod)
        y=pow(3,max(dpl[i]-1,0),mod)
        z=pow(3,dpr[i],mod)
        w=pow(3,max(dpr[i]-1,0),mod)
        x=(x*dpa[i])%mod
        y=(y*dpl[i])%mod
        z=(z*dpc[i])%mod
        w=(w*dpr[i])%mod
        s=(x+y)%mod
        u=(z+w)%mod
        t=(s*u)%mod
        ans = (ans+t)%mod
print(ans)
### BUGGY CODE ###

N = int(input())
A = []
x = 0
for i in range(N):
    A.append(int(input()))

P = list(set(A))

for j in range(len(P)):
    if A.count(int(P[j]))%2==1:
        x += 1

print(x)

### FIXED CODE ###

N = int(input())
A = set()
x = 0
for i in range(N):
    s = int(input())
    if s in A:
        A.remove(s)
    else:
        A.add(s)



print(len(A))
### BUGGY CODE ###

import math

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

a.sort()

ans = 0
res = 1
flag = False
for b in a:
    if b == 0:
        flag = True
        break
    ans += math.log10(b)
    res *= b

if flag:
    print(0)
else:
    if ans > 18:
        print(-1)
    else:
        res2 = res - 1000000000000000000
        if res2 > 0:
            print(-1)
        else:
            print(res)


### FIXED CODE ###

n = int(input())

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

ans = 1

for b in a:
    if b == 0:
        ans = 0
        break
    else:
        ans *= b
        if ans > pow(10, 18):
            ans = -1
            break

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

import math
n = int(input())
ans = ""
for i in range(n):
  for j in range(i + 1, n):
    ixorj = i ^ j
    cnt = 1
    while ixorj >= 2:
      cnt += 1
      ixorj //= 2
    ans += str(cnt)
    if j != n-1:
      ans += " "
  if i != n-2:
    ans += "\n"
print(ans)

### FIXED CODE ###

import math
n = int(input())
for i in range(n):
  ans = ""
  for j in range(i + 1, n):
    ixorj = i ^ j
    cnt = 1
    while ixorj >= 2:
      cnt += 1
      ixorj //= 2
    ans += str(cnt)
    if j != n-1:
      ans += " "
  print(ans)
### BUGGY CODE ###

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

mod = 998244353

dp = [[0] * (S+1) for i in range(N+1)]
dp[0][0] = 1

for i in range(N):
    for j in range(S+1):
        dp[i+1][j] += 2*dp[i][j]
        dp[i+1][j] %= mod
        if j + A[i] <= S:
            dp[i+1][j+A[i]] += dp[i][j]
            dp[i+1][j+A[i]] %= mod

print(dp[N][S])

### FIXED CODE ###

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

mod = 998244353

dp = [[0 for j in range(S+1)] for i in range(N+1)]
dp[0][0] = 1

for i in range(N):
    for j in range(S+1):
        dp[i+1][j] += 2*dp[i][j]
        dp[i+1][j] %= mod
        if j + A[i] <= S:
            dp[i+1][j+A[i]] += dp[i][j]
            dp[i+1][j+A[i]] %= mod

print(dp[N][S])
### BUGGY CODE ###

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

for i in range(n):
    ans = 0
    for j in range(n - 1):
        if i + 1 == a[j]:
            ans += 1
    print(ans)


### FIXED CODE ###

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

ans = [0]* n

for i in a:
    ans[i - 1] += 1
    
for i in range(n):
    print(ans[i])
### BUGGY CODE ###

from sys import setrecursionlimit
setrecursionlimit(10000000)

N = int(input())
adj = [list() for _ in range(N)]
for _ in range(N-1):
    a,b = map(int,input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)

# path
goal = N-1
def rec(prev, cur):
    if cur == goal:
        return [cur]
    for n in adj[cur]:
        if n != prev:
            res = rec(cur,n)
            if res:
                return res + [cur]
    return None

path = rec(None, 0)
path.reverse()
black = path[(len(path)-1)//2]
white = path[(len(path)-1)//2+1]

# count
cnt = 0
def rec(prev, cur):
    return sum(rec(cur, n) for n in adj[cur] if n != prev) + 1

bscore = rec(white,black)
print('Fennec' if bscore*2 > N else 'Snuke')

### FIXED CODE ###

from sys import setrecursionlimit
setrecursionlimit(10000000)

def solve():
    N = int(input())
    adj = [list() for _ in range(N)]
    for _ in range(N-1):
        a,b = map(int,input().split())
        adj[a-1].append(b-1)
        adj[b-1].append(a-1)

    # path
    goal = N-1
    path = [0]
    candidates = [adj[0][:]]
    while path[-1] != goal:
        while not candidates[-1]:
            candidates.pop()
            path.pop()
        u = candidates[-1].pop()
        candidates.append([n for n in adj[u] if n != path[-1]])
        path.append(u)

    black = path[(len(path)-1)//2]
    white = path[(len(path)-1)//2+1]

    # count
    path = [black]
    candidates = [[n for n in adj[black] if n != white]]
    cnt = 0
    try:
        while True:
            while not candidates[-1]:
                cnt += 1
                candidates.pop()
                path.pop()
            u = candidates[-1].pop()
            candidates.append([n for n in adj[u] if n != path[-1]])
            path.append(u)
    except IndexError:
        pass
    bscore = cnt
    print('Fennec' if bscore*2 > N else 'Snuke')


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

a = int(input())
b =list(input().split())


c = 0

for i in range(a):
    if (int(b[i]) - int(min(b[i:a])))>1:
      c+=1
      break
if c==0: print("Yes")
else: print("No")

### FIXED CODE ###

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

c = 0

for i in range(a):
  if i>0:
    if (b[i] - b[i-1])<-1:
      c+=2
    if (b[i] - b[i-1])==-1:
      c+=1
    if (b[i] - b[i-1])>0:
      c=0
  if c>=2: break
if c<=1: print("Yes")
else: print("No")
### BUGGY CODE ###

import numpy as np

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

tmp = np.zeros(n)
tmp = list(x)
indexhold = np.argsort(tmp)
for i in range(n):
    for j in range(n):
        if i == indexhold[j] and j < n/2:
            print(tmp[indexhold[int(n/2)]])
        elif i == indexhold[j] and j >= n/2:
            print(tmp[indexhold[int(n/2) -1]])    


### FIXED CODE ###

import numpy as np
n = int(input())
x = [int(i) for i in input().split()]

index_hold = np.argsort(x)
index_hold_rev = [0 for i in range(n)]
for i in range(n):
    index_hold_rev[index_hold[i]] = i
for i in range(n):
    if index_hold_rev[i] < n/2:
        print(x[index_hold[int(n/2)]])
    else:
        print(x[index_hold[int(n/2-1)]])
### BUGGY CODE ###

swap_count = 0


def main():
  num = int(input())
  elements = []
  for i in range(0, num):
    elements.append(int(input()))

  # Get intervals
  interval = 1
  intervals = [interval]
  while True:
    interval = int_f(interval)
    if interval > num:
      break
    intervals.insert(0, interval)
  # intervals.reverse()

  for interval in intervals:
    insertion_sort(elements, num, interval)

  print(len(intervals))
  print(' '.join([str(interval) for interval in intervals]))
  print(swap_count)
  for val in elements:
    print(val)


def int_f(x):
  return 3 * x + 1


def insertion_sort(elements, num, interval=1):
  global swap_count

  i = interval
  while i < num:
    j = i
    while interval <= j:
      if elements[j - interval] <= elements[j]:
        break

      elements[j - interval], elements[j] = elements[j], elements[j - interval]
      swap_count += 1
      j -= interval
    i += 1


if __name__ == '__main__':
  main()

### FIXED CODE ###

import math


swap_count = 0


def main():
  num = int(input())
  elements = []
  for i in range(0, num):
    elements.append(int(input()))

  # Get intervals
  interval = 1
  intervals = [interval]
  while True:
    interval = int_f(interval)
    if interval > num:
      break
    intervals.insert(0, math.ceil(interval))

  for interval in intervals:
    insertion_sort(elements, num, interval)

  print(len(intervals))
  print(' '.join([str(interval) for interval in intervals]))
  print(swap_count)
  for val in elements:
    print(val)


def int_f(x):
  return 2.25 * x + 1


def insertion_sort(elements, num, interval=1):
  global swap_count

  i = interval
  while i < num:
    j = i
    while interval <= j:
      if elements[j - interval] <= elements[j]:
        break

      elements[j - interval], elements[j] = elements[j], elements[j - interval]
      swap_count += 1
      j -= interval
    i += 1


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

n, q = map(int, input().split())
neighbor = [[] for _ in range(n)]
pl = []

for i in range(n-1):
    a, b = map(int, input().split())
    neighbor[a-1].append(b-1)
    neighbor[b-1].append(a-1)

for i in range(q):
    pl.append(list(map(int, input().split())))

parent = [-1 for _ in range(n)]
child = [[] for _ in range(n)]
parent[0] = 0
point = [0] * n


def makeTree():
    global parent, neighbor, child
    queue = [[0, 0]]
    while len(queue) > 0:
        now = queue.pop(0)

        for neiv in neighbor[now[0]]:
            if parent[neiv] == -1:
                parent[neiv] = now[0]
                queue.append([neiv, now[1]])
                child[now[0]].append(neiv)


def calcPoint():
    global pl, parent, point
    for p in pl:
        point[p[0] - 1] += p[1]

    queue = child[0]
    while len(queue) > 0:
        now = queue.pop(0)
        point[now] += point[parent[now]]
        queue.extend(child[now])


makeTree()

calcPoint()

print(*point)


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n, q = map(int, input().split())
neighbor = [[] for _ in range(n)]
point = [0]*n

for i in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    neighbor[a].append(b)
    neighbor[b].append(a)

for i in range(q):
    p, x = map(int, input().split())
    point[p-1] += x


def dfs(now, past):
    for nv in neighbor[now]:
        if nv == past:
            continue
        point[nv] += point[now]
        dfs(nv, now)


dfs(0, -1)


print(*point)
### BUGGY CODE ###

import numpy as np
from collections import deque

N, Q = map(int, input().split())
nodes = np.array([0]*(N+1))
subtree_flag = [False]*(N+1)
subtree = np.array([[0]*(N+1) for i in range(N+1)])
tree = [set() for _ in range(N+1)]

for i in range(1, N):
  a, b = map(int, input().split())
  tree[a].add(b)

def add(p, x):
  dq = deque()
  dq.append(p)
  subtree[p][p] = 1
  while len(dq) > 0:
    tp = dq.popleft()
    nodes[tp] += x
    subtree[p][tp] = 1
    for np in tree[tp]:
      dq.append(np)

for i in range(Q):
  p, x = map(int, input().split())
  if subtree_flag[p]:
     nodes += subtree[p] * x
  else:
    add(p, x)
    subtree_flag[p]=True
print(" ".join([str(i) for i in nodes[1:]]))

### FIXED CODE ###

N, Q = map(int, input().split())
tree = [[] for i in range(N)]

for i in range(N-1):
  a, b = map(int, input().split())
  tree[a-1].extend([b])

nodes = [0]*N
for _ in range(Q):
  p, x = map(int, input().split())
  nodes[p-1]+=x

for i in range(N-1):
  for j in tree[i]:
    nodes[j-1]+=nodes[i]
print(" ".join(list(map(str, nodes))))
### BUGGY CODE ###

import itertools

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

l = [True, False]
max_diff_v_c = 0
for flags in itertools.product(l, repeat=n):
    # print(' '.join(map(str, flags)))
    
    sum_v = 0
    sum_c = 0
    for i in range(len(flags)):
        if flags[i]:
            sum_v += v[i]
            sum_c += c[i]

    diff_v_c = sum_v - sum_c

    if max_diff_v_c < diff_v_c:
        max_diff_v_c = diff_v_c
        
print(max_diff_v_c)

### FIXED CODE ###

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

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

print(max_diff_v_c)
### BUGGY CODE ###

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

pin=set()
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            pin.add(s[i]+s[j]+s[k])
print(len(pin))


### FIXED CODE ###

N=int(input())
s=input()

count=0

for i in range(0,10):
    if str(i) in s[:-2]:
        index_1=s.index(str(i))

        for j in range(0,10):
            if str(j) in s[index_1+1:-1]:
                index_2=s[index_1+1:-1].index(str(j))+index_1+1

                for k in range(0,10):
                    if str(k) in s[index_2+1:]:
                        count+=1
print(count)
### BUGGY CODE ###

s = input()
sc = s[::-1]
n = int(input())
l = [list(input().split()) for i in range(n)]

#last = 1

for i in range(n):
    if l[i][0] == '1':
        save = s
        s = sc
        sc = save
    elif l[i][1] == '1':
        s = l[i][2] + s
        sc += l[i][2]
    else:
        s += l[i][2]
        sc = l[i][2] + sc

print(s)

### FIXED CODE ###

import copy
from collections import deque
s = deque(input())
sc = copy.deepcopy(s) 
sc.reverse()
n = int(input())
l = [list(input().split()) for i in range(n)]

for i in range(n):
    if l[i][0] == '1':
        save = s
        s = sc
        sc = save
    elif l[i][1] == '1':
        s.appendleft(l[i][2])
        sc.append(l[i][2])
        #s = l[i][2] + s
        #sc += l[i][2]
    else:
        s.append(l[i][2])
        sc.appendleft(l[i][2])
        #s += l[i][2]
        #sc = l[i][2] + sc

print(''.join(s))
### BUGGY CODE ###

import sys
import math
import numpy as np
pos=input()
pos=pos.split()
N=int(pos[0])
M=int(pos[1])

item=input()
item=item.split()
item=list(map(float,item))
npitem=np.array(item)
for i in np.arange(1,M+1):
  npitem[np.argmax(npitem)]=np.floor(np.max(npitem)/2.0)
    
print(int(np.sum(npitem)))












### FIXED CODE ###

import sys
import math
import numpy as np
from heapq import heappush, heappop
pos=input()
pos=pos.split()
N=int(pos[0])
M=int(pos[1])
sum=0

item=input()
item=item.split()
item=list(map(float,item))

hq=[]
for i in item:
  heappush(hq,-i)
  
for j in range(1,M+1):
  temp=heappop(hq)
  heappush(hq,math.ceil(temp/2.0))
  
for k in range(0,N):
  sum-=heappop(hq)
print(int(sum))