peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
N, K = map(int, input().split())
A = list(map(int, input().split()))

mi = 0
ma = 10**9
while(ma - mi != 1):
    c = 0
    mid = (ma + mi) // 2
    for i in range(N):
        c += A[i] // mid - (A[i] % mid == 0)
    if c > K:
        mi = mid
    else:
        ma = mid
print(ma)
# Judge status: Wrong Answer
A,B = map(int,input().split())

cnt =0

for i in range(A,B+1):
    Str = str(i)
    
    if Str[0:2] ==Str[3:]:
        cnt += 1
        
print(cnt)
# Judge status: Accepted
#!/usr/bin/env python3
import itertools
import math
n = int(input())
s = [list(map(int, input().split())) for i in range(n)]
a = 0
for j in itertools.permutations(range(n)):
    for k in range(n-1):
        a += ((s[j[k]][0] - s[j[k+1]][0])**2 + (s[j[k]][1] - s[j[k+1]][1])**2)**0.5
print(a/math.factorial(n))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

s = 0

for i in range(n):
    s += b[a[i]-1]
    if i > 0 and a[i-1] + 1 == a[i]:
        s += c[a[i-1]-1]

print(s)
# Judge status: Wrong Answer
a, b, c, d = (int(i) for i in input().split())
takahashi = (c+b) // b
aoki = (d+a) // a
if takahashi <= aoki:
    print("No")
else: print("Yes")
# Judge status: Accepted
S = str(input())

f, r = map(int, (S[:2], S[2:]))
ans = ''
if 1 <= f <= 12 and 1 <= r <= 12:
  ans = 'AMBIGUOUS'
elif 1 <= f <= 12:
  ans = 'MMYY'
elif 1 <= r <= 12:
  ans = 'YYMM'
else:
  ans = 'NA'

print(ans)
# Judge status: Wrong Answer
lst = [input().split()+[str(i+1)] for i in range(int(input()))]
print("\n".join([i[2] for i in sorted(lst, key=lambda x:(-1*int(x[1]), x[0]))]))
# Judge status: Accepted
A = []
B = []
C = []

for i in range(1,101):
    t0 = i
    t1 = i*100
    t2 = i*100*100
    A.append(t0)
    B.append(t1)
    C.append(t2)

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

if d == 0:
    if n == 100:
        print(101)
    else:
        print(A[n-1])
elif d == 1:
    if n == 100:
        print(100*101)
    else:
        print(B[n-1])
else:
    if n == 100:
        print(100*100*101)
    else:
        print(C[n-1])
# Judge status: Wrong Answer
N ,M = (map(int , input().split()))
e_dict = {}
for i in range(N):
    A ,B = (map(int , input().split()))
    e_dict[A] = B
e_dict_sorted = dict(sorted(e_dict.items(), key=lambda x:x[0]))
honsuu = 0
kane = 0
for k , v in e_dict_sorted.items():
    honsuu += v
    kane += k * v
    if honsuu >= M:
        break
hiku = honsuu - M
ans = kane - (hiku*k)
print(ans)
# Judge status: Wrong Answer
N=int(input())
K=int(input())
X=int(input())
Y=int(input())
if N<=K:
  print(X*N)
else:
  print(X*N+Y*(N-K))
