Harryxun/stf_run huggingface dataset:
ans = 0

def calc_final_data(suhsi_data, eat_data, sushi_num):
    global ans
    ans_kari = 0
    neta_hist = set()
    for i in range(sushi_num):
        if eat_data[i]:
            neta_hist.add(str(suhsi_data[i][0]))
            ans_kari += suhsi_data[i][1]
    ans_kari += len(neta_hist) * len(neta_hist)
    if ans_kari > ans:
        ans = ans_kari

def eat_sushi(suhsi_data, max_eat, eat_data_kari, index, eat_flg, sushi_num):
    eat_data = eat_data_kari.copy()
    if index == sushi_num or eat_data.count(1) == max_eat:
        calc_final_data(suhsi_data, eat_data, sushi_num)
        return
    if eat_flg:
        eat_data[index] = 1
    eat_sushi(suhsi_data, max_eat, eat_data, index+1, 0, sushi_num)
    eat_sushi(suhsi_data, max_eat, eat_data, index+1, 1, sushi_num)


def calc_eat(suhsi_data, max_eat, eat_data, sushi_num):
    eat_sushi(suhsi_data, max_eat, eat_data, 0, 0, sushi_num)
    eat_sushi(suhsi_data, max_eat, eat_data, 0, 1, sushi_num)

def print_ans():
    global ans
    print(ans)

def main():
    sushi_num, max_eat = list(map(int, input().split()))
    suhsi_data = [list(map(int, input().split())) for i in range(sushi_num)]
    eat_data = [0 for i in range(sushi_num)]
    calc_eat(suhsi_data, max_eat, eat_data, sushi_num)
    print_ans()

if __name__ == '__main__':
    main()

### FIXED CODE ###


import heapq


def main():
    num_sushi, chose_num = map(int, input().split())
    data = [list(map(int, input().split())) for i in range(num_sushi)]

    data.sort(key=lambda x: -x[1])
    delicious_heap = []
    count_d, count_n = 0, 0
    neta_data = [0 for i in range(num_sushi + 1)]

    for i in range(chose_num):
        neta, oishisa = data[i]

        if neta_data[neta]:
            heapq.heappush(delicious_heap, oishisa)
        else:
            neta_data[neta] = 1
            count_n += 1

        count_d += oishisa

    ans = count_d + count_n ** 2

    for i in range(chose_num, num_sushi):
        if len(delicious_heap) == 0:
            break
        neta, oishisa = data[i]

        if neta_data[neta]:
            continue
        neta_data[neta] = 1
        count_n += 1
        pop_oishisa = heapq.heappop(delicious_heap)
        count_d += oishisa - pop_oishisa

        ans = max(ans, count_d + count_n ** 2)

    print(ans)


if __name__ == '__main__':
    main()
import numpy as np
from itertools import product

H,W,K = map(int, input().split())
S = np.array(([list(map(int,list(input()))) for _ in range(H)])).T

if sum(sum(s) for s in S)<=K:
    print(0)
else:
    answer = (H-1) * (W-1)
    for X in product([False,True], repeat=H-1):
        ans = np.sum(X)
        if ans >= answer:
            continue
        M = [[0]]
        for i, x in enumerate(X):
            if x:
                M.append([])
            M[-1].append(i+1)
        D = np.array([0]*len(M))
        for s in S:
            D[:] += [sum(s[i] for i in m) for m in M]
            if any(d > K  for d in D):
                ans += 1
                if ans >= answer:
                    break
                D[:] = [sum(s[i] for i in m) for m in M]
                if any(d > K for d in D):
                    ans = answer + 1
                    break

        answer = min(answer,ans)

    print(answer)

### FIXED CODE ###


def main():
    from itertools import product
    import numpy as np

    H,W,K = map(int, input().split())
    S = (np.array([list(map(int,list(input()))) for _ in range(H)]).T).tolist()

    if sum(sum(s) for s in S)<=K:
        print(0)
    else:
        answer = (H-1) * (W-1)
        for X in product([False,True], repeat=H-1):
            ans = np.sum(X)
            if ans >= answer:
                continue
            M = [[0]]
            for i, x in enumerate(X):
                if x:
                    M.append([])
                M[-1].append(i+1)
            D = [0]*len(M)
            for s in S:
                for k, m in enumerate(M):
                    D[k] += sum(s[i] for i in m)
                if any(d > K  for d in D):
                    ans += 1
                    if ans >= answer:
                        break
                    for k, m in enumerate(M):
                        D[k] = sum(s[i] for i in m)
                    
                    if any(d > K for d in D):
                        ans = answer + 1
                        break

            answer = min(answer,ans)

        print(answer)

