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

N = int(input())
x = input()

def onecount(mojix):
    ones=0
    for j in mojix:
        if j=="1":
            ones+=1
    return ones


def popcount(new2bit,ones,count):
    #print("popcount start",count,new2bit,int(new2bit,2),ones)
    
    if ones==0:
        return count
    
    else:
        ten=int(new2bit,2)
        div=ten%ones
        
        count+=1
        
        new2bit=bin(div)
        ones=onecount(str(new2bit))
        
        return popcount(new2bit,ones,count)

GroundOnes=onecount(x)

for i in range(N):
    
    if x[i]=="1":
        x_ith="0"
        ones=GroundOnes-1
    else:
        x_ith="1"
        ones=GroundOnes+1
        
    if i==0:
        new2bit=x_ith+x[i+1:]
    elif i<N-1:
        new2bit=x[:i]+x_ith+x[i+1:]
    else:
        new2bit=x[:i]+x_ith

        
    #ones=onecount(new2bit)
    print(popcount(new2bit,ones,0))
        

### FIXED CODE ###

N=int(input())
x=input()
def popcount(X,ones,count): 
    #print(count,bin(X),X,ones)
    if ones==0:
        return count
    else:
      
        X=X%ones
        
        count+=1
 
        ones=str(bin(X)).count("1")
        
        return popcount(X,ones,count)
 

    
GroundOnes=x.count("1")
GroundX=int(x,2)

if GroundOnes>1:
    CaseOne= GroundX%(GroundOnes-1)
else:
    CaseOne=2

CaseZero= GroundX%(GroundOnes+1)

TwoPowerCaseOne=[]
TwoPowerCaseZero=[]

# if GroundOnes>1:
#     for j in range(N):
#       TwoPowerCaseOne.append(pow(2,(N-j-1) , (GroundOnes-1)))
#       TwoPowerCaseZero.append(pow(2**(N-j-1), (GroundOnes+1)))
# else:
#     for j in range(N):
#       TwoPowerCaseZero.append(pow(2**(N-j-1), (GroundOnes+1)))
  
    
for i in range(N):
    
    #CaseOne
    if x[i]=="1":
        ones=GroundOnes-1
        if ones>0:
            X=CaseOne-pow(2,N-i-1,ones)
        else:
            X=0
    #CaseZero
    else:
        ones=GroundOnes+1
        X=CaseZero+pow(2,N-i-1,ones)
            
 
    # print("for loop",i)
    # print("ones",ones)
    # print("new2bit",new2bit)
    #print(" ------ return --- ",popcount(X,ones,0))
    print(popcount(X,ones,0))
### BUGGY CODE ###

def main():
    N = int(input())
    P = list(map(int,input().split()))

    count = 0

    for i in range(N):
        Pj = P[0:i+1]
        min_P = min(Pj)
        if(P[i] == min_P):
            count += 1

    print(count)
'''
    for i in range(N):
        for j in range(i):
            if(P[i] > P[j]):
                flag = False
                break
        if(flag):
            count += 1
        flag = True
    print(count)
    '''

if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys

def main():
    input = sys.stdin.readline

    N = int(input())
    P = list(map(int,input().split()))

    #result = list()

    minimum = P[0]
    count = 1
    for i in range(N):
        if(minimum > P[i]):
            minimum = P[i]
            count += 1
    print(count)
#        Pj = list(P[j] for j in range(i+1))
        #print(Pj)
        #Pj = P[0:i+1]
#        min_P = min(Pj)
#        result.append(min_P)
#        print(min_P)
#        if(P[i] == min_P):
#            count += 1

    '''
    count = 0
    flag = True

    for i in range(N):
        for j in range(i):
            if(P[i] > P[j]):
                flag = False
                break
        if(flag):
            count += 1
        flag = True
    print(count)
    '''

if __name__ == "__main__":
    main()
### BUGGY CODE ###

mod = 10**9+7 #出力の制限
N = 2*10**6+5

