Harryxun/stf_run huggingface dataset:
def solution(path1, path2, path3):
    counts = [0, 0, 0, 0]
    paths = [path1, path2, path3]
    for path in paths:
        counts[path[0] - 1] += 1
        counts[path[1] - 1] += 1

    countsOfCounts = [0, 0]
    for count in counts:
        if count == 1:
            if countsOfCounts[0] == 2:
                return "NO"
            countsOfCounts[0] += 1
        elif count == 2:
            if countsOfCounts[1] == 2:
                return "NO"
            countsOfCounts[1] += 1
        else:
            return "NO"
    return "YES"


if __name__ == "__main__":
    s1, s2, s3 = input().split('\n')
    path1 = [int(s) for s in s1.split(' ')]
    path2 = [int(s) for s in s2.split(' ')]
    path3 = [int(s) for s in s3.split(' ')]

    print(solution(path1, path2, path3))


### FIXED CODE ###

def solution(path1, path2, path3):
    counts = [0, 0, 0, 0]
    paths = [path1, path2, path3]
    for path in paths:
        counts[path[0] - 1] += 1
        counts[path[1] - 1] += 1

    countsOfCounts = [0, 0]
    for count in counts:
        if count == 1:
            if countsOfCounts[0] == 2:
                return "NO"
            countsOfCounts[0] += 1
        elif count == 2:
            if countsOfCounts[1] == 2:
                return "NO"
            countsOfCounts[1] += 1
        else:
            return "NO"
    return "YES"


path1 = [int(s) for s in input().split(' ')]
path2 = [int(s) for s in input().split(' ')]
path3 = [int(s) for s in input().split(' ')]

print(solution(path1, path2, path3))
import math

N = int(input())

aa = list(map(int, input().split()))

bb = aa[:]

i = math.floor(N / 2)

while i > 0:
    if aa[i] == 1:  # 自分が奇数
        if aa[i * 2] == 0:  # 2倍が偶数
            bb[i] = 1
        else:  # 2倍が奇数
            bb[i] = 0
    else:  # 自分が偶数
        if aa[i * 2] == 0:  # 2倍が偶数
            bb[i] = 0
        else:  # 2倍が奇数
            bb[i] = 1
    i -= 1

bbKisu = filter(lambda n: n % 2 == 1, bb)
count = len(list(bbKisu))

print(count)
for i in range(N):
    if bb[i] == 1:
        print(i + 1)






### FIXED CODE ###

import math

N = int(input())

aa = list(map(int, input().split()))

bb = aa[:]

i = N

while i > 0:

    total = 0
    j = i * 2

    while j <= N:
        total ^= bb[j - 1]
        j += i

    bb[i - 1] = total ^ aa[i - 1]
    i -= 1

bbKisu = list(filter(lambda n: n % 2 == 1, bb))
count = len(bbKisu)

print(count)
for i in range(N):
    if bb[i] == 1:
        print(i + 1)
import sys
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a
#リストの最小公倍数
def lcm(a):    
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

N = ir()
A = lr()
A.sort()
MOD = 10 ** 9 + 7
l = []
first = A[0]
l = [x//gcd(x, first) for x in A[1:]]
x = lcm(l) #B[0]
answer = x%MOD

for i in range(1, N):
    answer += (first * x // A[i]) % MOD

print(answer%MOD)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a
#リストの最小公倍数
def lcm(a):    
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

N = ir()
A = lr()
A.sort()
if N == 1:
    print(1)
    exit()
MOD = 10 ** 9 + 7
l = []
first = A[0]
l = [x//gcd(x, first) for x in A[1:]]
x = lcm(l) #B[0]
answer = x%MOD

for i in range(1, N):
    answer += first * x // A[i]

print(answer%MOD)
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N,Y = map(int, input().split())
if Y % 1000 != 0:
  print("-1 -1 -1")
  exit(1)

for sen in range(0, N+1):
  for gosen in range(0, N+1):
    if sen+gosen > N:
      print("-1 -1 -1")
      exit(1)
    man = N - sen - gosen
    if 10000*man + 5000*gosen + 1000*sen == Y:
      print("{} {} {}".format(man, gosen, sen))
      exit(1)


### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

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

for sen in range(0, N+1):
  for gosen in range(0, N+1):
    man = N - sen - gosen
    if man < 0: break
    if 10000*man + 5000*gosen + 1000*sen == Y:
      print("{} {} {}".format(man, gosen, sen))
      exit(0)

print("-1 -1 -1")
h,w=map(int,input().split())
a = [list(input()) for _ in range(w)]

row=[False]*h
col=[False]*w

for i in range(h):
    for j in range(w):
        if a[i][j]=="#":
            row[i]=True
            col[j]=True

for i in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j],end="")
        print()


### FIXED CODE ###

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

row=[False]*h
col=[False]*w

for i in range(h):
    for j in range(w):
        if a[i][j]=="#":
            row[i]=True
            col[j]=True

for i in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j],end="")
        print()
