Harryxun/stf_run huggingface dataset:
def nCr(n, r):
    import math
    return math.factorial(n) // ((math.factorial(n - r) * math.factorial(r)))
MOD = 1000000007

n, k = map(int, input().split())
b, r = k, n-k
for i in range(0, k):
    x = nCr(b - 1,  i) # 青いブロックの分け方
    y = nCr(r + 1 , r- i)

    print(x * y % MOD)

### FIXED CODE ###

def nCr(n, r):
    import math
    return math.factorial(n) // ((math.factorial(n - r) * math.factorial(r)))
MOD = 1000000007

n, k = map(int, input().split())
b, r = k, n-k
for i in range(0, k):
    x = nCr(b - 1,  i) # 青いブロックの分け方
    if r - i < 0:
        print(0)
    else:
        y = nCr(r + 1, r - i)
        print(x * y % MOD)
import numpy as np
def factorial(n):
  if (n==1):
    return 1
  return n*factorial(n-1)

n = int(input())
x = []
y = []
for i in range(n):
  x_, y_ = list(map(int, input().split()))
  x.append(x_)
  y.append(y_)
val = 0
for i in range(n):
  for j in range(i+1, n):
    val += np.sqrt((x[i] - x[j])**2 + (y[i] - y[j])**2)

ans = val/factorial(n) * factorial(n-1) * 2
print(ans)

### FIXED CODE ###

N = int(input())
xy = [list(map(int, input().split())) for i in range(N)]
 
from itertools import permutations
from math import sqrt
 
paths = list(permutations(range(N), N))
l = len(paths)
total = 0
for path in paths:
    tmp = 0
    x, y = xy[path[0]][0], xy[path[0]][1]
    for p in path[1:]:
        px, py = xy[p][0], xy[p][1]
        tmp += sqrt((px-x)**2 + (py-y)**2)
    total += tmp
print(total / l)
A,B=input().split()
B=Decimal(B)
A=int(A)
ans=int(A*B)
 
print(ans)

### FIXED CODE ###

from decimal import Decimal

A,B=input().split()
B=Decimal(B)
A=int(A)
ans=int(A*B)
 
print(ans)
n = int(input())
arr = list(map(int,input().split()))
arr.sort(reverse=True)
ans = 1
limit = 10 * 18

if arr[-1] == 0:
  ans = 0
else:
  for i in arr:
    ans *= arr[i]
    if ans > limit:
      ans = -1
      break
print(ans)

### FIXED CODE ###

n = int(input())
arr = list(map(int,input().split()))
arr.sort(reverse=True)
ans = 1
limit = 10**18

if arr[-1] == 0:
  ans = 0
else:
  for i in arr:
    ans *= i
    if ans > limit:
      ans = -1
      break
print(ans)
D = input()
T = input()
S = input()

if(D/S <= T) print("Yes")
else print("No")

### FIXED CODE ###

D,T,S = map(int,input().split())

if(D/S <= T):
	print("Yes")
else:
	print("No")
A,B,N = map(int, input().split())

def f(a, b, n):
    fl1 = (a * (n + 1)) // b
    fl2 = (n + 1) // b
    fl = fl1 - (a * fl2)
    return fl
   #return int(a * n / b) - a * int(n / b)

print(f(A, B, B-1) if N >= B-1 else f(A, B, N))

### FIXED CODE ###

K = int(input())
A,B = map(int, input().split())
C = K
count = 1
ans = "NG"

while (C<=B):
    #print("test")
    if(A<=C and C<=B):
        ans ="OK"
    C = K*count
    count += 1
    #print(C)


