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

import heapq
def SME(start,end):

    if end > N : end = N
    count = 0
    for i,x in enumerate(Whole[start:end]):
        heapq.heappush(A,[x,i])
    for j in range(start,end):
        a = heapq.heappop(A)
        for i in range(L):
            idx = a[1] + i
            try :
                if ANS[idx] : continue
                else :
                    ANS[idx] = a[0]
                    count += 1
            except IndexError : continue
        if count > N * parameter : break
    for i in range(L):
        if ANS[i] : continue
        else : ANS[i] = min(Whole[:i+1])
    for i in range(L,N):
        if ANS[i] : continue
        else : ANS[i] = min(Whole[i+1-L:i+1])
    return ANS
  
[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
A = []
parameter = 0.991
ANS = [None]*N
ANS = SME(0, N)
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-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 ###

# -*- coding: utf-8 -*-

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

b = []
for ele in a:
    b.append(ele)
    b = b[::-1]

print(*b)


### FIXED CODE ###

# -*- coding: utf-8 -*-

from collections import deque

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

b = deque()
for i, ele in enumerate(a):
    if i % 2:
        b.appendleft(ele)
    else:
        b.append(ele)

if n % 2:
    b.reverse()

print(*b)
### BUGGY CODE ###

l,r = map(int,input().split())
r = min(r,l+4038)
ans = 2018
for i in range(l,r+1):
    for j in range(i+1,r+1):
        x = i*j%2019
        ans = min(ans,x)
print(ans)

### FIXED CODE ###

l,r = map(int,input().split())
r = min(r,l+2017)
ans = 2018
for i in range(l,r+1):
    for j in range(i+1,r+1):
        x = i*j%2019
        ans = min(ans,x)
print(ans)
### BUGGY CODE ###

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

ans = [0 for i in range(n)]
c = 0
c1 = n+1
for i in range(n//2+1) :
  f = 0
  f1 = 0
  c += 1
  c1 -= 1
  for j in range(n) :
    if a[j] == c :
      ans[c-1] = j + 1
      f = 1
    if a[j] == c1 :
      ans[c1-1] = j + 1
      f1 = 1
    if f == 1 and f1 == 1 :
      break
print(*ans)

### FIXED CODE ###

import numpy as np

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

ans = np.argsort(a)
ans += 1

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

import sys
from collections import deque

H, W = map(int, input().split())
Ch, Cw = (int(i) - 1 for i in input().split())
Dh, Dw = (int(i) - 1 for i in input().split())
G = [list(sys.stdin.readline().strip()) for _ in range(H)]

def bfs(start):
    zeroQ = deque()
    oneQ = deque()
    zeroQ.append(start)
    dist[start[1]][start[0]] = 0

    while zeroQ or oneQ:
        if zeroQ:
            x, y = zeroQ.popleft()
        else:
            x, y = oneQ.popleft()
        
        for dx in range(-2, 3):
            for dy in range(-2, 3):
                nx = x + dx
                ny = y + dy
                
                if not(0 <= nx < W and 0 <= ny < H):
                    continue
                if G[ny][nx] == '#':
                    continue
                if abs(dx) + abs(dy) == 0:
                    continue
                
                cost = 0 if abs(dx) + abs(dy) == 1 else 1
                
                if dist[ny][nx] <= dist[y][x] + cost:
                    continue
                dist[ny][nx] = dist[y][x] + cost
                
                if cost == 0:
                    zeroQ.append((nx, ny))
                else:
                    oneQ.append((nx, ny))

dist = [[10 ** 9 for _ in range(W)] for _ in range(H)]

bfs((Cw, Ch))
# for g in dist:
#     print(g)
if dist[Dh][Dw] == 10 ** 9:
    print(-1)
else:
    print(dist[Dh][Dw])


### FIXED CODE ###

import sys
from collections import deque

H, W = map(int, input().split())
Ch, Cw = (int(i) - 1 for i in input().split())
Dh, Dw = (int(i) - 1 for i in input().split())
G = [list(sys.stdin.readline().strip()) for _ in range(H)]

def bfs(start):
    zeroQ = deque()
    oneQ = deque()
    zeroQ.append(start)
    dist[start[1]][start[0]] = 0

    while zeroQ or oneQ:
        if zeroQ:
            x, y = zeroQ.popleft()
        else:
            x, y = oneQ.popleft()
        
        for dx in range(-2, 3):
            for dy in range(-2, 3):
                nx = x + dx
                ny = y + dy
                
                if not(0 <= nx < W and 0 <= ny < H):
                    continue
                if G[ny][nx] == '#':
                    continue
                if abs(dx) + abs(dy) == 0:
                    continue
                
                cost = 0 if abs(dx) + abs(dy) == 1 else 1
                
                if dist[ny][nx] <= dist[y][x] + cost:
                    continue
                dist[ny][nx] = dist[y][x] + cost
                
                if cost == 0:
                    zeroQ.append((nx, ny))
                else:
                    oneQ.append((nx, ny))

dist = [[10 ** 9 for _ in range(W)] for _ in range(H)]

bfs((Cw, Ch))
# for g in dist:
#     print(g)
if dist[Dh][Dw] == 10 ** 9:
    print(-1)
else:
    print(dist[Dh][Dw])
### BUGGY CODE ###

s=list(input())

N=len(s)

f=True
cnt=0
while f:
    f=False
    for i in range(2,N):
        if "".join(s[i-2:i+1])=="ABC":
            s[i-2]="B"
            s[i-1]="C"
            s[i]="A"
            cnt+=1
            f=True
print(cnt)

### FIXED CODE ###

so=input()

s=""

N=len(so)
i=0
while i<N:
    if so[i]=="A":
        s=s+"A"
        i+=1
    elif so[i:i+2]=="BC":
        s=s+"B"
        i+=2
    elif so[i]=="C" or so[i]=="B":
        s=s+"D"
        i+=1

L=len(s)
f=False
cnt=0
a=0
for i in range(L):
    if s[i]=="A":
        f=True
        a+=1
    elif f and s[i]=="B":
        cnt+=a
    elif s[i]=="D":
        f=False
        a=0
print(cnt)
### BUGGY CODE ###

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

def P(n):
  return (n + 1) / 2
  
ans = []
for i in range(N - (K - 1)):
  a = p[i: i + K]
  if sum(a) > sum(ans):
    ans = a

A = 0
for x in range(K):
  A += P(ans[x])

print(A)

### FIXED CODE ###

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

a = 0
for i in range(N - K + 1):
  if i == 0:
    b = sum(p[0:K])
  else:
    b = b - p[i-1] + p[i + K - 1]
  
  if b > a:
    a = b
    f = i

ans = 0
for j in range(K):
  ans += (p[f + j] + 1) / 2

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

import sys
input = sys.stdin.readline

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

## 種類数の求め方
# 1. A内の要素を取り出して、それがA内に存在するとき：種類＋１
# 2. その要素を重複数だけAから削除してループ

kinds = 0
A = sorted(A)
duplicatedList = []
while len(A) > 0:
    if A[0] in A:
        kinds += 1
        duplicatedList.append(A.count(A[0]))
        for j in range(A.count(A[0])):
            A.remove(A[0])

if kinds <= K:
    print('0')
elif kinds > K:
    duplicatedList = sorted(duplicatedList)
    tmp = 0
    for i in range(kinds-K):
        tmp += duplicatedList[i]
    print(tmp)

### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
d={}
l=[]
for i in range(n):
    try:
        l[d[a[i]]]+=1
    except:
        d[a[i]]=len(l)
        l.append(1)
ans=0
l.sort()
for i in range(len(l)-k):
    ans+=l[i]
print(ans)
### BUGGY CODE ###


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

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

for i in range(N):
    x = X[:]
    x.pop(i)
    x.sort(reverse=True)

#    print(x)
    print( x[((len(x)+1) // 2)-1] )


### FIXED CODE ###


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

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

x = X[:]
x.sort()
m1 = x[N//2 - 1]
m2 = x[N//2]

for a in X:
    if a <= m1:
        print(m2)
    else:
        print(m1)
### BUGGY CODE ###

import math
n = int(input())
max = 0
s = 10**int(math.log(n,10)) - 1
for i in range(s,n+1):
    num = sum(list(map(int,list(str(i)))))
    max = num if num > max else max
print(max)


### FIXED CODE ###

import math
n = int(input())
s = 10**(int(math.log(n,10))+1) - 1
while s>n:
    s -= 10**int(math.log(n,10))
print(sum(list(map(int,list(str(s))))))
### BUGGY CODE ###

x = int(input())
# A>B
for i in range(1,int(x**(1))+1):
  if x%i==0:
    for j in range(i):
      a=j
      b=j-i
      if a**5-b**5==x:
        print(a,b)
        break

### FIXED CODE ###

x=int(input())
import math
import sys
A=[math.pow(i,5) for i in range(-1000,1000,1)]
B=[math.pow(i,5) for i in range(-1000,1000,1)]
for n in A:
  for m in B:
    if n-m==x:
      print(-1000+A.index(n),-1000+B.index(m))
      sys.exit()
### BUGGY CODE ###

n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = list(input())
leng = len(t)
ans = 0


for i in range(leng):
    if i >= k:
    
        if t[i] == t[i-k]:
            check = 2
            while True:
                if i < k*check:
                    break
                
                if t[i] == t[i-k*check]:
                    check += 1
                    continue
                else:
                    break
            
            if check%2 == 0:
                continue
            else:
                pass
        
    if t[i] == "r":
        ans += p
        
    elif t[i] == "s":
        ans += r

        
    elif t[i] == "p":
        ans += s
        
print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
r,s,p = map(int, input().split())
t = list(input())

ans = 0

for i in range(n):
    valian = t[i]
    if valian == 'r':
        ans += p
    elif valian == 's':
        ans += r
    else:
        ans += s
        
for i in range(k):
    check = ''
    for j in range(i, n, k):
        if check == '':
            check = t[j]
            continue
        
        if check == t[j]:
            if t[j] == 'r':
                ans -= p
            elif t[j] == 's':
                ans -= r
            else:
                ans -= s
            check = ''
        else:
            check = t[j]
        
print(ans)
### BUGGY CODE ###

k,s = map(int,input().split())
count = 0
for i in range(k+1):
    for j in range(k+1):
        for l in range(k+1):
            if i+j+l == s:
                count += 1
print(count)


### FIXED CODE ###

k,s = map(int,input().split())
count = 0
for i in range(k+1):
    for j in range(k+1):
        if 0 <= s-(i+j) <=k:
            count += 1
print(count)
### BUGGY CODE ###

N, M = [int(i) for i in input().split()]
Groups = [{i} for i in range(N)]
dsts = [-1 for i in range(N)]
ABs = [[int(i)-1 for i in input().split()] for i in range(M)]
for A, B in ABs:
    dst = min(A, B)
    src = max(A, B)
    # print('A', A, B, dst, src)
    while(dsts[dst] != -1):
        dst = dsts[dst]
    while(dsts[src] != -1):
        src = dsts[src]
    if dst == src:
        continue
    dsts[src] = dst
    Groups[dst] = Groups[dst] | Groups[src]
    Groups[src] = {}
    # print(Groups)
    # print(dsts)
ans = 0
for group in Groups:
    ans = max(ans, len(group))
print(ans)


### FIXED CODE ###

N, M = [int(i) for i in input().split()]
Groups = [1 for i in range(N)]
dsts = [-1 for i in range(N)]
ABs = [[int(i)-1 for i in input().split()] for i in range(M)]
for A, B in ABs:
    dst = min(A, B)
    src = max(A, B)
    # print('A', A, B, dst, src)
    while(dsts[dst] != -1):
        dst = dsts[dst]
    while(dsts[src] != -1):
        src = dsts[src]
    if dst != min(A, B):
        omdst = min(A, B)
        while(dsts[omdst] != dst):
            n_omdst = dsts[omdst]
            dsts[omdst] = dst
            omdst = n_omdst
    if src != max(A, B):
        omsrc = max(A, B)
        while(dsts[omsrc] != src):
            n_omsrc = dsts[omsrc]
            dsts[omsrc] = src
            omsrc = n_omsrc

    if dst == src:
        continue
    dst2 = min(dst, src)
    src2 = max(dst, src)
    dsts[src2] = dst2
    Groups[dst2] += Groups[src2]
    Groups[src2] = 0
    # print(Groups)
    # print(dsts)
print(max(Groups))
### BUGGY CODE ###

def solve():
    a = input()
    a = list(a)
    q = int(input())
    
    rev = 0
    for _ in range(q):
        _q = [i for i in input().split()]
        t, f, c =0, 0, 0
        t = int(_q[0])
        if t == 2:
            f, c = int(_q[1]), _q[2]
        
        if t == 1:
            rev = 1 - rev
        elif t == 2:
            if (f + rev) % 2 == 1:
                a.insert(0, c)
            else:
                a.append(c)
                
    if rev == 1:
        a = list(reversed(a))
    
    print("".join(a))


if __name__ == "__main__":
    solve()

### FIXED CODE ###

def solve():
    a = input()
    q = int(input())
    
    top = []
    tail = []
    rev = 0
    for _ in range(q):
        _q = [i for i in input().split()]
        t, f, c =0, 0, 0
        t = int(_q[0])
        if t == 2:
            f, c = int(_q[1]), _q[2]
        
        if t == 1:
            rev = 1 - rev
        elif t == 2:
            if (f + rev) % 2 == 1:
                top.append(c)
            else:
                tail.append(c)
                
    if rev == 1:
        a = a[::-1]
        _top = tail
        tail = top
        top = _top
    
    print("".join(list(reversed(top))), end="")
    print(a, end="")
    print("".join(tail))


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

from collections import deque
H, W = map(int, input().split())
k=[]
l=[]
for i in range(W):
    ta,tb = map(int, input().split())
    if ta == 1:
        k.append(tb)
    if tb == H:
        l.append(ta)
s = 0
for i in range(len(k)):
    for j in range(len(l)):
        if k[i] == l[j]:
            s = 1
if s ==1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


### FIXED CODE ###

from collections import deque
H, W = map(int, input().split())
k=[0]*200000
for i in range(W):
    ta,tb = map(int, input().split())
    if ta == 1:
        k[tb-1]+=1
    if tb == H:
        k[ta-1]+=1
s = 0
for i in range(len(k)):
    if k[i]>=2:s=1
if s ==1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
### BUGGY CODE ###

# D - Dice in Line

N, K = map(int, input().split())
P = list(int(x) for x in input().split())

A = []

for i in range(K-1, N):
    A.append(sum(P[i-(K-1):i+1]))

print(0.5*(K+max(A)))

### FIXED CODE ###

# D - Dice in Line

N, K = map(int, input().split())
P = list(int(x) for x in input().split())

S = [0] * (N+1)

for i in range(N):
    S[i+1] = S[i] + P[i]

ans = 0

for j in range(K, N+1):
    if S[j]-S[j-K]>ans:
        ans = S[j]-S[j-K]

print(0.5*(K+ans))
### BUGGY CODE ###

n,k,q = map(int,input().split())
a = [0 for  _ in range(q)]
point = [k for _ in range(n)]
for i in range(q):
    a[i] = int(input())

for i in range(q):
    for j in range(len(point)):
        point[j] -= 1
    point[a[i]-1] += 1

for i in range(n):
    if(point[i] > 0):
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

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

for i in range(q):
    a[i] = int(input())

for i in range(q):
    point[a[i]-1] += 1

for i in range(n):
    if(point[i] > q-k):
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

S = input()
if not len(S):
  print(0)
else:
  N = len(S)
  ans = 0
  while '10' in S or '01' in S:
    S = S.replace('10', '')
    ans += N - len(S)
    N = len(S)
    S = S.replace('01', '')
    ans += N - len(S)
    N = len(S)
  print(ans)

### FIXED CODE ###

S = input()
print(min(S.count('0'), S.count('1')) * 2)
### BUGGY CODE ###

import numpy as np
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = []
C = []

X = np.array([0]*(10**5))
Y = np.array([i  for i in range(1, (10**5)+1)])

for j in range(N):
    X[A[j]-1] += 1

for i in range(Q):
    b, c = map(int, input().split())
    a = X[b-1]
    X[b-1] = 0
    X[c-1] += a
    print(X@Y)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
X = [0] * (10**5)

for i in range(N):
    X[A[i]-1] += 1

ans = sum(A)

for j in range(Q):
    b, c = map(int, input().split())
    a = X[b-1]
    X[b-1] = 0
    X[c-1] += a
    ans = ans - a*b + c*a
    print(ans)
### BUGGY CODE ###

#!/usr/bin/env pypy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    K=input()
    D=I()
    N=len(str(K))
    
    #dp[i][j]はi桁目まで見て，総和のmodがj，tight&lose
    dpt=[[0]*D for _ in range(N+1)]
    dpl=[[0]*D for _ in range(N+1)]
    
    start=int(K[0])
    
    #初期化
    dpt[0][0]=1
            
    #推移
    for i in range(N):
        num=(int(K[i]))
        #t
        for j in range(D):
            if dpt[i][j]!=0:
                dpt[i+1][(j+num)%D]=1
                for k in range(num):
                    dpl[i+1][(j+k)%D]+=1
        #l
        for j in range(D):
            for k in range(10):
                dpl[i+1][(j+k)%D]+=dpl[i][j]
                
    #0もカウントしているmので1ひく
    print((dpt[-1][0]+dpl[-1][0]-1)%mod)
    
    
            
            
    
    

main()


### FIXED CODE ###

#!/usr/bin/env pypy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    K=input()
    D=I()
    N=len(str(K))
    
    #dp[i][j]はi桁目まで見て，総和のmodがj，tight&lose
    dpt=[[0]*D for _ in range(N+1)]
    dpl=[[0]*D for _ in range(N+1)]
    
    start=int(K[0])
    
    #初期化
    dpt[0][0]=1
            
    #推移
    now=0#tが0ではない位置
    
    for i in range(N):
        num=(int(K[i]))
        #t
        dpt[i+1][(now+num)%D]=1
        for k in range(num):
            dpl[i+1][(now+k)%D]+=1
        now=(now+num)%D
                    
        
        #l，尺取り
        S=0
        for j in range(10):#初期化，0~9までの和
            S+=dpl[i][j%D]
            
        for j in range(D):#あまりが10~D-1,0~9の順に配る
            dpl[i+1][(j+9)%D]+=S
            dpl[i+1][(j+9)%D]%=mod
            S+=dpl[i][(j+10)%D]-dpl[i][j%D]
        
                
    #0もカウントしているmので1ひく
    print((dpt[-1][0]+dpl[-1][0]-1)%mod)
    
    
            
    
    

main()
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = [None]*n

for i in range(n):
    buf = 0
    for j in range(n):
        if i != j:
            buf = buf^a[j]
    ans[i]=str(buf)
print(' '.join(ans))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = [None]*n
all = 0

for i in range(n):
    all = all^a[i]

for i in range(n):
    ans[i]=str(all^a[i])
print(' '.join(ans))
### BUGGY CODE ###

from sys import stdin
input=stdin.readline
n=int(input().rstrip())
count=0
for i in range(1,n):
    
    for t in range(1,n):
        if n-i*t>0:
            count +=1
        else:
            break
print(count)


### FIXED CODE ###

from sys import stdin
input=stdin.readline
n=int(input().rstrip())
count=0
for i in range(1,n):
    
    for t in range(1,n):
        if n-i*t>0:
            count +=1
        else:
            break
print(count)
### BUGGY CODE ###

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

for i in range(N):
  for j in range(i):
    if P[i]>P[j]: 
      ans -= 1
      break
  
print(ans)

### FIXED CODE ###

N = int(input())
P = list(map(int,input().split()))
ans = 1
small = P[0]
for i in range(1,N):
  if P[i] <= small: 
    ans += 1
    small = P[i]
print(ans)
### BUGGY CODE ###

N=int(input())
A=[int(i) for i in input().split()]
sorted_A=sorted(A)

def add(B,a,n):
    x = a
    while x<=n:
        B[x]+=1
        x+=x&(-x)
        
def sums(B,a):
    x=a
    S=0
    while x!=0:
        S+=B[x]
        x-=x&(-x)
    return S
  
def invnumber(n,A):
  S=[0]*n
  A=sorted([(A[i],i) for i in range(n)])
  for i in range(1,n):
     S[A[i][1]]=i
  B=[0]*(n*2+1)
  invs=0
  for i in range(n):
      s=S[i]+n
      invs+=sums(B,s)
      add(B,s,n*2)
  return n*(n-1)//2-invs
  
def Check(x):
  S=[0]
  for i in range(N):
    if A[i]>sorted_A[x]:
      S.append(S[-1]+1)
    else:
      S.append(S[-1]-1)
  return invnumber(N+1,S)
      
l,r=0,N-1
while l<r:
  m=(l+r)//2
  if Check(m)>(N*(N+1)//4):
    r=m
  else:
    l=m+1
print(sorted_A[l])


### FIXED CODE ###

N=int(input())
A=[int(i) for i in input().split()]
sorted_A=sorted(A)

def add(B,a,n):
    x = a
    while x<=n:
        B[x]+=1
        x+=x&(-x)
        
def sums(B,a):
    x=a
    S=0
    while x!=0:
        S+=B[x]
        x-=x&(-x)
    return S
  
  
  
def invnumber(n,A):
  B=[0]*(n*2+1)
  invs=0
  for i in range(n):
      s=A[i]+n
      invs+=sums(B,s)
      add(B,s,n*2)
  return n*(n-1)//2-invs
  
def Check(x):
  S=[0]
  for i in range(N):
    if A[i]>sorted_A[x]:
      S.append(S[-1]+1)
    else:
      S.append(S[-1]-1)
  return invnumber(N+1,S)
      
l,r=0,N-1
while l<r:
  m=(l+r)//2
  if Check(m)>N*(N+1)//4:
    r=m
  else:
    l=m+1
print(sorted_A[l])
### BUGGY CODE ###

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

B=[0 for _ in range(n)]

for K in range(k):
    for i in range(n):
        num=A[i]
        for j in range(max(0,i-num),min(n,i+num+1)):
            B[j] +=1
    A=B
    B=[0 for _ in range(n)]
print(*A)

### FIXED CODE ###

n,k=map(int,input().split())
A=list(map(int,input().split()))
C=[n for i in range(n)]

for m in range(k):
    B=[0 for _ in range(n)]
    for i in range(n):
        l,r=max(0,i-A[i]),min(n-1,i+A[i])
        B[l] +=1
        if r+1<n:B[r+1] -=1
    for i in range(n-1):
        B[i+1]=B[i]+B[i+1]
    A=B
    if A==C:break
print(*A)