Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
inputs = []
dict = {}
for i in range(m):
  p, y = map(int, input().split())
  inputs.append((p, y))
  same = dict.get(p, [])
  same.append(y)
  dict[p] = same

for v in dict.values():
  v.sort()

for i in inputs:
  p = i[0]
  x = dict[p].index(i[1]) + 1
  print(str(p).zfill(6) + str(x).zfill(6))

Fixed submission:
n, m = map(int, input().split())
inputs = []
for i in range(m):
  p, y = map(int, input().split())
  inputs.append([i, p, y, 0])

inputs = sorted(inputs, key = lambda i:i[2])
count = [0 for i in range(n)]
for i in inputs:
  count[i[1]-1] += 1
  i[3] = count[i[1]-1]

inputs = sorted(inputs, key = lambda i:i[0])

for i in inputs:
  print('{0[1]:06}{0[3]:06}'.format(i))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

ans = n
for i in range(n):
  ans = min(ans, s[0:i].count('W') + s[i + 1:n].count('E'))
print(ans)

Fixed submission:
n = int(input())
s = input()

w = 0
e = s.count('E')
ans = w + e
for si in s:
  if si == 'E':
    e -= 1
  else:
    w += 1
  ans = min(ans, w + e)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())

ans = 0
if k == 0:
    ans = n ** 2
