Harryxun/stf_run huggingface dataset:
import resource
import sys


# Will segfault without this line.
resource.setrlimit(resource.RLIMIT_STACK, [0x10000000, resource.RLIM_INFINITY])
sys.setrecursionlimit(0x100000)

mod = int(1e9+7)

def dfs(i,dp,bad):
    if i == 0:
      return 1
    if i in dp:
      return dp[i]
    dp[i] = 0
    for d in (1,2):
      x = i-d;
      if 0 <= x and x not in bad:
        dp[i] += dfs(x,dp,bad)
        dp[i] %= mod
    return dp[i]

n,m = [int(a) for a in input().split()]
bad = set()
for _ in range(m):
  a = int(input())
  bad.add(a)
print(dfs(n,dict(),bad))


### FIXED CODE ###

import sys
sys.setrecursionlimit(200000)

mod = int(1e9+7)

def dfs(i,dp,bad):
    if i == 0:
      return 1
    if i in dp:
      return dp[i]
    dp[i] = 0
    for d in (1,2):
      x = i-d;
      if 0 <= x and x not in bad:
        dp[i] += dfs(x,dp,bad)
        dp[i] %= mod
    return dp[i]

n,m = [int(a) for a in input().split()]
bad = set()
for _ in range(m):
  a = int(input())
  bad.add(a)
print(dfs(n,dict(),bad))
N = int(input())

import sys
sys.setrecursionlimit(10 ** 9)

memo = [-1] * (N + 1)

def dfs(x):
    if x >= 0 and memo[x] != -1:
        return memo[x]
    ans = False
    if x == 0:
        memo[x] = 1
        return True
    elif x < 0:
        memo[x] = 0
        return False
    else:
        ans |= dfs(x - 100)
        ans |= dfs(x - 101)
        ans |= dfs(x - 102)
        ans |= dfs(x - 103)
        ans |= dfs(x - 104)
        ans |= dfs(x - 105)
    memo[x] = 1 if ans else 0
    return ans
if dfs(N):
    print(1)
else:
    print(0)


### FIXED CODE ###

N = int(input())

import sys
sys.setrecursionlimit(10 ** 9)

memo = [-1] * (N + 1)

def dfs(x):
    if x >= 0 and memo[x] != -1:
        return memo[x]
    ans = False
    if x == 0:
        memo[x] = 1
        return True
    elif x < 0:
        return False
    else:
        ans |= dfs(x - 100)
        ans |= dfs(x - 101)
        ans |= dfs(x - 102)
        ans |= dfs(x - 103)
        ans |= dfs(x - 104)
        ans |= dfs(x - 105)
    memo[x] = 1 if ans else 0
    return ans
if dfs(N):
    print(1)
else:
    print(0)
import math
n,d=map(int,input().split(' '))
cnt=0
while n>0:
    x,y=map(int,input().split(' '))
    res=math.sqrt(x**2+y**2)
    if res<=d:
        cnt+=1
print(cnt)


### FIXED CODE ###

import math
n,d=map(int,input().split(' '))
cnt=0
while n>0:
    x,y=map(int,input().split(' '))
    res=math.sqrt(x**2+y**2)
    if res<=d:
        cnt+=1
    n=n-1
print(cnt)
X,Y,Z = map(str,intput().split())

print(Z,X,Y)

### FIXED CODE ###

X,Y,Z=list(map(int,input().split()))

print(Z, X, Y)
N,T=map(int,input().split())
res=2000
for i in N:
  c,t=map(int,input().split())
  if t>T:
    continue
  else:
    res=min(res,c)
if res==2000:
  print("TLE")
else:
  print(res)

### FIXED CODE ###

N,T=map(int,input().split())
res=2000
for i in range(N):
  c,t=map(int,input().split())
  if t>T:
    continue
  else:
    res=min(res,c)
if res==2000:
  print("TLE")
else:
  print(res)
import sys

in_=sys.argv[1]
with open(in_,"r") as f:
    lis=[]
    for line in f:
        line=line.strip()
        lis.append(line)
        
for i in sorted(lis,reverse=True):
    print(i)
    if i==2:
        break

### FIXED CODE ###

lis=[]
for i in range(10):
  lis.append(int(input()))
 
for i in sorted(lis,reverse=True)[:3]:
  print(i)
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces
def tr(x):
    if "DEBUG" in globals(): sys.stderr.write(f"{x}\n")

n, t = na()