def main():
    k = int(input())
    s = input()
    n = len(s)
 
    def cmb1(n, r, mod):
        if ( r<0 or r>n ):
            return 0
        r = min(r, n-r)
        return g1[n] * g2[r] * g2[n-r] % mod
 
    mod = 10**9+7 #出力の制限
    N = 2*10**6+5
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル
 
    for i in range( 2, N + 1 ):
        g1.append( ( g1[-1] * i ) % mod )
        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2.append( (g2[-1] * inverse[-1]) % mod )
 
    def power(a, n, mod):
        bi=str(format(n,"b")) #2進数
        res=1
        for i in range(len(bi)):
            res=(res*res) %mod
            if bi[i]=="1":
                res=(res*a) %mod
        return res
 
    ans = 0
    for i in range(k+1):
        temp = power(25, i, mod)
        temp *= cmb1(i+n-1, n-1, mod)
        temp %= mod
        temp *= power(26, k-i, mod)
        temp %= mod
        ans += temp
    print(ans%mod)
 
if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    k = int(input())
    s = input()
    n = len(s)

    def cmb1(n, r, mod):
        if ( r<0 or r>n ):
            return 0
        r = min(r, n-r)
        return g1[n] * g2[r] * g2[n-r] % mod

    mod = 10**9+7
    N = 2*10**6
    fac = [1]*(N+1)
    finv = [1]*(N+1)
    for i in range(N):
        fac[i+1] = fac[i] * (i+1) % mod
    finv[-1] = pow(fac[-1], mod-2, mod)
    for i in reversed(range(N)):
        finv[i] = finv[i+1] * (i+1) % mod

    def cmb1(n, r, mod):
        if r <0 or r > n:
            return 0
        r = min(r, n-r)
        return fac[n] * finv[r] * finv[n-r] % mod

    def power(a, n, mod):
        bi=str(format(n,"b")) #2進数
        res=1
        for i in range(len(bi)):
            res=(res*res) %mod
            if bi[i]=="1":
                res=(res*a) %mod
        return res

    ans = 0
    for i in range(k+1):
        temp = power(25, i, mod)
        temp *= cmb1(i+n-1, n-1, mod)
        temp %= mod
        temp *= power(26, k-i, mod)
        temp %= mod
        ans += temp
    print(ans%mod)

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

def abc142_c():    
    n = int(input())
    a = list(map(int,input().split()))
    i = 0
    dict = {}

    for num in a:
        i += 1
        dict[i] = num

    sorted_arrive_list = sorted(dict.items(), key=lambda x :x[1])
    ans = ''
    for l in sorted_arrive_list:
        ans = ans + str(l[0]) + ' '
    print(ans)

if __name__ ==  '__main__':
    abc142_c()

### FIXED CODE ###

def abc142_c2():    
    n = int(input())
    a = list(map(int, input().split()))
    # ansを格納する空のリストを準備
    ans = [0] * n

    # enumerate()でインデックスと取り出してansに格納
    for val, num in enumerate(a, 1):
        ans[num - 1] = val
    # リストの前に*をつけるとアンパックされる
    print(*ans)
if __name__ ==  '__main__':
    abc142_c2()
### BUGGY CODE ###

n,m,q=map(int,input().split())
x=[[0]*(n+1) for i in range(n+1)]
c=[[0]*(n+1) for i in range(n+1)]
for i in range(m):
  l,r=map(int,input().split())
  x[l][r]+=1
for i in range(1,n+1):
  for j in range(1,n+1):
    c[i][j]=c[i][j-1]+x[i][j]
for i in range(q):
  p,q=map(int,input().split())
  s=0
  for j in range(p,q+1):
    s+=c[j][q]-c[j][p-1]
  print(s)

### FIXED CODE ###

n,m,q=map(int,input().split())
x=[[0]*(n+1) for i in range(n+1)]
c=[[0]*(n+1) for i in range(n+1)]
for i in range(m):
  l,r=map(int,input().split())
  x[l][r]+=1