else:
    for b in range(k + 1, n + 1):
        for a in range(k, b):
            ans += ((n - a) // b) + 1

print(ans)


Fixed submission:
n, k = map(int, input().split())

ans = 0
if k == 0:
    ans = n ** 2
else:
    for b in range(k + 1, n + 1):
        ans += (b - k) * (n // b)
        last_count = n % b - k + 1
        ans += last_count if last_count > 0 else 0

print(ans)
Buggy python submission (verdict: Runtime Error):
n, y = map(int, input().split())

a = 0
b = 0
c = n
ans = c * 1000

while ans < y:
    if y - ans >= 9000:
        tmp = (y - ans) // 9000
        a += tmp
        c -= tmp
    elif y - ans >= 4000:
        tmp = (y - ans) // 4000
        b += tmp
        c -= tmp
    ans = a * 10000 + b * 5000 + c * 1000

if ans != y:
    a = b = c = -1

print(a, b, c)


Fixed submission:
n = input().split('/')
n[0] = str(int(n[0]) + 1)

print('/'.join(n))
Buggy python submission (verdict: Time Limit Exceeded):
n, y = map(int, input().split())

a = 0
b = 0
c = n
ans = c * 1000

while ans < y:
    if y - ans >= 9000:
        tmp = (y - ans) // 9000
        a += tmp
        c -= tmp
    elif y - ans >= 4000:
        tmp = (y - ans) // 4000
        b += tmp
        c -= tmp
    ans = a * 10000 + b * 5000 + c * 1000

if ans != y:
    a = b = c = -1

print(a, b, c)


Fixed submission:
n, y = map(int, input().split())

a, b, c = (-1, -1, -1)
for i in range(n + 1):
  for j in range(n + 1 - i):
    k = n - (i + j)
    if 10000 * i + 5000 * j + 1000 * k == y:
      a, b, c = (i, j, k)
      break
print(a, b, c)

Buggy python submission (verdict: Time Limit Exceeded):
n, y = map(int, input().split())

a = 0
b = 0
c = n
ans = c * 1000

while ans < y:
    if y - ans >= 9000:
        tmp = (y - ans) // 9000
        a += tmp
        c -= tmp
    elif y - ans >= 4000:
        tmp = (y - ans) // 4000
        b += tmp
        c -= tmp
    ans = a * 10000 + b * 5000 + c * 1000

if ans != y:
    a = b = c = -1

print(a, b, c)


Fixed submission:
n, y = map(int, input().split())

a, b, c = (-1, -1, -1)
for i in range(n + 1):
  for j in range(n + 1 - i):
    k = n - (i + j)
    if 10000 * i + 5000 * j + 1000 * k == y:
      a, b, c = (i, j, k)
      break
print(a, b, c)

Buggy python submission (verdict: Runtime Error):
n, y = map(int, input().split())

a = y // 10000
b = (y - a * 10000) // 5000
c = (y - a * 10000 - b * 5000) // 1000
n = a + b + c

while ans != y:
    if y - ans >= 9000:
        tmp = (y - ans) // 9000
        a += tmp
        c -= tmp
    elif y - ans >= 4000:
        tmp = (y - ans) // 4000
        b += tmp
        c -= tmp
    ans = a * 10000 + b * 5000 + c * 1000

if ans != y:
    a = b = c = -1

print(a, b, c)


Fixed submission:
n, y = map(int, input().split())

a, b, c = (-1, -1, -1)
for i in range(n + 1):
  for j in range(n + 1 - i):
    k = n - (i + j)
    if 10000 * i + 5000 * j + 1000 * k == y:
      a, b, c = (i, j, k)
      break
print(a, b, c)

Buggy python submission (verdict: Time Limit Exceeded):
n, y = map(int, input().split())

a = 0
b = 0
c = n
ans = c * 1000

while ans < y:
    if y - ans >= 9000:
        a += 1
        c -= 1
    elif y - ans >= 4000:
        b += 1
        c -= 1
    ans = a * 10000 + b * 5000 + c * 1000

if ans != y:
    a = b = c = -1

print(a, b, c)


Fixed submission:
n, y = map(int, input().split())

a, b, c = (-1, -1, -1)
for i in range(n + 1):
  for j in range(n + 1 - i):
    k = n - (i + j)
    if 10000 * i + 5000 * j + 1000 * k == y:
      a, b, c = (i, j, k)
      break
print(a, b, c)
Buggy python submission (verdict: Runtime Error):
-*- coding: utf-8 -*-
 
import math
 
l = rawinput().split()
print(math.ceil(l[0] + l[1])


Fixed submission:
# -*- coding: utf-8 -*-
 
import math
 
l = list(map(int, input().split()))
print(math.ceil((l[0] + l[1])/2))

Buggy python submission (verdict: Runtime Error):
-*- coding: utf-8 -*-
 
import math
 
l = raw_input().split()
print(math.ceil(l[0] + l[1])

Fixed submission:
# -*- coding: utf-8 -*-
 
import math
 
l = list(map(int, input().split()))
print(math.ceil((l[0] + l[1])/2))

Buggy python submission (verdict: Runtime Error):
-*- coding: utf-8 -*-

import math

l = rawinput().split()
print(math.ceil(l[0] + l[1])


Fixed submission:
# -*- coding: utf-8 -*-
 
import math
 
l = list(map(int, input().split()))
print(math.ceil((l[0] + l[1])/2))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))

count = dict()
for i in a:
  count[i] = count.get(i, 0) + 1

ans = 0
while len(count) > k:
  key, value = min(count.items(), key=lambda x : x[1])
  del count[key]
  ans += value

print(ans)

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

count = {}
for i in a:
  count[i] = count.get(i, 0) + 1

print(sum(sorted(count.values())[:-k]))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

count = {}
for ai in a:
  count[ai] = count.get(ai, 0) + 1

ans = 0
for key in count.keys():
  ans = max(ans, count.get(key - 1) + count.get(key) + count.get(key + 1))
print(ans)

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

count = {}
for ai in a:
  count[ai] = count.get(ai, 0) + 1

ans = 0
for key in count.keys():
  ans = max(ans, count.get(key - 1, 0) + count.get(key) + count.get(key + 1, 0))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())

ans = 0
for x in range(k + 1):
  for y in range(k + 1):
    for z in range(k + 1):
      if x + y + z == s:
        ans += 1
print(ans)

Fixed submission:
k, s = map(int, input().split())

ans = 0
for x in range(k + 1):
  for y in range(k + 1):
    if 0 <= s - (x + y) <= k:
      ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
res, tmp = 0, 0
for c in s:
    if c == 'R':
        tmp += 1
        res = max(res, tmp)
    else:
        tmp = 0

print(res)

Fixed submission:
s = input().strip()
res, tmp = 0, 0

for c in s:
    if c == 'R':
        tmp += 1
        res = max(res, tmp)
    else:
        tmp = 0

print(res)

Buggy python submission (verdict: Runtime Error):
S = input()

if "RRR" in S:
  print(3)
else "RR" in S:
  print(2)
else "R" in S:
  print(1)
else:
  print(0)

Fixed submission:
S = input()

if "RRR" in S:
  print(3)
elif "RR" in S:
  print(2)
elif "R" in S:
  print(1)
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
n = int(input())
cnt  = [0 for i in range(10001)]

for x in range(1,105):
    for y in range(1, 105):
        for z in range(1, 105):
                ans = x**2 + y**2 + z**2 + x*y + y*z + z*x 
                if ans <= 10000:    
                    cnt[ans] +=1
for i in range(1, N+1):  
    print(cnt[i])

Fixed submission:
L,R,d = map(int,input().split())

cnt=0
for i in range(L,R+1):
    if i%d==0:
        cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
letter=input()

if letter==letter.upper():
    print(A)
else:
    print(B)

Fixed submission:
letter=input()

if letter==letter.upper():
    print('A')
else:
    print('a')
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n,k=map(int,input().split())
price=list(map(int,input().split()))

n_list=[]
for com in itertools.combinations(price,k):
    s=sum(com)
    n_list.append(s)
print(min(n_list))


Fixed submission:
N, K = map(int, input().split())
p = list(map(int, input().split()))
print(sum(sorted(p)[:K]))

Buggy python submission (verdict: Runtime Error):
import itertools
prod = functools.partial(functools.reduce, operator.mul)
n,k=map(int,input().split())
price=list(map(int,input().split()))

n_list=[]
for com in itertools.combinations(price,k):
    s=sum(com)
    n_list.append(s)
print(min(n_list))

Fixed submission:
N, K = map(int, input().split())
p = list(map(int, input().split()))
print(sum(sorted(p)[:K]))
Buggy python submission (verdict: Runtime Error):
X,Y=map(int,input().split())

if 2*X<Y<4*X and (Y-2*X)%2==0 and (4*X-Y)%2==0:
    print("Yes")
elif (4*X-Y)/2==1 and (Y-2*X)/2==0:
    print("Yes")
elif (4*X-Y)/2==0 and (Y-2*X)/2==1:
    print("Yes")
else:
    print("No")

Fixed submission:
var=list(map(int,input().split()))

if var[0]==0:
    print(1)
elif var[1]==0:
    print(2)
elif var[2]==0:
    print(3)
elif var[3]==0:
    print(4)
elif var[4]==0:
    print(5)
Buggy python submission (verdict: Runtime Error):
import functools
import operator
n = int(input())
number = map(int,input().split())
X = functools.partial(functools.reduce, operator.mul)
s=X(number)
if s>=pow(10,18):
    print(-1)
else:
    print(s)

Fixed submission:
a, b = map(int,input().split())

print(a*b)
Buggy python submission (verdict: Time Limit Exceeded):
import functools
import operator

n = int(input())
number = map(int,input().split())
X = functools.partial(functools.reduce, operator.mul)

s=X(number)
if s>pow(10,18):
    print(-1)
else:
    print(s)

Fixed submission:
def main():
    N = int(input())
    A = list(map(int,input().split()))

    if 0 in A:
        print(0)
        return

    prod = 1
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1)
            return
    print(prod)
main()

Buggy python submission (verdict: Time Limit Exceeded):
import functools
import operator

n = int(input())
number = map(int,input().split())
X = functools.partial(functools.reduce, operator.mul)

s=X(number)
if s>pow(10,18):
    print(-1)
else:
    print(s)

Fixed submission:
def main():
    N = int(input())
    A = list(map(int,input().split()))

    if 0 in A:
        print(0)
        return

    prod = 1
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1)
            return
    print(prod)