mincost = 99999999999999
for i in range(n):
    c, u = na()
    if u <= t:
        mincost = min(mincost, c)

if mincost == 99999999999999:
    print("TLE")
else:
    print(mincost)


### FIXED CODE ###

import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, t = na()

mincost = 99999999999999
for i in range(n):
    c, u = na()
    if u <= t:
        mincost = min(mincost, c)

if mincost == 99999999999999:
    print("TLE")
else:
    print(mincost)
s=int(input())
ans=1
for i in range(1,n+1):
  ans=ans%(10**9+7)*n
  
  
print(ans%10000000007)

### FIXED CODE ###

s=int(input())
ans=1
for i in range(1,s+1):
  ans=ans%(10**9+7)*i
  
  
print(ans%(10**9+7))
def iread():
    return int(input())


def sread():
    return input()


def aread_int():
    tmp = input().split()
    ret = [int(i) for i in tmp]
    return ret


def aread_str():
    return input().split()

if __name__ == '__main__':
    n, x = map(int, input().split())
    l = aread_int()
    current = 0
    cnt = 0
    while current + l[cnt] <= x :
        current += l[cnt]
        cnt += 1
    
    print(cnt + 1)

### FIXED CODE ###

def iread():
    return int(input())


def sread():
    return input()


def aread_int():
    tmp = input().split()
    ret = [int(i) for i in tmp]
    return ret


def aread_str():
    return input().split()

if __name__ == '__main__':
    n, x = map(int, input().split())
    l = aread_int()
    current = 0
    cnt = 0
    while cnt < n and current + l[cnt] <= x :
        current += l[cnt]
        cnt += 1
    
    print(cnt + 1)
length0 = input()
length = length0.split()
a = length[0]
b = length[1]
print(str(a)+" "+str(b))
#area = a*b
#per = 2*a+2*b
#print(str(area)+" "+str(per))


### FIXED CODE ###

length0 = input()
#print(length0)
length = length0.split()
a = int(length[0])
b = int(length[1])
#print(str(a)+" "+str(b))
area = a*b
per = 2*a+2*b
print(str(area)+" "+str(per))
import itertools

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

list_ = itertools.combinations(range(n),2))
count = 0;

for i in range(len(list_)):
  count += D[list_[i][0]] + D[list_[i][1]];
  
print(count)


### FIXED CODE ###

import itertools

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

list_ = list(itertools.combinations(range(n),2))
count = 0;

for i in range(len(list_)):
  count += D[list_[i][0]] * D[list_[i][1]];
  
print(count)
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    p = list(map(int, input().split()))

    ans = 0
    i = 0
    # while i < N:
    for i in range(N):
        if i+1 == p[i]:
            tmp = p[i]
            p[i] = p[i+1]
            p[i+1] = tmp
            ans += 1
            # i += 1
        # i += 1
    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

# import sys
# input = sys.stdin.readline

def main():
    N = int(input())
    p = list(map(int, input().split())) + [N+1]

    ans = 0
    i = 1
    for i in range(N):
        if i+1 == p[i]:
            tmp = p[i]
            p[i] = p[i+1]
            p[i+1] = tmp
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()
while True:
    n = int(input())
    if n == 0:
        break
    
    sum_a = 0
    sum_b = 0
    
    for i in range(n):
        a,b = map(int, raw_input().split())
        
        if a > b:
            sum_a = sum_a + a + b
        elif a < b:
            sum_b = sum_b + a + b
        elif a == b:
            sum_a = sum_a + a
            sum_b = sum_b + b

    print("%s %s" %(sum_a,sum_b))

        



### FIXED CODE ###

while 1:
    n = int(input())
    if n == 0:
        break
    
    sum_a = 0
    sum_b = 0
    
    for i in range(n):
        a,b = map(int, input().split())
        
        if a > b:
            sum_a = sum_a + a + b
        elif a < b:
            sum_b = sum_b + a + b
        elif a == b:
            sum_a = sum_a + a
            sum_b = sum_b + b

    print(sum_a,sum_b)
t = input()
t = t.reprace("?","D")
print(t)

### FIXED CODE ###

t = input()
t = t.replace("?","D")
print(t)
i = int(input())
str = input()
r_count = 0

for color in str:
    if color == 'R':
        r_count+=1

if r_count * 2 > i:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

print('Yes') if len(set(input().split(' '))) == 1 else print('No')
s = str(input())
cou = 700
for i in range(3):


### FIXED CODE ###

s = str(input())
cou = 700
for i in range(3):
    if s[i] == "o":
        cou += 100
