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

import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    n,k=map(int,input().split())
    val=(n-1)*(n-2)//2
    if k>val:
        print(-1)
    else:
        edge=[(1,i) for i in range(2,n+1)]
        rem=val-k
        a,b=2,3
        cnt=0
        while True:
            if b<=n:
                if edge[-1]!=(a,b):
                    edge.append((a,b))
                    cnt+=1
                    if cnt==rem:
                        break
                b+=1
            else:
                a+=1
                b=a+1
                edge.append((a,b))
                cnt+=1
                if cnt==rem: break
        
        print(len(edge))
        for i in edge:
            print(*i)
        #print()



    
resolve()

### FIXED CODE ###

# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

    n, k = map(int, input().split())
    val = (n-1)*(n-2)//2
    if k > val:
        print(-1)
    else:
        rem = val-k
        print(n-1+rem)
        for i in range(2,n+1):
            print(1,i)
        a, b = 2, 3
        cnt = 0
        for i in range(rem):
            print(a,b)
            if b < n:
                b+=1
            else:
                a += 1
                b = a+1



resolve()
### BUGGY CODE ###

import bisect
import math
N = int(input())
A = list(map(int, input().split()))
A.sort()
already = set()

def is_in(t, n):
    i = bisect.bisect_left(A[:n], t)
    if i == n:
        return -1

    while i < n and t == A[i]:
        if i not in already:
            already.add(i)
            return i
        i += 1

    return -1

res = 0
for n in range(len(A) - 1, -1, -1):
    if n in already:
        continue

    a = A[n]
    t = 1 << (int(math.log2(a)) + 1)

    while t > a:
        i = is_in(t - a, n)
        if i != -1:
            res += 1
            break
        t >>= 1

print(res)



### FIXED CODE ###

import bisect
import math
N = int(input())
A = list(map(int, input().split()))
T = [2 ** i for i in range(31)]
A.sort()
already = set()


def to_dic(A):
    d = {}
    for a in A:
        d[a] = d.setdefault(a, 0) + 1

    return d

def is_in(t, num):
    i = D.setdefault(t, 0)
    if i == 0:
        return 0
    s = min(i, num)
    D[t] -= s
    return s


res = 0
D = to_dic(A)
A2 = list(D.keys())
A2.sort()

for n in range(len(A2) - 1, -1, -1):
    a = A2[n]

    if a in T:
        res += D[a] // 2
        D[a] = 0

        if D[a] % 2 == 0:
            continue

    num = D[a]
    t = 1 << (int(math.log2(a)) + 1)

    while t > a:
        s = is_in(t - a, num)
        res += s
        num -= s
        if num == 0:
            break

        t >>= 1

print(res)
### BUGGY CODE ###

def prime2(x):
    if x == 2: return True
    else:
        for s in stock:
            if x % s == 0: return False
        for j in xrange(3,int(x*0.5),2):
            if x % j == 0: return False
        else:
            stock.append(x)
            return True
        
n = input()
count = 0
stock = [2]
for i in xrange(n):
    if prime2(input()): count += 1
print count

### FIXED CODE ###

import math
def prime(x):
    if x == 2: return True
    elif x % 2 == 0: return False
    else:
        for j in xrange(3,int(math.sqrt(x))+1,2):
            if x % j == 0: return False
        else:
            return True 
n = input()
count = 0
for i in xrange(n):
    if prime(input()): count += 1
print count
### BUGGY CODE ###

