Harryxun/stf_run huggingface dataset:
N,K=map(int,input().split())
X=list(map(int,input().split()))
if X[0]>0:
    b=X[K]
elif X[0]==0:
    b=X[K-1]
elif 0 in X:
    a=0
    b=10**9
    for i in range(N):
        if X[i]==0:
            a=i
            break
    for j in range(max(0,K-1-a),min(K-a+1,N-a+1)):
        if b>X[a+j]-X[a+j-K+1]+min(abs(X[a+j]),abs(X[a+j-K+1])):
            b=X[a+j]-X[a+j-K+1]+min(abs(X[a+j]),abs(X[a+j-K+1]))
else:
    a=0
    b=10**9
    for i in range(N):
        if X[i]>0:
            a=i
            break
    for j in range(max(-1,K-a-1),min(K-a+1,N-a+1)):
        if b>X[a+j]-X[a+j-K+1]+min(abs(X[a+j]),abs(X[a+j-K+1])):
            b=X[a+j]-X[a+j-K+1]+min(abs(X[a+j]),abs(X[a+j-K+1]))
print(b)

### FIXED CODE ###

N,K=map(int,input().split())
X=list(map(int,input().split()))
if X[0]>=0:
    b=X[K-1]
elif X[-1]<=0:
    b=abs(X[-K])
elif 0 in X:
    a=0
    b=10**9
    for i in range(N):
        if X[i]==0:
            a=i
            break
    for j in range(max(0,K-1-a),min(K,N-a)):
        if b>X[a+j]-X[a+j-K+1]+min(abs(X[a+j]),abs(X[a+j-K+1])):
            b=X[a+j]-X[a+j-K+1]+min(abs(X[a+j]),abs(X[a+j-K+1]))
else:
    a=0
    b=10**9
    for i in range(N):
        if X[i]>0:
            a=i
            break
    for j in range(max(-1,K-a-1),min(K,N-a)):
        if b>X[a+j]-X[a+j-K+1]+min(abs(X[a+j]),abs(X[a+j-K+1])):
            b=X[a+j]-X[a+j-K+1]+min(abs(X[a+j]),abs(X[a+j-K+1]))
print(b)
N = int(input())
A = map(int, input().split())
for i in range(N):
    A[i] = 1/A[i]
a = sum(A)
print(1/a)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
for i in range(N):
    A[i] = 1/A[i]
a = sum(A)
print(1/a)
l = []
for i in range(5):
    l.append(int(input()))

ans = 10**10

import itertools
t = 0
for P in itertools.permutations(l,len(l)):
    for p in P:
        t += p
        if (p % 10) != 0:
            tt = 10-p%10
            t += (10 - p%10)


    ans = min(ans , t-tt)
    t = 0
print(ans)


### FIXED CODE ###

l = []
for i in range(5):
    l.append(int(input()))

ans = 10**10

import itertools
t = 0
tt = 0
for P in itertools.permutations(l,len(l)):
    for p in P:
        t += p
        if (p % 10) != 0:
            tt = 10-p%10
            t += (10 - p%10)
    ans = min(ans , t-tt)
    t = 0
print(ans)
i = 0

while 1:
  x = raw_input()
  i += 1
  if x == "0":
    break
  print "Case %s: %s" % i,x

### FIXED CODE ###

i = 0

while 1:
  x = raw_input()
  i += 1
  if x == "0":
    break
  print "Case %d: %s" % (i,x)
H,W = map(int,input().split())

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

num=0

for i in range(H):
    for j in range(W):
        if i%2==0:
            n=j
        else:
            n=W-1-j
        if A[i][n]%2==1:
            A[i][n]-=1
            if i!=H-1 and (i%2==0 and n==W-1) or (i%2==1 and n==0):
                num+=1
                A[i+1][n]+=1
                print(i+1,n+1,i+2,n+1)
            if (i%2==0 and n!=W-1) or (i%2==1 and n!=0):
                num+=1
                A[i][n+(-1)**(i%2)]+=1
                print(i+1,n+1,i+1,n+1+(-1)**(i%2))



