Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    x = [int(xn) for xn in input().split()]
    x_sorted = sorted(x)
    idx_median = (n - 1) // 2
    for xn in x:
        target = [*x_sorted]
        target.remove(xn)
        print(target[idx_median])


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    x = [int(xn) for xn in input().split()]
    x_sorted = sorted(x)
    idx_median = n // 2
    median_low = x_sorted[idx_median - 1]
    median_high = x_sorted[idx_median]
    for xn in x:
        print(median_high if xn <= median_low else median_low)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = int(input())
print('Yes' if n % 500 % a == 0 else 'No')

Fixed submission:
n = int(input())
a = int(input())
print('Yes' if (n % 500) <= a else 'No')
Buggy python submission (verdict: Runtime Error):
from collections import Counter

n, k = map(int, input().split())
a = [int(an) for an in input().split()]
ans = 0
set_a = set(a)
num_of_types = len(set_a)
if num_of_types > k:
  cnt = Counter(a)
  ans = sum(sorted(cnt.values())[: num_of_types - k])

print(ans)

Fixed submission:
print(input().count('1'))

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = [int(an) for an in input().split()]
ans = 0
set_a = set(a)
num_of_types = len(set_a)
if num_of_types > k:
  ans = sum(sorted([a.count(num) for num in set_a])[:num_of_types - k])
print(ans)

Fixed submission:
print(input().count('1'))

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

ans = -1
isEven = True

while isEven:
  list_tmp = []
  for an in a:
    if an % 2 ==0:
      list_tmp.append(an / 2)
    else:
      isEven = False
      break;
  a = list_tmp
  ans += 1

print(ans)


Fixed submission:
print(input().count('1'))

Buggy python submission (verdict: Runtime Error):
import sys

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


ans = 0
isEven = True

while isEven:
  list_tmp = []
  for an in a:
    if an % 2 ==0:
      list_tmp.append(an / 2)
    else:
      isEven = False
      break;
  a = list_tmp
  ans += 1

print(ans - 1)

Fixed submission:
print(input().count('1'))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = [int(an) for an in input().split()]
ans = 0
set_a = set(a)
num_of_types = len(set_a)
if num_of_types > k:
  ans = sum(sorted([a.count(num) for num in set_a])[:num_of_types - k])
print(ans)

Fixed submission:
from collections import Counter

n, k = map(int, input().split())
a = [int(an) for an in input().split()]
ans = 0
set_a = set(a)
num_of_types = len(set_a)
if num_of_types > k:
  cnt = Counter(a)
  ans = sum(sorted(cnt.values())[: num_of_types - k])

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = [int(an) for an in input().split()]
ans = 0
set_a = set(a)
num_of_types = len(set_a)
if num_of_types > k:
  ans = sum(sorted([a.count(num) for num in set_a])[:num_of_types - k])
print(ans)

Fixed submission:
from collections import Counter

n, k = map(int, input().split())
a = [int(an) for an in input().split()]
ans = 0
set_a = set(a)
num_of_types = len(set_a)
if num_of_types > k:
  cnt = Counter(a)
  ans = sum(sorted(cnt.values())[: num_of_types - k])

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = [int(an) for an in input().split()]
ans = 0
set_a = set(a)
num_of_types = len(set_a)
if num_of_types > k:
  ans = sum(sorted([a.count(num) for num in set(a)])[:num_of_types - k])
print(ans)

Fixed submission:
from collections import Counter

n, k = map(int, input().split())
a = [int(an) for an in input().split()]
ans = 0
set_a = set(a)
num_of_types = len(set_a)
if num_of_types > k:
  cnt = Counter(a)
  ans = sum(sorted(cnt.values())[: num_of_types - k])

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):

def sign(x):
    return (x > 0) - (x < 0)


def main():
    _ = int(input())
    a = map(int, input().split())
    ans = []
    arr = []
    for an in a:
        if len(arr) < 2:
            arr.append(an)
        else:
            state = sum([el - arr[i] for i, el in enumerate(arr[1:])])
            if state == 0:
                arr.append(an)
            else:
                current = an - arr[-1]
                if current == 0 or sign(state) == sign(current):
                    arr.append(an)
                else:
                    ans.append(arr)
                    arr = [an]
    ans.append(arr)

    print(len(ans))


if __name__ == '__main__':
    main()


Fixed submission:

def sign(x):
    return (x > 0) - (x < 0)


def main():
    _ = int(input())
    a = map(int, input().split())
    ans = []
    arr = []
    state = 0
    for an in a:
        if len(arr) < 2:
            arr.append(an)
        else:
            state += (arr[-1] - arr[-2])
            if state == 0:
                arr.append(an)
            else:
                current = an - arr[-1]
                if current == 0 or sign(state) == sign(current):
                    arr.append(an)
                else:
                    ans.append(arr)
                    arr = [an]
                    state = 0
    ans.append(arr)

    print(len(ans))