M=998244353;n,A,B,K=map(int,input().split());F=[1]
for i in range(n):F+=[F[-1]*(i+1)%M]
C=lambda k:F[n]*pow(F[k]*F[n-k],M-2,M)if 0<=k<=n else 0;a=0
for i in range(n+1):
 r=K-i*A
 if r%B==0:a+=C(r//B)*C(i)
print(a%M)

### FIXED CODE ###

U = 3*10**5
MOD = 998244353
 
fact = [1]*(U+1)
fact_inv = [1]*(U+1)
 
for i in range(1,U+1):
    fact[i] = (fact[i-1]*i)%MOD
fact_inv[U] = pow(fact[U], MOD-2, MOD)
 
for i in range(U,0,-1):
    fact_inv[i-1] = (fact_inv[i]*i)%MOD

def comb(n, k):
    if k < 0 or k > n:
        return 0
    z = fact[n]
    z *= fact_inv[k]
    z %= MOD
    z *= fact_inv[n-k]
    z %= MOD
    return z
  
n, a, b, k = map(int, input().split())
ans = 0
for i in range(n+1):
  r = k - i*a
  if r%b==0 and 0 <= r//b <= n:
    ans += comb(n, i) * comb(n, r//b)
    ans %= MOD
print(ans)
### BUGGY CODE ###

import itertools

n = int(input())
l = [int(v) for v in input().split()]

comb = list(itertools.combinations(l, 3))
count = 0
for i in range(len(comb)):
    x = comb[i][0] + comb[i][1]
    y = comb[i][1] + comb[i][2]
    z = comb[i][0] + comb[i][2]
    if x > comb[i][2] and y > comb[i][0] and z > comb[i][1]:
        count += 1
    else:
        continue

print(count)


### FIXED CODE ###

import bisect


def triangles():
    n = int(input())
    l = [int(v) for v in input().split()]
    l.sort()

    count = 0
    for i in range(n):
        for j in range(i + 1, n):
            c = l[i] + l[j]
            index = bisect.bisect_left(l, c)
            count += max(index - j - 1, 0)

    print(count)


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

n, q = map(int, input().split())
lst = [int(i) for i in input().split()]
sum_list = [0]
total = 0
for i in range(n):
  total += lst[i]
  sum_list.append(total)
for _ in range(q):
  t, a, b = map(int, input().split())
  if t == 0:
    for i in range(a + 1, n + 1):
      sum_list[i] += b
  else:
    print(sum_list[b] - sum_list[a])
    

### FIXED CODE ###

class bit:
  def __init__(self, n):
    self.size = n
    self.bit = [0] * (n + 1)
  
  def make(self, lst):
    self.bit = [0] + lst[:]
    for i in range(1, self.size + 1):
      if i + (i & -i) > self.size:
        continue
      self.bit[i + (i & -i)] += self.bit[i]
  
  def add(self, a, b):
    i = a + 1
    while i <= self.size:
      self.bit[i] += b
      i += i & -i
  
  def sum(self, a):
    i = a
    ret = 0
    while i > 0:
      ret += self.bit[i]
      i -= i & -i
    return ret
  
  def sub(self, a, b):
    return self.sum(b) - self.sum(a)

n, q = map(int, input().split())
lst = [int(i) for i in input().split()]
l = bit(n)
l.make(lst)
for _ in range(q):
  t, a, b = map(int, input().split())
  if t == 0:
    l.add(a, b)
  else:
    print(l.sub(a, b))
### BUGGY CODE ###

MAX_K: int = 200

gt = [[0 for _ in range(MAX_K + 1)] for _ in range(MAX_K + 1)]

def gcd(x: int, y: int) -> int:
    ret: int = 0
    if x < y:
        ret = gcd(y, x)
    elif y == 0:
        ret = x
    elif y == 1:
        ret = 1
    else:
        ret = gcd(y, x % y)
    gt[x][y] = ret
    # print(f"gcd({x}, {y}) = {ret}")
    return ret

k = int(input())
print(sum([gcd(gcd(i + 1, j + 1), l + 1) for i in range(k) for j in range(k) for l in range(k)]))


### FIXED CODE ###

MAX_K: int = 200

gt = [[0 for _ in range(MAX_K + 1)] for _ in range(MAX_K + 1)]

def gcd(x: int, y: int) -> int:
    if gt[x][y] > 0:
        return gt[x][y]
    ret: int = 0
    if x < y:
        ret = gcd(y, x)
    elif y == 0:
        ret = x
    elif y == 1:
        ret = 1
    else:
        ret = gcd(y, x % y)
    gt[x][y] = ret
    # print(f"gcd({x}, {y}) = {ret}")
    return ret

k = int(input())
print(sum([gcd(gcd(i + 1, j + 1), l + 1) for i in range(k) for j in range(k) for l in range(k)]))
### BUGGY CODE ###

N=int(input())
String=input()
max=0

for f in range(len(String)):
    S=String[f:]
    A = [0] * len(S)
    A[0] = len(S)
    i, j = 1, 0
    #print(S)
    while(i<len(S)):
        #print(A)
        #print("i= " + str(i) + "j= " + str(j))
        while(i+j<len(S) and S[j]==S[i+j] and j<i):
            #print("i= "+str(i)+"j= "+str(j))
            j+=1
        A[i]=j
        if(j>max):
            max=j
            #print(max)
        if(j==0):
            i+=1
            continue
        k=1
        while(k+i<len(S) and k+A[k]<j):
            A[i+k]=A[k]
            k+=1
        i+=k
        j=0


#print(A)
print(max)

### FIXED CODE ###

N=int(input())
S=input()

max = 0
index = 0
for i in range(1,len(S)-1):
    s1=S[index:i]
    s2=S[i:]
    if s1 in s2:
        max=len(s1)
    else:
        index+=1
        
print(max)
### BUGGY CODE ###

def gcd(a, b):
    while b:
        r = a % b
        a,b = b,r
    return a

def lcm(a, b):
    return a // gcd(a, b) * b

MOD = 10**9 + 7

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

m = 1
for e in a:
    m = lcm(m, e)

ans = 0
for e in a:
    ans += m // e
    ans %= MOD

print(ans)


### FIXED CODE ###

def lcm(a, b):
    from fractions import gcd

    return a // gcd(a, b) * b


def main():
    _ = int(input())
    a = list(map(int, input().split()))
    x = 1

    for e in a:
        x = lcm(x, e)

    ans = 0
    for e in a:
        ans += x // e

    print(ans % int(1e9 + 7))


main()
### BUGGY CODE ###

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

next=A[0]
for i in range(K-1):
    next=A[next-1]
print(next)

### FIXED CODE ###

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

s=[]
ordn=[]
for i in range(n+1):
    ordn.append(-1)

v=1
while(ordn[v] == -1):
    ordn[v]=len(s)
    s.append(v)
    v=a[v-1]

c=len(s)-ordn[v]
l=ordn[v]

if k<l:
    print(s[k])
else:
    k -= l
    k%=c
    print(s[l+k])
### BUGGY CODE ###

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

count =0

while(not a==[]):
    am = min(a)
    c = a.count(am)
    a = [j for j in a if not j %am ==0]
    if c ==1:
        count =count +1

print(count)

### FIXED CODE ###

import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
ac = [0 for i in range(10**6+2)]



for i in a:
    ac[i] +=1
a = sorted(set(a))
count =0

for i in a:
    if ac[i]>0:
        if ac[i] == 1:
            count += 1
        for j in range(i,10**6+2,i):
            if not ac[j]==0:
                ac[j]=0


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

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

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

AB = []
for a in A:
  for b in B:
    AB.append(a + b)

AB.sort(reverse=True)
AB = AB[:min(3001, X * Y * Z + 1)]
ABC = []
for c in C:
  for ab in AB:
    ABC.append(ab + c)
ABC.sort(reverse=True)

print(*ABC[:K], sep='\n')


### FIXED CODE ###

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

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

AB = []
for a in A:
  for b in B:
    AB.append(a + b)

AB.sort(reverse=True)
AB = AB[:min(3001, X * Y * Z + 1)]
ABC = []
for c in C:
  for ab in AB:
    ABC.append(ab + c)
ABC.sort(reverse=True)
for i in range(K):
  print(ABC[i])
### BUGGY CODE ###

#ABC074C
A, B, C, D, E, F=map(int, input().split())
A=100*A
B=100*B
count_A=F//A
count_B=F//B
count_C=F//C
count_D=F//D
max=-1
ans=[0]*2
total=0
density=0
for i in range(count_A+1):
    for j in range(count_B+1):
        if i*A+j*B<=F and 0<i*A+j*B:
            for k in range(count_C+1):
                if i*A+j*B+k*C<=F:
                    for l in range(count_D+1):
                        total=i*A+j*B+k*C+l*D
                        if total!=0:
                            density=(k*C+l*D)/total
                            if total<=F and density<=E/(100+E) and max<=density:
                                max=density
                                ans[0]=total
                                ans[1]=k*C+l*D
                                if density==E/(100+E):
                                    break
print(' '.join(map(str, ans)))


### FIXED CODE ###

#ABC074C
A, B, C, D, E, F=map(int, input().split())
A=100*A
B=100*B
count_A=F//A
count_B=F//B
count_C=F//C
count_D=F//D
max=-1
ans=[0]*2
total=0
density=0
for i in range(count_A+1):
    for j in range(count_B+1):
        if i*A+j*B<=F and 0<i*A+j*B:
            for k in range(count_C+1):
                if i*A+j*B+k*C<=F:
                    for l in range(count_D+1):
                        total=i*A+j*B+k*C+l*D
                        if total!=0:
                            density=(k*C+l*D)/total
                            if total<=F and density<=E/(100+E) and max<density:
                                max=density
                                ans[0]=total
                                ans[1]=k*C+l*D
                                if density==E/(100+E):
                                    print(' '.join(map(str, ans)))
                                    exit()
print(' '.join(map(str, ans)))
### BUGGY CODE ###

s = input()
q = int(input())

#qs = []
for i in range(q):
    x = input()
    if x[0] == '1':
        #qs.append(x)
        s = s[::-1]
    else:
        #qs.append(x.split(' '))
        xx = x.split(' ')
        if xx[1] == '1':
            s = xx[2] + s
        else:
            s = s + xx[2]
print(s)

### FIXED CODE ###

s = input()
q = int(input())

#qs = []
hanten = 0
mae = ''
ushiro = ''
for i in range(q):
    x = input()
    if x[0] == '1':
        #qs.append(x)
        hanten += 1
    else:
        xx = x.split(' ')
        #qs.append(x.split(' '))
        if xx[1] == '1':
            if hanten % 2 == 0:
                mae = xx[2] + mae
            else:
                ushiro = ushiro + xx[2]
        else:
            if hanten % 2 == 0:
                ushiro = ushiro + xx[2]
            else:
                mae = xx[2] + mae           

if hanten % 2 == 0:
    s = mae + s + ushiro
else:
    s = ushiro[::-1] + s[::-1] + mae[::-1]

print(s)
### BUGGY CODE ###

S = input()
all_remains = [0]*13
for digits, s in enumerate(S[::-1]):
    temp_remains = [0]*13     
    if s == '?':
        if digits == 0:
            for i in range(10):
                temp_remains[i % 13] += 1
        else:
            for i in range(10):
                r = i * (10**digits) % 13
                for j in range(13):
                    temp_remains[ (j + r) % 13] += all_remains[j]
    else:
        if digits == 0:
                temp_remains[int(s)] += 1
        else:
            n = int(s)*(10**digits) % 13
            for j in range(13):
                temp_remains[(j + n) % 13] += all_remains[j]
    all_remains = temp_remains
print(all_remains[5]%(10**9+7))


### FIXED CODE ###

def main():
    M=10**9+7
    r=tuple(tuple((j-k)*9%13 for j in range(10))for k in range(13))
    d=[1]+[0]*12
    for c in input():
      if c>'9':
        d=[sum(d[j]for j in k)%M for k in r]
      else:
        d=[d[(int(c)-k)*9%13]for k in range(13)]
    print(d[5])
main()
### BUGGY CODE ###

data = list(input())[::-1]

count = 0
i = 0
# while 1:
for i in range(len(data)):
    # print(i)
    if data[i] == 'W':
        count += data[i+1:].count('B')
        # count += 1
        # data[i], data[i+1] = 'B', 'W'
        # break
    # else:
    #     break
print(count)


### FIXED CODE ###

data = list(input())

count = 0
# i = 0
# while 1:
count_b = 0
for i in range(len(data)):
    # print(i)
    if data[i] == 'W':
        count += count_b
        # count += 1
        # data[i], data[i+1] = 'B', 'W'
        # break
    else:
        count_b += 1
    # else:
    #     break
print(count)
### BUGGY CODE ###

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

x=1
while K:
    if K&1: x=A[x-1]
    K>>=1

    A2 = []
    for i in range(N):
        A2.append(A[A[i]-1])
    A=A2

print(x)


### FIXED CODE ###

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

x=1
while K:
    if K&1: x=A[x-1]
    K>>=1

    A2 = [None]*N
    for i,a in enumerate(A):
        A2[i]=A[A[i]-1]
    A=A2

print(x)
### BUGGY CODE ###

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

friend = [[] for _ in range(n)]
block = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    friend[a-1].append(b-1)
    friend[b-1].append(a-1)
for _ in range(k):
    c, d = map(int, input().split())
    block[c-1].append(d-1)
    block[d-1].append(c-1)

ans = [0] * n #answer
seen = [0] * n #未探索なら0、探索済なら1
todo = [] #探索保留

#DFS
for i in range(n):
    if seen[i] == 0:
        element = [] #連結要素
        seen[i] = 1
        todo.append(i)
        element.append(i)
        size = 0

        while todo != []:
            for j in friend[todo[-1]]:
                if seen[j] == 0:
                    seen[j] = 1
                    todo.append(j)
                    element.append(j)
                    size += 1
                    break
            else:
                del todo[-1]

        for j in element:
            bl = 0
            for k in block[j]:
                if k in element:
                    bl += 1

            #size = len(element) - 1
            ans[j] = size - len(friend[j]) - bl
        
    print(ans[i])

### FIXED CODE ###

# 参考URL https://note.nkmk.me/python-union-find/
class UnionFind():
    # parents
    # 各要素の親要素の番号を格納するリスト
    # 要素が根（ルート）の場合は-(そのグループの要素数)を格納する
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    # find(x)
    # 要素xが属するグループの根を返す
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    # union(x, y)
    # 要素xが属するグループと要素yが属するグループとを併合する
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    # same(x, y)
    # 要素x, yが同じグループに属するかどうかを返す
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # size(x)
    # 要素xが属するグループのサイズ（要素数）を返す
    def size(self, x):
        return -self.parents[self.find(x)]

import sys
def input():
    return sys.stdin.readline().strip()

n, m, k = map(int, input().split())
ans = [-1 for _ in range(n)]
uf = UnionFind(n)

for _ in range(m):
    a, b = map(int, input().split())
    uf.union(a-1, b-1)
    ans[a-1] -= 1
    ans[b-1] -= 1

for _ in range(k):
    c, d = map(int, input().split())
    if uf.same(c-1, d-1):
        ans[c-1] -= 1
        ans[d-1] -= 1

for i in range(n):
    ans[i] += uf.size(i)

print(' '.join(map(str, ans)))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sun Jun 24 18:23:54 2018
ITP22C
@author: maezawa
"""

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

for i in range(q):
    c = list(map(int, input().split()))
    if c[0] == 0:
        if a[c[1]]:
            if a[c[1]][-1] < c[2]:
                a[c[1]].append(c[2])
            else:
                for j in reversed(range(len(a[c[1]])-1)):
                    if a[c[1]][j] < c[2]:
                        a[c[1]].insert(j+1, c[2])
                        break
                else:
                    a[c[1]].insert(0, c[2])
        
        else:
            a[c[1]].append(c[2])
    elif c[0] == 1:
        if a[c[1]]:
            print(a[c[1]][-1])
    else:
        if a[c[1]]:
            a[c[1]].pop()




### FIXED CODE ###

import heapq

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

for i in range(q):
    c = list(map(int, input().split()))
    if c[0] == 0:
        heapq.heappush(a[c[1]],-c[2])
    elif c[0] == 1:
        if a[c[1]]:
            print(-a[c[1]][0])
    else:
        if a[c[1]]:
            heapq.heappop(a[c[1]])
### BUGGY CODE ###

N, Ma, Mb= (int(i) for i in input().split())
L = []
for i in range(N):
    a, b, c = (int(i) for i in input().split())
    L.append((a, b, c))

dp= [[[float("inf")] * (10 * N + 11) for a in range(10 * N + 11) ] for i in range(N + 1)]
dp[0][0][0] = 0

for i in range(N):
    a, b, c = L[i]
    for ca in range(10 * N + 1):
        for cb in range(10 * N + 1):
            dp[i+1][ca][cb] = min(dp[i+1][ca][cb], dp[i][ca][cb])
            dp[i+1][ca + a][cb + b] = min(dp[i+1][ca + a][cb + b], dp[i][ca][cb] + c)

reslis = []
ra, rb = (Ma, Mb)
while ra <= 10 * N and rb <= 10 * N:
    reslis.append(dp[N][ra][rb])
    ra += Ma
    rb += Mb

reslis.sort()
res = reslis[0]
if res == float("inf"):
    print(-1)
else:
    print(res)


### FIXED CODE ###

N, Ma, Mb= (int(i) for i in input().split())
L = []
for i in range(N):
    a, b, c = (int(i) for i in input().split())
    L.append((a, b, c))

dp= [[[float("inf")] * (10 * N + 11) for a in range(10 * N + 11) ] for i in range(N + 1)]
dp[0][0][0] = 0

for i in range(N):
    a, b, c = L[i]
    for ca in range(10 * N + 1):
        for cb in range(10 * N + 1):
            dp[i+1][ca][cb] = min(dp[i+1][ca][cb], dp[i][ca][cb])
            dp[i+1][ca + a][cb + b] = min(dp[i+1][ca + a][cb + b], dp[i][ca][cb] + c)

reslis = []
ra, rb = (Ma, Mb)
while ra <= 10 * N and rb <= 10 * N:
    reslis.append(dp[N][ra][rb])
    ra += Ma
    rb += Mb

reslis.sort()
res = reslis[0]
if res == float("inf"):
    print(-1)
else:
    print(res)
### BUGGY CODE ###

import numpy as np
N,Q = list(map(int, input().split(" ")))
v_list = np.zeros(N+1, dtype=np.int) # n-1でやること注意
dic_tree = {}
for i in range(N):
    dic_tree[i+1] = [] 

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

# make tree
for k in reversed(range(N)):
    if len(dic_tree) == 0:
        continue
    
    for node in dic_tree[k+1]:
        if len(dic_tree[node]) != 0:
            dic_tree[k+1].extend(dic_tree[node])
        
for i in range(Q):
    p, x = list(map(int, input().split(" ")))
    
    v_list[dic_tree[p]] += x
    v_list[p] += x

print(" ".join(map(str, v_list[1:])))

### FIXED CODE ###

from collections import deque

N,Q = list(map(int, input().split()))
tre = [[] for _ in range(N)]
val = [0] * N
for i in range(N-1):
    a,b = list(map(int, input().split()))
    tre[a-1].append(b-1)
    tre[b-1].append(a-1)

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

stack = deque([0])
visited = [False] * N
visited[0] = True
while stack:
    cur = stack.pop()
    for target in tre[cur]:
        if visited[target]:
            continue
        visited[target] = True
        stack.append(target)
        val[target] += val[cur]

print(*val)
### BUGGY CODE ###

import sys
from itertools import accumulate
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    for _ in range(60 if k >= 60 else k):
        B = [0] * (n + 1)
        for i in range(n):
            left = max(0, i - A[i])
            right = min(n, i + A[i] + 1)
            B[left] += 1
            B[right] -= 1

        B = list(accumulate(B))
        A = B
    print(*B[:n])


if __name__ == '__main__':
    resolve()


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    for x in range(k if k < 50 else 50):
        B = [0] * n
        for j in range(n):
            l = max(0, j - A[j])
            r = min(n - 1, j + A[j])
            B[l] += 1
            if r + 1 < n:
                B[r + 1] -= 1

        for x in range(1, n):
            B[x] += B[x - 1]
        A = B

    print(*A)


if __name__ == '__main__':
    resolve()