main()
Buggy python submission (verdict: Runtime Error):
n=input()
n_list=list(map(int,input().split()))

counter=0
while all(i%2==0 for i in n_list):
     n_list=[i/2 for i in n_list]

    #n_list=[i/2 for i in n_list]
    counter=+1
print(counter)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
cnt = 0

while True:
   if [i for i in a if i % 2 == 1]:
       break
   a = [i/2 for i in a]
   cnt += 1

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
n_length=list(map(int,input().split()))

counter=0
while all(i%2==0 for i in n_length):
    n_list=[i/2 for i in n_length]
    counter=+1
print(counter)
    

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
cnt = 0

while True:
   if [i for i in a if i % 2 == 1]:
       break
   a = [i/2 for i in a]
   cnt += 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
x,k,d = input().split()
ans = 0
if abs(x) > abs(k*d):
    ans =  abs(x) - abs(k*d)
else:
    kaisuu = abs(x)/d 
    k_2 = k - kaisuu
    if k_2/2 == 2:
        ans = abs(x) - d*kaisuu 
    else:
        ans = (abs(x) - d*kaisuu) - d
print(ans)


Fixed submission:
x,k,d = input().split()
x = int(x)
k = int(k)
d = int(d)
ans = 0
if abs(x) >= abs(k*d):
    ans =  abs(x) - abs(k*d)