print(ans)
s = input()
k = int(input())
m = 0
n = 0
j = 0
for i in range(len(s)):
    if s.count(s[0]) == len(s):
        print(len(s) * k // 2)
        exit()
    if len(s) <= j + 1:
        if s[0]==s[j]:
            n+=1
        break
    if s[j] == s[j + 1]:
        if j == len(s) - 1:
            n += 1
        else:
            m += 1
        j += 1
    j += 1
print(m * k + n * (k - 1))


### FIXED CODE ###

s = input()
k = int(input())
m = 0
n = 0
j = 0
for i in range(len(s)):
    if s.count(s[0]) == len(s):
        print(len(s) * k // 2)
        exit()
    if len(s) <= j + 1:
        if s[0] == s[-1] == s[-2]== s[-3]== s[-4]== s[-5]== s[len(s)//3] \
                and s[0] == s[1] == s[2]== s[3]== s[4]== s[5]:
            n+=1
        break
    if s[j] == s[j + 1]:
        if j == len(s) - 1:
            n += 1
        else:
            m += 1
        j += 1
    j += 1
print(m * k + n*(k-1))
S = input()
n = len(S)
dp = [0 for _ in range(n+1)]
count = [0 for _ in range(2019)]
count[0] = 1
for i in range(1,n+1):
    dp[i] = (dp[i-1]+int(S[n-i])*10**(i-1)) % 2019
    count[dp[i]] += 1

for i in range(2019):
    count[i] = count[i]*(count[i]-1)/2

print(int(sum(count)))

### FIXED CODE ###

S,W = map(int, input().split())
if S<=W:
    print("unsafe")
else:
    print("safe")
import numpy as np
n = int(input())
a = [input() for _ in range(n)]
a_sort = sorted(a)
for i in range(n):
    if i == np.argmax(a):
        print(a_sort[-2])
    else:
        print(a_sort[-1])

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline
N = int(input())
A = [int(input()) for _ in range(N)]
B = A[:]
max1 = max(A)
A.remove(max1)
max2 = max(A)

for i in B:
    if i == max1:
        print(max2)
    else:
        print(max1)
n = int(input())
for i in range(n):
	line = list(map(float,input().split()))
	if round(line[2] - line[0], 2) == 0:
		if round(line[6] - line[4], 2) == 0:
			print("YES")
		else:
			print("NO")
	else:
		AB = (line[3] - line[1]) / (line[2] - line[0])
		CD = (line[7] - line[5]) / (line[6] - line[4])
		if round(AB - CD, 8) == 0:
			print("YES")
		else:
			print("NO")

### FIXED CODE ###

from fractions import Fraction

def sroap(x1,y1,x2,y2):
	if x2 - x1 == 0:
		return float("inf")
	else:
		return Fraction(y2 - y1,x2 - x1)
		
N = int(input())
for n in range(N):
	Ax,Ay,Bx,By,Cx,Cy,Dx,Dy = map(lambda x: round(x * 10 ** 5),(map(float,input().split())))
	if sroap(Ax,Ay,Bx,By) == sroap(Cx,Cy,Dx,Dy):
		print("YES")
	else:
		print("NO")
"""
---アルゴリズム概要---
閉路のないグラフなので、シンプルにxからKまでまっすぐに進んでから、Kからyにまっすぐ進むことを考えればよい。
クエリの数Qが10**5個あるので、ノードaからノードbにまっすぐ進む場合のコストをメモしていくのがよさそう。

次に、どうやってノードaからノードbへの「まっすぐ進む道」＝「まっすぐ進むための次のノード」を判断するかだが、
これは、ノードaが直接つながっているノードのうち、
ノードbへのコストが最も少ないものがまっすぐ進むための次のノードとなる。
"""

N = int(input())
edges = [{} for _ in range(N)]
#dpでiからjへの最短コストを管理する。
for _ in range(N-1):
    a,b,c = map(int,input().split())
    edges[a-1][b]=c
    edges[b-1][a]=c

Q,K = map(int,input().split())
dp = [float("INF")]*(N)

path = {}
def dfs(i,c):
    dp[i-1]=c
    path[i]=""
    for n,cost in edges[i-1].items():
        if n not in path:
            dfs(n, c + cost)

dfs(K,0)
for _ in range(Q):
    x,y = map(int,input().split())
    print(dp[x-1]+dp[y-1])

### FIXED CODE ###

"""
--- アルゴリズム概要 ---
前計算で頂点Kから各ノードへの最短路を記録しておき、
各クエリに対しては、dp[a]+dp[b]を返せばよい。

頂点Kから各ノードへの最短ルートはdfsとかで記録していけばよい。
"""
def main():
    from collections import deque
    import sys
    sys.setrecursionlimit(20000000)
    input = sys.stdin.readline
    N = int(input())
    AB = [[]for _ in range(N+1)]
    for i in range(N-1):
        a,b,c = map(int,input().split())
        AB[a].append((b,c))
        AB[b].append((a,c))

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

    path = {K:""}
    dp = [0]*(N+1)
    que = deque()
    for n,c in AB[K]:
        que.append((n,c))
    while que:
        now,cost = que.pop()
        path[now]=""
        dp[now]=cost
        for n,c in AB[now]:
            if n not in path:
                que.append((n,cost+c))
    for i in range(Q):
        x,y=map(int,input().split())
        print(dp[x]+dp[y])
main()
import math

num = int(input)
print(math.factorial(num))

### FIXED CODE ###


import math

num = int(input())
print(math.factorial(num))
N = int(input())
values = [int(s) for s in input().split()]
rest = 1000
for i in range(N):
  if rest >= 1000:
  	if values[i] >= values[i+1]:
    	have = values[i] // rest
	    rest = values[i] % rest
  elif value != 0:
    rest += values[i] * have
print(rest)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
money = 1000
stock = 0
for i in range(N-1):
    if A[i+1] > A[i]:
        stock = money // A[i]
        money = money % A[i]
        money += stock * A[i+1]
print(money)
N,K=map(int,input().split())

A=[int(i) for i in input().split()]
if K > N or K>30:
    output=""
    for i in range(N):
         output+=(str(N)+" ")
    print(output)
else:
    for _ in range(K):
        A_next =[1 for i in range(N)]
        for i in range(N):
            for j in range(A[i]):
                if (i+j+1) < N:
                    A_next[i+j+1]+=1
                if (i-j-1) >= 0:
                    A_next[i-j-1]+=1
        A=A_next
    output=""
    for i in A_next:
        output+=(str(i)+" ")
    print(output)
        
    

### FIXED CODE ###

name = input()
name = name[:3]
print(name)
def binaryinsertion(A,x):
    left=0;right=len(A)-1
    while(True):
        centre = left + (right-left)//2
        if(right - left < 2):
            if(x[0]<A[left][0]):A.insert(left,x)
            else :
                if(x[0]<A[right][0]):A.insert(right,x)
                else:A.insert(right+1,x)
            break
        else:
            if(x[0] < A[centre][0]) :
                right = centre - 1
            elif(A[centre][0] < x[0]) :
                left = centre + 1
            else : 
                A.insert(centre,x)
                break

[N,L] = [int(x) for x in input().split()]
A = [[int(x),int(i)] for i,x in enumerate(input().split())]
sweep = A[:L]
sweep = sorted(sweep)
ans = [str(sweep[0][0])]
for i in range(L,N) :
    sweep.remove(A[i-L])
    binaryinsertion(sweep,A[i])
    ans.append(str(sweep[0][0]))
print(" ".join(ans))

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
n=int(input())
for i in range(1,9):
  for j in range(9):
    if i*j==n:
      a+=1
if a>0:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n=int(input())
a=0
for i in range(1,10):
  for j in range(1,10):
    if i*j==n:
      a+=1
if a>0:
  print("Yes")
else:
  print("No")
print(min(int(input(),int(input()))+min(int(input(),int(input())))

### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
print(min(a,b)+min(c,d))
import sys
import math

args = sys.argv

hp = int(args[1])
attack = int(args[2])

if(hp <= attack):
    ans = "1"
else:
    ans = str(math.ceil(hp / attack))

print(int(ans))

### FIXED CODE ###

import math

hp , attack = map(int,input().split())

if(hp <= attack):
    ans = "1"
else:
    ans = str(math.ceil(hp / attack))

print(int(ans))
import sys

num_list = []

for line in sys.stdin.readlines():
    num_list.append(int(line.strip()))

num_list.remove(num_list[0])

count = 0

for num in num_list:
    if num != 1:
        for i in range(2, num-1)
            if num % i == 0:
                continue
    count += 1

print count

### FIXED CODE ###

import sys
import math

count = 0

num_list = []

for line in sys.stdin.readlines():
    num_list.append(int(line.strip()))

num_list.remove(num_list[0])

for num in num_list:
        flag = 0
        for i in range(2, int(math.sqrt(num)) + 1):
            if num % i == 0:
                flag = 1
                break
        if flag == 0:
            count += 1

print count
s = str(input())
t= str(input())

sdict = {}
for i in range(len(s)):
    if s[i] not in sdict:
        sdict[s[i]]=[]
    sdict[s[i]].append(i+1)
    
#print(sdict)

#二分木探索
def search(list_,mark_,sta,gol):
    if  sta == gol:
            return list_[sta]
    else:
            mid = (gol-sta)//2
            if list_[mid]>mark_:
                return search(list_,mark_,sta,mid)
            else:
                return search(list_[mid:],mark_,mid+1,gol)

ans = 0
mark = 0
for _ in range(len(t)):
    target = t[_]
    if target not in sdict:
        ans = -1
        break
    else:
        if sdict[target][-1]<=mark:
            mark = sdict[target][0]
            ans += len(s)
        elif sdict[target][0]>mark:
            mark = sdict[target][0]
        else:
            posi = search(sdict[target],mark,0,len(sdict[target])-1)
            mark = posi
        
if ans != -1:
    ans += mark
print(ans)

### FIXED CODE ###

s = str(input())
t= str(input())

sdict = {}
for i in range(len(s)):
    if s[i] not in sdict:
        sdict[s[i]]=[]
    sdict[s[i]].append(i+1)
    
#print(sdict)

#二分木探索
def search(list_,mark_,sta,gol):
    if  sta == gol:
            return list_[sta]
    else:
            mid = (gol+sta)//2
            if list_[mid]>mark_:
                return search(list_,mark_,sta,mid)
            else:
                return search(list_,mark_,mid+1,gol)

ans = 0
mark = 0
for _ in range(len(t)):
    target = t[_]
    if target not in sdict:
        ans = -1
        break
    else:
        if sdict[target][-1]<=mark:
            mark = sdict[target][0]
            ans += len(s)
        elif sdict[target][0]>mark:
            mark = sdict[target][0]
        else:
            posi = search(sdict[target],mark,0,len(sdict[target])-1)
            mark = posi
        
if ans != -1:
    ans += mark
print(ans)
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A = sorted(readInts())
dic = defaultdict(int)
cnt = 0
A = set(A)
# ------------
is_prime = [True] * (10**6+1)
#print('a')
for i in range(n):
    #ll += 1
    #print(i)
    if is_prime[A[i]] == True:
        for j in range(2*A[i], 10**6+1,A[i]):
            is_prime[j] = False # その素数の倍数のやつ

 # -----------
for i in A:
    dic[i] += 1
cnt = 0
if A[0] == 1:
    if dic[1] >= 2:
        print(0)
        exit()
    else:
        print(1)
        exit()
for a in A:
    if is_prime[a] and not dic[a] >= 2:
        #print(a)
        cnt += 1
print(cnt)


### FIXED CODE ###

#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A = sorted(readInts())
dic = defaultdict(int)
cnt = 0
for i in A:
   dic[i] += 1
A = list(set(A))
# ------------
is_prime = [True] * (10**6+1)
#print('a')
for i in range(len(A)):
    #ll += 1
    #print(i)
    #print(A[i])
    if is_prime[A[i]] == True:
        for j in range(2*A[i], 10**6+1,A[i]):
            is_prime[j] = False # その素数の倍数のやつ

 # -----------
cnt = 0
if A[0] == 1:
    if dic[1] >= 2:
        print(0)
        exit()
    else:
        print(1)
        exit()
for a in A:
    if is_prime[a] and not dic[a] >= 2:
        #print(a)
        cnt += 1
print(cnt)
N = int(input())
S = str(input())
for i in range(N):
    if S[i]+S[i+1]+S[i+2] == 'ABC':
        a += 1
    if i == N - 3:
        break
print(a)

### FIXED CODE ###

N = int(input())
S = input()
a = 0
for i in range(N):
    if S[i]+S[i+1]+S[i+2] == 'ABC':
        a += 1
    if i == N - 3:
        break
print(a)
import sys

def f(x):
    p=0
    cnt=0
    for i in range(n-1,-1,-1):
        while p<n and a[i]+a[p]<x:
            p+=1
        cnt+=n-p
    return cnt

n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()

l,r=a[0]*2,a[n-1]*2

while r-l>0:
    if r-l<=1:
        if f(r)==m: md=r;break 
        else: md=l;break
    md=(r+l)//2
    k=f(md)
    if k==m: break
    elif k>m: l=md
    else: r=md


p=0
cnt=0
ans=0

for q in range(n-1,-1,-1):
    try:
        while p<n and a[q]+a[p]<=md:
            p+=1
    except:
        p=n

    cnt+=n-p
    ans+=a[q]*(n-p)*2
    if p==n: break


ans+=(m-cnt)*md
print(ans)

### FIXED CODE ###

import sys

def f(x):
    p=0
    cnt=0
    for i in range(n-1,-1,-1):
        while p<n and a[i]+a[p]<x:
            p+=1
        cnt+=n-p
    return cnt

n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()

l,r=a[0]*2,a[n-1]*2
md=(r+l)//2
while r-l>0:
    if r-l<=1:
        if f(r)==m: md=r;break 
        else: md=l;break
    md=(r+l)//2
    k=f(md)
    if k==m: break
    elif k>m: l=md
    else: r=md

p=0
cnt=0
ans=0

for q in range(n-1,-1,-1):
    try:
        while p<n and a[q]+a[p]<=md:
            p+=1
    except:
        b=1
        while True:
            b+=1

    if p==n: break
    cnt+=n-p
    ans+=a[q]*(n-p)*2


ans+=(m-cnt)*md
print(ans)
n,m,k=map(int,input().split())
if n%k==0 or m%k==0:
	print("Yes")
else:
	print("No")


### FIXED CODE ###

n,m,k=map(int,input().split())
for nn in range(n+1):
	for mm in range(m+1):
		if nn*m+mm*n-2*mm*nn==k:
			print("Yes")
			exit()
print("No")
a, b = map(int,input().split())
x, y = abs(a), abs(b)

if a >= 0:
    if b > 0:
        if a > b:
            a, b = map(int,input().split())
x, y = abs(a), abs(b)

if a >= 0:
    if b > 0:
        if a > b:
            ans = abs(x-y) + 2
        else:
            ans = abs(x-y)
            
    else:
        ans = abs(x-y) + 1

else:
    if b >= 0:
        ans = min(abs(x-y)+1, b - a)
    else:
        if b > a:
            ans = abs(x-y)
        else:
            ans = abs(x-y) + 2

print(ans)

### FIXED CODE ###

a, b = map(int,input().split())
x, y = abs(a), abs(b)

if a >= 0:
    if b > 0:
        if a > b:
            ans = abs(x-y) + 2
        else:
            ans = abs(x-y)
            
    else:
        ans = abs(x-y) + 1

else:
    if b >= 0:
        ans = min(abs(x-y)+1, b - a)
    else:
        if b > a:
            ans = abs(x-y)
        else:
            ans = abs(x-y) + 2

print(ans)
N = input()
nums = list(map(int, input().split()))

first = None
start = nums[0]
next = None

for num in nums:
    if start ^ num in nums:
        next = num
        first = start

if next == None:
    print("No")
else:
    while len(nums) > 1:
        next2 = start ^ next
        if next2 in nums:
            nums.remove(start)
            nums.remove(next)
            start = next
            next = next2
        else:
            print("No")
            break

    if len(nums) <= 1:
        if start ^ next == first:
            print("Yes")
        else:
            print("No")


### FIXED CODE ###

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

result = 0

for num in nums:
    result ^= num

if result == 0:
    print('Yes')
else:
    print('No')
x,y = map(int, input().split())
a=0
b=0
if x=="A":
  a=10
elif x=="B":
  a=11
elif x=="C":
  a=12
elif x=="D":
  a=13:
elif x=="E":
  a=14
elif x=="F":
  a=15
  
  
if y=="A":
  b=10
elif y=="B":
  b=11
elif x=="C":
  b=12
elif x=="D":
  b=13
elif x=="E":
  b=14
elif x=="F":
  b=15

if a<b:
  print("<")
elif a>b:
  print(">")
elif a==b:
  print("=")


### FIXED CODE ###

x,y = map(str, input().split())
a=0
b=0
if x=="A":
  a=10
elif x=="B":
  a=11
elif x=="C":
  a=12
elif x=="D":
  a=13
elif x=="E":
  a=14
elif x=="F":
  a=15
  
  
if y=="A":
  b=10
elif y=="B":
  b=11
elif y=="C":
  b=12
elif y=="D":
  b=13
elif y=="E":
  b=14
elif y=="F":
  b=15

if a<b:
  print("<")
elif a>b:
  print(">")
elif a==b:
  print("=")
import sys
import math


def input():
    return sys.stdin.readline().strip()


MOD = 10 ** 9 + 7
sys.setrecursionlimit(20000000)


def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    a = A[0]
    B = set()
    for i in range(1, N):
        g = math.gcd(A[i], a)
        if g == 1:
            B.add(1)
        elif g == a:
            continue
        else:
            B.add(g)
    if len(B) == 0:
        print(a)
    else:
        print(min(B))


if __name__ == "__main__":
    main()


### FIXED CODE ###

n=int(input())
a=[int(i) for i in input().split()]
while len(a)>1:
    c=[]
    d=min(a)
    for i in range(len(a)):
        if a[i]!=d:
            div=a[i]%d
            if div!=0:
                c.append(div)
    c.append(d)        
    a=c
print(a[0])
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
top, bottom = 0, M-1

if len(A) == 1:
    for _ in range(M):
        A[0] //= 2
else:
    for _ in range(M):
        A[top] //= 2
        if A[top] >= A[bottom]:
            bottom -= 1
            continue
        else:
            top += 1
print(sum(A))

### FIXED CODE ###

import heapq
N, M = map(int, input().split())
heap = [-i for i in list(map(int, input().split()))]
heapq.heapify(heap)
for i in range(M):
    heapq.heappush(heap, -(-heapq.heappop(heap)//2))
print(-sum(heap))
def Base_n_to_10(X,n):
    out = 0
    for i in range(1,len(str(X))+1):
        out += int(X[-i])*(n**(i-1))
    return out#int outn=int(input())
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
n=int(input())
x=input()
ans=[]
pc=x.count("1")
x10=Base_n_to_10(x,2)
for i in range(1,n+1):
  if x[i-1]=="0":
    ans.append((x10+pow(2,n-i,pc+1))%(pc+1))
  else:
    ans.append((x10+pow(2,n-i,pc-1))%(pc-1))
la=[float("inf")]*n
for i in range(1,n+1):
  i10=str(Base_10_to_n(i, 2)).count("1")
  if i%i10==0:
    la[i-1]=1
  else:
    la[i-1]=la[(i%i10)-1]+1
for a in ans:
  if a==0:
    print(1)
  else:
    print(1+la[a-1])
  



### FIXED CODE ###

def Base_n_to_10(X,n):
    out = 0
    for i in range(1,len(str(X))+1):
        out += int(X[-i])*(n**(i-1))
    return out#int outn=int(input())
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
n=int(input())
x=input()
ans=[]
pc=x.count("1")
la=[float("inf")]*pc
for i in range(1,pc+1):
    i10=str(Base_10_to_n(i, 2)).count("1")
    if i%i10==0:
      la[i-1]=1
    else:
      la[i-1]=la[(i%i10)-1]+1
if pc!=1:
  x10=Base_n_to_10(x,2)
  a=x10%(pc+1)
  b=x10%(pc-1)
  for i in range(1,n+1):
    if x[i-1]=="0":
      ans.append((a+pow(2,n-i,pc+1))%(pc+1))
    else:
      ans.append((b-pow(2,n-i,pc-1))%(pc-1))
  for a in ans:
    if a==0:
      print(1)
    else:
      print(1+la[a-1])
else:
  x10=Base_n_to_10(x,2)
  for i in range(1,n+1):
    if x[i-1]=="0":
      ans.append((x10+pow(2,n-i,pc+1))%(pc+1))
    else:
      ans.append("n")
  for a in ans:
    if a==0:
      print(1)
    elif a=="n":
      print(0)
    else:
      print(1+la[a-1])
N, M = map(int,input().split())

s = M//N
for i in range(1,s):
  if M%i == 0:
    ans = i
print(ans)

### FIXED CODE ###

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

s = M//N
for i in reversed(range(1,s+1)):
  if M%i == 0:
    ans = i
    break
print(ans)
num = int(input())
a_i = list(map(int, input().split()))
list.sort(a_i, reverse=True)
if num <= 3:
    print(sum(a_i[:num - 1]))
else:
    ans = sum(a_i[:2])
    for x in range(3, num):
        if x == 3: ans += a_i[1]
        else: ans += a_i[x // 2]
print(ans)


### FIXED CODE ###

num = int(input())
a_i = list(map(int, input().split()))
list.sort(a_i, reverse=True)
if num <= 3:
    print(sum(a_i[:num - 1]))
else:
    ans = sum(a_i[:2])
    for x in range(3, num):
        if x == 3: ans += a_i[1]
        else: ans += a_i[x // 2]
    print(ans)
N = int(input())
S = [input() for _ in range(N)]

print(len(set(S))

### FIXED CODE ###

N = int(input())
S = [input() for _ in range(N)]
 
print(len(set(S)))
# -*- coding: utf-8 -*-
def shiritori(a, b):
    return a[len(a)-1:] == b[:1]


a, b, c = map(int, raw_input().split())
if shiritori(a, b) is True and shiritori(b, c) is True:
    print("YES")
else:
    print("NO")


### FIXED CODE ###

# -*- coding: utf-8 -*-
def shiritori(a, b):
    return a[len(a)-1:] == b[:1]


a, b, c = input().split()
if shiritori(a, b) is True and shiritori(b, c) is True:
    print("YES")
else:
    print("NO")