print(cou)
while 1 :
s= raw_input
a, op, b = s.split()
if op == ? : break
print eval(s)


### FIXED CODE ###

while True:
  s = raw_input()
  a, op, b = s.split()
  if op == '?': break
  print eval(s)
s=input()
K=int(input())
s=list(s)
#a-z 97-122
for i, s_ in enumerate(s):
    if s_!='a':
        if ord(s_)+K >= 123:
            s[i]='a'
            K -= (123-ord(s_))
if K>0:
    asc=ord(s[-1])+K%26
    s[-1]=chr(asc)
print ("".join(s))

### FIXED CODE ###

# -*- coding: utf-8 -*-
raw = raw_input()

ans =  raw[:4]+' '+raw[4:]

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


As = {}
Maxs = {}
Enji = [0 for n in range(N)]
EnjiRate = [0 for n in range(N)]

for i in range(N):
    A, B = map(int, input().split())
    if B in As:
        As[B].append(A)
        Maxs[B] = max(Maxs[B], A)
    else:
        As[B] = [A]
        Maxs[B] = A
    EnjiRate[i] = A
    Enji[i] = B

MaxHist = {}
for k, v in Maxs.items():
    if v in MaxHist:
        MaxHist[v].add(k)
    else:
        MaxHist[v] = set([k])


def addMap(target, key, val):
    if key in target:
        target[key].add(val)
    else:
        target[key] = set([val])


def removeMap(target, key, val):
    if len(target[key]) == 1:
        del target[key]
    else:
        target[key].remove(val)


minMax = sorted(MaxHist)[0]

for i in range(Q):
    c, D = map(int, input().split())
    C = c - 1
    prevPos = Enji[C]
    As[prevPos].remove(EnjiRate[C])
    if EnjiRate[C] == Maxs[prevPos]:
        # 再計算
        prevMax = Maxs[prevPos]
        removeMap(MaxHist, prevMax, prevPos)
        if len(As[prevPos]) > 0:
            currentMax = max(As[prevPos])
            Maxs[prevPos] = currentMax
            addMap(MaxHist, currentMax, prevPos)
    Enji[C] = D
    if D not in As:
        As[D] = []

    As[D].append(EnjiRate[C])

    if D in Maxs:
        if EnjiRate[C] > Maxs[D]:
            # 再計算
            currentMax = EnjiRate[C]
            prevMax = Maxs[D]
            removeMap(MaxHist, prevMax, D)
            Maxs[D] = currentMax
            addMap(MaxHist, currentMax, D)
    else:
        # これが最大
        currentMax = EnjiRate[C]
        Maxs[D] = currentMax
        addMap(MaxHist, currentMax, D)

    if minMax in MaxHist:
        print(minMax)
    else:
        print(sorted(MaxHist)[0])


### FIXED CODE ###

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

for idx, i in enumerate(X):
    if i == 0:
        print(idx+1)
import numpy as np
a = int(input())
b = int(input())
add = a+b
minus = a-b
cross = a*b
lis = np.array([add, minus, cross])
print(np.max(lis))

### FIXED CODE ###

a,b=input().split()
a = int(a)
b = int(b)
ad = a+b
minus = a-b
cross = a*b
lis = [ad, minus, cross]
print(max(lis))
S = list(input())
T = list(input())
S.sort()
T.sort()
SKind = []
TKind = []
cnt = 1
for i in range(1,len(S)):
    if i == 0:
        cnt+=1
    elif i == N-1:
        if S[i]==S[i-1]:
            cnt += 1
            SKind.append(cnt)
        else:
            SKind.append(cnt)
            SKind.append(1)
    elif S[i]==S[i-1]:
        cnt+=1
    elif S[i]!=S[i-1]:
        SKind.append(cnt)
        cnt = 1
#    print(SKind)
cnt = 1        
for i in range(1,len(T)):
    if i == 0:
        cnt+=1
    elif i == N-1:
        if T[i]==T[i-1]:
            cnt += 1
            TKind.append(cnt)
        else:
            TKind.append(cnt)
            TKind.append(1)
    elif T[i]==T[i-1]:
        cnt+=1
    elif T[i]!=T[i-1]:
        TKind.append(cnt)
        cnt = 1
#    print(TKind)
#print(SKind,TKind)
SKind.sort()
TKind.sort()
if SKind == TKind:
    print("Yes")
else: print("No")

### FIXED CODE ###