else:
    kaisuu = int(abs(x)/d)
    k_2 = k - kaisuu
    if k_2%2 == 0:
        ans = abs(x) - d*kaisuu 
    else:
        ans = abs((abs(x) - d*kaisuu) - abs(d))
print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
def add(i,x):
    global BIT
    i+=1
    while i<=n:
        BIT[i] += x
        i += i&(-i)
        
def bitsum(i):
    x = 0
    i+=1
    while i>0:
        x += BIT[i]
        i -= i&(-i)
    return x

def sums(l,r):
    return bitsum(r-1)-bitsum(l-1)

n,q = map(int,input().split())
c = list(map(int,input().split()))
pi = [-1]*(n+1)
ps = [[] for _ in range(n)]
qs = [[] for _ in range(n)]
for i in range(n):
    l = pi[c[i]]
    if l!=-1:
        ps[l].append(i)
    pi[c[i]] = i
for i in range(q):
    l,r = map(int,input().split())
    l,r = l-1,r-1
    qs[l].append((r,i))
BIT = [0]*(n+1)
ans = [None]*q
for x in range(n-1,-1,-1):
    for y in ps[x]:
        add(y,1)
    for r,i in qs[x]:
        ans[i] = r-x+1-bitsum(r)

for i in ans:
    print(i)

Fixed submission:
def add(i,x):
    global BIT
    i+=1
    while i<=n:
        BIT[i] += x
        i += i&(-i)
        
def bitsum(i):
    x = 0
    i+=1
    while i>0:
        x += BIT[i]
        i -= i&(-i)
    return x

def sums(l,r):
    return bitsum(r-1)-bitsum(l-1)

n,q = map(int,input().split())
c = list(map(int,input().split()))
pi = [-1]*(n+1)
ps = [[] for _ in range(n)]
qs = [[] for _ in range(n)]
for i in range(n):
    l = pi[c[i]]
    if l!=-1:
        ps[l].append(i)
    pi[c[i]] = i
for i in range(q):
    l,r = map(int,input().split())
    l,r = l-1,r-1
    qs[l].append((r,i))
BIT = [0]*(n+1)
ans = [None]*q
for x in range(n-1,-1,-1):
    for y in ps[x]:
        add(y,1)
    for r,i in qs[x]:
        ans[i] = r-x+1-bitsum(r)

for i in ans:
    print(i)
Buggy python submission (verdict: Runtime Error):
from heapq import *

def solve(p:list):
    s = 0
    n = len(p)
    data = [[] for _ in range(n+1)]
    for i,j in p:
        data[min(i,n)].append(j)
    H = []
    heapify(H)
    for i in range(n,0,-1):
        for j in data[i]:
            heappush(H,-j)
        if H:
            s -= heappop(H)
    return s
    
t = int(input())
for _ in range(t):
    n = int(input())
    ans = 0
    pl = []
    pr = []
    for _ in range(n):
        k,l,r = map(int,input().split())
        m = min(l,r)
        ans += m
        l,r = l-m,r-m
        if l:
            pl.append((k,l))
        else:
            pr.append((n-k,r))
    print(ans+solve(pl)+solve(pr))

Fixed submission:
l,r,d = map(int,input().split())
a = (l-1)//d
b = r//d
print(b-a)
Buggy python submission (verdict: Runtime Error):
d = int(input())
c = list(map(int,input().split()))
data = [0]*(26)
ans = 0
for i in range(1,d+1):
    s = list(map(int,input().split()))
    L = []
    for j in range(26):
        out,ind = -float("inf"),-1
        sub = s[j]
        for k in range(26):
            if j == k:
                continue
            sub -= c[k]*(i-data[k])
        L.append(sub)
    out = L.index(max(L))+1
    print(out)
    data[out] = i

Fixed submission:
import random
for i in range(365):
    print(random.randint(1,26))