import itertools

N, K = map(int, input().split())
Ds = list(map(int, input().split()))
NDs = list(set([i for i in range(10)]) - set(Ds))
NDs = list(map(str, NDs))

min_price = 10000
for p in itertools.product(NDs, repeat=len(str(N))):
    if p[0] == '0':
        continue
    price = int(''.join(p))
    if price < N:
        continue
    min_price = min(price, min_price)

if min_price == 10000:
    for p in itertools.product(NDs, repeat=len(str(N)+1)):
        if p[0] == '0':
            continue
        price = int(''.join(p))
        min_price = min(price, min_price)

print(min_price)

### FIXED CODE ###

import itertools

N, K = map(int, input().split())
Ds = list(map(int, input().split()))
NDs = list(set([i for i in range(10)]) - set(Ds))
NDs = list(map(str, NDs))

min_price = 100000
for p in itertools.product(NDs, repeat=len(str(N))):
    if p[0] == '0':
        continue
    price = int(''.join(p))
    if price < N:
        continue
    min_price = min(price, min_price)

if min_price == 100000:
    for p in itertools.product(NDs, repeat=len(str(N))+1):
        if p[0] == '0':
            continue
        price = int(''.join(p))
        min_price = min(price, min_price)

print(min_price)
li_1 = list(map(int,input().split()))
N = li_1[0]
K = li_1[1]

D = list(map(int,input().split()))


minvalue=N
temp=0

for i in range(N+1):
    i=i+N
    numtemp=i
    num_4=int(i/10000)
    i=i-10000*num_4
    num_3=int(i/1000)
    i=i-1000*num_3
    num_2=int(i/100)
    i=i-100*num_2
    num_1=int(i/10)
    i=i-10*num_1
    num_0=i
    
    for j in range(K):
        if (num_0!=D[j])and(num_1!=D[j])and(num_2!=D[j])and(num_3!=D[j]):
            if j==K-1:
                temp=1
        else:
            break
    if temp==1:
        num=numtemp
        break

print(num)
    

### FIXED CODE ###

li_1 = list(map(int,input().split()))
N = li_1[0]
K = li_1[1]

D = list(map(int,input().split()))


minvalue=N
temp=0

for i in range(10*N):
    i=i+N
    numtemp=i
    if numtemp>=10000:
        num_4=int(i/10000)
        i=i-10000*num_4
    else:
        num_4=10
        
    if numtemp>=1000:
        num_3=int(i/1000)
        i=i-1000*num_3
    else:
        num_3=10
        
    if numtemp>=100:
        num_2=int(i/100)
        i=i-100*num_2
    else:
        num_2=10
        
    if numtemp>=10:
        num_1=int(i/10)
        i=i-10*num_1
    else:
        num_1=10
        
    num_0=i
    
    for j in range(K):
        if (num_0!=D[j])and(num_1!=D[j])and(num_2!=D[j])and(num_3!=D[j])and(num_4!=D[j]):
            temp+=1
            
    if temp==K:
        num=numtemp
        break
    
    temp=0

print(num)
N=int(input())
a=eval(input().replace(' ','*'))
print(-1 if a>10**18 else a)

### FIXED CODE ###

_=input()
A=sorted(list(map(int,input().split())))
B=1
for a in A:
    B*=a
    if B>10**18:
        B=-1
        break
print(B)
s_inv = str(input())[::-1]
dp = [1]+[0]*2018
ans = 0
num = 0
k = 1 
for i in range(len(s_inv)):
  num+=int(s_inv[i])*k % 2019
  dp[num] += 1
  k = k*10 % 2019
for i in dp:
  ans += i*(i-1)/2

### FIXED CODE ###

s_inv = str(input())[::-1]
dp = [1]+[0]*2018
MOD = 0
ans = 0
num = 0
k = 1

for i in range(len(s_inv)):
  num+=int(s_inv[i])*k
  MOD = num % 2019
  dp[MOD] += 1
  k = k*10
  k %= 2019