S = list(input())
T = list(input())
S.sort()
T.sort()
SKind = []
TKind = []
cnt = 1
for i in range(1,len(S)):
    if i == len(S)-1:
        if S[i]==S[i-1]:
            cnt += 1
            SKind.append(cnt)
        else:
            SKind.append(cnt)
            SKind.append(1)
    elif S[i]==S[i-1]:
        cnt+=1
    elif S[i]!=S[i-1]:
        SKind.append(cnt)
        cnt = 1
cnt = 1        
for i in range(1,len(T)):
    if i == len(T)-1:
        if T[i]==T[i-1]:
            cnt += 1
            TKind.append(cnt)
        else:
            TKind.append(cnt)
            TKind.append(1)
    elif T[i]==T[i-1]:
        cnt+=1
    elif T[i]!=T[i-1]:
        TKind.append(cnt)
        cnt = 1
SKind.sort()
TKind.sort()
if SKind == TKind:
    print("Yes")
else: print("No")
#coding: utf-8

import sys

for line in sys.stdin:
    l = (map(int,line.split()))
    l.sort()
    a = l[0]
    b = l[1]
    for i in range(2,b+1):
        if a%i == 0 and b%i == 0:
            ans = i:
    print a*b/ans,ans

### FIXED CODE ###

#coding: utf-8

import sys

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

for line in sys.stdin:
    l = map(int,line.split())
    l.sort()
    a = l[0]
    b = l[1]
    print gojo(a,b),a*b/gojo(a,b)
a=input()
b=input()
c=input()

def mix(s,t):
    for length in range(len(s),0,-1):
        u=s[-length:]
        v=t[:length]

        #print(u,v)

        for i in range(length):
            if u[i]==v[i] or u[i]=="?" or v[i]=="?":
                continue
            else:
                break
        else:
            ret=""
            for i in range(length):
                if u[i]=="?":
                    ret+=v[i]
                else:
                    ret+=u[i]
                
            return s[:-length]+ret+t[length:]

    return s+t

ANS=[mix(mix(a,b),c),mix(mix(b,a),c),mix(mix(c,b),a),mix(mix(b,c),a),mix(mix(c,a),b),mix(mix(a,c),b),mix(c,mix(a,b)),mix(c,mix(b,a)),mix(a,mix(c,b)),mix(a,mix(b,c)),mix(b,mix(c,a)),mix(b,mix(a,c))]
L=1<<30
for a in ANS:
    L=min(L,len(a))
print(L)


### FIXED CODE ###

a=input()
b=input()
c=input()

X=[a,b,c]
LEN=[len(a),len(b),len(c)]

MF=[[[1]*2001 for j in range(3)] for i in range(3)]

for i in range(3):
    for j in range(3):
        if i==j:
            continue
        for k in range(2001):
            for l in range(LEN[j]):
                if k+l>=LEN[i]:
                    break
                if X[i][k+l]!="?" and X[j][l]!="?" and X[i][k+l]!=X[j][l]:
                    MF[i][j][k]=0
                    break

ANS=1000000
for i in range(3):
    for j in range(3):
        if i==j:
            continue
        for k in range(2001):
            if MF[i][j][k]==1:
                for l in range(2001):
                    if ANS<=max(LEN[i],LEN[j]+k,LEN[3-i-j]+k+l):
                        break
                    if MF[j][3-i-j][l]==1 and (k+l>2000 or MF[i][3-i-j][k+l]==1):
                        ANS=max(LEN[i],LEN[j]+k,LEN[3-i-j]+k+l)

print(ANS)
import sys

argv = sys.argv
a = []

P = int(argv[1])
Q = int(argv[2])
R = int(argv[3])

a.append(P)
a.append(Q)
a.append(R)
max = 0
for i in a:
    if max < i:
        max = i

print(sum(a)-max)

### FIXED CODE ###

import sys

a = []


P, Q, R=map(int, input().split())
a.append(P)
a.append(Q)
a.append(R)
max = 0
for i in a:
    if max < i:
        max = i

print(sum(a)-max)
s,w = map(int,input().split())

if s<=W:
  print('unsafe')
else:
  print('safe')

### FIXED CODE ###

s,w = map(int,input().split())

if s<=w:
  print('unsafe')
else:
  print('safe')
a,b,c,d,e,f=map(int,input().split())

DP=[[0,0] for _ in range(f+1)]
DP[a*100][0]=a*100
DP[b*100][0]=b*100