Buggy python submission (verdict: Runtime Error):
def choose(n,a,mod):
    x, y = 1, 1
    for i in range(a):
        x = x * (n - i) % mod
        y = y * (i + 1) % mod
    return x * pow(y, mod - 2, mod) % mod

n,m = map(int,input().split())
ans = 0
mod = pow(10**9+7)
for i in range(n+1):
    if i == 0:
        stand = choose(m,n,mod)
        ans += stand
        k = 1
    else:
        k*=i
        k %= mod
        stand *= (-1)*n*pow(m,mod-2,mod)
        stand %= mod
        ans += pow(k,mod-2,mod)*stand
        ans %= mod
ans *= k
ans %= mod
print(ans)

Fixed submission:
mod = pow(10,9)+7
n,m = map(int,input().split())
ans = 0
inv = [0,1]
fact = [1,1]
ifact = [1,1]
for i in range(2,m+1):
    inv.append(inv[mod%i]*(mod-int(mod/i))%mod)
    fact.append(i*fact[-1]%mod)
    ifact.append(ifact[-1]*inv[i]%mod)

def combi(a,b):
    return fact[a]*ifact[b]*ifact[a-b]%mod
def permi(a,b):
    return fact[a]*ifact[a-b]%mod

for i in range(n+1):
    now = combi(n,i)
    now *= permi(m-i,n-i)
    now %= mod
    ans += now*(-1)**(i&1)
    ans %= mod
ans *= permi(m,n)
ans %= mod
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def choose(n,a,mod):
    x, y = 1, 1
    for i in range(a):
        x = x * (n - i) % mod
        y = y * (i + 1) % mod
    return x * pow(y, mod - 2, mod) % mod

k = int(input())
n = len(input())
mod = pow(10,9)+7
start = 1
ans = start*pow(26,k,mod)
for i in range(1,k+1):
    start *= (i+n-1)*pow(i,mod-2,mod)
    start %= mod
    ans += (start*pow(25,i,mod)*pow(26,k-i,mod))
    ans %= mod
print(ans)

Fixed submission:
def choose(n,a,mod):
    x, y = 1, 1
    for i in range(a):
        x = x * (n - i) % mod
        y = y * (i + 1) % mod
    return x * pow(y, mod - 2, mod) % mod

k = int(input())
n = len(input())
mod = pow(10,9)+7
start = 1
ans = start*pow(26,k,mod)
for i in range(1,k+1):
    start *= (i+n-1)*pow(i,mod-2,mod)
    start %= mod
    ans += (start*pow(25,i,mod)*pow(26,k-i,mod))
    ans %= mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def choose(n, a):
    global mod
    x, y = 1, 1
    for i in range(a):
        x = x * (n - i) % mod
        y = y * (i + 1) % mod
    return x * pow(y, mod - 2, mod) % mod

k = int(input())
n = len(input())
mod = pow(10,9)+7
ans = 0
for i in range(k+1):
    ans += (choose(i+n-1,n-1)*pow(25,i,mod)*pow(26,k-i,mod))
    ans %= mod
print(ans)

Fixed submission:
def choose(n,a,mod):
    x, y = 1, 1
    for i in range(a):
        x = x * (n - i) % mod
        y = y * (i + 1) % mod
    return x * pow(y, mod - 2, mod) % mod

k = int(input())
n = len(input())
mod = pow(10,9)+7
start = 1
ans = start*pow(26,k,mod)
for i in range(1,k+1):
    start *= (i+n-1)*pow(i,mod-2,mod)
    start %= mod
    ans += (start*pow(25,i,mod)*pow(26,k-i,mod))
    ans %= mod
print(ans)
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate
from collections import Counter
n = int(input())
T = []
for _ in range(n):
    T.append(int(input()))
T.sort()
print(sum(accumulate(T)))
dic = Counter(T)
ans = 1
mod = 10**9+7
for i in dic.values():
    for j in range(1,i+1):
        ans *= j
        ans %= mod
print(ans)

Fixed submission:
x,y = map(int,input().split())
if y % 2 != 0:
    print("No")
    exit()
a = y//2-x
b = 2*x-y//2
if a >= 0 and b >= 0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
search = list(map(int,input().split()))
search.sort()
dp = [1]*(search[-1]+1)
if search[0] == 1:
    if search[1] != 1:
        print(1)
    else:
        print(0)