for i in dp:
  ans += i*(i-1)/2

print(int(ans))
def rec(s):
  if s == '':
    return True
  else:
    res = False
    res = res or rec(s[7:]) if len(s) > 6 and s[0:7] == 'dreamer' else res
    res = res or rec(s[5:]) if len(s) > 4 and s[0:5] == 'dream' else res
    res = res or rec(s[5:]) if len(s) > 4 and s[0:5] == 'erase' else res
    res = res or rec(s[6:]) if len(s) > 5 and s[0:6] == 'eraser' else res
    return res
  
print('YES' if rec(input()) else 'NO')

### FIXED CODE ###

def solve(s):
  while True:
    if s == '':
      return True
    else:
      if s[0:7] == 'dreamer'[::-1]:
        s = s[7:]
      elif s[0:5] == 'dream'[::-1]:
        s = s[5:]
      elif s[0:5] == 'erase'[::-1]:
        s = s[5:]
      elif s[0:6] == 'eraser'[::-1]:
        s = s[6:]
      else:
        return False
  
print('YES' if solve(input()[::-1]) else 'NO')
H,W=map(int, input().split())
A=[input() for _ in range(H)]

import queue
q=queue.Queue()
B=[[0]*H for _ in range (W)]
cnt=0
for i in range(H):
    for j in range(W):
        if A[i][j]=="#":
            q.put((i,j))
            B[i][j]=1
while sum([sum(B[k]) for k in range(H)])<H*W:
    new_q=[]
    while q.empty()==False:
        new_q.append(q.get())
    for t in new_q:
        if t[0]!=0:
            q.put((t[0]-1, t[1]))
            B[t[0]-1][t[1]]=1
        if t[0]!=H-1:
            q.put((t[0]+1, t[1]))
            B[t[0]+1][t[1]]=1
        if t[1]!=0:
            q.put((t[0], t[1]-1))
            B[t[0]][t[1]-1]=1
        if t[1]!=W-1:
            q.put((t[0], t[1]+1))
            B[t[0]][t[1]+1]=1
    cnt+=1
print(cnt)

### FIXED CODE ###

H,W=map(int, input().split())
A=[input() for i in range(H)]

from collections import deque

q=deque([])
B=[[None]*W for _ in range (H)]
for i in range(H):
    for j in range(W):
        if A[i][j]=="#":
            q.append((i,j))
            B[i][j]=0
dx=[-1,1,0,0]
dy=[0,0,-1,1]
while len(q)>0:
  XY=[]
  while len(q)>0:
     XY.append(q.popleft())
  for xy in XY:
    for i in range(4):
      if 0<=(xy[0]+dx[i])<=H-1 and 0<=(xy[1]+dy[i])<=W-1:
        if B[xy[0]+dx[i]][xy[1]+dy[i]]==None:
          B[xy[0]+dx[i]][xy[1]+dy[i]]=B[xy[0]][xy[1]]+1
          q.append((xy[0]+dx[i],xy[1]+dy[i]))
        else: pass
      else: pass
print(max([max(B[i]) for i in range(H)]))
n = int(input())
a = list(map(int, input().split()))
d = {}
for i in range(n):
  d.get(a[i], 0) += 1
data = sorted(list(set(a)))
prime_bool = [True]*(max(a)+1)
prime_bool[0] = False
count = 0
for i in range(len(data)):
  p = data[i]
  if prime_bool[p]:
    if c[p] == 1:
      count += 1
    #print(p)
    for j in range(2*p, max(a)+1, p):
      prime_bool[j] = False

print(count)



### FIXED CODE ###

import collections

n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
c = collections.Counter(a)
data = sorted(list(set(a)))
max_ = max(a)+1
prime_bool = [True]*max_
prime_bool[0] = False

for i in range(len(data)):
  p = data[i]
  if prime_bool[p]:
    #print(p)
    k = 2
    while k*p < max_:
      prime_bool[k*p] = False
      k += 1

count = 0
for i in range(len(prime_bool)):
  if prime_bool[i]:
    if c[i] == 1:
      count += 1
print(count)
#print(prime_bool)
# https://atcoder.jp/contests/abc042/tasks/arc058_a
# 最悪でも10**6探索する程度なのでNを一つづつ足して全探索でもよくね？


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


def is_inD(n: int):
    tmp = set(str(n))
    return tmp.isdisjoint(D)

