Harryxun/stf_run huggingface dataset:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


def popcount(x):
    '''xの立っているビット数をカウントする関数
    (xは64bit整数)'''

    # 2bitごとの組に分け、立っているビット数を2bitで表現する
    x = x - ((x >> 1) & 0x5555555555555555)

    # 4bit整数に 上位2bit + 下位2bit を計算した値を入れる
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)

    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f # 8bitごと
    x = x + (x >> 8) # 16bitごと
    x = x + (x >> 16) # 32bitごと
    x = x + (x >> 32) # 64bitごと = 全部の合計
    return x & 0x0000007f


n = I()
x = S()
cnt = sum([int(i) for i in x])
ret1 = 1
ret2 = 1
rem1 = 0
rem2 = 0
for i in range(n - 1, -1, -1):
    if x[i] == "1":
        rem1 = (rem1 + ret1) % (cnt + 1)
        rem2 = (rem2 + ret2) % (cnt - 1)
    ret1 = ret1 * 2 % (cnt + 1)
    ret2 = ret2 * 2 % (cnt - 1)

for j in range(n):
    ans = 1
    if x[j] == "1":
        if cnt == 1:
            print(0)
            continue
        r = (rem2 - pow(2, n - 1 - j, cnt - 1)) % (cnt - 1)
        while r:
            r = r % popcount(r)
            ans += 1
        print(ans)
    else:
        r = (rem1 + pow(2, n - 1 - j, cnt + 1)) % (cnt + 1)
        while r:
            r = r % popcount(r)
            ans += 1
        print(ans)

### FIXED CODE ###

N=int(input())
X=input()
Y=int(X,2)
Z=Y
C=X.count('1')
if C==1:
  for i in range(N):
    if X[i]=='1':
      print(0)
    elif i==N-1:
      print(2)
    else:
      print(1)
  exit()
Y,Z=Y%(C+1),Z%(C-1)
def f(x):
  if x==0:
    return 0
  return 1+f(x%bin(x).count('1'))
 
for i in range(N):
  if X[i]=='1':
    print(1+f((Z-pow(2,N-i-1,C-1))%(C-1)))
  else:
    print(1+f((Y+pow(2,N-i-1,C+1))%(C+1)))
N=int(input())
S,T=str(int, input().split())
ans = ""
for i in range(N):
  ans = ans + S[i] + T[i]
print(ans)

### FIXED CODE ###

N=int(input())
S,T=map(str, input().split())
ans = ""
for i in range(N):
  ans = ans + S[i] + T[i]
print(ans)
n=int(input())
arr=list(map(int,input().split()))
vis[0] = 0
if n < 2:
  print(vis[0])
vis[1] = abs(arr[0]-arr[1])
for i in range(2, n):
    step_1 = abs(arr[i-1]-arr[i-2]) + vis[i-1]
    step_2 = abs(arr[i-1]-arr[i-3]) + vis[i-2]
    vis[i] = min(step_1, step_2)
print(vis[i-1])

### FIXED CODE ###

n=int(input())
arr=list(map(int,input().split()))
if n < 2:
  print(0)
vis = [0] * n
vis[0] = 0
vis[1] = abs(arr[0]-arr[1])
for i in range(2, n):
    step_1 = abs(arr[i]-arr[i-1]) + vis[i-1]
    step_2 = abs(arr[i]-arr[i-2]) + vis[i-2]
    vis[i] = min(step_1, step_2)
print(vis[-1])
S = input()
sl = [*S]

if sl[0]==sl[1] and sl[2]==sl[3] and sl[0]!=sl[2]:
  print("Yes")
elif sl[0]==sl[2] and sl[1]==sl[3] and sl[0]!=sl[1]:
  print("Yes")
elif sl[0]==sl[3] and sl[1]==sl[2] and sl[0]!=sl[1]:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

S = input()
sl = list(S)

if sl[0]==sl[1] and sl[2]==sl[3] and sl[0]!=sl[2]:
  print("Yes")
elif sl[0]==sl[2] and sl[1]==sl[3] and sl[0]!=sl[1]:
  print("Yes")
elif sl[0]==sl[3] and sl[1]==sl[2] and sl[0]!=sl[1]:
  print("Yes")