if __name__ == '__main__':
    main()
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):
    z = s - x - y
    if z <= k and z >= 0:
      ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
def main():
    h, _ = map(int, input().split())
    c = [input() for _ in range(h)]
    for cn in c:
        print(cn)
        print(cn)


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    print("vowel" if input() in 'aeiou' else "consonant")


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
#C - Walking Takahashi

x, k, d = map(int, input().split())

p = abs(x)

if p/d < k:
  k = k - (p // d)
  p = p % d

  if k % 2 == 0:
    print(abs(p))
  elif p < 0:
    print(abs(p + d))
  else:
    print(abs(p - d))

elif x >= 0:
  print(abs(x - (k * d)))
else:
  print(abs(x + (k * d)))




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):
#C - Walking Takahashi

x, k, d = map(int, input().split())

p = abs(x)

if p/d < k:
  k = k - (p // d)
  p = p % d

  if k % 2 == 0:
    print(abs(p))
  elif p < 0:
    print(abs(p + d))
  else:
    print(abs(p - d))

elif x >= 0:
  print(abs(x - (k * d)))
else:
  print(abs(x + (k * d)))



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):
#C - Walking Takahashi

x, k, d = map(int, input().split())

p = abs(x)

if p/d < k:
  k = k - (p // d)
  p = p % d

  if k % 2 == 0:
    print(abs(p))
  elif p < 0:
    print(abs(p + d))
  else:
    print(abs(p - d))

elif x >= 0:
  print(abs(x - (k * d)))
else:
  print(abs(x + (k * d)))




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: Time Limit Exceeded):
n = int(input())
list = list(input())
lisr_r = list[::-1]
list_len = len(list)
ans = 0
count = 0

while count < n:
  if 'W' not in list or 'R' not in list:
    break

  w = list.index('W')
  r = lisr_r.index('R')

  if w > list_len - 1 - r:
    break

  list[w] = 'R'
  lisr_r[r] = 'W'

  ans += 1
  count += 1

print(ans)


Fixed submission:
n = int(input())
list = input()
count_r = list.count('R')
ans = list[:count_r].count('W')

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list = list(input())
lisr_r = list[::-1]
list_len = len(list)
ans = 0

while True:
  if 'W' not in list or 'R' not in list:
    break

  w = list.index('W')
  r = lisr_r.index('R')

  if w > list_len - 1 - r:
    break

  list[w] = 'R'
  lisr_r[r] = 'W'

  ans += 1

print(ans)


Fixed submission:
n = int(input())
list = input()
count_r = list.count('R')
ans = list[:count_r].count('W')

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list = list(input())
list_len = len(list)
ans = 0

while True:
  if 'W' not in list or 'R' not in list:
    break

  w = list.index('W')
  r = list_len - 1 - list[::-1].index('R')

  if w > r:
    break

  list[w] = 'R'
  list[r] = 'W'

  ans += 1

print(ans)


Fixed submission:
n = int(input())
list = input()
count_r = list.count('R')
ans = list[:count_r].count('W')

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, m, k = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

t = 0
ans = 0

for i in range(n):
  t = sum(a[:i+1])
  if t <= k and i + 1 > ans:
      ans = i + 1
  elif t > k:
    break

  for j in range(m):
    t = sum(a[:i+1]) + sum(b[:j+1])
    if t <= k and i + j + 2> ans:
      ans = i + j + 2
    elif t > k:
      break

print(ans)




Fixed submission:
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 python submission (verdict: Time Limit Exceeded):
n, m, k = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

t = 0
ans = 0

for i in range(n):
  if sum(a[:i+1]) <= k and i + 1 > ans:
      ans = i + 1

  for j in range(m):
    if sum(a[:i+1]) + sum(b[:j+1]) <= k and i + j + 2> ans:
      ans = i + j + 2

print(ans)



Fixed submission:
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 python submission (verdict: Runtime Error):
from collections import deque 

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

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

q = deque()
q.append(1)
ans = [0 for _ in range(N)]

while len(q) > 0:
	v = q.popleft()
	for ike in root[v - 1]:
		q.append(ike)
		if(ans[ike - 1] == 0):
			ans[ike - 1] = v

	root[v-1].clear()

print('Yes')
for a in ans[1::]:
	print(a)

Fixed submission:
from collections import deque 

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

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

q = deque()
q.append(1)
ans = [0 for _ in range(N)]

while len(q) > 0:
	v = q.popleft()
	for ike in root[v - 1]:
		q.append(ike)
		if(ans[ike - 1] == 0):
			ans[ike - 1] = v

	root[v-1].clear()

