Harryxun/stf_run huggingface dataset:
def func():
    N, k = map(int, input().split() )
    h = list( map(int,input().split()) )

    dp = [0] * N
    for n in range(1, N):
        # can_min = 10**4
        # for k in range(1,K+1l):
        #     if n-k >= 0 :
        #         can = dp[n-k] + abs(h[n]-h[n-k])
        #         can_min = min(can, can_min)
        # dp[n] = can_min 
        dp[n] = min([ dp[max(n-k, 0)] + abs(h[n]-h[max(n-k,0)]) for k in range(max(n-k,0)) ])
    print(dp[N-1])

if __name__=='__main__':
    func()





### FIXED CODE ###



def func():
    N, k = map(int, input().split() )
    h = list( map(int,input().split()) )

    dp = [float('inf')] * N
    dp[0] = 0
    for n in range(1, N):
        # can_min = 10**4
        # for k in range(1,K+1l):
        #     if n-k >= 0 :
        #         can = dp[n-k] + abs(h[n]-h[n-k])
        #         can_min = min(can, can_min)
        # dp[n] = can_min 
        dp[n] = min([ dp[j] + abs(h[n]-h[j]) for j in range(max(n-k,0), n) ])
    print(dp[N-1])

if __name__=='__main__':
    func()
import collections
n, m = [int(i) for i in input().split()]
todc = collections.defaultdict(lambda: [])
lendc = collections.defaultdict(lambda: -1)

for k in range(m):
    i, j = input().split()
    todc[int(j)] += [int(i)]

def maxlen(n):
    if len(todc[n]) == 0:
        lendc[n] = 0
        return 0
    else:
        m = 0
        for i in todc[n]:
            if lendc[i] == -1:
                lendc[i] = maxlen(i)
            m = max(m, lendc[i]+1)
        return m

k = 0
for i in range(1, n+1):
    if lendc[i] == -1:
        lendc[i] = maxlen(i)
    k = max(k, lendc[i])
print(k)

### FIXED CODE ###

import collections
n, m = [int(i) for i in input().split()]
todc = collections.defaultdict(lambda: [])
lendc = collections.defaultdict(lambda: -1)


for k in range(m):
    i, j = [int(n) for n in input().split()]
    todc[j] += [i]


def maxlen(n):
    if len(todc[n]) == 0:
        lendc[n] = 0
        return 0
    else:
        m = 0
        for i in todc[n]:
            if lendc[i] == -1:
                lendc[i] = maxlen(i)
            m = max(m, lendc[i]+1)
        return m
       

def maxlen_stack(org_n):
    stack = [org_n]
    while stack:
        n = stack.pop()
        if len(todc[n]) == 0:
            lendc[n] = 0
        else:
            m = 0
            recursive = []
            for i in todc[n]:
                if lendc[i] == -1:
                    recursive.append(i)
                else:
                    m = max(m, lendc[i]+1)
            if recursive:
                stack += [n] + recursive
            else:
                lendc[n] = m         
    return lendc[org_n]

k = 0
for i in range(1, n+1):
    if lendc[i] == -1:
        #lendc[i] = maxlen(i)
        lendc[i] = maxlen_stack(i)
    k = max(k, lendc[i])