else:
  print("No")
print(input().split().replace(" ","")


### FIXED CODE ###

T , S = input().split()
print(S +T)
s = input()
k = len(s)

ans = 0

for bit in range(1 << k-1):
    f = s[0]
    
    for i in range(k-1):
        # if bit & (1 << i)で、bitにiが含まれているか（フラグが立っているか）を判定してくれるらしい
        if bit & (1 << i):
            f += '+'
        f += f[i + 1]
    ans += sum(list(map(int, f.split('+'))))

print(ans)

### FIXED CODE ###

s = input()
n = len(s)

ans = 0

for bit in range(1 << (n - 1)):
    # 各場合で式 f を生成する
    f = s[0]

    for i in range(n - 1):
        if bit & (1 << i):
            # フラグが立っているならば "+" を式の末尾に追加する
            f += "+"
        f += s[i + 1]

    ans += sum(map(int, f.split("+")))

print(ans)
n, m = map(int, input().split())
graph = {i: [] for i in range(1, m + 1)}
for _ in range(m):
    u, v = map(int, input().split())
    graph[u].append(v)
    graph[v].append(u)

def dfs(i):
    ret = 0
    if all(han):
        return 1
    for j in range(1, n + 1):
        if han[j] == False and j in graph[i]:
            han[j] = True
            ret += dfs(j)
            han[j] = False
    return ret

han = [False] * (n + 1)
han[0] = True
han[1] = True
ans = dfs(1)
    
print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
graph = {i: [] for i in range(1, n + 1)}
for _ in range(m):
    u, v = map(int, input().split())
    graph[u].append(v)
    graph[v].append(u)

def dfs(i):
    ret = 0
    if all(han):
        return 1
    for j in range(1, n + 1):
        if han[j] == False and j in graph[i]:
            han[j] = True
            ret += dfs(j)
            han[j] = False
    return ret

han = [False] * (n + 1)
han[0] = True
han[1] = True
ans = dfs(1)
    
print(ans)
import re
S = list(input())
ans=0
cou=2
Ccou=0
A=S.count('A')
C=S.count('C')
jud = len(re.findall('[a-z]', S))
rep=len(S)-2
if S[0]=='A':
    ans=+1
rep=len(S)-2
for i in range(1,rep):
    if S[cou]=='C':
        Ccou=Ccou+1
    cou=cou+1
if Ccou == 1:
    ans=ans+1
if ans ==2 and A==1 and C==1 and jud==2:
    print("AC")
else:
    print("WA")

### FIXED CODE ###

import re
S = list(input())
S2=''.join(S)
ans=0
cou=2
Ccou=0
A=S.count('A')
C=S.count('C')
jud = len(re.findall('[A-Z]', S2))
rep=len(S)-2
if S[0]=='A':
    ans=+1
rep=len(S)-2
for i in range(1,rep):
    if S[cou]=='C':
        Ccou=Ccou+1
    cou=cou+1
if Ccou == 1:
    ans=ans+1
if ans ==2 and A==1 and C==1 and jud==2:
    print("AC")
else:
    print("WA")
#%%
W, H = [int(i) for i in input().split()]
maze = [[] for _ in range(H)]

num_black = 0
for i in range(H):
    temp = input()
    for j in temp:
        maze[i].append(j)
        if j == "#":
            num_black += 1

#%%
import copy, collections

maze_copy = copy.deepcopy(maze)
color = [["W"] * W for _ in range(H)]


def BFS(Y, X):
    vec = [[1, 0], [-1, 0], [0, 1], [0, -1]]
    color[Y][X] = "G"
    que = collections.deque()
    maze_copy[Y][X] = 1
    que.append([Y, X])

    while len(que) != 0:
        u = que.popleft()
        for y, x in vec:
            temp_x = u[1] + x
            temp_y = u[0] + y
            if (0 <= temp_x < W and 0 <= temp_y < H
                    and maze_copy[temp_y][temp_x] == "." and color[temp_y][temp_x] == "W"):
                color[temp_y][temp_x] = "G"
                maze_copy[temp_y][temp_x] = maze_copy[u[0]][u[1]] + 1
                que.append([temp_y, temp_x])


BFS(0, 0)
if maze_copy[-1][-1] == ".":
    print(-1)
else:
    print(W * H - num_black - maze_copy[-1][-1])



### FIXED CODE ###

#%%
H, W = [int(i) for i in input().split()]
maze = [[] for _ in range(H)]

num_black = 0
for i in range(H):
    temp = input()
    for j in temp:
        maze[i].append(j)
        if j == "#":
            num_black += 1
            
#%%
import copy, collections

maze_copy = copy.deepcopy(maze)
color = [["W"] * W for _ in range(H)]


X, Y = 0, 0
vec = [[1, 0], [-1, 0], [0, 1], [0, -1]]
color[Y][X] = "G"
que = collections.deque()
maze_copy[Y][X] = 1
que.append([Y, X])

while len(que) != 0:
    u = que.popleft()
    for y, x in vec:
        temp_x = u[1] + x
        temp_y = u[0] + y
        if (0 <= temp_x < W and 0 <= temp_y < H
                and maze_copy[temp_y][temp_x] == "." and color[temp_y][temp_x] == "W"):
            color[temp_y][temp_x] = "G"
            maze_copy[temp_y][temp_x] = maze_copy[u[0]][u[1]] + 1
            que.append([temp_y, temp_x])
    
if maze_copy[-1][-1] == ".":
    print(-1)
else:
    print(W * H - num_black - maze_copy[-1][-1])
r,g,b = map(int,input()).split()

a = r * 100 + g * 10 + b
if a % 4 == 0:
  print("YES")
else:
  print("NO")


### FIXED CODE ###

r,g,b = map(int,input().split())

a = r * 100 + g * 10 + b
if a % 4 == 0:
  print("YES")
else:
  print("NO")
N,M = map(int,input().split())

judge = [False]*N
WAcnt = [0] * N
ACcnt = 0
for i in range(M):
    p,S = (x for x in input().split())
    p = int(p)
    if judge[p-1] == False:
        if S == "AC":
            judge[p-1] = True
            ACcnt += 1
        else:
            WAcnt[p-1] += 1

WAans = 0
for i in range(N):
    if judge[p-1] == True:
        WAans += WAans[p-1]

print(ACcnt,WAans)

### FIXED CODE ###

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

judge = [False]*N
WAcnt = [0] * N
ACcnt = 0
for i in range(M):
    p,S = (x for x in input().split())
    p = int(p)
    if judge[p-1] == False:
        if S == "AC":
            judge[p-1] = True
            ACcnt += 1
        else:
            WAcnt[p-1] += 1

WAans = 0
for i in range(N):
    if judge[i] == True:
        WAans += WAcnt[i]

print(ACcnt,WAans)
a,b,c = map(int,input())
a = set([a,b,c])
print(len(a))


### FIXED CODE ###

a,b,c = map(int,input().split())
a = set([a,b,c])
print(len(a))
S = input()
T = input()

ans = [0 for i in range(len(S)-len(T))]
for i in range(len(S)-len(T)):
    cnt = len(T)
    for j in range(len(T)):
        if S[i+j] == T[j]:
            cnt -= 1
    ans[i] = cnt
print(min(ans))


### FIXED CODE ###

S = input()
T = input()

ans = [0 for i in range(len(S)-len(T)+1)]
for i in range(len(S)-len(T)+1):
    cnt = len(T)
    for j in range(len(T)):
        if S[i+j] == T[j]:
            cnt -= 1
    ans[i] = cnt
print(min(ans))
def Area(a, b):
    return a*b

def Lap(a, b):
    return 2*(a+b)

num = input()
a,b = int(num.split())
print('{} {}'.format(Area(a,b), Lap(a,b)))

### FIXED CODE ###

def Area(a, b):
    return a*b

def Lap(a, b):
    return 2*(a+b)

num = input()
a,b = num.split()
a = int(a)
b = int(b)
print('{} {}'.format(Area(a,b), Lap(a,b)))
T = int()
X = int()

print( T / X )

### FIXED CODE ###

T,X =map(int, input().split())
print(float(T)/float(X))
while True:
 h,w=map(int,input().split())
 if h==0:break
 for y in range(h):
  print('*'**w)

### FIXED CODE ###

while 1:
 h,w=map(int,input().split())
 if h==0:break
 print(('#'*w+'\n')*h)
def isOver(a,b):
    return True if (a[0]-b[0])**2 + (a[1]-b[1])**2 <= 4.0 else False
 
def largestGroup(mtrx,num):
    mx = 1
    ls = [num]
    for i in mtrx[num]:
        if i == num:
        	continue
       	m = youKnow(mtrx,ls,i)
        mx = max(mx,m)
    return mx
 
def youKnow(mtrx,ls,num):
    mx = len(ls)
    if set(ls) <= set(mtrx[num]):
        if num not in ls:
            ls.append(num)
        for i in list(set(mtrx[num])-set(ls)):
            m = youKnow(mtrx,ls,i)
            mx = max(mx,m)
    return mx
 
while True:
    max_over = 0
    n = int(raw_input())
    if n == 0: break
    seals = [map(float, raw_input().split(",")) for i in range(n)]
 
    overs = []
    for i in range(n):
        over = []
        for j in range(n):
            if isOver(seals[i],seals[j]):
                over.append(j)
        overs.append(over)
         
    ref = [i for i in range(n)]
    for i in ref:
        num_over = largestGroup(overs,i)
        for j in overs[i]:
            ref.remove(j)
        if num_over > max_over:
            max_over = num_over
    print max_over

### FIXED CODE ###

def isOver(array,x,y):
	return True if (array[0]-x)**2+(array[1]-y)**2 <= 1.01 else False
	
while True:
    mx = 0
    n = int(raw_input())
    if n == 0: break
    seals = [map(float, raw_input().split(",")) for i in range(n)]
    x = 0
    while x < 10.0:
    	y = 0.0
    	while y < 10.0:
    		num = 0
    		for seal in seals:
    			if isOver(seal,x,y):
    				num += 1
    		mx = max(mx,num)
    		y += 0.1
        x += 0.1
    print mx
n = int(input())
L = list(map(int, input().split())
ans = 0
c = 0

L.sort()

for i in range(n-2):
  for j in range(i+1, n):
    c = L[i]+L[j]
    l = j
    r = bisect.bisect_left(L, c, lo=l) -1
    ans += (r-l)

print(ans)

### FIXED CODE ###

import bisect

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

ans=0
for i in range(n-1):
  for j in range(i+1,n):
    idx=bisect.bisect_left(L,L[j]+L[i])
    ans+=max(0,idx-j-1)

print(ans)
# -*- coding: utf-8 -*-
N = int(input())
L = list(map(int, input().split()))
tri = 0
ran = list(range(N-2))

for i in ran:
    for j in ran:
        for k in range(N-2-i-j):
            if ((L[i] + L[i+j+1]) > L[i+j+k+2]) and ((L[i] + L[i+j+k+2]) > L[i+j+1]) and ((L[i+j+k+2] + L[i+j+1]) > L[i]):
                tri += 1
print(tri)

### FIXED CODE ###

MK = input()
mado = int(MK.split(" ")[0])
katen = int(MK.split(" ")[1])
 
n = mado - (katen*2)
 
if n >= 0:
  print(n)
else:
  print(0)
#!/usr/bin/env python3
import collections
import itertools as it
import math
import numpy as np
 
#  = input()
n  = int(input())
#  = map(int, input().split())
#  = list(map(int, input().split()))
t  = [int(input()) for i in range(n)]
#
# c = collections.Counter()
print(np.lcm.reduce(t))


### FIXED CODE ###

#!/usr/bin/env python3
import collections
import itertools as it
import math
import numpy as np
import functools
 
#  = input()
n  = int(input())
#  = map(int, input().split())
#  = list(map(int, input().split()))
t  = [int(input()) for i in range(n)]
#
# c = collections.Counter()

def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a%b)

def multiple(a, b):
    return a*b // euclid(a, b)

def gcd(nums):
    return functools.reduce(euclid, nums)

def lcm(nums):
        return functools.reduce(multiple, nums)

print(lcm(t))
import math
import copy
from copy import deepcopy
import sys
import fractions
import numpy as np
from functools import reduce
# import statistics
import heapq


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===
n = getInputInt()
data = getSomeInputListInt(n)

data_sorted = sorted(data, key=lambda x:x[1], reverse=True)

lim = sys.maxsize
flg = True

for d in data_sorted:
    if lim > d[1]:
        lim = d[1]
    lim -= d[0]

    if lim<0:
        flg = False
        break

if flg:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

import math
import copy
from copy import deepcopy
import sys
import fractions
import numpy as np
from functools import reduce
# import statistics
import heapq


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===
n = getInputInt()
data = getSomeInputListInt(n)

data_sorted = sorted(data, key=lambda x:x[1], reverse=True)

lim = sys.maxsize
flg = True

for d in data_sorted:
    if lim > d[1]:
        lim = d[1]
    lim -= d[0]

    if lim<0:
        flg = False
        break

if flg:
    print("Yes")
else:
    print("No")
x=int(input())
y=int(input())
if x<9 and y<9:
  print("Yay!")
else:
  print(":(")

### FIXED CODE ###

x,y=map(int,input().split())
if x<9 and y<9:
  print("Yay!")
else:
  print(":(")
n=int(input())
b=list(map(int,input().split()))
a=b
condition=''
cnt=0
wa=0
for i in range(n):
  wa+=a[i]
  if i == 0:
    if a[i]>0:
      condition='minus'
    else:
      condition='plus'
  elif condition == 'plus':
    condition='minus'
    if wa<=0:
      cnt+=abs(wa)+1
      a[i]+=abs(wa)+1
      wa+=abs(wa)+1
  elif condition == 'minus':
    condition='plus'
    if wa>=0:
      cnt+=abs(wa)+1
      a[i]-=abs(wa)+1
      wa-=abs(wa)+1

cnt1=cnt
a=b
condition=''
cnt=0
wa=0
for i in range(n):
  a[i]=a[i]/abs(a[i])*(-1)
  cnt+=abs(a[i])+1
  wa+=a[i]
  if i == 0:
    if a[i]>0:
      condition='minus'
    else:
      condition='plus'
  elif condition == 'plus':
    condition='minus'
    if wa<=0:
      cnt+=abs(wa)+1
      a[i]+=abs(wa)+1
      wa+=abs(wa)+1
  elif condition == 'minus':
    condition='plus'
    if wa>=0:
      cnt+=abs(wa)+1
      a[i]-=abs(wa)+1
      wa-=abs(wa)+1

cnt2=cnt
print(min(cnt1,cnt2))

### FIXED CODE ###

n=int(input())
b=list(map(int,input().split()))
a=b[:]

cnt=0
wa=0
condition='plus'
for i in range(n):
  wa+=a[i]
  if condition == 'plus':
    condition='minus'
    if wa<=0:
      cnt+=abs(wa)+1
      a[i]+=abs(wa)+1
      wa+=abs(wa)+1
  elif condition == 'minus':
    condition='plus'
    if wa>=0:
      cnt+=abs(wa)+1
      a[i]-=abs(wa)+1
      wa-=abs(wa)+1

cnt1=cnt
a=b[:]
cnt=0
wa=0
condition='minus'
for i in range(n):
  wa+=a[i]
  if condition == 'plus':
    condition='minus'
    if wa<=0:
      cnt+=abs(wa)+1
      a[i]+=abs(wa)+1
      wa+=abs(wa)+1
  elif condition == 'minus':
    condition='plus'
    if wa>=0:
      cnt+=abs(wa)+1
      a[i]-=abs(wa)+1
      wa-=abs(wa)+1

cnt2=cnt
print(min(cnt1,cnt2))
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    A = [I() for _ in range(N)]

    is_ok = True

    # A[i] > iと、2以上大きくなるところがあるとダメ
    if [A[i] for i in range(N) if A[i] > i]:
        is_ok = False
    else:
        for i in range(N - 1):
            if A[i] + 1 < A[i+1]:
                is_ok = False
                break

    if is_ok:
        # 後ろの上昇列から作っていく 上昇列の最後の数字だけ回数がかかる
        ans = 0
        for i in range(N - 1):
            if A[i] >= A[i+1]:
                ans += A[i]
        if A[-2] >= A[-1]:
            ans += A[-1]
        else:
            ans += 1

    if is_ok:
        print(ans)
    else:
        print(-1)

if __name__ == '__main__':
    resolve()


### FIXED CODE ###

import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    A = [I() for _ in range(N)]

    is_ok = True

    # A[i] > iと、2以上大きくなるところがあるとダメ
    if [A[i] for i in range(N) if A[i] > i]:
        is_ok = False
    else:
        for i in range(N - 1):
            if A[i] + 1 < A[i+1]:
                is_ok = False
                break

    if is_ok:
        # 後ろの上昇列から作っていく 上昇列の最後の数字だけ回数がかかる
        ans = 0
        if N == 1:
            ans = 0
        else:
            for i in range(N - 1):
                if A[i] >= A[i+1]:
                    ans += A[i]
            ans += A[-1]

    if is_ok:
        print(ans)
    else:
        print(-1)

if __name__ == '__main__':
    resolve()
a = list(map(int,input().split()))
N = a[0]
K = a[1]

i = 2
x = (N-K+1)
y = 1
z = (x*y)%(10**9+7)
print(z)

while (N-K+1) >= i and K >= i:
    x = (N-K+2-i)*x/i
    y = (K-i+1)*y/(i-1)
    z = (x*y)%(10**9+7)
    print(int(z))
    i = i + 1

### FIXED CODE ###

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

i = 2
x = (N-K+1)
y = 1
z = (x*y)%(10**9+7)
print(z)

while K >= i:
    if (N-K+1) >= i:
        x = (N-K+2-i)*x//i
        y = (K-i+1)*y//(i-1)
        z = (x*y)%(10**9+7)
        print(z)
    else:
        print(0)
    i = i + 1
n,k=map(int,input().split());d=input().split()
while 1:
    for c in str(n):
        if c in d:break
    else:
        print(n)
        exit()
    n += 1

### FIXED CODE ###

A=input()
print(['NO','YES'][(A.count('5')==2)*(A.count('7')==1)])
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n = input()
k = int(input())

def calc(i, k):
    return comb(len(n) - i - 1, k) * 9 ** k

ans = 0
if len(n) == k:
    ans +=1

for i in range(len(n)):
    if len(n)-i > k:
        ans += calc(i, k)
    k -= 1
    if k < 0:
        break
    ans += (int(n[i]) - 1) * calc(i, k)

print(ans)


### FIXED CODE ###

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

n = input()
k = int(input())

def calc(i, k):
    return comb(len(n) - i - 1, k) * 9 ** k

def cnt(n):
    cnt = 0
    for c in n:
        if c != "0":
            cnt += 1
    return cnt

ans = 0
if cnt(n) == k:
    ans += 1


for i in range(len(n)):
    if int(n[i]) == 0:
        continue
    if len(n)-i > k:
        ans += calc(i, k)
    k -= 1
    if k < 0:
        break
    if len(n)-i > k:
        ans += (int(n[i]) - 1) * calc(i, k)
print(ans)
#abc123d
 
x,y,z,k=map(int,raw_input().split())
a=sorted(map(int,raw_input().split()),reverse=True)
b=sorted(map(int,raw_input().split()),reverse=True)
c=sorted(map(int,raw_input().split()),reverse=True)
 
ab=sorted([i+j for i in a for j in b],reverse=True)
res=sorted([ij+l for ij in ab[:k] for l in c],reverse=True)
for i in res[:k]:
 print i

### FIXED CODE ###

#abc123d
 
x,y,z,k=map(int,raw_input().split())
a=sorted(map(int,raw_input().split()),reverse=True)
b=sorted(map(int,raw_input().split()),reverse=True)
c=sorted(map(int,raw_input().split()),reverse=True)
 
ab=sorted([i+j for i in a for j in b],reverse=True)
res=sorted([ij+l for ij in ab[:k] for l in c],reverse=True)
for i in res[:k]:
	print i
a = int(input())
b = int(input())
c = int(input())
d = int(a+b+c)
print(d)
if d>=22 :
    print("bust")
else:
    print("win")

### FIXED CODE ###

a = input()
a = a.split()
result = map(lambda x: int(x), a)
res = 0
for num in result:
    res = res + num
if res>=22 :
    print("bust")
else:
    print("win")