print('Yes')
for a in ans[1::]:
	print(a)
Buggy python submission (verdict: Runtime Error):
R =  float(input())
C = 3.14159*2*R
print(c)


Fixed submission:
R =  float(input())
print(3.14159*2*R)
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
print(map(C, A, B)

Fixed submission:
A, B, C = map(int, input().split())
print(C, A, B)
Buggy python submission (verdict: Runtime Error):
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))


S=list(ns())
T=list(ns())

INF=10**9
ans=INF
for i in range(len(S)-len(T)):
    tmp=0
    for j in range(len(T)):
        if(S[i+j]!=T[j]):
            tmp+=1
    ans=min(ans,tmp)

print(tmp)
            




Fixed submission:
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))


S=list(ns())
T=list(ns())

INF=10**9
ans=INF
for i in range(len(S)-len(T)+1):
    tmp=0
    for j in range(len(T)):
        if(S[i+j]!=T[j]):
            tmp+=1
    ans=min(ans,tmp)

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
import  math
import fractions
from collections import defaultdict
import heapq
from bisect import bisect_left,bisect

stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

H,W,M=nm()
r=[0]*(10**6)
c=[0]*(10**6)
mass=set()
for i in range(M):
    h,w=nm()
    mass.add(H*h+w)
    r[h]+=1
    c[w]+=1

rl=[]
cl=[]

r_max=0
for i in range(1,H+1):
    r_max=max(r[i],r_max)
    
c_max=0
for i in range(1,W+1):
    c_max=max(c[i],c_max)

for i in range(1,H+1):
    if(r[i]==r_max):
        rl.append(i)

for i in range(1,W+1):
    if(c[i]==c_max):
        cl.append(i)



for i in rl:
    for j in cl:
        if(i*H+j not in mass):
            print(r[0]+c[0])
            sys.exit(0)


print(r[0]+c[0]-1)


Fixed submission:
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N,X,T=nm()
if(N%X==0):
    ans=(N//X)*T
else:
    ans=(N//X+1)*T

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

A,B,C=nm()
K=int(input())

count=0
while(B<A):
    B*=2
    count+=1
while(C<B):
    C*=2
    count+=1

print('No' if K<c else 'Yes')



    


Fixed submission:
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

A,B,C=nm()
K=int(input())

count=0
while(B<=A):
    B*=2
    count+=1
while(C<=B):
    C*=2
    count+=1

print('No' if K<count else 'Yes')
Buggy python submission (verdict: Runtime Error):
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N=int(input())
ac=0
wa=0
tle=0
re=0
for i in range(N):
    S=ns()
    if(S=='AC'):
        ac+=1
    elif(S=='WA'):
        wa+=1
    elif(S=='TLE'):
        tle+=1
    elif(S=='RE'):
        re+=1


print('AC x '+str(ac))
print('WA x '+str(wa))
print('TLE x '+str(tle))
print('RE x '+str(re))


AC × 3
WA × 1
TLE × 2
RE × 0

Fixed submission:
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N=int(input())
ac=0
wa=0
tle=0
re=0
for i in range(N):
    S=ns()
    if(S=='AC'):
        ac+=1
    elif(S=='WA'):
        wa+=1
    elif(S=='TLE'):
        tle+=1
    elif(S=='RE'):
        re+=1


print('AC x '+str(ac))
print('WA x '+str(wa))
print('TLE x '+str(tle))
print('RE x '+str(re))

Buggy python submission (verdict: Runtime Error):
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N=int(input())
ac=0
wa=0
tle=0
re=0
for i in range(N):
    S=ns()
    if(S=='AC'):
        ac+=1
    elif(S=='WA'):
        wa+=1
    elif(S=='TLE'):
        tle+=1
    elif(S=='RE'):
        re+=1


print('AC x '+str(ac))
print('WA x '+str(wa))
print('TLE x '+str(tle))
print('RE x '+str(re))


AC × 3
WA × 1
TLE × 2
RE × 0

Fixed submission:
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N=int(input())
ac=0
wa=0
tle=0
re=0
for i in range(N):
    S=ns()
    if(S=='AC'):
        ac+=1
    elif(S=='WA'):
        wa+=1
    elif(S=='TLE'):
        tle+=1
    elif(S=='RE'):
        re+=1


print('AC x '+str(ac))
print('WA x '+str(wa))
print('TLE x '+str(tle))
print('RE x '+str(re))
Buggy python submission (verdict: Runtime Error):
import sys
import  math
from heapq import *
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))


N=int(input())
A=nl()
A.sort()
A_MAX=10**6+5
p_l=[0]*(A_MAX)
c=0