for i in range(1,n+1):
  for j in range(1,n+1):
    c[i][j]=c[i][j-1]+x[i][j]
for i in range(q):
  p,q=map(int,input().split())
  s=0
  for j in range(p,q+1):
    s+=c[j][q]-c[j][p-1]
  print(s)
### BUGGY CODE ###

n = int(input())
l = sorted(list(map(int, input().split())))

cnt = 0

for i in range(n):
    a = l[i]
    for j in range(i+1, n):
        b = l[j]
        for k in range(j+1, n):
            c = l[k]
            if a + b > c:
                cnt += 1
            else:
                break

print(cnt)

### FIXED CODE ###

from bisect import *

n = int(input())
l = sorted(list(map(int, input().split())))

cnt = 0

for i in range(n):
    a = l[i]
    for j in range(i+1, n):
        b = l[j]
        lower = max(j+1, bisect_right(l, b-a))
        upper = bisect_left(l, a+b)
        cnt += max(0, upper-lower)

print(cnt)
### BUGGY CODE ###

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

for i in range(1,N+1):
    print(A.count(i))


### FIXED CODE ###

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

ans = [0] * N

for i in range(N-1):
    ans[A[i] -1] += 1

for i in range(N):
    print(ans[i])
### BUGGY CODE ###

N = int(input())
S = input()
b = N
for i in range(0, N):
    c = S[0: i].count("#")
    d = S[i+1: N].count(".")
    if c + d < b:
        b = c + d
print(b)

### FIXED CODE ###

N = int(input())
S = input()
b = S.count(".")
c = 0
d = N
for i in range(0, N):
    if S[i] == ".":
        b -= 1
        d = min(b+c, d)
    if S[i] == "#":
        c += 1
        d = min(b + c -1, d)
print(d)
### BUGGY CODE ###

import copy

n = int(input())

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

soredx = sorted(x)

for i in range(n):
    temp = copy.deepcopy(soredx)
    temp.remove(x[i])
    print(temp[int(n/2-1)])


### FIXED CODE ###

n = int(input())

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

soredx = sorted(x)

migi = soredx[int(n/2-1)]
hidari = soredx[int(n/2)]

for i in range(n):
    if(migi<x[i]):
        print(migi)
    else:
        print(hidari)
### BUGGY CODE ###

X = int(input())
def modpow(a, n, mod):
    ret = 1
    while n > 0:
        if n % 2 == 1:
            ret = ret * a % mod
        a *= a
        a = a % mod
    return ret
i = 0
L = list()
while True:
    num = modpow(i,5,X)
    if num in L:
        j = L.index(num)
        ret = '{} {}'.format(i,j)
        print(ret)
        break
    else:
        L.append(num)
        i += 1

### FIXED CODE ###

X = int(input())
L = list()
i = 0
while True:
    if i ** 5 > 10 ** 11:
        break
    L.append(i ** 5)
    i += 1
flag = False
ret = ''
for i in range(len(L)):
    if flag:
        break
    for j in range(i+1, len(L)):
        if L[j] - L[i] == X :
            ret ='{} {}'.format(j,i)
            flag = True
            break
        if L[j] + L[i] == X :
            ret ='{} {}'.format(j,-i)
            flag = True
            break
print(ret)
### BUGGY CODE ###

def calc(x,y):
    n = len(x)
    m = len(y)
    d = [[0 for _ in range(m+1)] for _ in range(n+1)]
    for i in range(n):
        s = x[i]
        for j in range(m):
            if s == y[j]:
                d[i+1][j+1] = d[i][j]+1
            else:
                d[i+1][j+1] = max(d[i+1][j],d[i][j+1])
    return d[n][m]

q = int(input())
for i in range(q):
    x = input()
    y = input()
    print(calc(x,y))


### FIXED CODE ###

