Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import itertools
n, g = map(int, input().split())
L = []
for i in range(n):
    t = list(map(int, input().split()))
    # 得点の情報を追加
    t.append((i+1)*100)
    L.append(t)

ans = 100 * n
for v in itertools.permutations(L):
    # print(v)
    score = 0
    count = 0
    k = 0
    p = v[k][0]
    while score < g:
        score += v[k][2]
        p -= 1
        count += 1
        if p == 0:
            score += v[k][1]
            k += 1
            if k < n:
                p = v[k][0]
        # print(v,count,score,k,p)
    ans = min(ans, count)
print(ans)

# ミス
# P = []
# G = []
# for i in range(n):
#     s, t = map(int, input().split())
#     P.insert(0, s)
#     G.insert(0, t//100)
# score = 0
# k = 0
# count = 0
# while score < g:
#     count += 1
#     if 1 in P:
#         j = P.index(1)
#         score += n-j + G[j]
#         P[j] = 0
#         if j == k:
#             k += 1
#     else:
#         score += n-k
#         P[k] -= 1
#     print(P,G,score,count,k)
# print(count)

### FIXED CODE ###

import itertools
n, g = map(int, input().split())
L = []
for i in range(n):
    t = list(map(int, input().split()))
    # 配点
    t.append((i+1)*100)
    # この配点の問題を全部解いた時の得点
    t.append((i+1)*100*t[0]+t[1])
    L.append(t)
# print(L)