for i in range(len(A)):
    if(i==0):
        if(A[i]==A[i+1]):
            continue
    elif(i==(len(A)-1)):
        if(A[i]==A[i-1]):
            continue
    else:
        if(A[i]==A[i-1] or A[i]==A[i+1]):
            continue 
    if(p_l[A[i]]==0):
        c+=1
        for k in range(A[i]*2,A_MAX,A[i]):
            if(p_l[k]):
                continue
            p_l[k]=1

print(c)
        
    
    


Fixed submission:
import sys
import  math
from heapq import *
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))


N=int(input())
A=nl()
A.sort()
A_MAX=10**6+5
p_l=[0]*(A_MAX)
c=0
if(len(A)==1):
    print(1)
    sys.exit(0)

for i in range(len(A)):
    if(p_l[A[i]]!=0):
        continue
    for k in range(A[i],A_MAX,A[i]):
        if(p_l[k]):
            continue
        p_l[k]=1
    if(i<(len(A)-1) and A[i]==A[i+1]):
        continue
    c+=1
    

print(c)
Buggy python submission (verdict: Runtime Error):
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))


A,V=nm()
B,W=nm()
T=int(input())

d=abs(A-B)
move_s=(V-W)
if(move_s<=0):
    print("NO")
    sys.exit(0)
if(T<=((d//move_s)+1)):
    print("NO")
    sys.exit(0)
print("YES")



T1=d//move_b
T2=(d%move_b)//move_b
if((d%move_b)%move_b!=0):
    print('No')
    sys.exit(0)
if(T2+T1<=T):
    print('yes')
    sys.exit(0)
else:
    print('No')
    sys.exit(0)


Fixed submission:
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))


A,V=nm()
B,W=nm()
T=int(input())

d=abs(A-B)
move_s=(V-W)
if(move_s<=0):
    print("NO")
    sys.exit(0)
if(((d//move_s))<=(T-1) or ((d//move_s)==T and (d%move_s==0)) ):
    print("YES")
    sys.exit(0)
print("NO")
Buggy python submission (verdict: Runtime Error):
import sys
import  math
import fractions
from collections import defaultdict
import numpy as np
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N,K=nm()
A=nl()

imos_l=[0]*(N+1)

for i in range(K):    
    imos_l=[0]*(N+1)
    for j in range(len(A)): 
        imos_l[max(j-A[j],0)]+=1
        imos_l[min(j+A[j]+1,N)]-=1
    for j in range(len(imos_l)-1):
        imos_l[j+1]=imos_l[j]+imos_l[j+1]
    for j in range(len(A)):
        A[j]=imos_l[j]
    flag=True
    for j in range(len(A)):
        if(A[j]<N):
            flag=False
    if(flag):
        print(*A)
        sys.exit(0)

print(*A)
            
        



Fixed submission:
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N,K=nm()
A=nl()

imos_l=[0]*(N+1)

for i in range(K):    
    imos_l=[0]*(N+1)
    for j in range(len(A)): 
        imos_l[max(j-A[j],0)]+=1
        imos_l[min(j+A[j]+1,N)]-=1
    for j in range(len(imos_l)-1):
        imos_l[j+1]=imos_l[j]+imos_l[j+1]
    for j in range(len(A)):
        A[j]=imos_l[j]
    flag=True
    for j in range(len(A)):
        if(A[j]<N):
            flag=False
    if(flag):
        print(*A)
        sys.exit(0)

print(*A)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import  math
import fractions
from collections import defaultdict
import numpy as np
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N,K=nm()
A=nl()

imos_l=[0]*(N+1)

for i in range(K):    
    imos_l=[0]*(N+1)
    for j in range(len(A)): 
        imos_l[max(j-A[j],0)]+=1
        imos_l[min(j+A[j]+1,N)]-=1
    for j in range(len(imos_l)-1):
        imos_l[j+1]=imos_l[j]+imos_l[j+1]
    for j in range(len(A)):
        A[j]=imos_l[j]
    flag=True
    for j in range(len(A)):
        if(A[j]<N):
            flag=False
    if(flag):
        print(*A)
        sys.exit(0)

print(*A)
            
        



Fixed submission:
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N,K=nm()
A=nl()

imos_l=[0]*(N+1)

for i in range(K):    
    imos_l=[0]*(N+1)
    for j in range(len(A)): 
        imos_l[max(j-A[j],0)]+=1
        imos_l[min(j+A[j]+1,N)]-=1
    for j in range(len(imos_l)-1):
        imos_l[j+1]=imos_l[j]+imos_l[j+1]
    for j in range(len(A)):
        A[j]=imos_l[j]
    flag=True
    for j in range(len(A)):
        if(A[j]<N):
            flag=False
    if(flag):
        print(*A)
        sys.exit(0)

print(*A)