print(k)
def coin(a, b, c):

    global count
    global m

    if a % c[0] == 0:

        count = min(count, b + a // c[0])

        return count

    elif b + a // c[0] >= count:

        return n

    elif c[0] < n:

        return min(coin(a - c[0], b + 1, c), coin(a, b, c[1:]))

    else:

        return coin(a, b, c[1:])


n, m = map(int, input().split())

money = sorted(list(map(int, input().split())), reverse = True)

count = n

print(coin(n, 0, money))



### FIXED CODE ###

def coin(n, p, c):
    global count
    global m
    if n % c[0] == 0:
        count = min(count, p + n // c[0])
        return count
    elif p + n // c[0] >= count:
        return n
    elif c[0] < n:
        return min(coin(n - c[0], p + 1, c), coin(n, p, c[1:]))
    else:
        return coin(n, p, c[1:])

n, m = map(int, input().split())

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

mon.sort(reverse = True)

count = n

print(coin(n, 0, mon))
n = int(input())
x＝list(map(int, input().split()))
y = []
for i in range(n):
  if x[i]>x[i+1]:
    y.append(x[i]-1)
  else:
    y.append(x[i])
for j in range(n):
  if y[j]>y[j+1]:
    print("No")
    exit()
print("Yes")

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
m = 0
for i in range(n):
  m = max(m,a[i])
  if a[i] < m-1:
    print("No")
    exit()
print("Yes")
a, b = input().split
if a > b:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

a, b = input().split()
if a == b:
  print("Yes")
else:
  print("No")
order = list(input())
X, Y = map(int, input().split())

Xs = []
Ys = []
now_lis = Xs
cnt = 0
for s in order:
    if s=='T':
        now_lis.append(cnt)
        now_lis = Ys if now_lis==Xs else Xs
        cnt = 0
    else:
        cnt += 1
now_lis.append(cnt)
lx = len(Xs)
ly = len(Ys)

def dp(length, lis, goal):
    M = sum(lis)
    dp = [[0]*(M*2) for _ in range(length+1)]
    dp[0][M] = 1
    for i, x in enumerate(lis, 1):
        for j in range(M*2):
            if dp[i-1][j]==1:
                if not (j+x>=M*2 or j+x<0):
                    dp[i][j+x] = 1
                if not (j-x<0 or j-x>=M*2):
                    dp[i][j-x] = 1
    return dp[-1][goal+M]

if dp(lx, Xs, X) and dp(ly, Ys, Y):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

order = list(input())
X, Y = map(int, input().split())
 
Xs = []
Ys = []
cnt = 0
now_lis = Xs
x_dir = 1
for s in order:
    if s=='T':
        if not cnt==0:
            now_lis.append(cnt)
        now_lis = Ys if x_dir else Xs
        x_dir = not x_dir
        cnt = 0
    else:
        cnt += 1
if not cnt==0:
    now_lis.append(cnt)

if order[0]=='T':
    x_start = 0
else:
    x_start = Xs[0]
    del Xs[0]

def dp(start, lis, goal):
    nodes = set([start])
    for x in lis:
        nx = set()
        L = list(nodes)
        for l in L:
            nx.add(l+x)
            nx.add(l-x)
        nodes = nx
    return goal in nodes
 
if dp(x_start, Xs, X) and dp(0, Ys, Y):
    print('Yes')
else:
    print('No')
def main():
    N= int(input())
    A= int(input())
    B= int(input())

    if N==1:
        print("Hello World") 
    else:
        print(A+B)
        
main()

### FIXED CODE ###

def main():
    N= int(input())
    if N==1:
        print("Hello World") 
    else:
        A= int(input())
        B= int(input())
        print(A+B)

        
main()
n, k = map(int, input().split())
s = input() # str

zero_positions = []
flag = False
zeros = []
for i in range(n):
    if s[i] == '0':
        zeros.append(i)
        flag = True
    if s[i] == '1' and flag:
        flag = False
        zero_positions.append(zeros)
        zeros = []
if zeros != []:
    zero_positions.append(zeros)

def get_one_positions(s):
    one_positions_len = []
    flag = False
    ones_len = 0
    for i in range(n):
        if s[i] == '1':
            ones_len += 1
            flag = True
        if s[i] == '0' and flag:
            flag = False
            one_positions_len.append(ones_len)
            ones_len = 0
    if ones_len != []:
        one_positions_len.append(ones_len)
    return(max(one_positions_len))

one_positions_lens = []
for i in range(len(zero_positions) - k + 1):
    choice = []
    for j in range(k):
        choice.extend(zero_positions[i + j])

    # reverse
    s_new = []
    for l in range(n):
        if l in choice:
            s_new.append('1')
        elif s[l] == '1':
            s_new.append('1')
        elif s[l] == '0':
            s_new.append('0')


    # count
    one_positions_len = get_one_positions(s_new)
    one_positions_lens.append(one_positions_len)

print(max(one_positions_lens))


### FIXED CODE ###

n, k = map(int, input().split())
s = input()

counts = []
tmp = []
for i in range(len(s)):
    if tmp == []:
        tmp = [s[i], 1]
    else:
        if tmp[0] == s[i]:
            tmp[1] += 1
        else:
            counts.append(tmp)
            tmp = [s[i], 1]
if tmp:
    counts.append(tmp)

zero_ints = 0
for char, count in counts:
    if char == '0':
        zero_ints += 1

if counts[0][0] == '0':
    left = 0
else:
    left = 1
right = left - 2

used = 0
l = 0
for char, count in counts:
    if char == '0':
        if used < k:
            used += 1
            right += 2
        else:
            break
    l += count

ans = l
for i in range(zero_ints):
    l = l - counts[left][1]
    if left - 1 >= 0:
        l-= counts[left - 1][1]
    if right + 2 < len(counts):
        l += counts[right + 2][1]
    if right + 3 < len(counts):
        l += counts[right + 3][1]
    ans = max(ans, l)
    left += 2
    right += 2
    # print(left, right, l)
print(ans)
def li():
    return [int(x) for x in input().split()]

N, K = li()
P = [0] + li()
C = [0] + li()

def get_cycle(start_i):
    cycle = []
    i = start_i
    while True:
        i = P[i]
        if i == start_i:
            break
        cycle.append(i)
    cycle.append(start_i)
    return cycle

def get_cycle_scores(cycle):
    score = 0
    scores = [score]
    for i in cycle:
        score += C[i]
        scores.append(score)
    return scores

max_scores = []
for start_i in range(1,N+1):
    cycle = get_cycle(start_i)
    scores = get_cycle_scores(cycle)
    cycle_len = len(cycle)
    score_per_cycle = scores[cycle_len]
    # 1cycle以下の場合は全て調べればよし
    # または、1サイクルごとのスコアがマイナスならサイクルを回らないのがハイスコア
    if K <= len(cycle) or score_per_cycle <= 0:
        max_score = max(scores[move] for move in range(1, K+1))
        max_scores.append(max_score)
        continue
    # 1サイクルごとのスコアがプラスなら限界までサイクルを回るのがハイスコア
    # ラスト1cycleのスコアを調べる
    scores_last_cycle = []
    for move in range(K-cycle_len+1, K+1):
        # 何周したか
        loop_cnt = move // cycle_len
        # あまり
        rest_move = move % cycle_len
        # スコア = 1周ごとのスコア * 何周したか + あまり
        score = loop_cnt * score_per_cycle + scores[rest_move]
        scores_last_cycle.append(score)

    max_scores.append(max(scores_last_cycle))

print(max(max_scores))



### FIXED CODE ###

def li():
    return [int(x) for x in input().split()]

N, K = li()
P = [0] + li()
C = [0] + li()

def get_cycle(start_i):
    cycle = []
    i = start_i
    while True:
        i = P[i]
        if i == start_i:
            break
        cycle.append(i)
    cycle.append(start_i)
    return cycle

def get_cycle_scores(cycle):
    score = 0
    scores = [score]
    for i in cycle:
        score += C[i]
        scores.append(score)
    return scores

max_scores = []
for start_i in range(1,N+1):
    cycle = get_cycle(start_i)
    scores = get_cycle_scores(cycle)
    cycle_len = len(cycle)
    score_per_cycle = scores[cycle_len]
    # 1cycle以下の場合は全て調べればよし
    if K <= len(cycle):
        max_score = max(scores[move] for move in range(1, K+1))
        max_scores.append(max_score)
        continue
    # 1サイクルごとのスコアがマイナスならサイクルを回らないのがハイスコア
    if score_per_cycle <= 0:
        max_score = max(scores[move] for move in range(1, cycle_len+1))
        max_scores.append(max_score)
        continue
    # 1サイクルごとのスコアがプラスなら限界までサイクルを回るのがハイスコア
    # ラスト1cycleのスコアを調べる
    scores_last_cycle = []
    for move in range(K-cycle_len+1, K+1):
        # 何周したか
        loop_cnt = move // cycle_len
        # あまり
        rest_move = move % cycle_len
        # スコア = 1周ごとのスコア * 何周したか + あまり
        score = loop_cnt * score_per_cycle + scores[rest_move]
        scores_last_cycle.append(score)

    max_scores.append(max(scores_last_cycle))

print(max(max_scores))
N = int(input())
S = [int(x) for x in input().split()]
if 'Y' in S:
  print("Four")
else:
  print("Three")
  

### FIXED CODE ###

N = int(input())
S = [x for x in input().split()]
if 'Y' in S:
  print("Four")
else:
  print("Three")
def logic(S, K):
    if len(S) == 1:
        return int(S)
    if S[0:5] == "11111":
        return 1
    a = S.replace("1", "")
    return int(a[0])


if __name__ == '__main__':
    print(logic(input(), input()))


### FIXED CODE ###

def logic(S, K):
    if len(S) == 1:
        return int(S)
    if S[0:int(K)].replace("1","") == "":
        return 1
    a = S.replace("1", "")
    if len(a) == 0:
        return 1
    return int(a[0])


if __name__ == '__main__':
    print(logic(input(), input()))
x, y, a, b, c = map(int, input().split())
arrayP = list(input().split())
arrayQ = list(input().split())
arrayR = list(input().split())
arrayP.sort(reverse=True)
arrayQ.sort(reverse=True)
arrayR.sort(reverse=True)
arrayAns = []
for i in range(x):
    arrayAns.append(int(arrayP[i]))
for i in range(y):
    arrayAns.append(int(arrayQ[i]))
arrayAns.sort()
for i in range(len(arrayR)):
    if arrayAns[0] <= int(arrayR[i]):
        arrayAns[0] = int(arrayR[i])
        arrayAns.sort()
print(sum(arrayAns))

### FIXED CODE ###

s = input()
if s[2] == s[3]:
    if s[4] == s[5]:
        print("Yes")
    else:
        print("No")
else:
    print("No")
X, Y, Z, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
A = sorted([int(x) for x in A], reverse=True)
B = sorted([int(x) for x in B], reverse=True)
C = sorted([int(x) for x in C], reverse=True)

res = []
i, j, k = 0, 0, 0
while len(res) < K:
  res.append(A[i]+B[j]+C[k])
  res.append(A[i+1]+B[j]+C[k])
  res.append(A[i]+B[j+1]+C[k])
  res.append(A[i]+B[j]+C[k+1])
  i,j,k = i+1, j+1, k+1
res = sorted(res, reverse=True)[:K]
for i in res:
  print(i)

### FIXED CODE ###

from heapq import *

X, Y, Z, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
A = sorted([int(x) for x in A], reverse=True)
B = sorted([int(x) for x in B], reverse=True)
C = sorted([int(x) for x in C], reverse=True)

res = []
memo = []
ans = []
heappush(res, (-A[0]-B[0]-C[0], 0, 0, 0))
while len(ans) < K:
  e, i, j, k = heappop(res)
  ans.append(-e)
  if i+1 < X and [i+1, j, k] not in memo:
    heappush(res, (-A[i+1]-B[j]-C[k], i+1, j, k))
    memo.append([i+1, j, k])
  if j+1 < Y and [i, j+1, k] not in memo:
    heappush(res, (-A[i]-B[j+1]-C[k], i, j+1, k))
    memo.append([i, j+1, k])
  if k+1 < Z and [i, j, k+1] not in memo:
    heappush(res, (-A[i]-B[j]-C[k+1], i, j, k+1))
    memo.append([i, j, k+1])

for i in ans:
  print(i)
import sys

def debug(*args):
    print(*args, file=sys.stderr)


x_diff_of_5th_factor = int(input())


for a in range(-119, 118):
    for b in range(-118, 119):
        if a ** 5 - b ** 5 == x_diff_of_5th_factor:
            print('{} {}'.format(a, b))
            sys.exit(0)

sys.exit(1)


### FIXED CODE ###

import sys

def debug(*args):
    print(*args, file=sys.stderr)


x_diff_of_5th_factor = int(input())


for a in range(-118, 119):
    for b in range(-119, 118):
        if a ** 5 - b ** 5 == x_diff_of_5th_factor:
            print('{} {}'.format(a, b))
            sys.exit(0)

sys.exit(1)
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
import math
input_line = input().split()

N = int(input_line[0])
M = int(input_line[1])
counter = 0 

counter = math.factorial(N) / math.factorial(N - 2)* math.factorial(2) + math.factorial(M) / math.factorial(M - 2)* math.factorial(2)
        
print(combinations_count(N,2)+ combinations_count(M,2))



### FIXED CODE ###

import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
input_line = input().split()

N = int(input_line[0])
M = int(input_line[1])
counter = 0 
if N > 1:
    counter += combinations_count(N,2) 
if M > 1:
    counter += combinations_count(M,2)
        
print(counter)
s = input()
t = set(s)
if len(t) == 2 and s.count(list(t[0])) == 2:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

s = input()
t = set(s)
if len(t) == 2 and s.count(list(t)[0]) == 2:
  print("Yes")
else:
  print("No")
# -*- coding: utf-8 -*-
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


n, k = map(int, input().split())
red_n = n - k + 1

const = 1000000007

for i in range(1, k+1, 1):
    cnt = cmb(red_n, i) * cmb(k-1, i-1)
    print(cnt % const)


### FIXED CODE ###

# -*- coding: utf-8 -*-
from operator import mul
from functools import reduce

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


n, k = map(int, input().split())
red_n = n - k + 1

const = 1000000007

for i in range(1, k+1, 1):
    cnt = cmb(red_n, i) * cmb(k-1, i-1)
    print(cnt % const)
r = float(input())

s = r * r * math.pi
l = r * 2 * math.pi

print("{0:5f}{1:.5f}".format(s, l))

### FIXED CODE ###

import math
r = float(input())

s = r * r * math.pi
l = (r + r)* math.pi

print('%.5f %.5f' % (s, l))
import numpy as np
import math
N,M = map(int,input().split())
ls = []
for n in range(N):
  ls.append(list(map(int,input().split())))
ls = np.array(ls)
idx = np.argsort(ls[:,1])[::-1]
#print (ls[idx])
days = list(range(1,M+1))
days = {k: 0 for k in days}
#print (days)
sum = 0
for work in ls[idx]:
  d = work[0]
  while(d<=M):
    if d in days:
      sum+=work[1]
      days.pop(d)
      d=M+1
    else:
      d+=1
print (sum)
  
    

### FIXED CODE ###

import heapq
N,M = map(int,input().split())
ls = []
h = []
ans = 0
for n in range(N):
    ls.append(list(map(int,input().split())))
ls = sorted(ls,key=lambda ls:ls[0],reverse=False)
n = 0
for m in range(1,M+1):
    #print (m)
    while(n<N and ls[n][0]<=m ):
        heapq.heappush(h, -ls[n][1])
        n+=1
    if len(h)>0:
        ans -= heapq.heappop(h)
        # print (m,ans)
print (ans)
import numpy as np
from itertools import product

N, M = map(int, input().split())
S = np.zeros((M, N))  # (M, N), switch

for i in range(M):
    k, *s = map(int, input().split())
    s = [x - 1 for x in s]
    S[i, s] = 1
p = np.array(list(map(int, input().split())), dtype=np.int)

cnt = 0
for i in product([0, 1], repeat=N):
    a = np.array(i, dtype=np.int)  # N,
    b = (np.dot(S, a) % 2).astype(np.int)
    if np.all(b == p):
        cnt += 1
print(cnt)

### FIXED CODE ###

import numpy as np
from itertools import product

N, M = map(int, input().split())
S = np.zeros((M, N))  # (M, N), switch

for i in range(M):
    k, *s = map(int, input().split())
    s = [x - 1 for x in s]
    S[i, s] = 1
p = np.array(list(map(int, input().split())), dtype=np.int)

cnt = 0
for i in product([0, 1], repeat=N):
    a = np.array(i, dtype=np.int)  # N,
    b = (np.dot(S, a) % 2).astype(np.int)
    if np.all(b == p):
        cnt += 1
print(cnt)
n,k = map(int,input().split())
sunuke = []
for _ in range(int(input())):
    tmp = [int(s) for s in input().split()]
    for i in range(len(tmp)):
        sunuke.append(tmp[i])
print(n - len(set(sunuke)))

### FIXED CODE ###

n,k = map(int,input().split())
sunuke = []
for _ in range(k):
    d = input()
    tmp = [int(s) for s in input().split()]
    for i in range(len(tmp)):
        sunuke.append(tmp[i])

print(n - len(set(sunuke)))
from collections import Counter

#input
N,K = list(map(int,input().split()))
R,S,P = list(map(int,input().split()))

T = list(input())
T_ =T.copy()

# N=2*10**5
# T=[random.choice(['s', 'r', 'p']) for _ in range(N)]

check=set(['s', 'r', 'p'])

#得点
point={'r':P,'s':R,'p':S}
point

T_point = [0]*N
for n in range(N):
    T_point[n]=point[T[n]]
    
for k in range(K,N):
    check_out = set()
    if T[k] == T[k-K]: # K回前の手と同じ場合
        check_out.add(T[k])
        if k+K <= N:
            check_out.add(T[k+K])
            
        check_out=check-check_out
        
        T[k]=list(check_out)[0]
         
ans=0

for t in range(len(T)):
    if T[t] == T_[t]:
        ans += point[T[t]]
print(ans)

### FIXED CODE ###

from collections import Counter

#input
N,K = list(map(int,input().split()))
R,S,P = list(map(int,input().split()))

T = list(input())
T_ =T.copy()

# N=2*10**5
# T=[random.choice(['s', 'r', 'p']) for _ in range(N)]

check=set(['s', 'r', 'p'])

#得点
point={'r':P,'s':R,'p':S}
point

T_point = [0]*N
for n in range(N):
    T_point[n]=point[T[n]]
    
for k in range(K,N):
    check_out = set()
    if T[k] == T[k-K]: # K回前の手と同じ場合
        check_out.add(T[k])
        if k+K < N:
            check_out.add(T[k+K])
            
        check_out=check-check_out
        
        T[k]=list(check_out)[0]
         
ans=0

for t in range(len(T)):
    if T[t] == T_[t]:
        ans += point[T[t]]
print(ans)
S = list(input())
L = list('keyence')
if len(L) > len(S):
	print('NO')
else:
    while L[0] == S[0]:
        L = L[1:]
        S = S[1:]
    while len(L) != 0 and L[-1] == S[-1]:
        L = L[:-1]
        S = S[:-1]
    if L == []:
        print('YES')
    else:
        print('NO')

### FIXED CODE ###

S = list(input())
L = list('keyence')
while len(L)*len(S) > 0 and L[0] == S[0]:
    del L[0]
    del S[0]
while len(L)*len(S) > 0 and L[-1] == S[-1]:
    del L[-1]
    del S[-1]
if L == []:
    print('YES')
else:
    print('NO')
import numpy as np
N = int(input())
data = np.zeros((N,3))
for i in range(N):
    data[i] = np.array(input().split())

for n in range(10201):
    C_x = n // 101
    C_y = n % 101
    correctflg = True
    unsetflg = True
    for i,(x,y,h) in enumerate(data):
        if unsetflg:
            if h >= 1:
                H = abs(x-C_x)+abs(y-C_y)+h
                unsetflg = False
        else:
            if h >= 1 and H != abs(x-C_x)+abs(y-C_y)+h:
                correctflg = False
                break 
    if correctflg:
        print(C_x,C_y,int(H))
        break
    
            
            


### FIXED CODE ###

N = int(input())
if N == 1:
    print("Hello World")
else:
    A = int(input())
    B = int(input())
    print(A+B)
import numpy as np

N, K = map(int,input().split())
MOD = 10**9+7

# dp[i][j][k]:
# ウサギ1~i, カメ1~i (うちj個は相手が未定)まで見ていて，
# 確定している奇妙さがkであるような場合の数
dp = np.zeros((55,55,55*55), dtype='int64')
dp[0][0][0] = 1

for i in range(N+1):
    for j in range(N+1):
        for k in range(N*N+1):
            if k-2*j < 0 or i-1 < 0: continue

            dp[i][j][k] += (2*j+1) * dp[i-1][j][k-2*j] % MOD
            dp[i][j][k] %= MOD

            dp[i][j][k] += (j+1)*(j+1) * dp[i-1][j+1][k-2*j] % MOD
            dp[i][j][k] %= MOD

            if j > 0:
                dp[i][j][k] += dp[i-1][j-1][k-2*j]
                dp[i][j][k] %= MOD
            
print(dp[N][0][K])

### FIXED CODE ###

N, K = map(int,input().split())
MOD = 10**9+7

# dp[i][j][k]:
# ウサギ1~i, カメ1~i (うちj個は相手が未定)まで見ていて，
# 確定している奇妙さがkであるような場合の数
dp = []
for _ in range(55):
    dp.append([[0] * (55*55) for _ in range(55)])

dp[0][0][0] = 1

for i in range(N+1):
    for j in range(N+1):
        for k in range(N*N+1):
            if k-2*j < 0 or i-1 < 0: continue

            dp[i][j][k] += (2*j+1) * dp[i-1][j][k-2*j] % MOD
            dp[i][j][k] %= MOD

            dp[i][j][k] += (j+1)*(j+1) * dp[i-1][j+1][k-2*j] % MOD
            dp[i][j][k] %= MOD

            if j > 0:
                dp[i][j][k] += dp[i-1][j-1][k-2*j]
                dp[i][j][k] %= MOD
            
print(dp[N][0][K])
import numpy as np
N=int(input())
A=list(map(int, input().split()))
A=np.array(A)
left=0 
right=N-1
while left<right:
  ans=0
  mid=(left+right)//2
  if A[:mid+1].sum()<A[mid+1:].sum():
    ans=min(ans,A[:mid+1].sum()<A[mid+1:])
    left=mid+1
  else:
    right=mid
print(ans)

### FIXED CODE ###

import numpy as np
N=int(input())
A=list(map(int, input().split()))
A=np.array(A)
left=0 
right=N-1
while left<right:
  mid=(left+right)//2
  if A[:mid+1].sum()<A[mid+1:].sum():
    left=mid+1
  else:
    right=mid
if (abs(A[:left+1].sum()-A[left+1:].sum()))>(abs(A[:left].sum()-A[left:].sum())):
  print((abs(A[:left].sum()-A[left:].sum())))
else:
  print((abs(A[:left+1].sum()-A[left+1:].sum())))