### FIXED CODE ###

a,b = map(int,input().split())

if a*b%2==1:
    print("Yes")
else:
    print("No")
I = input("")
i = I.split(" ")
print(i)

N = int(i[0])
l = []
t = 0

for k in range(N):
    if i[k+1] not in l:
        l.append(i[k+1])
        t = t+1
print(len(l))


### FIXED CODE ###

N = int(input(""))
M = []
n = 0

for i in range(N):
    p = input("")
    M.append(p)

Mm = list(set(M))

print(len(Mm))
n = int(input())
T,A = map(int, input().split())
H = list(map(int, input().split()))
z = [abs(a - (t - h*0.006)) for h in H]
print( z.index(min(z)) +1 )

### FIXED CODE ###

n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
z=[abs(t-x*0.006-a) for x in h]
print(z.index(min(z))+1)
N = input()

print(N / 15)

print(N * 800 - ((N / 15) * 200))


### FIXED CODE ###

N = int(input())

print(N * 800 - ((N // 15) * 200))
a = int(input())
b = int(input())

if a == 2 or b == 2:
    print("No")
else:
    print("Yes")
##17024510 | nowg's solution for [AtCoder-4250] [Problem A]

### FIXED CODE ###

nums = input()

if '2' in nums:
    print("No")
else:
    print("Yes")
#17025159 | nowg's solution for [AtCoder-4250] [Problem A]
n,m=map(int,input().split())
p = [int(i)-1 for i in input().split() ]

uf = UnionFind(n)
for i in range(m):
    x,y = map(int,input().split())
    uf.union(x-1,y-1)

ans=0
groups = uf.all_group_members().values()

for c in groups:
    ans+= len( set(c) & set(p[i] for i in c ) ) 
print(ans)

### FIXED CODE ###

n,m=map(int,input().split())
p = [int(i)-1 for i in input().split() ]


tree=[[] for _ in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

from collections import deque

groups=[]
been=[0]*n
for i in range(n):
    if been[i]==0:
        group=[i]
        been[i]=1
        q = deque([(i,togo) for togo in tree[i]]) 
        while q:
            parent,x = q.popleft()
            if been[x]==1:
                continue
            been[x]=1
            group.append(x)
            for y in tree[x]:
                if y == parent:#親ノードを飛ばし
                    continue
                q.append((x,y))#子ノードを追加
        groups.append(group)

ans=0
for group in groups:
    ans+= len( set(group) & set(p[g] for g in group) )

print(ans)
n=int(input())
for i in range(9):
    for j in range(9):
        if n%(i*j)==0:
            print('Yes')
        else:
            print('No')

### FIXED CODE ###

n=int(input())
for i in range(9):
    for j in range(9):
        k = (i+1)*(j+1)
        if n==k:
            print('Yes')
            exit()
        else:
            continue
print('No')
s = input()
s = s.lstrip('AtCoder ')
s = s.rstrip(' Contest')
print('A' + s[0] + 'C')

### FIXED CODE ###

a, b, c = input().split()
print(a[0] + b[0] + c[0])
s = [int(input()) for i in range(5)]
k = int(input())
count =	0

for i in s:
    for j in s:
        if (i-j)**2 > k**2:
            print(":(")
            count+=1
	    break

if count == 0:
    print("Yay!")



### FIXED CODE ###

s = [int(input()) for i in range(5)]
k = int(input())
count = 0

for i in s:
    for j in s:
        if (i-j)**2 > k**2:
            print(":(")
            count+=1
            break
    if count == 1:
        break

if count == 0:
    print("Yay!")
import sys
n = int(input())

a = (list(map(int, input().split())))
dx = 10 ** 9 + 7

a = [i % dx for i in a if i != 0]

ans = 0
alist = []
for i in range(n):
    for j in range(i+1, n):
        alist.append((a[i] * a[j]) % dx)

for i in range(len(alist)):
    ans += alist[i]
    ans %= dx

ans %= dx
print(ans)


### FIXED CODE ###

n = int(input())

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

S = sum(a)

S2 = sum(map(lambda x: x * x, a ))

ans = (S * S - S2) // 2 % 1000000007
print(ans)
n, q = map(int, input().split())

ki = [[] for i in range(n + 1)]
for i in range(n - 1):
    a, b = map(int, input().split())
    ki[a].append(b)
    ki[b].append(a)
# print(ki)

cnt = [0] * (n + 1)
for i in range(q):
    p, x = map(int, input().split())
    cnt[p] += x
# print(cnt)


def d(y, parent):
    for k in ki[y]:
        if k == parent:
            continue
        cnt[k] += cnt[y]
        d(k, y)


d(1, -1)
print(*cnt[1:])


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
n, q = map(int, input().split())

ki = [[] for i in range(n + 1)]
for i in range(n - 1):
    a, b = map(int, input().split())
    ki[a].append(b)
    ki[b].append(a)
# print(ki)

cnt = [0] * (n + 1)
for i in range(q):
    p, x = map(int, input().split())
    cnt[p] += x


# print(cnt)


def d(y, parent):
    for i in ki[y]:
        if i == parent:
            continue
        cnt[i] += cnt[y]
        d(i, y)


d(1, -1)
print(*cnt[1:])
import math
n = input()
a = list(map(int, input().split()))
ans = float("inf")
for i in a:
    ans = min(ans, len(bin(i) - bin(i).rfind("1") - 1)
print(round(ans))

### FIXED CODE ###

import math
n = input()
a = list(map(int, input().split()))
ans = float("inf")
for i in a:
    ans = min(ans, len(bin(i)) - bin(i).rfind("1") - 1)
print(round(ans))
import math
N, X = map(int, input().split())

Xi = list(map(int, input().split()))
Xi.sort()
Di = []
found = False
for i in range(N - 1):
    if not found and Xi[i] < X and Xi[i + 1] >= X:
        Di.append(X - Xi[i])
        Di.append(Xi[i  + 1] - X)
        found = True
    elif Xi[i] != Xi[i + 1]:
        Di.append(Xi[i + 1] - Xi[i])
if not found:
    Di.append(X - Xi[-1])
Dl = len(Di)
if Dl == 0:
    print(abs(X - Xi[0]))
else:
    gcd = Di[0]
    for i in range(1, Dl):
        gcd = math.gcd(gcd, Di[i])
    print(gcd)

### FIXED CODE ###

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

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

Xi = list(map(int, input().split()))
Xi.sort()
Di = []
for i in range(N):
    Di.append(abs(X - Xi[i]))
DLen = len(Di)
g = Di[0]
for i in range(1, DLen):
    if Di[i] != 0:
        g = gcd(g, Di[i])
print(g)
# from operator import mul
# from functools import reduce

n=int(input())
a=list(map(int,input().split()))
limit=10**18

# if 0 in a:
#     print(0)
#     exit()

ans = 1
# ans = reduce(mul, a) #=> 1320

for i in range(a):
  ans *= a[i]
  if sum> limit:
  # if a[i] == 0:
  #   break
  # elif (ans*a[i]) > limit:
    ans = -1
    break

for i in range(n):
  if a[i] == 0:
      ans = 0

# if ans > limit:
#   print(-1)
# else:
print(ans)


### FIXED CODE ###

# from operator import mul
# from functools import reduce

n=int(input())
a=list(map(int, input().split()))
# limit=10**18

# if 0 in a:
#     print(0)
#     exit()

ans = 1
# ans = reduce(mul, a) #=> 1320

for i in range(n):
  ans *= a[i]
  if ans > 10 ** 18:
  # if a[i] == 0:
  #   break
  # elif (ans*a[i]) > limit:
    ans = -1
    break

for i in range(n):
  if a[i] == 0:
      ans = 0

# if ans > limit:
#   print(-1)
# else:
print(ans)
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    K, N = map(int, readline().split())
    A = map(int, readline().split())
    ans = max(K - max(A) + min(A),max(A) -min(A))
    print(ans)
    return

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    K, N = map(int, readline().split())
    A = list(map(int, readline().split()))
    sorted(A)
    d = [A[i]-A[i-1] for i in range(1,N)]
    d.append(K - max(A) + min(A))
    ans = K-max(d)
    print(ans)
    return

if __name__ == '__main__':
    main()
if X>= 30:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

X = int(input())

if X>=30:
  print('Yes')
else:
  print('No')
N = int(input())
A = list(map(int,input().split()))
c = 0
for i in range(N):
    if A[i] % 2 == 0:
        if A[i] %3 != 0 :
            if A[i] %5 != 0:
                c = 1
                break
if c == 0:
    print(APPROVED)
else:
    print(DENIED)
            
    



### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
c = 0
for i in range(N):
    if A[i] % 2 == 0:
        if A[i] %3 != 0 :
            if A[i] %5 != 0:
                c = 1
                break
if c == 0:
    print("APPROVED")
else:
    print("DENIED")
import math
n = int(input())
a = list(map(int, input().split()))
max_gcd = 1

def left_gcd(i):
    # i >= 1
    index = 0
    current_gcd = a[0]
    while index < i:
        current_gcd = math.gcd(current_gcd, a[index])
        index += 1

    return current_gcd

def right_gcd(i):
    # i < n-1
    index = n-1
    current_gcd = a[index]
    while index > i:
        current_gcd = math.gcd(current_gcd, a[index])
        index -= 1
    return current_gcd

for i in range(n):
    temp_gcd = 1
    if i == 0:
        temp_gcd = right_gcd(i)
    elif i == n-1:
        temp_gcd = left_gcd(i)
    else: 
        temp_gcd = math.gcd(left_gcd(i), right_gcd(i))
    max_gcd = max(temp_gcd, max_gcd)

print(max_gcd)

### FIXED CODE ###

def gcd(a,b):
    l = max(a,b)
    s = min(a,b)
    if s == 0:
        return l
    else:
        return gcd(s, l%s)

n = int(input())
a = [0] + list(map(int, input().split())) + [0]
max_gcd = 1
L = [0] * (n+2)
R = [0] * (n+2)

for i in range(1,n+2):
    L[i] = gcd(a[i],L[i-1])
    R[n+1-i] = gcd(a[n+1-i], R[n+2-i])
for i in range(1,n+1):
    max_gcd = max(max_gcd,gcd(L[i-1], R[i+1]))

print(max_gcd)
a,b = map(int(input()).split())
print(a*b)

### FIXED CODE ###

a,b = map(int,input().split())
print(a*b)
import numpy as np
import bisect
INF = 10 ** 9 + 7
N, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
aset = set(a)
bset = set(b)
ablst = [0] * ((N * M) + 1)
a.sort(), b.sort()

if len(aset) != len(a) or len(bset) != len(b):
    print(0)
    exit()

na = np.array(a)
nb = np.array(b)
for i in range(N):
    ablst[na[i]] += 1

for j in range(M):
    ablst[nb[j]] += 1
ans = 1
for i in range(N * M, 0, -1):
    ac = bisect.bisect_left(na, i)
    bc = bisect.bisect_left(nb, i)
    if ablst[i] == 2:
        ans *= 1
    elif ablst[i] == 1 and ac < N and na[ac] == i:
        ans *= (M - bc)
    elif ablst[i] == 1 and bc < M and nb[bc] == i:
        ans *= (N - ac)
    else:
        ans *= (N - ac) * (M - bc) - (N * M - i)
    ans %= INF
print(ans % INF)

### FIXED CODE ###

import bisect
INF = 10 ** 9 + 7
N, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
aset = set(a)
bset = set(b)
ablst = [0] * ((N * M) + 1)
a.sort(), b.sort()

if len(aset) != len(a) or len(bset) != len(b):
    print(0)
    exit()

for i in range(N):
    ablst[a[i]] += 1

for j in range(M):
    ablst[b[j]] += 1

ans = 1
for i in range(N * M, 0, -1):
    ac = bisect.bisect_left(a, i)
    bc = bisect.bisect_left(b, i)
    if ablst[i] == 2:
        ans *= 1
    elif ablst[i] == 1 and ac < N and a[ac] == i:
        ans *= (M - bc)
    elif ablst[i] == 1 and bc < M and b[bc] == i:
        ans *= (N - ac)
    else:
        acnt = bisect.bisect_left(a, i)
        bcnt = bisect.bisect_left(b, i)
        ans *= (N - ac) * (M - bc) - (N * M - i)
    ans %= INF
print(ans % INF)
from collections import defaultdict
x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)
dp = defaultdict(int)
dq = defaultdict(int)
dr = defaultdict(int)
ans = 0
ans += sum(p[:x])
ans += sum(q[:y])
pq = p[:x] + q[:y]
pq = sorted(pq)
for i in range(c):
  if pq[i] < r[i]:
    ans = ans - pq[i] + r[i]
print(ans)




### FIXED CODE ###

x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)

p = p[:x]
q = q[:y]
a = p + q + r 
a = sorted(a, reverse=True)
print(sum(a[:(x+y)]))
from operator import mul
from functools import reduce
 
def cmb(n,r):
    r = min(n-r,r)
    if r ==0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

inf = input().split()
N = int(inf[0])
K = int(inf[1])
M = N-K
for i in range(1,K+1):
  red = cmb(M+1,i)
  blue = cmb(K-1,i-1)
  print(red*blue%(10**9+7))


### FIXED CODE ###

from operator import mul
from functools import reduce
 
def cmb(n,r):
    r = min(n-r,r)
    if r==0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

inf = input().split()
N = int(inf[0])
K = int(inf[1])
M = N-K
for i in range(1,K+1):
  if M+1<i:
    red = 0
  else:
    red = cmb(M+1,i)
  blue = cmb(K-1,i-1)
  print(red*blue%(10**9+7))
import sys
sys.setrecursionlimit(10**7) #再帰関数の呼び出し制限
N, M = map(int, input().split())
A = [0]*(N+1)
for i in range(M):
    a, b = map(int, input().split())
    A[a].append([b])
    A[b].append([a])
visited=[1]+[0]*N
ans = 0
def DFS(x):
    if visited[x] == 1:
        return
    if sum(visited) == N:
        ans += 1
    visited[x] = 1
    for i in range(N):
        DFS(A[x][i])
    return ans
print(DFS(1))

### FIXED CODE ###


import itertools

N, M = map(int, input().split())
adj_matrix = [[0]* N for _ in range(N)]

for i in range(M): #隣接行列
    a, b = map(int, input().split())
    adj_matrix[a-1][b-1] = 1
    adj_matrix[b-1][a-1] = 1

cnt = 0

for each in itertools.permutations(range(N)):
    if each[0] != 0:
        break
    factor = 1
    for i in range(N-1):
        factor *= adj_matrix[each[i]][each[i+1]]
    cnt += factor

print(cnt)
a,b,c = input()
n = 0
for a in range(b):
    if c%a == 0 :
     n=n+1    
print(n)


### FIXED CODE ###

a,b,c = map(int,input().split())
n = 0
for i in range(a,b+1):
    if c%i == 0 :
     n = n+1
print(n)
def convert_binary(n):
    s = []
    while True:
        s.append(str(n % 2))
        n = int(n / 2)
        if n == 0:
            break
    return ''.join(s)[::-1]
 
def calc_xor(bs):
    maxlen = max([len(b) for b in bs])
    for i in range(len(bs)):
        bs[i] = '0' * (maxlen - len(bs[i])) + bs[i]
    s = ''
    for i in range(maxlen):
        if (sum([int(b[i]) for b in bs])) % 2 == 1:
            s += '1'
        else:
            s += '0'
    return s
 
def convert_decimal(binary):
    n = 0
    i = 0
    for b in binary[::-1]:
        n += (2 ** i) * int(b)
        i += 1
    return n
  
A, B = list(map(int, input().split(' ')))
 
print(convert_decimal(calc_xor([convert_binary(i) for i in list(range(A, B + 1))])))

### FIXED CODE ###

def convert_binary(n):
    if n == 0:
        return '0'
    s = []
    while True:
        s.append(str(n % 2))
        n = int(n / 2)
        if n == 0:
            break
    return ''.join(s)[::-1]
   
def calc_xor(b1, b2):
    maxlen = max(len(b1), len(b2))
    b1 = '0' * (maxlen - len(b1)) + b1
    b2 = '0' * (maxlen - len(b2)) + b2
    s = ''
    for i in range(maxlen):
        if (int(b1[i]) + int(b2[i])) % 2 == 1:
            s += '1'
        else:
            s += '0'
    return s
   
def convert_decimal(binary):
    n = 0
    i = 0
    for b in binary[::-1]:
        n += (2 ** i) * int(b)
        i += 1
    return n
 
def calc_xor_from_zero(n):
    if (n+1) % 2 == 0:
        count_pair = int((n+1) / 2)
        if count_pair % 2 == 0:
            return '0'
        else:
            return '1'
    else:
        count_pair = int((n+1) / 2)
        if count_pair % 2 == 0:
            return calc_xor('0', convert_binary(n))
        else:
            return calc_xor('1', convert_binary(n))
    
A, B = list(map(int, input().split(' ')))
 
print(convert_decimal(calc_xor(calc_xor_from_zero(A-1), calc_xor_from_zero(B))))
def minus_min(s):
  sum(s)-min(s)

n = int(input())
s = []
for i in range(n):
  s.append(input())

ss = sum(s)
if ss % 10 == 0:
  # sの中で10で割り切れない最小の数を引けば良い
  s.sort()
  m = [t for t in s if t%10!=0]
  if len(m) == 0:
    print(0)
   else:
    print(ss-min(m))


### FIXED CODE ###

n = int(input())
s = []
for i in range(n):
  s.append(int(input()))
 
ss = sum(s)
if ss % 10 == 0:
  # sの中で10で割り切れない最小の数を引けば良い
  s.sort()
  m = [t for t in s if t%10!=0]
  if len(m) == 0:
    print(0)
  else:
    print(ss-min(m))
else:
  print(ss)
N = int(input())
Hs = list(map(int, input().split()))
print(len([i for i in range(0, len(Hs)) if all(lambda j: Hs[j]<=Hs[j+1]), range(0, i)]))

### FIXED CODE ###

N = int(input())
Hs = list(map(int, input().split()))
print(len([i for i in range(0, len(Hs)) if all([Hs[j] <= Hs[i] for j in range(0, i)])]))
while 1:
	n = int(raw_input())
	if n == 0:
		break
	for i in range(n):
		x, y, z = map(int, raw_input())
		if y*z >= 1000000:
			print x
		else:
			print "NA"

### FIXED CODE ###

while True:
	n = int(raw_input())
	if n == 0:
		break
	data = {}
	order = []
	for i in range(n):
		id,price,quant = map(int, raw_input().split())
		if id in data:
			data[id] += price*quant
		else:
			data[id] = price*quant 
			order.append(id)
	if max(data.values()) <  1000000:
		print "NA"
	else:
		for k in order:
			if data[k] >=  1000000:
				print k
def add_or_do_nothing(s, i, pos):
    if i == len(s):
        pre_i = 0
        ans = 0
        for pos_i in pos:
            print(s[pre_i:pos_i], pre_i, pos_i)
            ans += int(s[pre_i:pos_i])
            pre_i = pos_i
        
        if pre_i == 0:
            ans = int(s)
        else:
            ans += int(s[pre_i:len(s)] if pre_i != len(s) else '0')
        return ans

    f_ans = add_or_do_nothing(s, i+1, pos)
    
    pos.append(i)
    s_ans = add_or_do_nothing(s, i+1, pos)
    
    return f_ans + s_ans

s = input()

pos = []
ans = add_or_do_nothing(s, 1, pos)

print(ans)

### FIXED CODE ###

def add_or_do_nothing(s, i, pos):
    if i == len(s):
        pre_i = 0
        ans = 0
        for i, pos_i in enumerate(pos, 1):
            if pos_i == '1':
                ans += int(s[pre_i:i])
                pre_i = i

        ans += int(s[pre_i:len(s)])
        return ans

    f_ans = add_or_do_nothing(s, i+1, pos+'0')
    s_ans = add_or_do_nothing(s, i+1, pos+'1')
    return f_ans + s_ans

s = input()

pos = ''
ans = add_or_do_nothing(s, 1, pos)

print(ans)
from numba import jit
@jit
def main():
    n,k = map(int,input().split())
    p = list(map(int,input().split()))
    c = list(map(int,input().split()))

    ans=-10**18
    for i in range(n):
        start,count=i,1
        val=c[start]
        while p[start]-1 != i:
            start = p[start]-1
            count += 1
            val += c[start]
        start = i
        if val > 0:
            a = (k//count-1)*val
            ans=max(a,ans)
            num=count+k%count
        else:
            a=0
            num=min(k,count)
        for _ in range(num):
            a += c[start]
            start=p[start]-1
            ans=max(a,ans)
    print(ans)
main()

### FIXED CODE ###

s=list(input())
count=0
for d in s:
    if d=="R":
        count += 1
if count == 2:
    if s[1]=="S":
        print(1)
    else:
        print(2)
else:
    print(count)
#D
import sys
sys.setrecursionlimit(10**7)
import sympy
n = int(input())

from functools import lru_cache

@lru_cache(maxsize=None)
def s(n,gokei):
    if n == 1:
        return gokei+1
    out = len(sympy.divisors(n))*n
    gokei += out
    return s(n-1,gokei)

print(s(n,0))

### FIXED CODE ###

#D
n = int(input())

ans = 0
for i in range(1,n+1):
    tmp = n // i
    ans += tmp * (i + n//i * i) // 2
    
print(ans)
N, K =map(int, input().split())

A = list(map(int, input().split()))
B = A*K

count=0
for i in range(N*K):
  for j in range(i, N*K):
    if B[i]>B[j]:
      count+=1

print(count)

### FIXED CODE ###

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

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

mod=10**9 +7
count=0
for i in range(N):
  for j in range(i+1, N):
    if A[i]>A[j]:
      count+=K
  for k in range(N):
    if A[i]>A[k]:
      count+=(K-1)*K//2
  

print(int(count%mod))
n, q = map(int, input().split())

ki = [[] for i in range(n + 1)]
for i in range(n - 1):
    a, b = map(int, input().split())
    ki[a].append(b)
    ki[b].append(a)
# print(ki)

cnt = [0] * (n + 1)
for i in range(q):
    p, x = map(int, input().split())
    cnt[p] += x
# print(cnt)


def d(y, parent):
    for i in ki[y]:
        if i == parent:
            continue
        cnt[i] += cnt[y]
        d(i, y)


d(1, -1)
print(*cnt[1:])


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
n, q = map(int, input().split())

ki = [[] for i in range(n + 1)]
for i in range(n - 1):
    a, b = map(int, input().split())
    ki[a].append(b)
    ki[b].append(a)
# print(ki)

cnt = [0] * (n + 1)
for i in range(q):
    p, x = map(int, input().split())
    cnt[p] += x


# print(cnt)


def d(y, parent):
    for i in ki[y]:
        if i == parent:
            continue
        cnt[i] += cnt[y]
        d(i, y)


d(1, -1)
print(*cnt[1:])
from math import factorial

def a(n,k):
  return factorial(n)//factorial(k)//factorial(n-k)

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

for i in range(k):
  print(a(n-k+1,i+1)*a(k-1,i)%mod)



### FIXED CODE ###

from math import factorial

def comb(a,b):
    return factorial(a) // factorial(b) // factorial(abs(a-b))

n, k = map(int, input().split())
for i in range(k):
    print(comb(k-1, i) * comb(n-k+1, i+1) % 1000000007)