main()
n=int(input())
a=[int(input()) for i in range(n)]
cost=abs(a[n-1])
a.append(0)
a.insert(0,0)
for i in range(n):
    tmp=abs(a[i]-a[i+1])
    cost+=tmp


### FIXED CODE ###

A,B,C,D=[int(input()) for i in range(4)]
print(min(A,B)+min(C,D))
import math

def C(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

for i in range(1, K+1):
    A = C(N - K + 1, i) * C(K - 1, i - 1) % 1000000007
    print(A)


### FIXED CODE ###

import math

def C(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

for i in range(1, K+1):
    if N - K + 1 < i:
        A = 0
    else:
        A = C(N - K + 1, i) * C(K - 1, i - 1) % 1000000007
    print(A)
import math
from bisect import bisect_left

n, d, a = map(int, input().split())
x_list = []
max_x = 0
for _ in range(n):
    x, h = map(int, input().split())
    x -= 1
    x_list.append([x, h])
    max_x = max(max_x, x)
x_list.sort()
xx = [x[0] for x in x_list]
ans = 0
for index_left, [x, h] in enumerate(c):
    if h > 0:
        ans += math.ceil(h / a)
        index_right = bisect_left(xx, x + (d * 2))
        for i in range(index_left, min(index_right + 1, n)):
            x_list[i][1] -= math.ceil(h / a) * a
print(ans)

### FIXED CODE ###

import math
from bisect import bisect_right

n, d, a = map(int, input().split())
x_list = []
max_x = 0
for _ in range(n):
    x, h = map(int, input().split())
    x -= 1
    x_list.append([x, h])
    max_x = max(max_x, x)
x_list.sort()
xx = [x[0] for x in x_list]
hh = [x[1] for x in x_list]
ans = 0
accum = [0 for _ in range(n)]
for index, [x, h] in enumerate(x_list):
    if index != 0:
        accum[index] += accum[index - 1]
    cnt = max(math.ceil((hh[index] - accum[index]) / a),  0)
    ans += cnt
    index_right = bisect_right(xx, xx[index] + (2 * d))
    accum[index] += cnt * a
    if index_right < n:
        accum[index_right] -= cnt * a
print(ans)
import math

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

ans=0

for xi in x:
    ans=math.gcd(ans,xi-X)

print(ans)

### FIXED CODE ###

def GCD(x,y):
    x,y=max(abs(x),abs(y)),min(abs(x),abs(y))
    if y==0:
        return x
    elif x%y==0:
        return y
    else:
        return GCD(y,x%y)

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

ans=0

for xi in x:
    ans=GCD(ans,xi-X)

print(ans)
my_result = 0
while N >= 1000:
    N = N - 1000
else:
    my_result += N
return my_result

### FIXED CODE ###

N = int(input())
while N > 1000:
  N = N - 1000
N = 1000 - N
print(N)
import math

def lcm(l):
    if len(l) == 1:
        return l[0]

    t = l[0]
    for i in range(1, len(l)):
        t = (t * l[i]) // math.gcd(t, l[i])
    return t

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

# process
a = lcm(A)
p = int(M/a-0.5)

# output
if p == 0: print(0)
else: print(p+1)


### FIXED CODE ###

from functools import reduce
from fractions import gcd

def lcm(l):
    if len(l) == 1:
        return l[0]

    t = l[0]
    for i in range(1, len(l)):
        t = (t * l[i]) // gcd(t, l[i])
    return t

# input
N, M = map(int, input().split())
A = list(map(lambda x: x//2, map(int, set(input().split()))))

# process
ans = 0
lc = lcm(A)

if lc <= M:
    f = True
    for a in A:
        if lc//a%2 == 0:
            f = False
            break

    if f:
        ans = int(M/lc-1)//2+1

# output
print(ans)
N = int(input())
str(N)
listN = sorted(N)
if listN.count("7") >= 1:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

N = int(input())
listN = sorted(str(N))
if listN.count("7") >= 1:
    print("Yes")
else:
    print("No")
a = [int(i) for i in input().split()]

if (sum(a) >= 22):
	print('bust' )
else:
  printa('win')


### FIXED CODE ###

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

if (sum(a) >= 22):
	print('bust' )
else:
	print('win')
cat, doccat, cat_much = input().split(" ")

If cat > cat_much:
    answer = "No"
elif cat == cat_much:
    answer = "no"
else cat < cat_much:
    elif cat + doccat >= cat_much:
        answer = "yes"
    else cat + doccat < cat_much

print(answer)

### FIXED CODE ###

cat, doccat, cat_much = input().split(" ")

if int(cat) > int(cat_much):
    answer = "NO"
elif int(cat) == int(cat_much):
    answer = "YES"
else:
    if int(cat) + int(doccat) >= int(cat_much):
        answer = "YES"
    else:
        answer = "NO"

print(answer)
N=int(input())
s=input()
tmp=[s[:i].count("#")+s[i:N].count(".") for i in range(N+1)]
print(min(tmp)+1)


### FIXED CODE ###

a,b,c=map(int, input().split())
if a>b:
    goal=a
    start=b
else:
    goal=b
    start=a
    
ans="No"
if c>start and c<goal:
    ans="Yes"
print(ans)
import collections
n = int(input())
a = list(map(int, input().split()))
q = int(input())
dic = collections.Counter(a)
sum_list = [x * y for (x, y) in dic.items()]
sum = sum(sum_list)
for i in range(q):
    if b in dic:
        b, c = map(int, input().split())
        print(sum - (b - c) * dic[b])


### FIXED CODE ###

import collections
n = int(input())
a = list(map(int, input().split()))
q = int(input())
dic = collections.Counter(a)
sum_list = [x * y for (x, y) in dic.items()]
sum = sum(sum_list)
for i in range(q):
    b, c = map(int, input().split())
    if b in dic and c not in dic:
        sum -= (b - c) * dic[b]
        print(sum)
        dic[c] = dic[b]
        del dic[b]
    elif b in dic and c in dic:
        sum -= (b - c) * dic[b]
        print(sum)
        dic[c] += dic[b]
        del dic[b]
    else:
        print(sum)
def solve(arr, target):
	return solve_rec(0, arr, target)

def solve_rec(i, arr, target):	
	if target == 0:
		return True
	if i >= len(arr):
		return False
	res1 = solve_rec(i + 1, arr, target)
	res2 = solve_rec(i + 1, arr, target - arr[i])
	if res1 == True or res2 == True:
		return True
	return False


n = int(input())
arr = list(map(int, input().split()))
q = int(input())
targets = list(map(int, input().split()))

for i in range(q):
	res = solve(arr, targets[i])
	if res == True:
		print('yes')
	else:
		print('no')



### FIXED CODE ###

def subset_sum(n, s, a):
	dp = [[0 for x in range(s+1)] for x in range(n+1)]
	dp[0][0]=1
	for i in range(n):
		v = a[i]
		for j in range(s+1):
			if v > j:
				dp[i+1][j] = dp[i][j]
			else:
				dp[i+1][j] = dp[i][j]+dp[i][j-v]
	return dp[n][s] > 0

n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
for i in range(q):
	if subset_sum(n, m[i], a) == True:
		print('yes')
	else:
		print('no')
#15rectangle
H,W=(int(i) for i in input().split())
while H!=0 or W!=0:
    for i in range(H-1):
        S=""
    for j in range(W):
            S+="#"
        print(S)
for j in range(W):
            S+="#"
        print(S, end=??????)
    H,W=(int(i) for i in input().split())
    if H!=0 or W!=0:
    print("\n")

### FIXED CODE ###

#15rectangle
H,W=(int(i) for i in input().split())
while H!=0 or W!=0:
    for i in range(H-1):
        S=""
        for j in range(W):
            S+="#"
        print(S)
    S=""
    for j in range(W):
        S+="#"
    print(S, end="")
    H,W=(int(i) for i in input().split())
  #  if H!=0 or W!=0:
    print("\n")
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
point = 0

for i in range(N):
  point += B[A[i]]
  if i>0 and A[i] == A[i-1]:
    point += C[A[i-1]]
print(point)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
point = 0

for i in range(N):
    point += B[A[i]-1]
    if i>0 and A[i]-1 == A[i-1]:
        point += C[A[i-1]-1]
print(point)
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    A, B, K = input_number_list()
    t = 0
    i = max(A,B)
    while t < K:
        i -= 1
        t += 1 if A % i == 0 and B % i == 0 else 0
    print(i)


main()

### FIXED CODE ###

def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    A, B, K = input_number_list()
    t = 0
    i = max(A,B)+1
    while t < K:
        i -= 1
        t += 1 if A % i == 0 and B % i == 0 else 0
    print(i)


main()
import sys
a = 1

While 1:
        x = sys.stdin.readline().strip()
        if x == "0":
                  break;
        print("Case {0}: {1}".format(a,x))
        a += 1
        

### FIXED CODE ###

import sys
a = 1

for i in sys.stdin:
        x = i.strip()
        if x == "0":
                break;
        print("Case {0}: {1}".format(a,x))
        a += 1
A,B,C = map(int,input().split())

if A != B and B != C and A != C:
    print("No")
elif A = B and B = C:
    print("No")
else:
    print("Yes")

### FIXED CODE ###

A,B,C = map(int,input().split())

if A != B and B != C and A != C:
    print("No")
elif A == B and B == C:
    print("No")
else:
    print("Yes")
a, b = map(int, input().split())

for i in range(1001):
    if int(i*0.08) == a and int(i*0.1) == b:
        num = i
        break

    elif a/0.08 < b/0.1:
        num = -1
        break

print(num)

### FIXED CODE ###

a, b = map(int, input().split())
num = -1

if a <= b:
    for i in range(1000000):
        if int(i*0.08) == a and int(i*0.1) == b:
            num = i
            break

        elif int(i*0.08) > a or int(i*0.1) > b:
            break

print(num)
#!/usr/bin/env python3
import sys


def solve(N: int, s: "List[str]"):
    x = 0
    a = 0
    b = 0
    for i in s:
        if(i[0] == 'B' and i[-1] == 'A'):
            x += 1
        elif(i[-1] == 'A'):
            a += 1
        elif(i[0] == 'B'):
            b += 1

    # ans1 = max(0,x-1) + (min(a,b) if a==b else min(a,b)+1)    
    
    if(x == 0):
        if(a == b):
            ans1 = min(a,b)
    else:
        ans1 = max(0,x-1)+min(a,b)
        if(a != b):
            ans1 += 1

    
    # ans1 = max(0,x-1) 
    # if(a == b):
    #     ans1 += min(a,b)
    # else:
    #     if(x == 0):
    #         ans1 += min(a,b)
    #     else:
    #         ans1 += min(a,b)+1 
    

    ans2 = 0
    for i in s:
        ans2 += i.count('AB')

    print(ans1+ans2)
    
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    s = [ next(tokens) for _ in range(N) ]  # type: "List[str]"
    solve(N, s)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys


def solve(N: int, s: "List[str]"):
    x = 0
    a = 0
    b = 0
    for i in s:
        if(i[0] == 'B' and i[-1] == 'A'):
            x += 1
        elif(i[-1] == 'A'):
            a += 1
        elif(i[0] == 'B'):
            b += 1

    # ans1 = max(0,x-1) + (min(a,b) if a==b else min(a,b)+1)    
    
    if(x == 0):
        ans1 = min(a,b)
    else:
        ans1 = max(0,x-1)+min(a,b)
        if(a > 0 or b > 0):
            ans1 += 1

    
    # ans1 = max(0,x-1) 
    # if(a == b):
    #     ans1 += min(a,b)
    # else:
    #     if(x == 0):
    #         ans1 += min(a,b)
    #     else:
    #         ans1 += min(a,b)+1 
    

    ans2 = 0
    for i in s:
        ans2 += i.count('AB')

    print(ans1+ans2)
    
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    s = [ next(tokens) for _ in range(N) ]  # type: "List[str]"
    solve(N, s)

if __name__ == '__main__':
    main()
A, B, C, D = map(int, input().split())

if A + B > C + D:
    print("Left")
elif A + B = C + D:
    print("Balanced")
else:
    print("Right")

### FIXED CODE ###

A, B, C, D = map(int, input().split())

if A + B > C + D:
    print("Left")
elif A + B == C + D:
    print("Balanced")
else:
    print("Right")
import sys
lines = sys.stdin.readlines()
K, N = map(int, lines[0].strip().split())
As = map(int, lines[1].strip().split())
dists = []
for idx, A in enumerate(As[:-1]):
  dists.append(A - As[idx+1])
dists.append(As[0]+(K-As[-1]))
print(K - max(dists))

### FIXED CODE ###

K, N = list(map(int, input().split()))
As = list(map(int, input().split()))
dists = []
for base, switch in zip(As[:-1], As[1:]):
    dists.append(switch - base)
dists.append(As[0]+(K-As[-1]))
print(K - max(dists))
s = list(input())
t=-1
cnt=0

for i in s[:m]:
    if i != s[t]:
        cnt+=1
    t-=1
    
print(cnt)

### FIXED CODE ###

s = list(input())
m=len(s)//2
t=-1
cnt=0

for i in s[:m]:
    if i != s[t]:
        cnt+=1
    t-=1
    
print(cnt)
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

N = int(sys.stdin.readline())

A = map(lambda x: int(x), sys.stdin.readline().split(' '))

total = 0
A.insert(0, 0)
A.append(0)

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

for i in range(1, N + 1):
	print(str(total - abs(A[i] - A[i + 1]) - abs(A[i] - A[i - 1]) + abs(A[i -1] - A[i + 1])))


### FIXED CODE ###

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

import sys

N = int(sys.stdin.readline())

A = sys.stdin.readline().split(' ')

A = [int(x) for x in A]

A.insert(0, 0)
A.append(0)

total = 0

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

for i in range(1, N + 1):
	print(str(total - abs(A[i] - A[i + 1]) - abs(A[i] - A[i - 1]) + abs(A[i -1] - A[i + 1])))
a, b = map(int, input().split())
if a<b: a,b=b,a
c = a*b
while b:
    a, b = b, a//b
print(c//b)

### FIXED CODE ###

a, b = map(int, input().split())
if a<b: a,b=b,a
c = a*b
while b: a, b = b, a%b
print(c//a)
S = input()
K = int(input())
target = []
def func(split_range):
    for i in range(0,len(S)-split_range+1):
        #print(S[0:0])
        #print(S[0:1])
        #print(S[i:i+split_range])
        #print(S[i:i+split_range])
        target.append(S[i:i+split_range])

for i in range(1,len(S)+1):
    #print(i)
    func(i)
#print(target)
print(sorted(set(target))[K-1]

### FIXED CODE ###

S = input()
K = int(input())
S_len = len(S)
ans = set()
for i in range(0, K+1):
    for j in range(0, S_len):
        if j + i <= S_len:
            t = S[j:j + i]
            if t != '':
                ans.add(t)
ans = list(ans)
ans.sort()
print(ans[K-1])
x = input()

if x in [a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z]:
  print('a')
else:
  print('A')

### FIXED CODE ###

x = input()

if x in ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]:
  print('a')
else:
  print('A')
s = str(input())
t = str(input())

ans = 0

for in range(3):
  if s[i]==t[i]:
    ans += 1
print(ans)

### FIXED CODE ###

s = str(input())
t = str(input())
 
ans = 0
 
for i in range(3):
  if s[i]==t[i]:
    ans += 1
print(ans)
N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()

s = int((N - 1) / 2)
m = A[0:s+1]
M = A[s+1:][::-1]

if N % 2 == 1:
    N -= 1
ans = [0 for _ in range(N)]

li = s
ri = s + 1

for i, (a, b) in enumerate(zip(m, M)):
    if i % 2 == 1:
        a, b = b, a
    ans[li] = a
    ans[ri] = b
    li -= 1
    ri += 1

if N % 2 == 1:
    if ans[0] < ans[-1]:
        ans = [m[-1]] + ans
    else:
        ans = ans + [m[-1]]

print(ans)

S = 0
for i, j in zip(ans[1:], ans[:-1]):
    S += abs(i - j)

print(S)

### FIXED CODE ###

N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()

if N % 2 == 0:
    c = N // 2
    S = -2 * sum(A[:c]) + 2 * sum(A[c:]) + A[c-1] - A[c]
else:
    c = (N-1) // 2
    tmp1 = -2 * sum(A[:c]) + 2 * sum(A[c+2:]) + A[c] + A[c+1]
    tmp2 = -2 * sum(A[:c-1]) + 2 * sum(A[c+1:]) - A[c-1] - A[c]
    S = max(tmp1, tmp2)

print(S)
N,K,*A = map(int, open(0).read().split())  
                                           
def left(i, d):                            
    if i < 0:                              
        return 0                           
    if i >= N:                             
        return 0                           
    v = A[i] - d + 0.5                     
    if v <= 0:                             
        return 0                           
    else:                                  
        return 1 + left(i - 1, d + 1)      
                                           
def right(i, d):                           
    if i < 0:                              
        return 0                           
    if i >= N:                             
        return 0                           
    v = A[i] - d + 0.5                     
    if v <= 0:                             
        return 0                           
    else:                                  
        return 1 + right(i + 1, d + 1)     
                                           
for _ in range(K):                         
    X = [0 for _ in range(N)]              
    for i, d in enumerate(A):              
        l = left(i-1, 1)                   
        r = right(i+1, 1)                  
        c = 1 + l + r                      
        X[i] = c                           
    A = X                                  
                                           
print(A)                                   

### FIXED CODE ###

N,K,*A = map(int, open(0).read().split())
                                         
for _ in range(K):                       
    b = [0] * N                          
    for i, d in enumerate(A):            
        b[max(0, i-d)] += 1              
        if i+d+1 < N:                    
            b[i+d+1] -= 1                
    for i in range(1, N):                
        b[i] += b[i-1]                   
    if A == b:                           
        break                            
    A = b                                
                                         
print(" ".join(map(str, A)))