for i in range(f+1):
    if DP[i][0]==0:continue
    for j in a,b:
        if i+j*100<=f:
            j *=100
            if DP[i][1]*100/(i+j)>=DP[i+j][1]*100/(i+j):
                DP[i+j]=[i+j,DP[i][1]]
    for j in c,d:
        if i+j<=f:
            if 100*(DP[i][1]+j)/(i+j)<=100*e/(100+e):
                if 100*(DP[i][1]+j)/(i+j)>=100*(DP[i+j][1])/(i+j):
                    DP[i+j]=[i+j,DP[i][1]+j]

ans,water=0,[a*100,0]
for x,y in DP:
    if x==0:continue
    if 100*y/x>ans:
        ans=100*y/x
        water=[x,y]
print(*water)

### FIXED CODE ###

inf=10**8
a,b,c,d,e,f=map(int,input().split())
a,b=100*a,100*b
DP=[inf]*(f+max(a,b)+1)
DP[a],DP[b]=0,0

for i in range(f+1):
    if DP[i]!=inf:
        DP[i+a]=DP[i]
        DP[i+b]=DP[i]
        for j in c,d:
            if 100*(DP[i]+j)/(i+j)<=100*e/(100+e):
                DP[i+j]=max(DP[i],DP[i]+j)

ans,index=0,[a,0]
for i in range(f+1):
    if DP[i]!=inf:
        if ans<100*DP[i]/i:
            ans=100*DP[i]/i
            index=[i,DP[i]]

print(*index)
T, X = map(int, input(),split())
print(T/X)

### FIXED CODE ###

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

print(T/X)
n,m=map(int,input().split())
s=input()
x=n
a=0
while x!=0:
  for i in range(m,0,-1):
    if s[x-i]=="0":
      x-=i
      a=a*10+i
      break
    if i==1:print(-1);exit()
print(*list(str(a))[::-1])

### FIXED CODE ###

n,m=map(int,input().split())
s=input()
x=n
a=[]
while x!=0:
  for i in range(min(m,x),0,-1):
    if s[x-i]=="0":
      x-=i
      a.append(i)
      break
    if i==1:print(-1);exit()
print(*a[::-1])
A, B, C= map(int, input().split())

if (A+B) >= C:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

A, B, C= map(int, input().split())

if (A+B) >= C:
    print("Yes")
else:
    print("No")
n = int(input())
a = [(A, i) for i, A in enumerate(map(int, input().split()))]

a.sort()
dp = [[-1]*n for _ in range(n)]

def recursive(l, r):
    if l > r:
        return 0
    if dp[l][r] >= 0:
        return dp[l][r]
    k = r - l
    energy, pos = a[k]
    from_l = energy * abs(l - pos)
    from_r = energy * abs(r - pos)
    ans = dp[l][r] = max(from_l + recursive(l+1, r), from_r + recursive(l, r-1))
    return ans

print(recursive(0, n-1))

### FIXED CODE ###

def main():
  N = int(input())
  INF = float('inf')
  A = [(i+1, a) for i, a in enumerate(map(int, input().split()))]
  A = sorted(A, key=lambda x: x[1], reverse = True)

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

  for s in range(1, N+1):
    for l in range(s+1):
      r = s - l
      dp[l][r] = max(dp[l-1][r] + A[s-1][1] * abs(A[s-1][0]-l), dp[l][r-1] + A[s-1][1] * abs(N-r+1-A[s-1][0]))
    
  ans = 0
  for m in range(N):
    if(dp[m][N-m] > ans):
      ans = dp[m][N-m]
    
  print(ans)

main()
N = int(input().strip())
x = []
y = []
h = []
for i in range(0, N):
    xi, yi, hi= [int(a) for a in input().strip().split()]
    x.append(xi)
    y.append(yi)
    h.append(hi)

def calc_H():
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            H = -1
            for i in range(0, N):
                Hi = h[i] + abs(x[i]-Cx) + abs(y[i]-Cy)
                if H == -1:
                    H = Hi

                if h[i] == 0:
                    if H > Hi:
                        break
                elif H != Hi:
                    break

                if i == N-1:
                    return Cx, Cy, H

print(*calc_H())

### FIXED CODE ###

N = int(input().strip())
xyh = []
for i in range(0, N):
    xi, yi, hi= [int(a) for a in input().strip().split()]
    xyh.append((xi, yi, hi))

xyh.sort(key = lambda t: t[2], reverse = True)