def calc(x,y):
    n = len(x)
    m = len(y)
    dp1 = [0]*(m+1)
    for i in range(n):
        s = x[i]
        dp2 = dp1[:]
        for j in range(m):
            if s == y[j]:
                dp1[j+1] = dp2[j]+1
            elif dp1[j+1] < dp1[j]:
                dp1[j+1] = dp1[j]
    return dp1[-1]

q = int(input())
for i in range(q):
    x = input()
    y = input()
    print(calc(x,y))
### BUGGY CODE ###

N,M=map(int,input().split())
A=list(map(int,input().split()))
for i in range(M):
    A[A.index(max(A))]=A[A.index(max(A))]//2
print(sum(A))

### FIXED CODE ###

import heapq 

N,M=map(int,input().split())
A=[-a for a in list(map(int,input().split()))]
heapq.heapify(A)
for _ in [0]*M:
    a=heapq.heappop(A)
    heapq.heappush(A,-((-a)//2))
    
res=0
for i in range(N):
    a=heapq.heappop(A)
    res+=-a
print(res)
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
A.sort()
num_tmp = [0]*(max(A)+1)

for a in A:
    num_tmp[a] += 1
    if num_tmp[a] == 1:
        for i in range(2*a,max(A)+1,a):
            num_tmp[i] = 2

ans = 0
for a in A:
    if num_tmp[a] == 1:
        ans += 1
        
print(ans)

### FIXED CODE ###

def main():
    N = int(input())
    A = list(map(int,input().split()))
    A.sort()
    MAX = A[-1]+1
    num_tmp = [0]*MAX

    for a in A:
        num_tmp[a] += 1
        if num_tmp[a] == 1:
            for i in range(2*a,MAX,a):
                num_tmp[i] = 2

    print(num_tmp.count(1))
    
main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline
read = sys.stdin.read

import numpy as np
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix

def main():
  n, m, s, t = map(int, input().split())
  U, V, A, B = np.array(read().split(), dtype=np.int64).reshape(m, 4).T
  csr_yen = csr_matrix((A, (U, V)), shape=(n+1, n+1))
  csr_snuuk = csr_matrix((B, (U, V)), shape=(n+1, n+1))
  G_yen = dijkstra(csr_yen, directed=False, indices=s)
  G_snuuk = dijkstra(csr_snuuk, directed=False, indices=t)
  G = G_yen + G_snuuk
  L = []
  L_append = L.append
  U = 10**15
  now = U
  for i in range(n, 0, -1):
    now = min(now, int(G[i]))
    L_append(U-now)
  print(*L[::-1], sep="\n")
  
if __name__ == "__main__":
  main()

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline
import heapq

def dijkstra(n, start, edge):
    dist = [float("inf")]*n
    dist[start] = 0
    que = [(0, start)]
    while que:
        d, v = heapq.heappop(que)
        if dist[v] < d:
            continue
        for nv, nd in edge[v]:
            if dist[nv] > d + nd:
                dist[nv] = d + nd
                heapq.heappush(que, (dist[nv], nv))
    return dist
    
n, m, s, t = map(int, input().split())
G_yen = [[] for _ in range(n+1)]
G_snuuk = [[] for _ in range(n+1)]
for _ in range(m):
    u, v, a, b = map(int, input().split())
    G_yen[u].append((v, a))
    G_yen[v].append((u, a))
    G_snuuk[u].append((v, b))
    G_snuuk[v].append((u, b))
dijk_yen = dijkstra(n+1, s, G_yen)
dijk_snuuk = dijkstra(n+1, t, G_snuuk)
L = []
U = 10**15
now = U
for i in range(n, 0, -1):
    now = min(now, dijk_yen[i]+dijk_snuuk[i])
    L.append(U-now)
print(*L[::-1], sep="\n")
### BUGGY CODE ###

# coding: utf-8
# Your code here!
k = int(input())

count = 0
ans = []
minN = 10**15

for i in reversed(range(10)):
    for j in reversed(range(1,10**5)):
        num = str(j)+"9"*i
        n = sum([int(k) for k in num])
        n = int(num)/n
        if(minN > n or n==1):
            minN = n
            ans.append(num)

print(len(ans[0]))
for i in list(reversed(ans))[:k]:
    print(i)

### FIXED CODE ###

# coding: utf-8
# Your code here!
k = int(input())
count = 0
ans = []
minN = 10**15

for i in reversed(range(13)):
    minN = 10**15
    for j in reversed(range(1,10**3)):
        num = str(j)+"9"*i
        n = sum([int(k) for k in num])
        n = int(num)/n
        if(minN > n or n==1):
            minN = n
            ans.append(int(num))

for i in list(sorted(list(set(ans))))[:k]:
    print(i)
### BUGGY CODE ###

N=int(input())
s=list(input())

ans=10**6
for i in range(1,N):
  ans=min(ans,s[:i-1].count("W")+s[i+1:].count("E"))
print(ans)

### FIXED CODE ###

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

#毎ステップ毎にカウントする処理→TLE
# ans=10**6
# for i in range(1,N):
#   ans=min(ans,s[:i-1].count("W")+s[i+1:].count("E"))
# print(ans)
ans=[]
ans.append(s[1:].count("E"))
tmp=ans[0]
for i in range(1,n):
  if s[i]=="E":
    tmp-=1
  if s[i-1]=="W":
    tmp+=1
  ans.append(tmp)
print(min(ans))
### BUGGY CODE ###

import numpy as np
import sys

N = int(input())
As = [list(map(int,input().split())) for i in range(N)]
As = np.array(As)-1
current_waitings = As[:,0]
game_counter = np.zeros(N).astype('int')

day = 0
completed_players = []
res = N*(N-1)//2
while res:
    day_player = []
    no_game = True
    for i,e1 in enumerate(current_waitings):
        if i in completed_players or e1 in day_player or i in day_player:
            continue
        if current_waitings[e1] == i:
            no_game = False
            res -= 1
            day_player.append(i)
            day_player.append(e1)
            if game_counter[i] == N-2:
                completed_players.append(i)
            if game_counter[i] <= N-3:
                game_counter[i] += 1
            if game_counter[e1] == N-2:
                completed_players.append(e1)
            if game_counter[e1] <= N-3:
                game_counter[e1] += 1
            current_waitings[i] = As[i][game_counter[i]]
            current_waitings[e1] = As[e1][game_counter[e1]]
    if no_game:
        print(-1)
        sys.exit()
    day += 1
print(day)


### FIXED CODE ###

from collections import deque
def solve():
    n = int(input())
    a = []
    for i in range(n):
        ai = [int(j)-1 for j in input().split()]
        a.append(deque(ai))
    d = set()
    q = deque()
    for i in range(n):
        ai = a[i].popleft()
        if i < ai:
            q.append((i, ai))
        else:
            q.append((ai, i))
    ans = 0
    while q:
        ans += 1
        nxt_q = deque()
        while q:
            i, ai = q.pop()
            if (i, ai) in d:
                if a[i]:
                    ni = a[i].popleft()
                    if i < ni:
                        nxt_q.append((i, ni))
                    else:
                        nxt_q.append((ni, i))
                if a[ai]:
                    ni = a[ai].popleft()
                    if ai < ni:
                        nxt_q.append((ai, ni))
                    else:
                        nxt_q.append((ni, ai))
            else:
                d.add((i, ai))
        q = nxt_q
    if any(i for i in a):
        ans = -1
    print(ans)

solve()
### BUGGY CODE ###

N, M = map(int, input().split())
a = M//N
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

ma = 0
for i in range(a, 0, -1):
    if M % i == 0:
        ma = max(ma, i)
    
print(ma)


### FIXED CODE ###

N, M = map(int, input().split(" "))
flg = 0
for i in range(N, M+1):
    if M % i == 0:
        print (M//i)
        flg = 1
        break
    if i**2 > M:
        break

if flg == 0:
    for i in range(M//N, 0, -1):
        if M % i == 0:
            print (i)
            break
### BUGGY CODE ###

a,b,x=map(int,input().split())
while a%x!=0:
	a+=1
while b%x!=0:
	b-=1
print((b-a)//x +1)


### FIXED CODE ###

a,b,x=map(int,input().split())
a+=(-a)%x
b-=a%x
print((b-a)//x +1)
### BUGGY CODE ###

s=list(input()+"a")
n=len(s)-1
list=[]
for i in range(n):
    if s[i]=="A":
        for j in range(i+1,n+1):
            if s[j]=="Z" and s[j+1]!="Z":
                list.append(j-i+1)
print(max(list))

### FIXED CODE ###

s=list(input())
n=len(s)
list=[]
for i in range(n):
    if s[i]=="A":
        list.append(i+1)
        break
for i in range(n):
    if s[n-1-i]=="Z":
        list.append(n-i)
        break
print(list[1]-list[0]+1)
### BUGGY CODE ###

import itertools,sys
for a in sys.stdin:
  c=0
  n,s=map(int,a.split())
  for e in itertools.permutations(range(10),n):
    x=0
    for i in range(n):
      x+=sum(e[i:])
      if x>s:break
    else:
      if x==s: c+=1
  print c

### FIXED CODE ###

import sys
K=1024
N=331
R=range(K)
B=[1,2,4,8,16,32,64,128,256,512]
C=[0]*K
D=[[0 for i in range(N)]for j in R]

for i in R:
  s=format(i,'b')
  n=s.count('1')
  C[i]=n
  if n==1:D[i][B.index(i)]=1
  else:
    for j in range(len(s)):
      if s[-j-1]=='1':
        dp=n*j
        i2=i-B[j]
        for k in range(N-dp):
          D[i][k+dp]+=D[i2][k]
   
for a in sys.stdin:
  n,s=map(int,a.split())
  x=0
  if s<N:x=sum([D[i][s] for i in R if C[i]==n])
  print x
### BUGGY CODE ###

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

for i in range(n):
    print(ai.count(i+1))

### FIXED CODE ###

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

ans = [0]*n
for i in range(len(ai)):
    ans[ai[i]-1] += 1
for i in range(len(ans)):
    print(ans[i])
### BUGGY CODE ###

n,k = map(int,input().split())
h = list(map(int,input().split()))
d = [0] + [10**10] * (n-1)
for i in range(1,n):
    s = max(0,i-k)
    for j in range(s,i):
        d[i]=min(d[i],d[j] + abs(h[i]-h[j]))
print(d[-1])

### FIXED CODE ###

n , k = map(int,input().split())
h = list(map(int,input().split()))
import numpy as np
h = np.array(h)
dp =np.zeros(n,dtype = int)
for i in range(1,n):
    s = max(0,i-k)
    dp[i] = np.min(dp[s:i] + np.abs(h[s:i] - h[i]))
print(dp[-1])
### BUGGY CODE ###

import sys
input = sys.stdin.readline
N, M = list(map(int, input().split()))
D = list(map(int, input().split()))
UB = [list(map(int, input().split())) for _ in range(M)]

R = {}
for i in range(M):
  a, b = UB[i]
  a -= 1
  b -= 1
  if a not in R: R[a] = [[b, i]]
  else: R[a].append([b, i])
  if b not in R: R[b] = [[a, i]]
  else: R[b].append([a, i])

DD = [[0] * 2 for _ in range(N)]
for i in range(N):
  DD[i][0] = D[i]
  DD[i][1] = i
DD.sort()
L = [0] * N
H = [0] * M
LL = [[-1] * 2 for _ in range(N)]
for i in range(N):
  h, x = DD[i]
  if L[x] == 0:
    if LL[x][0] == -1:
      for n, m in R[x]:
        LL[n] = [x, m]
        if D[n] == D[x] or L[n] != 0:
          H[m] = h
          if L[n] == 1:
            L[n] = 1
            L[x] = 2
          else:
            L[n] = 2
            L[x] = 1
          break
      else:
        print(-1)
        exit()
    else:
      n, m = LL[x]
      H[m] = h
      if L[n] == 1:
        L[n] = 1
        L[x] = 2
      else:
        L[n] = 2
        L[x] = 1

t = ""
for i in range(N):
  if L[i] == 1:
    t += "B"
  else:
    t += "W"
print(t)
for i in range(M):
  if H[i] == 0:
    print(10 ** 9)
  else:
    print(H[i])


### FIXED CODE ###

import sys
input = sys.stdin.readline
N, M = list(map(int, input().split()))
D = list(map(int, input().split()))
UB = [list(map(int, input().split())) for _ in range(M)]

LL = [[-1] * 2 for _ in range(N)]
for i in range(M):
  a, b = UB[i]
  a -= 1
  b -= 1
  if D[a] < D[b]:
    LL[b] = [a, i]
  elif D[a] > D[b]:
    LL[a] = [b, i]
  else:
    LL[a] = [b, i]
    LL[b] = [a, i]

DD = [[0] * 2 for _ in range(N)]
for i in range(N):
  DD[i][0] = D[i]
  DD[i][1] = i
DD.sort()
L = [0] * N
H = [0] * M

for i in range(N):
  h, x = DD[i]
  if L[x] == 0:
    if LL[x][0] == -1:
      print(-1)
      exit()
    else:
      n, m = LL[x]
      H[m] = h
      if L[n] == 1:
        L[n] = 1
        L[x] = 2
      else:
        L[n] = 2
        L[x] = 1

for i in range(N):
  if L[i] == 1:
    L[i] = "B"
  else:
    L[i] = "W"
print("".join(list(map(str, L))))
for i in range(M):
  if H[i] == 0:
    print(10 ** 9)
  else:
    print(H[i])
### BUGGY CODE ###

N, K = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]

E_p = []
for i in p:
    E_p.append((i + 1) / 2)

ans = 0
for i in range(N - K + 1):
    ans = max(ans, sum(E_p[i:i+K]))

print(ans)

### FIXED CODE ###

N, K = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]

E_acc = [0]
for i in range(N):
    E_acc.append((p[i] + 1) / 2 + E_acc[i])

ans = 0
for i in range(N - K + 1):
    ans = max(ans, E_acc[i + K] - E_acc[i])

print(ans)
### BUGGY CODE ###

from sys import stdin
from sys import setrecursionlimit
import numpy as np

setrecursionlimit(10 ** 7)

n,k = map(int,stdin.readline().rstrip().split())
a = list(map(int,stdin.readline().rstrip().split()))
a = np.array(a,dtype=np.int64)
lamp= np.zeros(n,dtype=np.int64)

for i,j in enumerate(a):
    lamp[max(0,i-j):min(n+1,i+j+1)] += 1

if k == 1:
    print(*lamp)
    exit()

for _ in range(min(k-1,20)):
    b = np.zeros(n,dtype=np.int64)
    for i,j in enumerate(lamp):
        b[max(0,i-j):min(n+1,i+j+1)] += 1
    lamp = b.copy()

lamp[lamp>n] = n

print(*lamp)

### FIXED CODE ###

from itertools import accumulate
from copy import deepcopy

n,k = map(int,input().split())
a = list(map(int,input().split()))
b = [0]*(n+1)

if k > 41:
    k = 41

for _ in range(k):
    b = [0]*(n+1)
    for i,j in enumerate(a):
        b[max(0,i-j)] += 1
        b[min(n,i+j+1)] -= 1
    a = list(accumulate(b))
    for i in range(n+1):
        if a[i] >= n:
            a[i] = n

print(*a[:-1])