# Judge status: Accepted
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 29 21:14:35 2020
"""

import sys
import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

N = int(input())
#X, Y = map(int,input().split())
a = np.array(list(map(int,input().split())))
b = np.array(list(map(int,input().split())))

c = b - a

ok = np.sum(c[c > 0]//2)
ng = np.sum(-c[c < 0])

if ok >= ng:
    ans = 'Yes'
else:
    ans = 'No'
print(ans)
# Judge status: Accepted
n =int(input())
l = [int(x) for x in list(str(n))]
#print(l)
n = l[len(l)-1]
#print(n)
if n==2 or n==4 or n==5 or n==7 or n==9:
  print('hon')
elif n==0 or n==1 or n==6 or n==8:
  print('pon')
else:
  print('bon')
# Judge status: Wrong Answer

n=int(input())
s=str(input())
e_cnt=s.count('E')
num=[0]*n #Wの数
num2=[0]*n #Eno左から数えた数
count=0
count2=0
for i in range(n):
    if s[i]=='W':
        num[i]=count
        num2[i]=e_cnt-count2
        count+=1
    else:
        num[i]=count
        num2[i]=e_cnt-count2 
        count2+=1
    
   

ans=[0]*n

for i in range(n):
    ans[i]=abs(num[i]+num2[i])
print(min(ans))
# Judge status: Accepted
import numpy as np
n = int(input())
a = np.array(input().split(),dtype=int)
mod = 10**9+7

twos = 1
ans = 0
for i in range(0,60):
    cou1 = np.count_nonzero((a >> i) & 1)
    ans += (cou1*(n-cou1)*twos)%mod
    twos = (twos*2)%mod

ans %= mod
print(ans)
# Judge status: Wrong Answer
def main():
	ip = input().split(" ")
	N = int(ip[0])
	M = int(ip[1])

	job = []

	for i in range(N):
		ip = input().split(" ")
		a = int(ip[0])
		b = int(ip[1])
		job.append([a,b])

	def keyFunc(j):
		return j[1]

	job = sorted(job, key=keyFunc, reverse=True)

	profit = 0

	for i in job:
		if i[0] <= M:
			profit += i[1]
			M -= 1
		if M == 0:
			break

	print(profit)

main()
# Judge status: Wrong Answer
n,d = map(int,input().split())
point = [list(map(int,input().split())) for _ in range(n)]
count = 0
for i in range(n-1):
  for j in range(i+1,n):
    d = 0
    for k in range(0,d):
      d += pow(point[i][k]-point[j][k],2)
    d = d**0.5
    if int(d)==d: count += 1
print(count)
# Judge status: Wrong Answer
s = list(input())
num = 0
n = len(s)
l = []
i = 0
while i < n:
  if s[i] == '<':
    l.append(num)
    num+=1
    i+=1
    if i==n:
      l.append(num)
  else:
    cur = 1
    while i < n and s[i]=='>':
      l.append(cur)
      i+=1
      cur+=1
    num = 0
print(sum(l))
# Judge status: Accepted
import sys
from sys import stdin

s = stdin.readline().rstrip()
n = len(s)
s = '|' + s + '|'
r = [0] * (n + 1)
l = [0] * (n + 1)

for i in range(1, n + 1):
    if s[i] == '<':
        l[i] = l[i - 1] + 1
    else:
        l[i] = 0
for i in range(n - 1, -1, -1):
    if s[i + 1] == '>':
        r[i] = r[i + 1] + 1
    else:
        r[i] = 0

ans = 0
for i in range(n + 1):
    ans += max(r[i], l[i])
# print(r, l)
print(ans)
# Judge status: Accepted
a, b, c = map(int, input().split())
print("bust" if a+b+c > 21 else "win")
# Judge status: Accepted
N = int(input())
ds = sorted(list(map(int, input().split())))
print(ds[len(ds)//2] - ds[len(ds)//2-1])
# Judge status: Accepted
N=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
print(sum(a[::2])-sum(a[1::2]))
# Judge status: Accepted
a, b, c = map(int, input().split())
if c-a-b > 0:
    if 4*a*b < (c-a-b)**2:
        print('Yes')
    else:
        print('No')
else:
    print('No')
# Judge status: Accepted
import math

h = int(input())
w = int(input())
n = int(input())

r = max(h, w)
print(math.ceil(n/r))
# Judge status: Wrong Answer
H,W,N = [int(input()) for _ in range(3)]
print(N/max(H,W)+1)
# Judge status: Wrong Answer
c=input()
if c=='a' or 'e' or 'i' or 'o' or 'u':
  print('vowel')
else:
  print('consonant')
# Judge status: Accepted
s = str(input().rstrip())
l=0
r=1
tmp =''
li = list()
while(r<=len(s)):
  if(s[l:r]!=tmp):
    li.append(s[l:r])
    tmp=s[l:r]
    l=r
    r+=1      
  else:
    r+=1

print(len(li))
# Judge status: Wrong Answer
x, y, a,b, c = map(int, input().split())
P = list(map(int, input().split())); P.reverse()
Q = list(map(int, input().split())); Q.reverse()
R = list(map(int, input().split())); R.reverse()

ans = P[:x] + Q[:y] + R
ans.sort(); ans.reverse()
ans = ans[:(x + y)]

print (sum(ans))
# Judge status: Wrong Answer
n, k ,q = map(int, input().split())
list_q = []
ans = ['Yes']*n
for _ in range(q):
  list_q.append(int(input()))
print(ans)
# Judge status: Wrong Answer
s = input()
k = int(input())

if s[0] != '1':
    print(s[0])
else:
    if k == 1:
        print(s[0])
    else:
        print(s[1])
# Judge status: Accepted
ans = 0
s = 100
for i in range(5):
    a = int(input())
    r = a % 10
    if r > 0:
        s = min(s, r)
    ans += a // 10 * 10 + (10 if r > 0 else 0)
if s == 100:
    print(ans)
else:
    print(ans + s - 10)
# Judge status: Wrong Answer
N,M,X,Y = map(int,input().split())

x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]

c=0
for i in range(X+1,Y+1):
  c =0
  if (i >=X and i <=Y) :
    c += 1
  if max(x) <= i :
    c += 1
  if min(y) >= i :
    c += 1
  
  if c == 3:
    print(i)
    print("No War")
    exit()
  else:
    continue
    
    
print("War")
# Judge status: Accepted
import math
import fractions
from functools import reduce

n, m = map(int, input().split())
a = list(map(lambda x:int(x)//2, input().split()))

t = 0
while all([i%(2**(t+1))==0 for i in a]):t+=1
a = [i//(2**t) for i in a]

if any([i%2==0 for i in a]):
  print(0)
else:
  b = reduce(lambda x,y:x*(y//fractions.gcd(x,y)),a) * (2**t)
  print((m//b+1)//2)
# Judge status: Accepted
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def main():
    a,b,k = map(int,input().split())
    from math import gcd
    y = make_divisors(gcd(a,b))
    print(y[-k])

if __name__ == '__main__':
    main()
# Judge status: Accepted
x,y=map(int,input().split())
#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)
print(lcm(x,y))
# Judge status: Accepted
n, m = map(int, input().split())

if 2*n >= m:
    print(m//2)
    exit(0)


c = m - (2*n)
s = c // 4

print(n+s)
# Judge status: Accepted
ans = ""
n = int(input())
l = list(map(int, input().split()))
s = 0
for a in l:
  s ^= a
for a in l:
  ans += str(s^a) + " "
print(ans[:-1])
# Judge status: Accepted
def main():
    n=int(input())
    s=input()
    
    ans=s.count('.')
    t=ans
    for i in range(n):
        if s[i]=='.':
            t-=1
        else:
            t+=1           
        ans=min(ans,t)
    print(ans)
    
if __name__=='__main__':
    main()
# Judge status: Accepted
n = int(input())
lst = list(map(int, input().split()))
dic = {}
for i in range(n):
  a = lst[i]
  dic.setdefault(a - 1, 0)
  dic[a - 1] += 1
  dic.setdefault(a, 0)
  dic[a] += 1
  dic.setdefault(a + 1, 0)
  dic[a + 1] += 1
print(max(list(dic.values())))
# Judge status: Accepted
N,M=map(int,input().split())
H=list(map(int,input().split()))
A=[]
for i in range(M):
    A.append(list(map(int,input().split())))
    
Q=[0]*N
for i in range(M):
    if H[A[i][0]-1]>=H[A[i][1]-1]:
        Q[A[i][1]-1]=-10**5
    if H[A[i][0]-1]<=H[A[i][1]-1]:
        Q[A[i][0]-1]=-10**5
n = sum(x>=0 for x in Q)
print(n)
# Judge status: Accepted
n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1,105):
    for j in range(1,105):
        for k in range(1,105):
            v = i*i+j*j+k*k+i*j+j*k+k*i;
            if v<10050:
            	ans[v]+=1
for i in range(n):
    print(ans[i+1])
# Judge status: Accepted
N = int(input())
D = [int(i) for i in input().split()]
D.sort()
print(D[int(N / 2)] - D[int(N / 2 - 1)])
# Judge status: Accepted
from itertools import accumulate
from fractions import gcd

N = int(input())
As = list(map(int, input().split()))

cum_gcd = list(accumulate(As, gcd))
cum_rev_gcd = list(accumulate(reversed(As), gcd))[::-1]

max_gcd = max(cum_gcd[-2], cum_rev_gcd[1])
for without in range(1, N-1):
    max_gcd = max(max_gcd, gcd(cum_gcd[without-1], cum_rev_gcd[without+1]))

print(max_gcd)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
ans = 0

for i in a:
  if i%2 ==0 and (i%3 !=0 and i%5 != 0):
    ans += 1
  else:
    pass
  
if ans >0:
  print("DENIED")
else:
  print("APPROVED")
# Judge status: Accepted
X, Y = map(int, input().split())
if 2*X <= Y <= 4*X and Y % 2 == 0: print("Yes")
else: print("No")
# Judge status: Wrong Answer
A, B = map(int, input().split())

ans = A + B

if A + B > 24:
    ans -= 24

print(ans)
# Judge status: Accepted
A,B = map(int,input().split())
if A==B:
	print('Draw')
elif A == 1:
	print('Alice')
elif B == 1:
	print('Bob')
elif A<B:print('Bob')
else:print('Alice')
# Judge status: Accepted
day_dict={'SUN':7, 'MON':6, 'TUE':5, 'WED':4, 'THU':3, 'FRI':2, 'SAT':1}
S=input()
print(day_dict[S])
# Judge status: Accepted
X,Y,A,B,C = map(int,input().split())
P = [int(i) for i in input().split()]
Q = [int(i) for i in input().split()]
R = [int(i) for i in input().split()]
from collections import deque
P_sort = sorted(P,reverse=True)[0:X]
Q_sort = sorted(Q,reverse=True)[0:Y]
R_sort = deque(sorted(R,reverse=True)[0:X+Y])
PQ = sorted(P_sort + Q_sort)
for i in range(len(PQ)):
    if R_sort[0] > PQ[i]:
        r = R_sort.popleft()
        PQ[i] = r
    if not R_sort:
      break
print(sum(PQ))
# Judge status: Accepted
x = int(input()) + 1
count = 0
for i in range(x):
  if i % 3 == 0:
    pass
  elif i % 5 == 0:
    pass
  else:
    count += i

print(count)
# Judge status: Accepted
from collections import Counter
N = int(input())
A = map(int, input().split())
Q = int(input())
ops = []
for _ in range(Q):
  b, c = map(int, input().split())
  ops.append((b,c))

cnt = Counter(A)
s = sum(k*v for k, v in cnt.items())
for b, c in ops:
  s -= b * cnt[b]
  s += c * cnt[b]
  cnt[c] += cnt[b]
  cnt[b] = 0
  print(s)
# Judge status: Accepted
c1 = list(map(int,input().split()))
c2 = list(map(int,input().split()))
c3 = list(map(int,input().split()))
print ("Yes") if c1[0]-c1[1] == c2[0]-c2[1] == c3[0]-c3[1] and c1[1]-c1[2] == c2[1]-c2[2] == c3[1]-c3[2] else print ("No")
# Judge status: Accepted
a,b = map(int,input().split())
if a <= 8 and b <= 8:
  print("Yay!")
else:
  print(":(")
# Judge status: Accepted
a, b, c = map(int, input().split())
print('YES' if b - a == c - b else 'NO')
# Judge status: Accepted
import bisect

def main():
  n=int(input())
  A=sorted(list(map(int,input().split())))
  B=list(map(int,input().split()))
  C=sorted(list(map(int,input().split())))
  lc=len(C)
  ans=0
  for b in B:
    ma = bisect.bisect_left(A, b)
    mc = lc-bisect.bisect_right(C, b)
    ans += ma*mc
  print(ans)

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
s = input()
search = 'keyence'
flg = True

for i in search:
    if i in s:
        idx = s.find(i)
        s = s[idx:]
    else:
        flg = False
        break
               
print('YES' if flg else 'NO')
# Judge status: Accepted
N = input()
K = int(input())
ans = '1'
for i in range(K):
  if i >= len(N):
    break
  if N[i] != '1':
    ans = N[i]
    break
print(ans)
# Judge status: Wrong Answer
n, m = map(int, input().rstrip().split())
hl = [int(v) for v in input().rstrip().split()]
goods = [ 1 for _ in range(n)]
for i in range(m):
    a, b = map(int, input().rstrip().split())
    a -= 1
    b -= 1
    if hl[a] < hl[b]:
        hl[a] = hl[b]
        goods[a] = 0
    elif  hl[a] > hl[b]:
        hl[b] = hl[a]
        goods[b] = 0

print(sum(goods))
# Judge status: Accepted
a, b, c = list(map(int, input().split()))
if a <= c <= b:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N,M = map(int,input().split())
for i in range(1,M+1):
    if N-2*i+1>N//2 or N%2==1:
        print(i,N-i+1)
    else:
        print(i,N-i)
# Judge status: Accepted
N = int(input())
X = list(map(int, input().split()))

total = 0
m = round(sum(X) / N)

for i in X:
    total += (m - i) ** 2
print(total)
# Judge status: Accepted
def main():
    mod = 10**9+7

    N = int(input())

    ans = 1

    for i in range(1, N+1):
        ans *= i
        ans %= mod

    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
A, B, C, K = map(int, input().split())
d = A - B if K % 2 == 0 else B - A
print(d if abs(d) <= 10**18 else "Unfair")
# Judge status: Accepted
n, k = map(int, input().split())
*a, = map(int, input().split())
ans = 1
n -= k
ans += (n+k-2)//(k-1)
print(ans)
# Judge status: Accepted
# coding: utf-8
# Your code here!

K = int(input())

s = 7 % K
for i in range(1, K+1) : 
    if i != 1 : 
        s = (10*s + 7) % K

    if s == 0 : 
        print(i)
        exit()

print(-1)
# Judge status: Accepted
from collections import deque
N=int(input())
A=list(map(int,input().split()))
l=[]
r=[]
for i in range(N):
  if i%2==0:
    r.append(A[i])
  else:
    l.append(A[i])
if N%2==0:
  print(*(list(reversed(l))+r))
else:
  print(*(list(reversed(r))+l))
# Judge status: Accepted
n = int(input())
l =[i for i in range(1, n+1)]
odds = [i for i in range(1, n+1) if i % 2 == 1]
print(float(len(odds))/float(len(l)))
# Judge status: Accepted
n = int(input())
a = [int(x) for x in input().split()]
a.sort(reverse=True)
key = []
p = -1
for i in range(1, n):
  if p == i:
    continue
  if a[i] == a[i-1]:
    key.append(a[i])
    if len(key) == 2:
      break
    p = i+1
if len(key) < 2:
  print(0)
else:
  print(key[0]*key[1])
# Judge status: Accepted
s = input()
t=input()
if t[:-1] == s:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
ans=1
out=10**18
for i in range(n):
    ans=ans*a[i]
    if out<ans:
        ans=-1
        break
for i in range(n):
    if a[i]==0:
        ans=0
        break
print(ans)
# Judge status: Accepted
ll = list(map(int, input().split()))
k = int(input())

for i in range(3):
    if max(ll) == ll[i]:
        ll[i] = ll[i]*(2**k)
print(sum(ll))
# Judge status: Wrong Answer
N = int(input())
ans = []

while N != 0:
    sup = N % 26
    ans.append(chr(96 + sup))
    N = N // 26

ans = ''.join(reversed(ans))
print(ans)
# Judge status: Wrong Answer
N = int(input())
H = list(map(int, input().split()))
ans = "Yes"
if N == 2:
    if H[0] > H[1]:
        ans = "No" 
else: 
    for i in range(N-2):
        if H[i] - H[i+2] >= 2:
            ans = "No"
print(ans)
# Judge status: Accepted
n = int(input())
ans = 0
for i in range(1, n+1, 2):
    count = 0
    for j in range(1, i+1):
        if i%j == 0:
            count += 1
    if count==8:
        ans+=1
print(ans)
# Judge status: Accepted
x, n = map(int, input().split())
p = set(map(int, input().split()))
l = set(i for i in range(102))
sa = 1000
ans = 0
for i in l-p:
    if sa > abs(x-i):
        sa = abs(x-i)
        ans = i
print(ans)
# Judge status: Accepted
N = int(input())
M = [0] * 100
for i in range(1, N+1):
    i = str(i)
    l, r = int(i[0]), int(i[-1])
    M[l*10+r] += 1
ans = 0
for i, cnt in enumerate(M):
    l, r = divmod(i, 10)
    ans += cnt * M[r*10+l]
print(ans)
# Judge status: Accepted
MOD = 10**9+7
N = int(input())
L = list(map(lambda x: bin(int(x))[2:], input().split()))
max_len = max([len(v) for v in L])
padL = ["0"*(max_len-len(v))+v for v in L]
cnt = [0]*max_len
for i in range(max_len):
    for l in padL:
        cnt[i] += 1 if l[i] == "1" else 0

ans = 0
v = 1
for i in range(max_len):
    ans += v*cnt[max_len-1-i]*(N-cnt[max_len-i-1])
    ans %= MOD
    v *= 2

print(ans)
# Judge status: Accepted
S = input()
if S == "Sunny":
  print("Cloudy")
elif S == "Cloudy":
  print("Rainy")
else:
  print("Sunny")
# Judge status: Accepted
N=int(input())
print((N//2+N%2)/N)
# Judge status: Wrong Answer
n = int(input())
h = list(map(int, input().split()))

#print(n)
#print(h)

best=1
for i in range(n):
	if (i==n-1) or (i==n-2 and h[i] < h[i+1]):
		m=0
	elif i==n-2 and h[i] >= h[i+1]:
		m=1
	else:
		m=1        
		while i+m<=n-1 and h[i] >= h[i+m]:
			m=m+1
		if i+m == n or h[i] < h[i+m] :
			m=m-1
	if m>best:
		best=m
print(best)
# Judge status: Accepted
K = int(input())
a,b = map(int,input().split())

for i in range(a,b+1):
    if i % K == 0:
        print("OK")
        quit()
print("NG")
# Judge status: Wrong Answer
import math

A, B, H, M = (int(x) for x in input().split())

if M * 360 / 60 > 180 :
    minuteAngle = M * 360 / 60 - 180
else : minuteAngle = M * 360 / 60

if M * 30 / 60 + H * 30 > 180 :
    hourAngle = M * 30 / 60 + H * 30 - 180
else : hourAngle = M * 30 / 60 + H * 30

if minuteAngle < hourAngle :
    angleC = hourAngle - minuteAngle
else : angleC = minuteAngle - hourAngle

print(angleC)
angleC = math.cos(math.radians(angleC))

print(math.sqrt((A ** 2) + (B ** 2) - (2 * A * B * angleC)))
# Judge status: Wrong Answer
T=list(input())


ans=[]
buff="D"

leng=len(T)

for i in range(leng):
    now=T[i]
    if now=="?":
        if (i+1 < leng) and T[i+1] in ["?", "D"]:
            if buff == "P":
                ans.append("D")
            else:
                ans.append("P")
        else:
            ans.append("D")
    else:
        ans.append(now)
    buff=now

print("".join(ans))
# Judge status: Accepted
H = int(input())
ans = 0
now = 1
while H > 0:
    ans += now
    now *= 2
    H //= 2

print(ans)
# Judge status: Accepted
import sys
import numpy as np
def Ii():return int(sys.stdin.buffer.read())
def Mi():return map(int,sys.stdin.buffer.readline().split())
def Li():return list(map(int,sys.stdin.buffer.readline().split()))
  
n,m,x = Mi()
a = []
b=[0]*m
b = np.array(b)
for i in range(n):
  a.append(Li())
  
ans = 10**7
def DFS(cost,start,skill):
  global ans
  if min(skill) >= x:
    ans = min(ans,cost)
    return ans
  for i in range(start,n):
    DFS(cost+a[i][0],i+1,skill+np.array(a[i][1:]))
  return ans

a = DFS(0,0,b)
if a == 10**7:
  a = -1
print(a)
# Judge status: Accepted
a,b,c = map(int,input().split())

if(a < b):
    if(a < c and c < b):
        print('Yes')
    else:
        print('No')
else:
    if(b < c and c < a):
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
n, k, s = map(int, raw_input().split())
if s == 10 ** 9:
    a = [s] * k + [1] * (n - k)
else:
    a = [s] * k + [s + 1] * (n - k)
for x in a:
    print x,
print
# Judge status: Wrong Answer
s = input()
kisuu = ['R', 'U', 'D']
guusuu = ['L', 'U', 'D']
for i in s[::2]:
    if i in kisuu:
        continue
    else:
        print('No')
        quit()
for j in s[2::2]:
    if j in guusuu:
        continue
    else:
        quit()
print('Yes')
# Judge status: Wrong Answer
# A - Biscuits
import numpy as np

N, P = map(int, input().split())
A = list(map(int, input().split()))
odd = len([i for i in A if i%2!=0])
if odd==0:
    ans = 0
else:
    ans = np.uint64(2**(N-1))
print(ans)
# Judge status: Wrong Answer
from sys import setrecursionlimit, exit
setrecursionlimit(1000000000)

def main():
    k = int(input())
    a, b = map(int, input().split())
    if b - a + 1 >= k:
        print('OK')
    else:
        print('NG')

main()
# Judge status: Wrong Answer
n = int(input())
a = [[i, int(input())] for i in range(n)]
a.sort(reverse=True, key=lambda x:x[1])
first, second = a[0][1], a[1][1]
a.sort(reverse=True, key=lambda x:x[0])
for i in range(n):
  print(first if a[i][1] != first else second)
# Judge status: Accepted
A,B = open(0).read().split()
A = int(A)
B = int(B.replace('.',''))
print(A*B//100)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
num4 = 0
num2 = 0
num0 = 0
for i in a:
    if i%4 == 0:
        num4 += 1
    elif i%2 == 0:
        num2 += 1
    else:
        num0 += 1
if num4 == 1 and num0 + num2 <= num4 + 1:
    print('Yes')
elif 2 <= num4 and num0 <= num4:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
S=sum(b)-sum(a)
if S<0:print("No")
else:
    cnt=0
    for i in range(n):
        cnt+=max(a[i]-b[i],0)
    if cnt<=S:print('Yes')
    else:print("No")
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse = True)
l = a[0]
del a[0]
r = min(a,key = lambda x:abs((l/2)-x))
print(l,r)
# Judge status: Wrong Answer
N = int(input())

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ans = []
c = 0
while N>0:
    n = N%26
    ans.append(n)
    N //= 26

ans.reverse()
o = []
for a in ans:
    s = ascii_lowercase[a-1]
    o.append(s)

print(''.join(o))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
ans = 0
a.sort()
r = [[a[0], 1]]
c = 1
for i in range(n-1):
    if a[i] == a[i+1]:
        r[-1][1] += 1
    else:
        r.append([a[i+1], 1])
for i in range(len(r)):
    if r[i][0] <= r[i][1]:
        ans += r[i][1] - r[i][0]
    else:
        ans += r[i][1]
print(ans)
# Judge status: Accepted
x, a, b = list(map(int,input().split()))

if abs(x-a) < abs(x-b):
  print('A')
else:
  print('B')
# Judge status: Accepted
a,b,c,k = map(int,input().split())

if k % 2 == 0:
    print(a-b)
else:
    print(b-a)
# Judge status: Accepted
# ABC 123: B – Five Dishes
import math

dishes = [int(input()) for _ in range(5)]

last_dish_index = 0
from10 = 0

for i in range(len(dishes)):
    tmp = dishes[i] % 10
    if tmp != 0 and 10 - tmp > from10:
        last_dish_index = i
        from10 = 10 - tmp % 10

last_dish = dishes.pop(last_dish_index)
print(sum([math.ceil(t / 10) * 10 for t in dishes]) + last_dish)
# Judge status: Accepted
N,K=[int(i) for i in input().split()]
X=[int(i) for i in input().split()]
m=10**9
for i in range(N-K+1):
    m=min(m,X[K-1+i]-X[i]+min(abs(X[K-1+i]),abs(X[i])))

print(m)