Harryxun/stf_run huggingface dataset:
# coding: utf-8
# Your code here!

import fractions
import sys

N, M = map(int, input().rstrip().split(' '))
S = [x for x in input()]
T = [x for x in input()]

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

L = lcm(N, M)

dp = [-1] * (L + 10)
for i, s in enumerate(S):
    dp[i*L//N] = s

flag = False   
for i, t in enumerate(T):
    if dp[i*L//M] != -1:
        if dp[i*L//M] != t:
            print(-1)
            flag = True
            break
            #sys.exit()
if flag == False:
    print(L)


### FIXED CODE ###

# coding: utf-8
# Your code here!

import fractions
import sys
from collections import defaultdict

N, M = map(int, input().rstrip().split(' '))
S = [x for x in input()]
T = [x for x in input()]

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

L = lcm(N, M)

dp = defaultdict(lambda: -1)

for i, s in enumerate(S):
    dp[i*L//N] = s

for i, t in enumerate(T):
    if dp[i*L//M] != -1:
        if dp[i*L//M] != t:
            print(-1)
            sys.exit()
print(L)
from itertools import groupby as gb
ans=""
for i,b in gb(input()):
  if i=="B":
    s=s[:-len(list(b))]
  else:s+=i*len(list(b))
print(ans)

### FIXED CODE ###

from itertools import groupby as gb
s=""
for i,b in gb(input()):
  if i=="B":
    s=s[:-len(list(b))]
  else:s+=i*len(list(b))
print(s)
n, a, b = map(int,input().split())

if a != 0:
  answer = n // (a+b)
  remainder = n % (a+b)
  print(answer*a) + min(a, remainder)
else:
  print(0)

### FIXED CODE ###

n, a, b = map(int,input().split())
 
if a != 0:
  answer = n // (a+b)
  remainder = n % (a+b)
  print((answer*a) + min(a, remainder))
else:
  print(0)
a=list(map(int,input().split()))
     
    if a.count("5")==2 and a.count("7")==1:
      print("YES")
    else:
      print("NO")

### FIXED CODE ###

a=input().split()
if a.count("5")==2 and a.count("7")==1:
   print("YES")
else:
   print("NO")
#!/usr/bin/env python3

def f(b, n):
    return n if (n < b) else f(b, n // b) + n % b

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

sqrt_n = int(n ** 0.5)
ans = -1
if n == s:
    ans = n + 1
else:
    for b in range(2, sqrt_n + 1):
        if f(b, n) == s:
            ans = b
            break
    else:
        for p in range(1, sqrt_n):
            if (n - s) % p != 0:
                continue
            b = (n - s) // p + 1
            if f(b, n) == s:
                ans = b
                break
print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
import math

def f(b, n):
    return n if (n < b) else f(b, n // b) + n % b

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

ans = -1
if n == s:
    ans = n + 1
else:
    for b in range(2, math.floor(n ** 0.5) + 1):
        if f(b, n) == s:
            ans = b
            break
    else:
        for p in range(1, math.ceil(n ** 0.5)):
            if (n - s) % p != 0:
                continue
            b = (n - s) // p + 1
            if math.floor(n ** 0.5) < b <= n and f(b, n) == s:
                ans = b
print(ans)
N,K=map(int, inpur().split())

if K%N==0:
  print(0)
else:
  print(1)

### FIXED CODE ###

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

if N%K==0:
  print(0)
else:
  print(1)
n,a = [input() for i in range(2)]

x=N%500 

if x<=a:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

n,a = [int(input()) for i in range(2)]

x=n%500 

if x<=a:
  print('Yes')
else:
  print('No')
n = input()
??????????????????
S = range(1, 14)
H = range(1, 14)
C = range(1, 14)
D = range(1, 14)
??????????????????
for i in range(0, n):
??????mk, num = raw_input().split()
????????????if mk == 'S':
??????????????????S[int(num)-1] = 0
????????????elif mk == 'H':
??????????????????H[int(num)-1] = 0
????????????elif mk == 'C':
??????????????????C[int(num)-1] = 0
????????????elif mk == 'D':
??????????????????D[int(num)-1] = 0
??????????????????
for i in range(0, 13):
??????if S[i] != 0:
????????????print 'S '+ str(S[i])
????????????????
for i in range(0, 13):
??????if H[i] != 0:
????????????print 'H '+ str(H[i])
????????????????
for i in range(0, 13):
??????if C[i] != 0:
????????????print 'C '+ str(C[i])
????????????????
for i in range(0,13):
??????if D[i] != 0:
????????????print 'D '+ str(D[i])

### FIXED CODE ###

n=input()
  
s=range(1,14)
h=range(1,14)
c=range(1,14)
d=range(1,14)
   
for i in range(n):
   m, k=raw_input().split()
   if m == 'S':
      s[int(k)-1] = 0
   elif m == 'H':
      h[int(k)-1] = 0
   elif m == 'C':
      c[int(k)-1] = 0
   elif m == 'D':
      d[int(k)-1] = 0
  
for i in range(0, 13):
   if s[i] != 0:
      print 'S '+str(s[i])
  
for i in range(0, 13):
   if h[i] != 0:
      print 'H '+str(h[i])
  
for i in range(0, 13):
   if c[i] != 0:
      print 'C '+str(c[i])
  
for i in range(0, 13):
   if d[i] != 0:
      print 'D '+str(d[i])
print(sum(i-1for i in map(int,open(0).read().split())[1:]))

### FIXED CODE ###

print(sum(i-1for i in list(map(int,open(0).read().split()))[1:]))
n,k = map(int,input().split())
A = list(map(int,input().split()))
B = []
b = 1
ans = 1
while ans:
  a = b
  b = A[a-1]
  B.append(b)
  if len(B) == k:
    ans = 0
  if B[-1] == B[-2]:
    ans = 0
print(B[k-1])


### FIXED CODE ###

N,K = map(int,input().split())
A = list(map(int,input().split()))
pos = 0
visit = [0] * N
move = []
roop = []
while visit[pos]!=2:
    if visit[pos]==0:
        move.append(pos)
    else:
        roop.append(pos)
    visit[pos] += 1
    pos = A[pos] - 1
if len(move)>K:
    print(move[K]+1)
else:
    print(roop[(K-(len(move)-len(roop)))%len(roop)]+1)
a,b=map(int,input().split())
if (a+b)%2 == 0:
    print(a+b)/2
else:
    print("IMPOSSIBLE")


### FIXED CODE ###

a,b=map(int,input().split())
if (a+b)%2 == 0:
    print((a+b)//2)
else:
    print("IMPOSSIBLE")
nput()
if x =='a':
    print('b')
if x =='b':
    print('c')
if x =='c':
    print('d')
if x =='d':
    print('e')
if x =='e':
    print('f')
if x =='f':
    print('g')
if x =='g':
    print('h')
if x =='h':
    print('i')
if x =='i':
    print('j')
if x =='j':
    print('k')
if x =='k':
    print('l')
if x =='l':
    print('m')
if x =='m':
    print('n')
if x =='n':
    print('o')
if x =='o':
    print('p')
if x =='p':
    print('q')
if x =='q':
    print('r')
if x =='r':
    print('s')
if x =='s':
    print('t')
if x =='t':
    print('u')
if x =='u':
    print('v')
if x =='v':
    print('w')
if x =='w':
    print('x')
if x =='x':
    print('y')
if x =='y':
    print('z')


### FIXED CODE ###

x = input()
if x =='a':
    print('b')
if x =='b':
    print('c')
if x =='c':
    print('d')
if x =='d':
    print('e')
if x =='e':
    print('f')
if x =='f':
    print('g')
if x =='g':
    print('h')
if x =='h':
    print('i')
if x =='i':
    print('j')
if x =='j':
    print('k')
if x =='k':
    print('l')
if x =='l':
    print('m')
if x =='m':
    print('n')
if x =='n':
    print('o')
if x =='o':
    print('p')
if x =='p':
    print('q')
if x =='q':
    print('r')
if x =='r':
    print('s')
if x =='s':
    print('t')
if x =='t':
    print('u')
if x =='u':
    print('v')
if x =='v':
    print('w')
if x =='w':
    print('x')
if x =='x':
    print('y')
if x =='y':
    print('z')
a = input()
return a**3

### FIXED CODE ###

a = input()
print a * a * a
a,b,c=map(int,input())
print(['No','Yes'][a+b>=c])

### FIXED CODE ###

a,b,c=map(int,input().split())
print(['No','Yes'][a+b>=c])
c=int(input())
print(c+1)

### FIXED CODE ###

c=str(input())
if c == 'a' :
    print("b")
elif c == 'b' :
    print("c")
elif c == 'c' :
    print("d")
elif c == 'd' :
    print("e")
elif c == 'e' :
    print ("f")
elif c == 'f' :
    print("g")
elif c == 'g' :
    print("h")
elif c == 'h' :
    print("i")
elif c == 'i' :
    print("j")
elif c == 'j' :
    print("k")
elif c == 'k' :
    print("l")
elif c == 'l' :
    print("m")
elif c == 'm' :
    print("n")
elif c == 'n' :
    print("o")
elif c == 'o' :
    print("p")
elif c == 'p' :
    print("q")
elif c == 'q' :
    print("r")
elif c == 'r' :
    print("s")
elif c == 's' :
    print("t")
elif c == 't' :
    print("u")
elif c == 'u' :
    print("v")
elif c == 'v' :
    print("w")
elif c == 'w' :
    print("x")
elif c == 'x' :
    print("y")
elif c == 'y' :
    print("z")
def fcd(a , b):
    
    if a>= b:
        while b != 0:
            a,b = b,a%b
        return a
    
    else:
        while a != 0:
            b,a = a,b%a
        return b
    
    
def lcm(a,b):
    return int(a*b/fcd(a , b))


n = int(input())
t_list = []
ans_list = []
for i in range(n):
    t_list.append(int(input()))
    
    
for i in range(len(t_list)):
    if i == 0:
        ans_list.append(t_list[0])
        continue
    elif i == 1:
        ans_list.append(lcm(t_list[0] , t_list[1]))
    
    else:
        ans_list.append(lcm(ans_list[i-2],t_list[i]))
print(ans_list[-1])

### FIXED CODE ###

def fcd(a , b):
    
    if a>= b:
        while b != 0:
            a,b = b,a%b
        return a
    
    else:
        while a != 0:
            b,a = a,b%a
        return b
    
    
def lcm(a,b):
    return a*b//fcd(a , b)


n = int(input())
t_list = []
ans_list = []
for i in range(n):
    t_list.append(int(input()))
    
    
for i in range(len(t_list)):
    if i == 0:
        ans_list.append(t_list[0])
        continue
    if i == 1:
        ans_list.append(lcm(t_list[0] , t_list[1]))
    
    if i >=2:
        ans_list.append(lcm(ans_list[-1],t_list[i]))
print(ans_list[-1])
s = input()
t = input()
print(t+s)

### FIXED CODE ###

S,T = input().split()
print(T+S)
N=int(input())

A=list(map(int,input().split()))
#B=[]
#C=[]
D=[0]*1000000000
E=[0]*1000000000

ans=0

for i in range(N):
  #B.append(A[i]+i+1)
  #C.append(-A[i]+i+1)
  D[A[i]+i+1]+=1
  E[-A[i]+i+1]+=1

for i in range(len(D)):
  #ans+=C.count(i)
  ans+=D[i]*E[i]

print(ans)

### FIXED CODE ###

N=int(input())
 
A=list(map(int,input().split()))
#B=[]
#C=[]
D=[0]*1000000
E=[0]*1000000
 
ans=0
 
for i in range(N):
  if A[i]<500000:
  #B.append(A[i]+i+1)
  #C.append(-A[i]+i+1)
  #if -A[i]+i>=0:
  	D[A[i]+i]+=1
  	E[-A[i]+i]+=1
   #print(E[-A[i]+i],-A[i]+i)

for i in range(1000000):
  #ans+=C.count(i)
  ans+=D[i]*E[i]
 
print(ans)
zimport sys
inputs = sys.stdin.readline
def main():
	ans = 1
	a = 0
	b = 0
	N, M = map(int,inputs().split())
	A =[0]*(M+1)
	for i in range(M):
		a = int(inputs())
		A[i] = a-1-b
		b = a + 1
	A[M] = N - b
	A.sort()
	if A [0] < 0:
		print(0)
		sys.exit()
	p = 1
	q = 1
	t = 0
	flg = 0
	while (A[t]<2):
		t = t+1
	if t > M:
		print(0)
		sys.exit()
	for k in range(2,N):
		r = p + q
		p = q
		q = r
		while (A[t] == k):
			ans = ans*r
			t += 1
			if t == M+1:
				flg = 1
				break
		if flg == 1:
			break
	if a == N - 1:
		print(ans%1000000007)
	else:
		print(ans%1000000007)
main()

### FIXED CODE ###

import sys
inputs = sys.stdin.readline
def main():
	ans = 1
	a = 0
	b = 0
	flg2 = 0
	N, M = map(int,inputs().split())
	A =[0]*(M+1)
	for i in range(M):
		a = int(inputs())
		A[i] = a-1-b
		b = a + 1
	A[M] = N - b
	A.sort()
	if A [0] < 0:
		flg2 = 1
	p = 1
	q = 1
	t = 0
	flg = 0
	while (A[t]<2):
		t = t+1
		if t > M:
			flg = 1
			break
	for k in range(2,N+1):
		r = p + q
		p = q
		q = r
		if flg == 1:
			break
		while (A[t] == k):
			ans = ans*r%1000000007
			t += 1
			if t == M+1:
				flg = 1
				break
		if flg == 1:
			break
	if flg2 == 0:
		print(ans%1000000007)
	else:
		print(0)
main()
n,m=map(int,input().split())
use=[0]
ans=1
for i in range(m):
    use.append(int(input()))
use.append(n)
print(use)
if N>=2:        
    lists=[1,2]

    for i in range(n-2):
        lists.append((lists[-1]+lists[-2])%1000000007)

    
    for i in range(m+1):
    
        if use[i+1]-use[i]==1 and i>=1:
            ans=0
            break
        else:
            ans=(ans*lists[int(use[i+1]-use[i]-2)])%1000000007
            
            
    print(ans)
elif N==1:
    print(1)


### FIXED CODE ###

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

lists=[]
for i in range(m):
    a=int(input())
    lists.append(a)

fiblist=[1,1]
for j in range(10**5):
    nums=(fiblist[-1]+fiblist[-2])%(10**9+7)
    fiblist.append(nums)
lists.insert(0,0)
lists.append(n)
ans=1
if m>=2:
    for i in range(m+1):
        if i==0:
            ans=ans*fiblist[lists[1]-lists[0]-1]
            ans=ans%(10**9+7)
        elif i==m:
            ans=ans*fiblist[lists[m+1]-lists[m]-1]
            ans=ans%(10**9+7)
        elif i!=0 and i!=m:
            if lists[i+1]-lists[i]==1:
                ans=0
                break
            else:
                ans=ans*fiblist[lists[i+1]-lists[i]-2]
                ans=ans%(10**9+7)
    print(ans) 
if m==0:
    print(fiblist[n])
if m==1:
    print(fiblist[lists[1]-1]*fiblist[n-lists[1]-1]%(10**9+7))
import numpy as np
import sys

n,x,m = (int(i) for i in input().split())
l = np.array([x])
ans = x
memo_array = [False]*m
for i in range(1,n):
    ans = ans**2%m
    if memo_array[ans]:
        loop_start = int(np.where(l==ans)[0])
        loop_num, mod = divmod((n-loop_start),(i-loop_start))
        print(np.sum(l[:loop_start]) + np.sum(l[loop_start:])*(loop_num)+np.sum(l[loop_start:loop_start+mod]))
        sys.exit()
    l = np.append(l,ans)
    memo_array[ans]=True
print(np.sum(l))

### FIXED CODE ###

import sys

n,x,m = (int(i) for i in input().split())
l = [x]
ans = x
memo_array = [-1]*(m+1)

for i in range(1,n):
    ans = ans**2%m
    idx = memo_array[ans]
    if idx != -1:
        loop_num, mod = divmod((n-idx),(i-idx))
        print(sum(l[:idx]) + sum(l[idx:])*(loop_num)+sum(l[idx:idx+mod]))
        sys.exit()
    l.append(ans)
    memo_array[ans]=i
print(sum(l))
import sys
import math
from collections import defaultdict, deque
from copy import deepcopy
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
def end_of_loop():raise StopIteration
    
    
def main():
    N, M = MI()
    Switch = [LI()[1:] for i in range(N)]
    P = LI()
    result = 0
    for i in range(2**N):
        temp = [0]*M
        for j in range(N):
            if i>>j & 1 != 0:
                for k in Switch[j]:
                    temp[k-1] += 1
        result += 1
        for num1, num2 in zip(temp, P):
            if num1 % 2 != num2:
                result -= 1
                break
    print(result)
            
        
if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
import math
from collections import defaultdict, deque
from copy import deepcopy
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
def end_of_loop():raise StopIteration
    
    
def main():
    N, M = MI()
    Switch = [LI() for i in range(M)]
    P = LI()
    result = 0
    for i in range(2**N):
        result += 1
        for index, swich in enumerate(Switch):
            if swich[0] == 0:
                continue
            temp = 0
            for j in range(swich[0]):
                if i >> (swich[j+1]-1) & 1 == 1:
                    temp += 1
            if temp % 2 != P[index]:
                result-=1
                break
            
    print(result)
                    
                    
            
            
        
if __name__ == "__main__":
    main()
from collections import deque
import sys
input = sys.stdin.readline


def solve(N, A, fromR=True):
    res = 0
    L, R = None, None

    while A:
        fromR = 1 - fromR

        if L is None:
            L = A.pop() if fromR else A.popleft()
            R = L
            continue

        if len(A) > 1:
            if fromR:
                x = A.pop()
                y = A.pop()
            else:
                x = A.popleft()
                y = A.popleft()
            res += abs((R + L) - (x + y))
            R, L = x, y
            continue

        if len(A) == 1:
            x = A.pop()
            res += max(abs(R - x), abs(L - x))
            continue

    return res


if __name__ == "__main__":
    N = int(input())
    A = [int(input()) for _ in range(N)]
    A = deque(sorted(A))

    ans1 = solve(N, A.copy(), 0)
    ans2 = solve(N, A, 1)
    ans = max(ans1, ans2)
    print(ans)


### FIXED CODE ###

from collections import deque
n = int(input())
a = [int(input()) for _ in range(n)]
a.sort()
x = deque(a)
y = deque(a)


def align(a, fromLeft=1):
    if fromLeft:
        p = a.popleft()
    else:
        p = a.pop()
    q = p

    res = 0
    fromLeft = 1 - fromLeft
    while a:
        p1 = a.popleft() if fromLeft else a.pop()
        if a:
            q1 = a.popleft() if fromLeft else a.pop()
            res += abs(p - p1) + abs(q - q1)
            p = p1
            q = q1
        else:
            res += max(abs(p - p1), abs(q - p1))
        fromLeft = 1 - fromLeft
    return res


ans = max(align(x, 1), align(y, 0))
print(ans)
c = input()
if c == a or e or i or o or u:
  print("vowel")
else:
  print("constant")

### FIXED CODE ###

c=input()

if c=="a" or c=="e" or c=="i" or c=="o" or c=="u":
  print("vowel")
else:
  print("consonant")
# -*- coding: utf-8 -*-

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

product = 1

if 0 in a_li:
    product = 0
else:
    for i in a_li:
        product *= i
        if product > 10**18:
            product = -1
            break
    break
            
print(product)

### FIXED CODE ###

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

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

product = 1

if 0 in a_li:
    product = 0
else:
    for i in a_li:
        product *= i
        if product > 10**18:
            print(-1)
            exit()

print(product)
import sys
sys.setrecursionlimit(10000)
N = int(raw_input())
dict = {}
for i in range(1,N+1):
    dict[i]={}
for i in range(1,N):
    a = map(int,raw_input().split())
    dict[a[0]].update({a[1]:a[2]})
    dict[a[1]].update({a[0]:a[2]})
leng = {}
q,K = map(int,raw_input().split())
def rec(bef,now):
    leng[now]=leng[bef]+dict[bef][now]
    for i in dict[now]:
        if i in leng:
            continue
        rec(now,i)
leng[K] = 0
for j in dict[K]:
    rec(K,j)
for i in range(0,q):
    a,b = map(int, raw_input().split())
    print leng[a]+leng[b]


### FIXED CODE ###

import sys
sys.setrecursionlimit(10000000)
N = int(raw_input())
dict = {}
for i in range(1,N+1):
    dict[i]={}
for i in range(1,N):
    a = map(int,raw_input().split())
    dict[a[0]].update({a[1]:a[2]})
    dict[a[1]].update({a[0]:a[2]})
leng = {}
q,K = map(int,raw_input().split())
def rec(bef,now):
    leng[now]=leng[bef]+dict[bef][now]
    for i in dict[now]:
        if i in leng:
            continue
        rec(now,i)
leng[K] = 0
for j in dict[K]:
    rec(K,j)
for i in range(0,q):
    a,b = map(int, raw_input().split())
    print leng[a]+leng[b]
s = input()
a = [i for i in s]
s = sorted(a)
b = 1
for i in range(len(s)-1):
  if s[i] == s[i+1]:
    b = 0
print("yes") if b = 1 else print("no")


  


### FIXED CODE ###

a,b = map(int,input().split())
print ("error") if a+b >=10 else print(a+b)
A, B = [int(i) for i in raw_input().split()]
print(reduce((lambda x,y:(x|y)-(x&y)),range(A,B+1)))

### FIXED CODE ###

A, B = [int(i) for i in raw_input().split()]


def func(n, m):
	return int((n + 1) / (2 ** m)) * 2 ** (m - 1) + max(0, (n + 1) % (2 ** m) - 2 ** (m - 1))

print sum((func(B, i) - func(A-1, i)) % 2 * 2 ** (i - 1) for i in range(1, 64))
N,Q=map(int,input().split())
graph=[[] for _ in range(N+1)]
for _ in range(n-1):
    a,b=map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)

values=[0]*(N+1)
for _ in range(q):
    p,x=map(int,input().split())
    values[p]+=x
def dfs(v,parent,add):
    values[v]+=add
    for x in graph[v]:
        if x==parent:
            continue
        dfs(x,v,values[v])

answer=' '.join(map(str,values[1:]))
print(answer)

### FIXED CODE ###

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

# 遅延評価で加えてあげるだけ

N,Q = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

value = [0] * (N+1)
for p,x in PX:
    value[p] += x

def dfs(v,parent,add):
    value[v] += add
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x,v,value[v])

dfs(1,0,0)

answer = ' '.join(map(str,value[1:]))
print(answer)
import numpy as np

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

def light(a_list):
    outcome= np.array([0]*(n+1))
    for i in range(n):
        outcome[max(0,i-a_list[i])] += 1
        outcome[min(n,i+a_list[i]+1)] -= 1
    outcome = np.cumsum(outcome)[:-1]
    return outcome

for _ in range(k):
    if sum(a) >= n*n:
        break
    a = light(a)

[print(aa,end=' ') for aa in a]

### FIXED CODE ###

import numpy as np
from numba import njit

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

@njit(cache=True)
def light(n,a_list):
    outcome= np.zeros(n+1, dtype=np.int64)
    for i in range(n):
        outcome[max(0,i-a_list[i])] += 1
        outcome[min(n,i+a_list[i]+1)] -= 1
    outcome = np.cumsum(outcome)[:-1]
    return outcome

for _ in range(k):
    if min(a) == n:
        break
    a = light(n,a)

[print(aa,end=' ') for aa in a]
n=int(input()
print(n//2+n%2)

### FIXED CODE ###

n=int(input())
print(n//2+n%2)
N=int(input())
s=""
for i in range(N):
    s.append(input())
print("AC x ".join(s.count("AC")))
print("WA x ".join(s.count("WA")))
print("TLE x ".join(s.count("TLE")))
print("RE x ".join(s.count("RE")))

### FIXED CODE ###

N=int(input())
s=[]
for i in range(N):
    s.append(input())
print("AC x ",s.count("AC"))
print("WA x ",s.count("WA"))
print("TLE x ",s.count("TLE"))
print("RE x ",s.count("RE"))
print(input().replace("2017","2018"))

### FIXED CODE ###

print(input().replace("2017","2018"))
n = int(input())
a = list(map(int, input()))
ans = 0
for i in range(n):
    if a[i]%2:
        a[i] = a[i]//2
    else:
        print(ans)
        exit()
    ans += 1

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 0
while True:
    i = 0
    while i <= n -1:
        if a[i]%2:
            print(ans)
            exit()
        else:
            a[i] = a[i]//2
        i += 1
    ans += 1
T = input()
print(T.replase("?","D"))

### FIXED CODE ###

print(input().replace("?","D"))