# 頭の悪い全探索
# for i in range(N, N + 10 ** 6):
#     if is_inD(i):
#         print(i)
#         exit()


# もっとスケーラブルな方法
all_nums = {str(i) for i in range(10)}
use_nums = all_nums - D
N_str = str(N)
L = len(N_str)

ans = []
for l in range(L):
    tmp = []
    for num in use_nums:
        if int(num) >= int(N_str[l]):
            tmp.append(num)
    ans.append(min(tmp))

print(int(''.join(ans)))


### FIXED CODE ###

# https://atcoder.jp/contests/abc042/tasks/arc058_a
# 最悪でも10**6探索する程度なのでNを一つづつ足して全探索でもよくね？


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


def is_inD(n: int):
    tmp = set(str(n))
    return tmp.isdisjoint(D)


for i in range(N, N + 10 ** 6):
    if is_inD(i):
        print(i)
        exit()
t, x = [ s for s in int(input())]
result = t/x
print(result)

### FIXED CODE ###

t, x = [ int(s) for s in input().split(' ')]
result = t/x
print(result)
s=input()
print("A"s[0]"C")

### FIXED CODE ###

print("A"+input()[8]+"C")
data = [int(x) for x in input().split(" ")]
print(max(sum(data),data[0]-data[1],data[0]*data[1])

### FIXED CODE ###

data = [int(x) for x in input().split(" ")]
print(max(sum(data),data[0]-data[1],data[0]*data[1]))
s=input()
if "k" in s and "y" in s and "n" in s and "c" in s and k.count("e")>=3:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

s=input()
for i in range(8):
    ans=s[:i]+s[-7+i:]
    if ans=="keyence":
        ans=0
        print("YES")
        break
if ans!=0:
    print("NO")
x, t = map(int, input().split())
if x-t >= 0:
  print(x-t)
 else:
  print(0)

### FIXED CODE ###

x, t = map(int, input().split())
if x-t >= 0:
  print(x-t)
else:
  print(0)
list=[int(input()) for i in range(5)]
sum=0
max=0
for x in list:
  y = -(-x//10)*10
  sum+=y
  max=((y-x), max)
print(sum-max)

### FIXED CODE ###

X=[int(input()) for i in range(5)]
Y=[]
for x in X:
  Y.append(-(-x//10)*10-x)
print(sum(X)+sum(Y)-(max(Y)))
N = int(input())
A = list(map(int, input().split()))

L = [0]
R = [0]

for i in range(N):
    L.append(fractions.gcd(L[i], A[i]))
    R.append(fractions.gcd(R[i], A[N - i - 1]))

ans = 0
for i in range(N):
    t = fractions.gcd(L[i], R[N - i - 1])
    ans = max(t, ans)

print(ans)

### FIXED CODE ###

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

L = [0]
R = [0]

for i in range(N):
    L.append(fractions.gcd(L[i], A[i]))
    R.append(fractions.gcd(R[i], A[N - i - 1]))

ans = 0
for i in range(N):
    t = fractions.gcd(L[i], R[N - i - 1])
    ans = max(t, ans)

print(ans)
from fractions import factorial

n, k = map(int, input().split())
mod = 10**9 + 7
def nck(a,b):
    return factorial(a) // (factorial(b) * factorial(a - b))

for i in range(1, k + 1):
	x = (nck(n-k+1,i) * min(i, k-i+1)) % mod
	print(x)


### FIXED CODE ###

n, k = map(int, input().split())
mod = 10**9 + 7

fact = [1] * (n+1)

for i in range(2, n+1):
	fact[i] = fact[i-1] * i


def nck(a,b):
    return fact[a] // (fact[b] * fact[a - b])

for i in range(1, k + 1):
	print((nck(n-k+1,i) * fact[k-1] // (fact[i-1] * fact[k-i])) % mod)
import math

def Repsept():
    
    num = int(input())

    mod_value = 1

    count = 1
    
    

    if num % 2 != 0:

        if is_prime(num):
                    
            while mod_value != 0:
                value = 7*(pow(10, count)-1)/9
                
                mod_value = value % num
    
                if mod_value != 0:
                    count = count + 1
    
            print(count)
            
        else:
            
            print(num-1)
        
    else:
    
        print(-1)

def is_prime(n):
    if n == 1: 
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

if __name__ == '__main__':
    Repsept()



### FIXED CODE ###

def Repsept():
    
    num = int(input())

    f=0
    n=num
    
    for i in range(10**6+1):
      if n==0:
        f=1
        print(i)
        break
      n=((n*10)+7)%num
    if f==0:
      print(-1)


if __name__ == '__main__':
    Repsept()
n = int(input())
print(n - (math.floor(n - 1 / 1000) + 1) * 1000)


### FIXED CODE ###

import math
n = int(input())
print((math.floor((n - 1) / 1000) + 1) * 1000 - n)
# utf-8:
import numpy as np


def main():
    n = int(raw_input())
    if n == 1:
        print(n)
    else:
        for i in range(n):
            sqrt = np.sqrt(n - i + 1)
            if sqrt - int(sqrt) == 0:
                print(n - i)
                break


if __name__ == '__main__':
    main()


### FIXED CODE ###

# utf-8:
import math as np


def main():
    n = int(raw_input())
    a = int(np.sqrt(n))
    print(a * a)


if __name__ == '__main__':
    main()
def get_path(start, goal, pred):
    return get_path_row(start, goal, pred)


def get_path_row(start, goal, pred_row):
    path = []
    i = goal
    while i != start and i >= 0:
        path.append(i)
        i = pred_row[i]
    if i < 0:
        return []
    path.append(i)
    return path[::-1]


def main():
    from scipy.sparse.csgraph import bellman_ford
    from scipy.sparse import csr_matrix
    from scipy.sparse.csgraph._shortest_path import NegativeCycleError
    import sys
    input = sys.stdin.buffer.readline
    N, M, P = (int(i) for i in input().split())
    g = [[10**6]*N for _ in range(N)]
    ban_v = set()
    for i in range(M):
        a, b, c = (int(i) for i in input().split())
        c -= P
        if a == b:
            ban_v.add(a-1)
        else:
            g[a-1][b-1] = -c

    csr = csr_matrix(g)
    ans = -1
    try:
        dist, p = bellman_ford(csr, indices=0, return_predecessors=True)
        path = get_path(0, N-1, p)
        if any(v in ban_v for v in path):
            ans = -1
        else:
            ans = max(0, int(dist[N-1]*-1))
    except NegativeCycleError:
        ans = -1
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    from itertools import product
    import sys
    input = sys.stdin.buffer.readline
    N, M, P = (int(i) for i in input().split())
    adj_list = [[] for _ in range(N)]
    radj_list = [[] for _ in range(N)]
    ok = [False]*N
    edge = []
    for i in range(M):
        a, b, c = (int(i) for i in input().split())
        c -= P
        adj_list[a-1].append(b-1)
        radj_list[b-1].append(a-1)
        edge.append((a-1, b-1, -c))

    def dfs(G, v):
        seen = [False]*N
        todo = [v]
        seen[v] = True
        while todo:
            u = todo.pop()
            for next_v in G[u]:
                if seen[next_v]:
                    continue
                seen[next_v] = True
                todo.append(next_v)
        return seen

    i = 0
    for s, rs in zip(dfs(adj_list, 0), dfs(radj_list, N-1)):
        ok[i] = s and rs
        i += 1

    # Bellman_ford
    d = [10**12]*N
    d[0] = 0
    update = True
    step = 0
    while update:
        update = False
        for a, b, c in edge:
            if not(ok[a]) or not(ok[b]):
                continue
            newD = d[a] + c
            if newD < d[b]:
                update = True
                d[b] = newD
        step += 1
        if step > N:
            return print(-1)
    print(max(0, d[N-1]*-1))


if __name__ == '__main__':
    main()
def main():
    N, Q = [int(s) for s in input().split()]
    adj = [[] for _ in range(N)]
    counters = [0] * N
    increments = [0] * N

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

    for _ in range(Q):
        p, x = [int(s) for s in input().split()]
        increments[p - 1] += x

    dfs(0, -1, 0, increments, adj, counters)
    print(' '.join(str(c) for c in counters))


def dfs(vertex, parent, increment, increments, adj, counter):
    increment += increments[vertex]
    counter[vertex] += increment

    for other in adj[vertex]:
        if other != parent:
            dfs(other, vertex, increment, increments, adj, counter)


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    N, Q = [int(s) for s in input().split()]
    adj = [[] for _ in range(N)]
    counters = [0] * N
    increments = [0] * N

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

    for _ in range(Q):
        p, x = [int(s) for s in input().split()]
        increments[p - 1] += x

    stack = [(0, 0, -1)]

    while stack:
        u, inc, parent = stack.pop()
        inc += increments[u]
        counters[u] += inc

        for v in adj[u]:
            if v != parent:
                stack.append((v, inc, u))

    print(' '.join(str(c) for c in counters))


if __name__ == '__main__':
    main()
N = int(input())

A = []

for i in range(N-1):
  a = int(input())
  A.append(a)

B = []

for j in range(N-1):
  temp = 0
  for i in A:
    if i-2 == j:
      temp += 1
  B.append(temp)        
for j in range(N-1):
  print(B[j])

### FIXED CODE ###

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

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

B = sum(A)

if N >= B:
  print(N-B)

else:
  print('-1')
import numpy as np
import sys
# import copy
# def input(): return sys.stdin.readline().rstrip()
# input = sys.stdin.readline
input = sys.stdin.buffer.readline
# sys.setrecursionlimit(10 ** 7)

N, K = map(int, input().split())
A = np.array(list(map(int, (input().split()))))
# A = list(map(int, (input().split())))
nd = np.zeros((N,N), dtype=bool)
# print(*A)
for i in range(K):
    # cnt = [0]*N
    for j in range(N):
        nd[j, max(j-A[j],0):min(j+A[j]+1,N)] = True
        # for k in range(max(j-A[j],0), min(j+A[j]+1,N)):
        #     cnt[k] += 1
    # print(nd)
    A = np.count_nonzero(nd, axis=0)
    if A[0] == A[N-1] == N:
        break
    # A = copy.copy(cnt)
    # print(*A)

print(*A)

### FIXED CODE ###

import numpy as np
from numba import njit
import sys
# import copy
# def input(): return sys.stdin.readline().rstrip()
# input = sys.stdin.readline
input = sys.stdin.buffer.readline
# sys.setrecursionlimit(10 ** 7)

N, K = map(int, input().split())
# A = np.array(list(map(int, (input().split()))))
A = np.array(input().split(), dtype=np.int64)
# A = list(map(int, (input().split())))
# nd = np.zeros((N,N), dtype=bool)
# print(*A)

# @njit('(i8[::1],)', cache=True)
@njit(cache=True)
def loop(A):
    for i in range(K):
        # cnt = [0]*N
        cnt = np.zeros_like(A)
        for j, x in enumerate(A):
            # nd[j, max(j-A[j],0):min(j+A[j]+1,N)] = True
            l = max(j-x,0)
            r = min(j+x+1,N)
            cnt[l] += 1
            if r<N:
                cnt[r] -= 1
            # for k in range(max(j-A[j],0), min(j+A[j]+1,N)):
            #     cnt[k] += 1
        # print(nd)
        # A = np.count_nonzero(nd, axis=0)
        # print(cnt)
        A = np.cumsum(cnt)
        if A[0] == A[N-1] == N:
            break
        # print(*A)
    return A

A = loop(A)
print(*A)
import math
n, W = map(int, input().strip().split())

values = []
weights = []
total = 10
for _ in range(n):
    w, v = map(int, input().strip().split())
    weights.append(w)
    values.append(v)
    total += v

dp = [[[0, math.inf] for j in range(total)] for i in range(n+1)]
for i in range(n+1):
    dp[i][0] = [1, 0]
for i in range(1,n+1):
    for v in range(1,total):
        exclude = dp[i-1][v]
        include = [0, math.inf]
        if v >= values[i-1]:
            if dp[i-1][v-values[i-1]][1] + weights[i-1] <= W:
                include = dp[i-1][v-values[i-1]]
        dp[i][v] = [exclude[0] or include[0], min(exclude[1], weights[i-1] + include[1])]
res = 0
for i in range(total):
    if dp[n][i][0] == 1:
        res = i
print(res)

### FIXED CODE ###

INF = 1000000000000
n, W = map(int, input().split())
values = []
weights = []
total = 10
for _ in range(n):
    w, v = map(int, input().split())
    weights.append(w)
    values.append(v)
    total += v
dp = [[INF for j in range(total)] for i in range(n+1)]
for i in range(n+1):
    dp[i][0] = 0
for i in range(1,n+1):
    for v in range(1,total):
        if v < values[i-1]:
            dp[i][v] = dp[i-1][v]
        else:
            dp[i][v] = min(dp[i-1][v],dp[i-1][v-values[i-1]]+weights[i-1]) 
res = 0
for i in range(total):
    if dp[n][i] <= W:
        res = i
print(res)