else:
    for i in search:
        k = 2*i
        while k <= search[-1]:
            if dp[k]:
                dp[k] = 0
                k += i
            else:
                break
    ans = 0
    flag = False
    j = -1
    for i in search:
        if flag:
            if i != j:
                flag = False
                ans -= dp[j]
        else:
            if i == j:
                flag = True
            else:
                ans += dp[i]
                j = i
    
print(ans-dp[search[-1]] if flag else ans)

Fixed submission:
n = int(input())
search = list(map(int,input().split()))
search.sort()
double = set([])
for i in range(n-1):
    if search[i+1] == search[i]:
        double.add(search[i])
dp = [1]*(search[-1]+1)
for i in search:
    if not dp[i]:
        continue
    if i in double:
        dp[i] = 0
    k = 2*i
    while k <= search[-1]:
        dp[k] = 0
        k += i
print(sum((dp[i] for i in search)))
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate
n,k = map(int,input().split())
A = list(map(int,input().split()))
for _ in range(min(k,50)):
    c = [0]*n
    for i,j in enumerate(A):
        l = max(0,i-j)
        r = min(n-1,i+j)
        c[l] += 1
        if r+1 < n:
            c[r+1] -= 1
    A = list(accumulate(c))
print(" ".join(map(str,A)))

Fixed submission:
from itertools import accumulate
n,k = map(int,input().split())
A = list(map(int,input().split()))
for _ in range(min(k,50)):
    c = [0]*n
    for i,j in enumerate(A):
        l = max(0,i-j)
        r = min(n-1,i+j)
        c[l] += 1
        if r+1 < n:
            c[r+1] -= 1
    A = list(accumulate(c))
print(" ".join(map(str,A)))

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate
n,k = map(int,input().split())
A = list(map(int,input().split()))
for _ in range(k):
    c = [0]*n
    for i,j in enumerate(A):
        l = max(0,i-j)
        r = min(n-1,i+j)
        c[l] += 1
        if r+1 < n:
            c[r+1] -= 1
    if A != list(accumulate(c)):
        A = list(accumulate(c))
    else:
        break
print(" ".join(map(str,A)))

Fixed submission:
from itertools import accumulate
n,k = map(int,input().split())
A = list(map(int,input().split()))
for _ in range(min(k,50)):
    c = [0]*n
    for i,j in enumerate(A):
        l = max(0,i-j)
        r = min(n-1,i+j)
        c[l] += 1
        if r+1 < n:
            c[r+1] -= 1
    A = list(accumulate(c))
print(" ".join(map(str,A)))

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
A = list(map(int,input().split()))
for _ in range(k):
    c = [0]*n
    for i,j in enumerate(A):
        for k in range(i-j,i+j+1):
            if 0 <= k <= n-1:
                c[k] += 1
    if A == c:
        break
    A = c
print(" ".join(map(str,A)))

Fixed submission:
from itertools import accumulate
n,k = map(int,input().split())
A = list(map(int,input().split()))
for _ in range(min(k,50)):
    c = [0]*n
    for i,j in enumerate(A):
        l = max(0,i-j)
        r = min(n-1,i+j)
        c[l] += 1
        if r+1 < n:
            c[r+1] -= 1
    A = list(accumulate(c))
print(" ".join(map(str,A)))
Buggy python submission (verdict: Time Limit Exceeded):
n,s = map(int,input().split())
A = list(map(int,input().split()))
mod = 998244353
dp = [[0 for i in range(s+1)] for j in range(n+1)]
dp[0][0] = 1
for i in range(n):
    for j in range(s+1):
        if j - A[i] >= 0:
            dp[i+1][j]=(dp[i][j]*2+dp[i][j-A[i]])%mod
        else:
            dp[i+1][j]=(dp[i][j]*2)%mod
print(dp[n][s])

Fixed submission:
n,s = map(int,input().split())
A = list(map(int,input().split()))
mod = 998244353
dp = [[0 for i in range(s+1)] for j in range(n+1)]
dp[0][0] = 1
for i in range(n):
    for j in range(s+1):
        if j - A[i] >= 0:
            dp[i+1][j]=(dp[i][j]*2+dp[i][j-A[i]])%mod
        else:
            dp[i+1][j]=(dp[i][j]*2)%mod
print(dp[n][s])