def calc_H():
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            H = -1
            for i in range(0, N):
                Hi = xyh[i][2] + abs(xyh[i][0]-Cx) + abs(xyh[i][1]-Cy)
                if H == -1:
                    H = Hi

                if xyh[i][2] == 0:
                    if H > Hi:
                        break
                elif H != Hi:
                    break

                if i == N-1:
                    return Cx, Cy, H

print(*calc_H())
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy


def main():
  r, c = map(int, input().split())
  g = numpy.array([[1 if v == '.' else 0 for v in input().strip()] for _ in range(r)])
  g = numpy.stack([g, g])

  for x in range(1, c):
    g[0, :, x] += g[0, :, x] * g[0, :, x - 1]

  for x in range(c - 2, -1, -1):
    g[0, :, x] = (g[0, :, x] != 0) * numpy.maximum(g[0, :, x], g[0, :, x + 1])

  for y in range(1, r):
    g[1, y] += g[1, y] * g[1, y - 1]

  for y in range(r - 2, -1, -1):
    g[1, y] = (g[1, y] != 0) * numpy.maximum(g[1, y], g[1, y + 1])

  g = g[0] + g[1]

  print(numpy.max(g) - 1)


if __name__ == '__main__':
  main()



### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy


def main():
  r, c = map(int, input().split())
  g = numpy.array([[1 if v == '.' else 0 for v in input().strip()] for _ in range(r)])
  g = numpy.array([g, g])

  for x in range(1, c):
    g[0, :, x] += g[0, :, x] * g[0, :, x - 1]

  for x in range(c - 2, -1, -1):
    g[0, :, x] = (g[0, :, x] != 0) * numpy.maximum(g[0, :, x], g[0, :, x + 1])

  for y in range(1, r):
    g[1, y] += g[1, y] * g[1, y - 1]

  for y in range(r - 2, -1, -1):
    g[1, y] = (g[1, y] != 0) * numpy.maximum(g[1, y], g[1, y + 1])

  g = g[0] + g[1]

  print(numpy.max(g) - 1)


if __name__ == '__main__':
  main()
from itertools import combinations
from collections import deque

N, M, X = map(int, input().split())
CA = [list(map(int, input().split())) for _ in range(N)]

row = [i for i in range(1, N+1)]
ans = float("INF")
for i in range(1, N):
  for v in combinations(row, i):
    q = deque(v)
    cost = 0
    Asum = [0]*M
    while q:
      a = q.popleft() - 1
      cost += CA[a][0]
      for j in range(M):
        Asum[j] += CA[a][j+1]
    flag = True
    for m in range(M):
      if Asum[m] < X:
        flag = False
    if flag:
      ans = min(ans, cost)
if ans == float("INF"):
  print(-1)
else:
  print(ans)

### FIXED CODE ###

S = input()
T = input()

if S + T[-1] == T:
  print("Yes")
else:
  print("No")
n=int(input())
a=[int(x) for x in input().split()]
import math
from functools import reduce
def prod(lists):
    ans=1
    for i in lists:
        ans=ans*i
    return ans
def gcd(numbers):
    return reduce(math.gcd, numbers)
lcm=prod(a)//gcd(a)
print(sum([(lcm-1)%ai for ai in a]))

### FIXED CODE ###

n=int(input())
a=[int(x) for x in input().split()]
print(sum([(ai-1)%ai for ai in a]))
import math

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

l = []
for i in range(n):
    if i <= k:
        m = math.ceil(math.log2(k/(i+1)))
        l.append(1/2**m)
    else:
        l.append(1)

print(1/n*sum(l))print(1/n*sum(l))

### FIXED CODE ###

import math

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

l = []
for i in range(n):
    if i <= k:
        m = math.ceil(math.log2(k/(i+1)))
        l.append(1/2**m)
    else:
        l.append(1)

print(1/n*sum(l))
l = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

n = int(input())
for i in range(n):
    b,f,r,v = [int(i) for input().split()]
    l[b-1][f-1][r-1] += v

for b in range(4):
    for f in range(3):
        out = ""
        for r in range(10):
            out += " " + str(l[b][f][r])
        print(out)
    if 3 != b:
        print("####################")


### FIXED CODE ###

l = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

n = int(input())
for i in range(n):
    b,f,r,v = [int(i) for i in input().split()]
    l[b-1][f-1][r-1] += v

for b in range(4):
    for f in range(3):
        out = ""
        for r in range(10):
            out += " " + str(l[b][f][r])
        print(out)
    if 3 != b:
        print("####################")