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

import heapq
N,M = list(map(int, input().split()))
A = list(map(int, input().split()))
A =[-i for i in A]
heapq.heapify(A)
for i in range(M):
    A[0] = -(-A[0]//2)
    heapq.heapify(A)
print(-1*sum(A))

### FIXED CODE ###

import heapq
N,M = list(map(int, input().split()))
A = list(map(int, input().split()))
A =[-i for i in A]
heapq.heapify(A)
for i in range(M):
    minA = heapq.heappop(A)
    heapq.heappush(A, -(-minA//2))
print(-1*sum(A))
### BUGGY CODE ###

import math

N=int(input())
A=list(map(int, input().split()))
c=0

for i in range(1,N):
  for j in range(N-i):
    #print(A[j],A[i+j])
    if A[j]+A[i+j]==i:
      c+=1
print(c)

### FIXED CODE ###

n=int(input())
A=list(map(int, input().split()))
d={}
c=0

for i,a in enumerate(A):
  if i+a not in d:
    d[i+a]=1
  else:
    d[i+a]+=1
  if i-a in d:
    c+=d[i-a]

print(c)
### BUGGY CODE ###

from collections import defaultdict
mod = 998244353
N = int(input())
S = input()
colors = ['R', 'G', 'B']
invs = {'R':'GB', 'G':'BR', 'B':'RG'}
cnt = defaultdict(int)
ans = 1
for i in range(N*3):
    s = S[i]
    inv = invs[s]
    if cnt[inv] != 0:
        ans *= cnt[inv]
        cnt[inv]-=1
        continue
    flag = False
    for c in colors:
        if c == s:
            continue
        if cnt[c]:
            ans*=cnt[c]
            cnt[c]-=1
            cnt[c+s]+=1
            cnt[s+c]+=1
            flag = True
    if not flag:
        cnt[s]+=1
    ans%=mod
for i in range(1, N+1):
    ans*=i
    ans%=mod
print(ans)

    

### FIXED CODE ###

from collections import defaultdict
mod = 998244353
N = int(input())
S = input()
colors = ['R', 'G', 'B']
invs = {'R':'GB', 'G':'BR', 'B':'RG'}
cnt = defaultdict(int)
ans = 1
for i in range(N*3):
    s = S[i]
    inv = invs[s]
    if cnt[inv] != 0:
        ans *= cnt[inv]
        ans%=mod
        cnt[inv]-=1
        continue
    flag = False
    for c in colors:
        if c == s:
            continue
        if cnt[c]:
            ans*=cnt[c]
            ans%=mod
            cnt[c]-=1
            cnt[c+s]+=1
            cnt[s+c]+=1
            flag = True
    if not flag:
        cnt[s]+=1
    ans%=mod
for i in range(1, N+1):
    ans*=i
    ans%=mod
print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3
#abc126 e

import sys
sys.setrecursionlimit(100000)
N,M = list(map(int,input().split()))
XYZ = [list(map(int,input().split())) for _ in range(M)]

G = [[] for _ in range(N)]

for i in XYZ:
    G[i[0]-1].append(i[1])
    G[i[1]-1].append(i[0])

check = [False for _ in range(N)]#各頂点を訪問したかどうか

def DFS(G,s):
    check[s-1] = True
    for i in G[s-1]:
        if not check[i-1]:
            DFS(G,i)
ans = 0
for i in range(N):
    if not check[i]:
        DFS(G,i+1)
        ans += 1
print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
#abc126 e

import sys
sys.setrecursionlimit(1000000)
N,M = list(map(int,input().split()))
XYZ = [list(map(int,input().split())) for _ in range(M)]

G = [[] for _ in range(N)]

for i in XYZ:
    G[i[0]-1].append(i[1])
    G[i[1]-1].append(i[0])

check = [False for _ in range(N)]#各頂点を訪問したかどうか

def DFS(G,s):
    check[s-1] = True
    for i in G[s-1]:
        if not check[i-1]:
            DFS(G,i)
ans = 0
for i in range(N):
    if not check[i]:
        DFS(G,i+1)
        ans += 1
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n,s = map(int,input().split())
a = list(map(int,input().split()))

mod = 998244353

res = 0

#dp[i][j]:a[i]まででf(L,?) = jとなるLの合計数
dp = [[0]*3003 for i in range(n)]

for i in range(n):
    if a[i] < s:
        res = (res+dp[i-1][s-a[i]]*(n-i))%mod
    elif a[i] == s:
        res = (res+(i+1)*(n-i))%mod
    for j in range(3003):
        if j < a[i]:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = dp[i-1][j] + dp[i-1][j-a[i]]
    dp[i][a[i]] += i+1
print(res)



### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    n,s = map(int,input().split())
    a = tuple(map(int,input().split()))

    mod = 998244353

    res = 0

    #dp[i][j]:a[i]まででf(L,?) = jとなるLの合計数
    dp = [[0]*3003 for i in range(n)]

    for i in range(n):
        if a[i] < s:
            res = (res+dp[i-1][s-a[i]]*(n-i))%mod
        elif a[i] == s:
            res = (res+(i+1)*(n-i))%mod
        for j in range(3003):
            if j < a[i]:
                dp[i][j] = dp[i-1][j]
            else:
                dp[i][j] = (dp[i-1][j] + dp[i-1][j-a[i]])%mod
        dp[i][a[i]] += i+1
    print(res)

if __name__ == "__main__":
    main()
### BUGGY CODE ###

s = input()

ans = 0
flag = True
while flag:
    s_tmp = s
    s = s.replace('01', '')
    s = s.replace('10', '')
    ans += (len(s_tmp) - len(s))
    flag = len(s_tmp) - len(s)

print(ans)

### FIXED CODE ###

import re

s = input()

c0, c1 = 0, 0
for i in s:
    if i=='0':
        c0 += 1
    else:
        c1 += 1

print(min(c0, c1)*2)

"""TLE
def trans_word(text):
    replacements = {'01': '', '10': ''}
    return re.sub('({})'.format('|'.join(map(re.escape, replacements.keys()))), lambda m: replacements[m.group()], text)

ans = 0
flag = True

while flag:
    s_tmp = s
    s = trans_word(s)
    ans += (len(s_tmp) - len(s))
    flag = len(s_tmp) - len(s)

print(ans)
"""
### BUGGY CODE ###

n,a,b,k = map(int,input().split())
mod = 998244353

fact = [1,1]
finv = [1,1]
inv = [0,1]
 
for i in range(2,n+5):
    fact.append((fact[-1]*i)%mod)
    inv.append((inv[mod%i]*(mod-mod//i))%mod)
    finv.append((finv[-1]*inv[-1])%mod)
 
def nCr(n,r,mod):
    if r > n:
        return 0
    else: 
        return fact[n]*finv[r]*finv[n-r]%mod

def nPr(n,r,mod):
    if r > n:
        return 0
    else: 
        return fact[n]*finv[n-r]%mod


ans = 0
for i in range(n+1):
    d = k-a*i
    if d < 0:
        break
    if d%b:
        continue
    x = d//b
    v = nCr(n,i,mod)
    for j in range(x+1):
        if i+j > n:
            break
        ans += v*nCr(i,x-j,mod)%mod*nCr(n-i,j,mod)%mod
        ans %= mod
print(ans)

### FIXED CODE ###

n,a,b,k = map(int,input().split())
mod = 998244353

fact = [1,1]
finv = [1,1]
inv = [0,1]
 
for i in range(2,n+5):
    fact.append((fact[-1]*i)%mod)
    inv.append((inv[mod%i]*(mod-mod//i))%mod)
    finv.append((finv[-1]*inv[-1])%mod)
 
def nCr(n,r,mod):
    if r > n:
        return 0
    else: 
        return fact[n]*finv[r]*finv[n-r]%mod

def nPr(n,r,mod):
    if r > n:
        return 0
    else: 
        return fact[n]*finv[n-r]%mod


ans = 0
for i in range(n+1):
    if i*a > k:
        break
    d = k-i*a
    if d%b or d//b > n:
        continue
    ans += nCr(n,i,mod)*nCr(n,d//b,mod)%mod
    ans %= mod
print(ans)
### BUGGY CODE ###

from itertools import product

N=int(input())
S=input()
t=["0","1","2","3","4","5","6","7","8","9"]

u=product(t,repeat=3)
ans=0
for com in u:
  flag=False
  x=com[0]
  y=com[1]
  z=com[2]
  for i in range(N):
    if S[i]==x:
      for j in range(i+1,N):
        if S[j]==y:
          for k in range(j+1,N):
            if S[k]==z:
              flag=True
  if flag:
    ans+=1
print(ans)

### FIXED CODE ###

from itertools import product

N=int(input())
S=list(input())
t=["0","1","2","3","4","5","6","7","8","9"]

u=product(t,repeat=3)
ans=0
for com in u:
  x=com[0]
  y=com[1]
  z=com[2]
  
  if x in set(S):
    idx_x = S.index(x)
    tmp1 = S[idx_x+1:]
    if y in set(tmp1):
      idx_y = tmp1.index(y)
      tmp2 = tmp1[idx_y+1:]
      if z in set(tmp2):
        ans+=1
        continue
        
print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
import bisect

def iterate_tokens():
    for line in sys.stdin:
        for word in line.split():
            yield word

def solve(N: int):
    tokens = iterate_tokens()
    colors_top = []
    for i in range(N):
        new = int(next(tokens))
        if colors_top:
            b = bisect.bisect_left(colors_top, new)
            if b == 0:
                colors_top = [new] + colors_top
            else:
                colors_top[b-1] = new
        else:
            colors_top.append(new)
    print(len(colors_top))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import bisect

def iterate_tokens():
    for line in sys.stdin:
        for word in line.split():
            yield word

def solve(N: int):
    tokens = iterate_tokens()
    colors_top = []
    for i in range(N):
        new = int(next(tokens))
        if colors_top:
            b = bisect.bisect_right(colors_top, -new)
            if b == len(colors_top):
                colors_top.append(-new)
            else:
                colors_top[b] = -new
        else:
            colors_top.append(-new)
    print(len(colors_top))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

n, k = map(int, input().split())
a = []
b = []
for i in range(n):
  a_, b_ = map(int, input().split())
  a.append(a_)
  b.append(b_)

res = []
for i in range(n):
  for _ in range(b[i]):
    res.append(a[i])
#print(res)
res.sort()
#print(res)
print(res[k-1])

### FIXED CODE ###

n, k = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
#print(ab)
ab.sort()
#print(ab)
for i in range(n):
  k = k-ab[i][1]
  if k <= 0:
    print(ab[i][0])
    exit()
### BUGGY CODE ###

n,q = [int(i) for i in input().split()]
s = input()

for i in range(q):
    l,r = [int(i) for i in input().split()]
    p = s[l-1:r]
    print(p.count("AC"))


### FIXED CODE ###

n,q = [int(i) for i in input().split()]
s = input()
cumsum = [0]*n
ans = 0
flag = False

for i in range(n):
    if flag:
        if s[i] == "C":
            ans += 1

    cumsum[i] = ans     

    flag = False

    if s[i] == "A":
        flag = True
    


for i in range(q):
    l,r = [int(i) for i in input().split()]
    ans = cumsum[r-1] - cumsum[l-1]
    print(ans)
### BUGGY CODE ###

import fractions
from functools import reduce
n = int(input())
a = list(map(int, input().split()))
def lcm_base(x, y):
    return (x*y) // fractions.gcd(x, y)

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

l = lcm(a)
mod = 10**9+7
total = 0
for i in a:
    total += l//i
    if total > mod:
        total %= mod
print(total)

### FIXED CODE ###

#GCD, LCM
def gcd_base(a, b):
    while b!=0:
        a, b = b, a%b
    return a

def lcm(num_list):
    ans = 1
    for i in num_list:
        ans = ans * i // gcd_base(ans, i)
    return ans

n = int(input())
a = list(map(int, input().split()))
l = lcm(a)
mod = 10**9+7
total = 0
for i in a:
    total += l//i
print(total%mod)
### BUGGY CODE ###

import numpy as np

N, K = map(int,input().split())
A = np.array(list(map(int,input().split())))

for _ in range(min(K,100)):
    imos = np.zeros(N+1,int)
    for i in range(N):
        l, r = max(i-A[i],0), min(i+A[i],N-1)
        imos[l] += 1
        imos[r+1] += -1
    
    A = np.cumsum(imos)[:N]

print(' '.join(A.astype(str)))



### FIXED CODE ###

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

for _ in range(K):
    flag = True
    for a in A:
        if a != N: flag = False
    if flag: break

    imos = [0] * (N+1)
    for i in range(N):
        l = max(i-A[i],0)
        r = min(i+A[i],N-1)
        imos[l] += 1
        imos[r+1] += -1
    
    for i in range(N):
        imos[i+1] += imos[i]
    
    A = imos[:N]

for a in A[:N]:
    print(a, end=" ")
print()
### BUGGY CODE ###

p = 10 ** 18

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

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

if ans > p:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

p = 10 ** 18

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

if 0 in a:
    print(0)
    quit()

for i in range(n):
    ans *= a[i]
    if ans > p:
        print(-1)
        quit()


print(ans)
### BUGGY CODE ###

N,Q=map(int,input().split())
s=input()
for i in range(Q):
    num=0
    l,r=map(int,input().split())
    print(s[l-1:r].count("AC"))

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
LR = [list(map(int, input().split())) for _ in range(Q)]
dp = [0] * (N)
for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        dp[i+1] = dp[i] + 1
    else:
        dp[i+1] = dp[i]

for l, r in LR:
    print(dp[r-1] - dp[l-1])
### BUGGY CODE ###

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

max = 0
tmp = 0
i = 1
j = 0
start = 0
sum = 0

#print(n[0]-3)

while(j <= n[0]-n[1]):
    start = j
    for i in range(n[1]):
        #print(start)
        for k in range(1,p[start]+1):
            sum += k
        tmp = tmp + (sum/p[start])
        start = start + 1
        sum = 0
    if(max < tmp):
        max = tmp
    #print("------")
    tmp = 0
    sum = 0
    i = 1
    j = j + 1


print(max)


### FIXED CODE ###

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

exp = [] #期待値のリスト
exp.append(0) #０の期待値
count = 1
max = 0
tmp = 0

for i in range(1,1001):
    exp.append(count/i)
    count = count + (i+1)

#まず最初のK個の期待値を求める
for i in range(n[1]):
    tmp = tmp + exp[p[i]]
if(tmp >= max):
    max = tmp

#尺取り法でK+1個目の期待値を足して、j(0から増えていく＝先頭の期待値)を引いていく
for j in range(n[0]-n[1]):
    #print(j,tmp)
    tmp = tmp + exp[p[j+n[1]]] - exp[p[j]]
    if(tmp >= max):
        max = tmp

print(max)
### BUGGY CODE ###

# coding: utf-8
from array import array
import sys
input = sys.stdin.readline

def f3(n, h, a):
    dp = array('L', [0] * (n + 1))
    for i in range(1, n + 1):
        m = max(dp[:h[i]])
        dp[h[i]] = m + a[i]
    return(max(dp))

n = int(input()) # 1 <= n <= 2 x 10^5
h = [0] + list(map(int, input().split()))
a = [0] + list(map(int, input().split()))
print(f3(n, h, a))


### FIXED CODE ###

# coding: utf-8

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

powof2 = lambda x: len("{:b}".format(x))

def f2(n, h, a):
    p = powof2(n)
    N = 2 ** p
    segt = [0] * (2 * N - 1)

    def getmax(a, b, i = 0, l = 0, r = N - 1):
        if r <= a or b <= l:
            return(0)
        if a <= l and r <= b:
            return(segt[i])
        i1 = 2 * i + 1
        i2 = i1 + 1
        lr = (l + r) // 2
        lmax = getmax(a, b, i1, l, lr)
        rmax = getmax(a, b, i2, lr, r)
        return(lmax if lmax > rmax else rmax)

    def setmax(i, v):
        si = i + N - 1
        segt[si] = v
        while si > 0:
            si = (si - 1) // 2
            si1 = 2 * si + 1
            si2 = si1 + 1
            segt[si] = segt[si1] if segt[si1] > segt[si2] else segt[si2]

    for i in range(1, n + 1):
        m = getmax(0, h[i])
        setmax(h[i], m + a[i])

    return(getmax(0, n))

n = int(input()) # 1 <= n <= 2 x 10^5
h = [0] + list(map(int, input().split()))
a = [0] + list(map(int, input().split()))
print(f2(n, h, a))
### BUGGY CODE ###

a, b, c, d = map(int,input().split())
li = [i for i in range(a, b+1)]
cf = [True if i%c != 0 else False for i in li]
df = [True if i%d != 0 else False for i in li]
n = 0
for i in range(len(cf)):
    if cf[i] and df[i]:
        n+=1
print(n)

### FIXED CODE ###

A, B, C, D = map(int, input().split())
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a*b//gcd(a,b)

def calc(n):
    return n-n//C-n//D+n//(lcm(C,D))
 
print(calc(B)-calc(A-1))
### BUGGY CODE ###


import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    H,W = map(int, input().split())
    grid = [list(input().rstrip()) for _ in range(H)]
    q = []
    visited = [[False]*W for _ in range(H)]
    for y in range(H):
        for x in range(W):
            if grid[y][x] == '#':
                q.append((y,x))
                visited[y][x] = True
    ans = -1
    while q:
        ans += 1
        new_q = []
        for y,x in q:
            for dy,dx in [(1,0),(-1,0),(0,1),(0,-1)]:
                ny = y+dy
                nx = x+dx
                if 0<=ny<H and 0<=nx<W and not visited[ny][nx]:
                    new_q.append((ny,nx))
                    visited[ny][nx] = True
        if new_q:
            q = new_q
        else:
            break
    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    H, W = map(int,input().split())
    visited = [[False]*W for _ in range(H)]
    q = []
    for y in range(H):
        S = input()
        for x, s in enumerate(S):
            if s == "#":
                q.append((y, x))
                visited[y][x] = True

    ans = -1
    while q:
        ans += 1
        nq = []
        for y, x in q:
            if 0 < x and not visited[y][x-1]:
                visited[y][x-1] = True
                nq.append((y,x-1))
            if x < W-1 and not visited[y][x+1]:
                visited[y][x+1] = True
                nq.append((y,x+1))
            if 0 < y and not visited[y-1][x]:
                visited[y-1][x] = True
                nq.append((y-1, x))
            if y < H-1 and not visited[y+1][x]:
                visited[y+1][x] = True
                nq.append((y+1,x))
        if nq:
            q = nq
        else:
            break

    print(ans)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

import math

def gcd3(a,b,c):
    return(math.gcd(math.gcd(a,b),c))

k = int(input())

print(sum([gcd3(a,b,c) for a in range(k,0,-1)
 for b in range(k,0,-1)
 for c in range(k,0,-1)]))

### FIXED CODE ###

from math import gcd

def gcd3(a,b,c):
    return(gcd(gcd(a,b),c))

k = int(input())

print(sum([gcd3(a,b,c) for a in range(1,k+1)
 for b in range(1,k+1)
 for c in range(1,k+1)]))
### BUGGY CODE ###

N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]

dp = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(N):
    for w in range(W + 1):
        dp[i + 1][w] = dp[i][w]
        if w - wv[i][0] >= 0:
            dp[i + 1][w] = max(dp[i + 1][w], dp[i][w - wv[i][0]] + wv[i][1])

print(dp[N][W])


### FIXED CODE ###

N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]

dp = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(N):
    for w in range(W + 1):
        dp[i + 1][w] = dp[i][w]
        if w - wv[i][0] >= 0:
            dp[i + 1][w] = max(dp[i + 1][w], dp[i][w - wv[i][0]] + wv[i][1])

print(dp[N][W])
### BUGGY CODE ###

R,G,B,N = map(int,input().split())

li = [R,G,B]
li.sort(reverse=True)
R = li[0]
G = li[1]
B = li[2]
#print(R,G,B)

ans = 0
for b in range(N//B+1):
    for g in range((N-B*b)//G+1):
        if N-B*b-G*g >= 0 and (N-B*b-G*g)%R == 0:
            ans += 1
print(ans)


### FIXED CODE ###

R,G,B,N = map(int,input().split())

li = [R,G,B]
li.sort(reverse=True)
R = li[0]
G = li[1]
B = li[2]
#print(R,G,B)

ans = 0
for b in range(N//B+1):
    for g in range((N-B*b)//G+1):
        if N-B*b-G*g >= 0 and (N-B*b-G*g)%R == 0:
            ans += 1
print(ans)
### BUGGY CODE ###

#!/usr/bin/env python
"""AtCoder Beginner Contest 167: C
https://atcoder.jp/contests/abc167/tasks/abc167_c
"""
import sys
import itertools

__author__ = 'bugttle <bugttle@gmail.com>'


def main():
    [N, M, X] = list(map(int, input().split()))

    l = []
    for n in range(N):
        l.append(list(map(int, input().split())))
    # print(l)

    status = [0]*M
    for n in range(N):
        for m in range(M):
            status[m] += l[n][m + 1]
    for v in status:
        if v < X:
            print(-1)
            return
    
    min_cost = sys.maxsize
    for p in itertools.permutations(range(N)):
        # print(p)
        cost = 0
        status = [0]*M
        for n in p:
            cost += l[n][0]
            isCompleted = True
            for m in range(M):
                status[m] += l[n][m + 1]
                if status[m] < X:
                    isCompleted = False
            if min_cost < cost:
                break
            # print(status)
            if isCompleted:
                # print('fin')
                # print(cost)
                if cost < min_cost:
                    min_cost = cost
                break
    if min_cost == sys.maxsize:
        print(-1)
    else:
        print(min_cost)
            
                    

                # status[m] += l[n][m]
    # for n in range(N):
    #     for m in range(M):
    #         print([n, m])
    # cost = 0
    # status = [[0]*M]*N
    # for n in range(N):
    #     for m in range(M):
    #         print(l[n][m + 1])
    #         # status[n][m] = l[n][m + 1]
    # print(status)

    


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python
"""AtCoder Beginner Contest 167: C - Skill Up
https://atcoder.jp/contests/abc167/tasks/abc167_c
"""

N, M, X = 0, 0, 0
BOOKS = []


def calc_price(book_combinations):
    price = 0
    understandings = [0] * M
    for i in range(len(book_combinations)):
        if book_combinations[i]:
            price += BOOKS[i][0]
            for j in range(len(BOOKS[i][1:])):
                understandings[j] += BOOKS[i][j + 1]
    for u in understandings:
        if u < X:  # couldn't understand
            return -1
    return price


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

    ans = float('inf')
    for i in range(1, 2 ** N):  # => 1: at least one book should be buy
        price = calc_price([(i >> j) & 1 for j in range(N)])
        if 0 < price and price < ans:
            ans = price
    if ans == float('inf'):
        ans = -1
    print(ans)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

N = int(input())

dic ={}

for i in range(N):
    a = input()
    if a in dic:
        dic[a] += 1
    else:
        dic[a] = 1

l = [j for j, k in dic.items() if k == max(dic.values())]
l.sort()

for a in l:
    print(a)

### FIXED CODE ###

N = int(input())

dic = {}

for _ in range(N):
    a = input()
    if a in dic:
        dic[a] += 1
    else:
        dic[a] = 1

m = max(dic.values())

for s in sorted(k for k in dic if dic[k] == m):
    print(s)
### BUGGY CODE ###

r, g, b, n = map(int, input().split())
a1, a2, a3 = sorted([r, g, b])

r = 0
I = n//a3+1
J = n//a2+1
for i in range(I):
    for j in range(J):
        t = n-i*a3-j*a2
        if t>=0 and t%a1==0:
            r += 1
print(r)

### FIXED CODE ###

r, g, b, n = map(int, input().split())
a1, a2, a3 = sorted([r, g, b])

r = 0
I = n//a3+1
for i in range(I):
    for j in range((n-i)//a2+1):
        t = n-i*a3-j*a2
        if t>=0 and t%a1==0:
            r += 1
print(r)
### BUGGY CODE ###

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

answer=1
for i in range(2,min(A,V)+1):
    if A%i==V%i==0:
        answer+=1
    while A%i==0:
        A/=i
    while V%i==0:
        V/=i

print(answer)

### FIXED CODE ###

import fractions
A,B=map(int,input().split())
A,B=min(A,B),max(A,B)
g=fractions.gcd(A,B)
ans=1
for i in range(2,int(g**0.5+1)):
  if g%i==0:
    ans+=1
    while g%i==0:
      g/=i
    if g==1:
      break
if g!=1:
  ans+=1
print(ans)
### BUGGY CODE ###

def calc_expected_value(n):
    sum_n = [i for i in range(1, n+1)]
    return sum(sum_n) / n


n, k_range = map(int, input().split())
p = list(map(int, input().split()))
e_list = [0] * (n+1)
ans = 0.0

for i in range(n):
    if i < k_range-1:
        e_list[i] = calc_expected_value(p[i])
    else:
        e_list[i] = calc_expected_value(p[i])
        ans = max(ans, sum([e_list[i-k] for k in range(k_range)]))

print(ans)

### FIXED CODE ###

def calc_expected_value(n):
    return (n+1) / 2


n, k_range = map(int, input().split())
p = list(map(int, input().split()))
e_list = [0] * n
ans_list = [0] * n
ans = 0.0

for i in range(n):
    e_list[i] = calc_expected_value(p[i])
    if i == k_range-1:
        ans_list[i] = sum([e_list[i-k] for k in range(k_range)])
    else:
        ans_list[i] = ans_list[i-1] + e_list[i] - e_list[i-k_range]

print(max(ans_list))