ans = g//100
# https://img.atcoder.jp/abc104/editorial.pdf bit全探索
for i in range(2**n):
    count = 0
    score = 0
    m = 0
    for j in range(n):
        if (i >> j) & 1:
            score += L[j][3]
            count += L[j][0]
        else:
            m = j
    # print(bin(i), m, score, count)
    if score >= g:
        ans = min(ans, count)
    else: # 解いていない配点の問題の中で一番配点が高いもの
        if (g - score)/L[m][2] <= L[m][0] and (g - score)%L[m][2] == 0:
            count += (g - score)//L[m][2]
        elif (g - score)/L[m][2] + 1 <= L[m][0]:
            count += ((g - score)//L[m][2])+1
        else:
            count = g//100
        ans = min(ans, count)
    # print(bin(i), m, L[m], score, count)
print(ans)

# 全探索したら時間超過
# ans = 100 * n
# for v in itertools.permutations(L):
#     score = 0
#     count = 0
#     k = 0
#     p = v[k][0]
#     while score < g:
#         score += v[k][2]
#         p -= 1
#         count += 1
#         if p == 0:
#             score += v[k][1]
#             k += 1
#             if k < n:
#                 p = v[k][0]
#     ans = min(ans, count)
# print(ans)

# DPっぽく解こうとしたけど失敗
# P = []
# G = []
# for i in range(n):
#     s, t = map(int, input().split())
#     P.insert(0, s)
#     G.insert(0, t//100)
# score = 0
# k = 0
# count = 0
# while score < g:
#     count += 1
#     if 1 in P:
#         j = P.index(1)
#         score += n-j + G[j]
#         P[j] = 0
#         if j == k:
#             k += 1
#     else:
#         score += n-k
#         P[k] -= 1
#     print(P,G,score,count,k)
# print(count)
### BUGGY CODE ###

import numpy as np
h,w,k=map(int,input().split())
s=np.array([list(map(int,list(input()))) for _ in range(h)])
def func(catyoko):
  cattate=0
  past=np.array([0]*10)
  now=np.array([0]*10)
  for wi in range(w):
    for i in range(1,len(catyoko)):
      now[i-1]=sum(s[catyoko[i-1]:catyoko[i],wi])
    if max(past+now)>k:
      if max(now)>k:
        return -10
      else:
        cattate+=1
      past=now.copy()
    else:
      past+=now
  return cattate+len(catyoko)-2

# 横方向の割り方は2^(h-1)通りある。h<=10なので横方向の割り方は全探索する。
# 縦方向の割り方は貪欲法
ans=h+w
for i in range(2**(h-1)):
  catyoko=[0]
  for j in range(h-1):
    if ((i>>j) & 1):#立っているビットのところで処理が走る
      catyoko.append(j+1)
  catyoko.append(h)
  a=func(catyoko)
  #print(a,catyoko)
  if a>=0:
    ans=min(ans,a)
print(ans)


### FIXED CODE ###

h,w,k=map(int,input().split())
s=[list(map(int,list(input()))) for _ in range(h)]
def func(catyoko):
  cattate=0
  past=[0]*10
  for wi in range(w):
    now=[0]*10
    for i in range(1,len(catyoko)):
      for j in range(catyoko[i-1],catyoko[i]):
        now[i-1]+=s[j][wi]
    if max([past[i]+now[i] for i in range(10)])>k:
      if max(now)>k:
        return -10
      else:
        cattate+=1
      past=[nowi for nowi in now]
    else:
      for i in range(10):
        past[i]+=now[i]
  return cattate+len(catyoko)-2

# 横方向の割り方は2^(h-1)通りある。h<=10なので横方向の割り方は全探索する。
# 縦方向の割り方は貪欲法
ans=h+w
for i in range(2**(h-1)):
  catyoko=[0]
  for j in range(h-1):
    if ((i>>j) & 1):#立っているビットのところで処理が走る
      catyoko.append(j+1)
  catyoko.append(h)
  a=func(catyoko)
  #print(a,catyoko)
  if a>=0:
    ans=min(ans,a)
print(ans)
### BUGGY CODE ###

import numpy as np
H,N=map(int, input().split())
M=[]
for i in range(N):
    a,b=map(int, input().split())
    M.append((a,b))

dp=[np.inf]*(H+1)
dp[0]=0
for i in range(1,H+1):
    sub=np.inf
    for j in range(N):
        a,b=M[j]
        if i-a>=0:
            sub=min(dp[i-a]+b,sub)
        else:
            sub=min(b,sub)
    dp[i]=sub

print(dp[H])
#print(dp)

### FIXED CODE ###

import numpy as np
H, N=map(int, input().split())
A=[]
B=[]
for i in range(N):
  a,b=map(int, input().split())
  A.append(a)
  B.append(b)
A=np.array(A)
B=np.array(B)
#n番目を1回は使う時の魔力最小値
dp=np.zeros((H+A.max()))
for i in range(1,H+1):
  dp[i]=(dp[i-A]+B).min()
  

      
      
print(int(dp[H]))
### BUGGY CODE ###

N = int(input())
for h in range(1,3501):
    for n in range(1,3501):
        try:
            tmp = n*h*N / ( 4*h*n - N*n - N* h)
        except:
            continue
        if tmp == tmp//1 and tmp > 0:
            print(h,n,int(tmp))
            exit()

### FIXED CODE ###

N = int(input())
for h in range(1,3501):
    for n in range(1,3501):
        try:
            tmp = n*h*N / ( 4*h*n - N*n - N* h)
        except:
            continue
        if tmp == tmp//1 and tmp > 0:
            print(h,n,int(tmp))
            exit()
### BUGGY CODE ###

# seishin.py
N = int(input())
*X, = map(int, input().split())
L = int(input())

K = 318

D = [[N]*(K+1) for i in range(N)]
j = N-1
for i in range(N-1, -1, -1):
    while j > 0 and X[j] - X[i] > L:
        j -= 1
    D[i][0] = j
for k in range(K):
    for i in range(N):
        if D[i][k] != N:
            D[i][k+1] = D[D[i][k]][k]
def solve(a, b):
    if not a < b:
        a, b = b, a
    res = 1
    for k in range(K, -1, -1):
        if D[a][k] < b:
            a = D[a][k]
            res += 2**k
    return res
Q = int(input())
ans = []
for i in range(Q):
    a, b = map(int, input().split())
    ans.append(solve(a-1, b-1))
print(*ans, sep='\n')

### FIXED CODE ###

# seishin.py
N = int(input())
*X, = map(int, input().split())
L = int(input())

K = 20

D = [[N]*(K+1) for i in range(N)]
j = N-1
for i in range(N-1, -1, -1):
    while j > 0 and X[j] - X[i] > L:
        j -= 1
    D[i][0] = j
for k in range(K):
    for i in range(N):
        if D[i][k] != N:
            D[i][k+1] = D[D[i][k]][k]
def solve(a, b):
    if not a < b:
        a, b = b, a
    res = 1
    for k in range(K, -1, -1):
        if D[a][k] < b:
            a = D[a][k]
            res += 2**k
    return res
Q = int(input())
ans = []
for i in range(Q):
    a, b = map(int, input().split())
    ans.append(solve(a-1, b-1))
print(*ans, sep='\n')
### BUGGY CODE ###

import sys
sys.setrecursionlimit(2000000000)
N = int(input())
import math
l = [int(x) for x in input().split()]
tobi = [0]*(math.ceil(N/2))
tobi[0] = l[0]
for i in range(1,math.ceil(N/2)):
    tobi[i] = tobi[i-1] + l[i*2]
def motomeru(x,y):
    if y == 0 or x == 0 or x == 1:
        return 0
    elif x % 2 == 0:
        return max(motomeru(x-2,y-1)+l[x-1],tobi[math.floor((x-1)/2)])
    else:
        return max(motomeru(x-2,y-1)+l[x-1],motomeru(x-1,y))
print(motomeru(N,N//2))

### FIXED CODE ###

import sys
sys.setrecursionlimit(2000000000)
N = int(input())
import math
l = [int(x) for x in input().split()]
tobi = [0]*(math.ceil(N/2))
tobi[0] = l[0]
for i in range(1,math.ceil(N/2)):
    tobi[i] = tobi[i-1] + l[i*2]
from functools import lru_cache
@lru_cache(maxsize=1000000000)
def motomeru(x,y):
    if y == 0 or x == 0 or x == 1:
        return 0
    elif x % 2 == 0:
        return max(motomeru(x-2,y-1)+l[x-1],tobi[math.floor((x-1)/2)])
    else:
        return max(motomeru(x-2,y-1)+l[x-1],motomeru(x-1,y))
print(motomeru(N,N//2))
### BUGGY CODE ###

N, M, K = map(int, input().split())
friend = [[] for _ in range(N+1)]
block = [[] for _ in range(N+1)]

for i in range(M):
  A,B = map(int, input().split())
  friend[A].append(B)
  friend[B].append(A)

for i in range(K):
  C,D = map(int, input().split())
  block[C].append(D)
  block[D].append(C)
#print(friend)
#print(block)

import queue
grouping = [False]*(N+1)
#print(grouping)
grouping[0] = True
groups = []
while False in grouping:
  for i in range(1,N):
    if grouping[i] == False:
      p = i
      break
  #print(p)
  visited = [False]*(N+1)
  group = [p]
  visited[p],grouping[p] =True,True
  q = queue.Queue()
  q.put(p)
  while not q.empty():
    #print('v:',visited)
    p = q.get()
    for f in friend[p]:
      #print(p,f)
      if visited[f]==False:
        q.put(f)
        group.append(f)
        visited[f],grouping[f] =True,True
  groups.append(group)
  #print('g:',grouping)
counts=[0]*(N+1)
for group in groups:
  gsize = len(group)
  for g in group:
    b = 0
    for h in block[g]:
      if h in group:
        b += 1
    counts[g] = gsize-1-len(friend[g])-b
print(' '.join(map(str,counts[1:])))
  

### FIXED CODE ###

N, M, K = map(int, input().split())
friend = [[] for _ in range(N+1)]
block = [[] for _ in range(N+1)]

for i in range(M):
  A,B = map(int, input().split())
  friend[A].append(B)
  friend[B].append(A)

for i in range(K):
  C,D = map(int, input().split())
  block[C].append(D)
  block[D].append(C)
#print(friend)
#print(block)

#import queue
grouping = [False]*(N+1)
#print(grouping)
grouping[0] = True
group = [0]*(N+1)
g_num = 0
g_cnt = []
for i in range(1,N+1):
  cnt = 0
  if grouping[i] == True:
    continue 
  group[i] = g_num
  grouping[i] = True
  #q = queue.Queue()
  #q.put(i)
  stack = [i]
  #while not q.empty():
  while len(stack)>0:
    #print('v:',visited)
    #p = q.get()
    p = stack.pop()
    for f in friend[p]:
      #print(p,f)
      if grouping[f]==False:
        #q.put(f)
        stack.append(f)
        group[f]=g_num
        grouping[f] =True
        cnt += 1
  g_num += 1
  g_cnt.append(cnt)
  #print('g:',grouping)
ans = []
for i in range(1,N+1):
  c = g_cnt[group[i]]-len(friend[i])
  for b in block[i]:
    if group[b]==group[i]:
      c -= 1
  ans.append(c)
print(*ans)
### BUGGY CODE ###

from collections import Counter

N = int(input())
input_list = []
input_counter = Counter()
ans = 10**10
index = 1
for i in input().split():
    item = int(i) - index
    input_list.append(item)
    input_counter[item] += 1
    index += 1


for i in input_counter.keys():
    ans = min(ans, sum(map(lambda x: abs(x-i)*input_counter[x], input_counter.keys())))

print(ans)

### FIXED CODE ###

N = int(input())

input_list = []
index = 1
for i in input().split():
    item = int(i) - index
    input_list.append(item)
    index += 1

input_list.sort()
b = input_list[N//2]

print(sum(map(lambda x: abs(x-b), input_list)))
### BUGGY CODE ###

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

for _ in range(m):
    a[0] //= 2
    a.sort(reverse = True)
    
print(sum(a))

### FIXED CODE ###

import heapq

n,m = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n):
    a[i] *= (-1)
heapq.heapify(a)

for i in range(m):
    b = heapq.heappop(a)
    b = - (b * (-1) // 2)
    heapq.heappush(a, b)
    
print(-sum(a))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
from functools import reduce
import fractions


def gcd(*numbers):
  return reduce(fractions.gcd, numbers)


n = int(input())
lst = list(map(int, input().split()))
min_v = min(lst)

max_gcd = 0
for i in range(n):
  arr = lst[:i] + lst[i + 1:len(lst)]
  if min_v < max_gcd:
    break
  wk_gcd = gcd(*arr)
  max_gcd = wk_gcd if wk_gcd > max_gcd else max_gcd

print(max_gcd)


### FIXED CODE ###

import fractions
from functools import reduce

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

# 累積GCD
left = [0] * (n + 1)
right = [0] * (n + 1)
for i in range(n):
  left[i + 1] = (fractions.gcd(left[i], a[i]))
  right[n - i - 1] = (fractions.gcd(right[n - i], a[n - 1 - i]))

ans = 0
for i in range(n):
  ans = max(ans, fractions.gcd(left[i], right[i + 1]))
print(ans)
### BUGGY CODE ###

N,K = map(int,input().split())
S = []
for _ in range(K):
    l,r = map(int,input().split())
    S+=[i for i in range(l,r+1)]
S.sort()

dp=[0]*(N+1)
dp[1]=1
 
for i in range(2,N+1):
    for j in S:
        if i<j:
            break
        else:
            dp[i]+=dp[i-j]
            dp[i]%998244353

#print(S)
#print(dp)
print(dp[-1]%998244353)

### FIXED CODE ###

N,K = map(int,input().split())
S = [tuple(map(int,input().split())) for _ in range(K)]
MOD=998244353
dp=[0]*N
dp[0]=1
for i in range(N-1):
    x = dp[i]
    dp[0]=0
    for k in range(K):
        l,r = S[k]
        if i+l < N:
            dp[i+l]+=x
            dp[i+l]%=MOD
        if i+r+1 < N:
            dp[i+r+1]-=x
            dp[i+r+1]%=MOD
    dp[i+1]+=dp[i]
    dp[i+1]%=MOD
print(dp[-1]%MOD)
### BUGGY CODE ###

N, M = map(int, input().split())
A = [int(i) for i in input().split()] 
A_sorted = sorted(A, reverse=True)

for i in range(M):
    s = A_sorted[:i+1]
    A_sorted[A_sorted.index(max(s))] /= 2 

ans = 0
for i in range(N):
    ans += A_sorted[i]//1
    
print(int(ans))

### FIXED CODE ###

import heapq
N, M = map(int, input().split())
A = [-int(i) for i in input().split()]
heapq.heapify(A)

for i in range(M):
    tmp_min = heapq.heappop(A)
    heapq.heappush(A, (-tmp_min//2)*(-1))
    

print(-sum(A))
### BUGGY CODE ###

import collections
s = collections.deque(input())
q = int(input())

rev = 1

for i in range(q):
    t = tuple(input().split())
    if t[0] == "1":
        rev *= -1
    elif t[1] == "1":
        if rev == 1:
            s.appendleft(t[2])
        else:
            s.append(t[2])
    else:
        if rev == 1:
            s.append(t[2])
        else:
            s.appendleft(t[2])

if rev != 1:
    s.reverse()

ans = ""

for i in range(len(s)):
    ans += s.popleft()

print(ans)

### FIXED CODE ###

s = input()
q = int(input())

rev = 0
head = []
tail = []

for i in range(q):
    t = input().split()
    if t[0] == "1":
        rev ^= 1
    else:
        if (int(t[1])-1)^rev == 0:
            head.append(t[2])
        else:
            tail.append(t[2])

h = "".join(head)
t = "".join(tail)

if rev == 0:
    print(h[::-1] + s + t)
else:
    s = s[::-1]
    print(t[::-1] + s + h)
### BUGGY CODE ###

import math
N, P = map(int, input().split())
x = math.floor(pow(P, 1/N))
x += 1

for i in range(x, 0, -1):
    if P % pow(i, N) == 0:
        print(i)
        break


### FIXED CODE ###

import math
N, P = map(int, input().split())
x = math.floor(math.pow(P, 1/N))
if x==1:
    print(1)
    exit()
x+=1
for i in range(x, 0, -1):
    if P % pow(i, N) == 0:
        print(i)
        break
### BUGGY CODE ###

import numpy as np

n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

status=np.array([n,0,0,0,0,0])
end=np.array([0,0,0,0,0,n])
t=0

while (status==end).all()==False:
    A=min(a,status[0])
    B=min(b,status[1])
    C=min(c,status[2])
    D=min(d,status[3])
    E=min(e,status[4])
    status=status-np.array([A,B-A,C-B,D-C,E-D,-E])
    t+=1
    # print(status)

print(t)

# m=min(a,b,c,d,e)

# if n<=m:
#     print(5)
# else:
#     print(n//m+1+4)



### FIXED CODE ###

import numpy as np

n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

# status=np.array([n,0,0,0,0,0])
# end=np.array([0,0,0,0,0,n])
# t=0

# while (status==end).all()==False:
#     A=min(a,status[0])
#     B=min(b,status[1])
#     C=min(c,status[2])
#     D=min(d,status[3])
#     E=min(e,status[4])
#     status=status-np.array([A,B-A,C-B,D-C,E-D,-E])
#     t+=1
#     # print(status)

# print(t)

m=min(a,b,c,d,e)

if n<=m:
    print(5)
else:
    if n%m==0:
        print(n//m+4)
    else:
        print(n//m+5)
### BUGGY CODE ###

# coding: utf-8
import sys
from math import log


def change_into_int(lists):
    tmps = lists.split(' ')
    num_list = []
    for n in tmps:
        num_list.append(int(n))
    return num_list


def create_result(one_list):
    ans = 0
    for n in one_list:
        ans = ans + log(n)
    return ans

            
def create_lists(data, point):
    num_lists = []
    flag = 0
    count = 0
    while(flag == 0):
        tmp_list = []
        for i in range(point):
            tmp_list.append(data[i+count])
            # print(i+count)
            if i+count == len(data)-1:
                flag = 1
        count = count + 1
        num_lists.append(tmp_list)
    return num_lists


if __name__ == "__main__":
    lines = []
    result_list = []
    for l in sys.stdin:
        lines.append(l.rstrip('\r\n'))

    num1 = change_into_int(lines[0])
    data = change_into_int(lines[1])
    lists = create_lists(data, num1[1])
    for one_list in lists:
        result_list.append(create_result(one_list))

    for n in range(len(result_list)-1):
        if result_list[n] < result_list[n+1]:
            print("Yes")
        else:
            print("No")


### FIXED CODE ###

# coding: utf-8
import sys
from math import log


def change_into_int(lists):
    tmps = lists.split(' ')
    num_list = []
    for n in tmps:
        num_list.append(int(n))
    return num_list


if __name__ == "__main__":
    lines = []
    result_list = []
    # 入力
    for l in sys.stdin:
        lines.append(l.rstrip('\r\n'))
    # int
    num1 = change_into_int(lines[0])
    data = change_into_int(lines[1])
    i = 0
    while(True):
        ans = data[i] - data[i+num1[1]]
        if ans < 0:
            print("Yes")
        else:
            print("No") 
        i = i + 1
        if i+num1[1] == len(data):
            break
### BUGGY CODE ###

import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
Adic={}
for i in range(N):
  if A[i] not in Adic:
    Adic[A[i]] = 1
  else:
    Adic[A[i]] += 1
Aset = set(A)
if 1 in Aset: #1がある場合
  if Adic[1] == 1:
    print(1)
  else:
    print(0)
  exit()
ans = 0
for j in range(N):
  Flag = True
  temp = A[j]
  i = 2
  if Adic[temp] >= 2:
    continue
  while i*i <= temp:
    #print(i,temp)
    if temp%i == 0:
      #print(i,temp//i,temp)
      if i in Aset or temp//i in Aset:
        Flag = False
        #print(i,temp//i,"X")
        break
    i += 1
  if not Flag:
    continue
  ans += 1
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
MAX = max(A) #Aの中の最大値
Adic={}
for i in range(N):
  if A[i] not in Adic:
    Adic[A[i]] = 1
  else:
    Adic[A[i]] += 1
Aset = set(A)
if 1 in Aset: #1がある場合
  if Adic[1] == 1:
    print(1)
  else:
    print(0)
  exit()
ans = 0
for j in range(N):
  temp = A[j]
  if Adic[temp] >= 2: #同じ数が複数ある場合には削除
    if temp in Aset:
      Aset.remove(temp)
  fmax = MAX//temp
  #print(fmax,temp)
  for i in range(2,fmax+10): #fmaxまで見る
    now = temp*i
    if now in Aset:
      Aset.remove(now)
#print(Aset)
print(len(Aset))
### BUGGY CODE ###

s=input()
M=10**9+7
import numpy as np
dp=np.zeros((len(s)+1,13),dtype="int64")
dp[0][0]=1
for i in range(-1,-len(s)-1,-1):
    dp[-i-1]%=M
    if s[i]!="?":
        a=(int(s[i])*(10**(-i-1)))%13
        for j in range(13):
            dp[-i][(j+a)%13]=dp[-i-1][j]
    elif s[i]=="?":
        dp[-i]=dp[-i-1]
        for k in range(1,10):
            a=k*(10**(-i-1))%13
            for j in range(13):
                dp[-i][(j+a)%13]+=(dp[-i-1][j])
print(dp[-1][5]%M)

### FIXED CODE ###

s=input()
dp=[[0]*13 for _ in range(len(s))]
if s[0]=='?':
  dp[0]=[1]*10+[0]*3
else:
  dp[0][int(s[0])]+=1

MOD=10**9+7
for i in range(1,len(s)):
  if s[i]=='?':
    for j in range(13):
      for k in range(10):
        dp[i][((j*10)%13+k)%13]+=dp[i-1][j]
        dp[i][((j*10)%13+k)%13]%=MOD
  else:
    k=int(s[i])
    for j in range(13):
      dp[i][((j*10)%13+k)%13]+=dp[i-1][j]
      dp[i][((j*10)%13+k)%13]%=MOD
print(dp[-1][5])
### BUGGY CODE ###

N = int(input())
S = []
Count = [0]*N

for T in range(0,N):
    Poll = input()
    if Poll in S:
        Count[S.index(Poll)] += 1
    else:
        S.append(Poll)
        Count[len(S)-1] += 1

Count = Count[:len(S)]
MaxIndex = [N for N,V in enumerate(Count) if V==max(Count)]
MaxS = sorted([S[I] for I in MaxIndex])
print('\n'.join(MaxS))

### FIXED CODE ###

import collections
N = int(input())
S = ['']*N
for T in range(0,N):
    S[T] = input()
Count = collections.Counter(S).most_common()
MaxC = Count[0][1]
Disp = []
for T in range(0,len(Count)):
    if Count[T][1] < MaxC:
        break
    Disp.append(Count[T][0])
print('\n'.join(sorted(Disp)))
### BUGGY CODE ###

import sys
input=sys.stdin.readline

def main():
    N=int(input())
    A=[list(map(int,input().split())) for i in range(N)]

    mod=10**9+7
    qqq=2**N

    data=[[] for i in range(2**N)]
    que=[0]

    dp=[0]*qqq
    dp[0]=1

    flag=[0]*qqq
    flag[0]=1

    que=[0]
    i=0

    while que:
        H=[]
        h=[0]*qqq
        for u in que:
            if u==qqq-1:
                break
            for j in range(N):
                if u&(1<<j)==0 and A[i][j]==1:
                    num=u+(1<<j)
                    h[num]=(h[num]+dp[u])%mod
                    if flag[num]==0:
                        flag[num]=1
                        H.append(num)
        else:  
            dp=h
            que=H
            i+=1
            continue
        break
    print(dp[-1])

if __name__=="__main__":
    main()

### FIXED CODE ###

import sys
input=sys.stdin.readline

N=int(input())
A=[list(map(int,input().split())) for i in range(N)]
mod=10**9+7

dp=[0]*2**N
que=[0]

data=[[] for i in range(N+1)]
for i in range(2**N):
    cnt=0
    for j in range(N):
        if i&(1<<j)==0:
            continue
        cnt+=1
    data[cnt].append(i)
    
for j in range(N):
    if A[0][j]==1:
        num=1<<j
        dp[num]+=1
                
for i in range(N):
    for j in range(N):
        if A[i][j]==1:
            num=1<<j
            for u in data[i]:
                dp[u^num]=(dp[u^num]+dp[u])%mod

print(dp[-1])
### BUGGY CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))
#dp[i]はiに来たときのコストの総和の最小値

dp=[float('inf')]*n
dp[0]=0

for i in range(1,n):
  for j in range(min(k,i)):
    dp[i]=min(dp[i],dp[i-j-1]+abs(h[i]-h[i-j-1]))

print(dp[n-1])

### FIXED CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))
#dp[i]はiに来たときのコストの総和の最小値

dp=[float('inf')]*n
dp[0]=0

for i in range(1,n):
  for j in range(min(k,i)):
    dp[i]=min(dp[i],dp[i-j-1]+abs(h[i]-h[i-j-1]))

print(dp[n-1])