Harryxun/stf_run huggingface dataset:
import sys
# from math import sqrt, gcd, ceil, log
from bisect import bisect
from collections import defaultdict, Counter
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

# sys.setrecursionlimit(10**6)



def solve():
	a, b, k = read(); a_ = read(); b_ = read()
	for i in range(1, a): a_[i] += a_[i-1]
	for i in range(1, b): b_[i] += b_[i-1]
	ans = 0
	while k > 0:
		inda = bisect(a_, k); indb = bisect(b_, k)
		# print(k, inda, indb, a_[inda-1], b_[indb-1])
		if inda > indb:
			k -= a_[inda-1];
			ans += inda
			a_ = a_[inda:]
		elif inda == indb:
			if a_[inda-1] < b_[indb-1]:
				k -= a_[inda-1];
				ans += inda
				a_ = a_[inda:]
			else:
				k -= b_[indb-1];
				ans += indb
				b_ = b_[indb:]
		else:
			k -= b_[indb-1];
			ans += indb
			b_ = b_[indb:]


	print(ans)





		

if __name__ == "__main__":
	solve()

### FIXED CODE ###

import sys
# from math import sqrt, gcd, ceil, log
from bisect import bisect
from collections import defaultdict, Counter
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

# sys.setrecursionlimit(10**6)



def solve():
	n, m, k = read()
	arr1 = [0]+read(); arr2 = [0]+read()
	for i in range(1, n+1):arr1[i] += arr1[i-1]
	for i in range(1, m+1):arr2[i] += arr2[i-1]

	i = 0; ans = 0
	while i < n+1 and arr1[i] <= k:
		tem = i + bisect(arr2, k-arr1[i])-1
		# print(tem, i, arr1[i], bisect(arr2, k-arr1[i]))
		ans = max(ans, tem)
		i += 1
	print(ans)

	





		

if __name__ == "__main__":
	solve()
H, W = map(int, input().split())
if H % 3 == 0 or W % 3 == 0:
    print(0)
elif H % 2 and W % 2:
    ans = float("inf")
    for h in range(1, H):
        y = (H - h) * W
        x = h * (W // 2)
        z = h * W - x
        ans = min(ans, max(a, b, c) - min(a, b, c))
    print(ans)
else:
    if W % 2:
        t = H
        H = W
        W = t
    ans = float("inf")
    for h in range(1, H):
        x = h * W // 2
        y = W * (H - h)
        ans = min(ans, abs(y - x))
    print(ans)

### FIXED CODE ###

H, W = map(int, input().split())
if H % 3 == 0 or W % 3 == 0:
    print(0)
else:
    ans = min(H, W)
    for h in range(1, H):
        y = (H - h) * W
        x = h * (W // 2)
        z = h * W - x
        ans = min(ans, max(x, y, z) - min(x, y, z))
    t = H
    H = W
    W = t
    for h in range(1, H):
        y = (H - h) * W
        x = h * (W // 2)
        z = h * W - x
        ans = min(ans, max(x, y, z) - min(x, y, z))
    print(ans)
N, Q  = map(int, input().split())
S = list(input())
Lsub = [0]*N
Rsub = [0]*N
L = 0
R = 0


for j in range(1,N):
  if SS[j-1] == "A" and SS[j] == "C":
    L += 1
  Lsub[j] = L

for j in reversed(range(0,N-1)):
  if SS[j] == "A" and SS[j+1] == "C":
    R += 1
  Rsub[j] = R



ans = [0] * Q

for i in range(Q):
  L, R = map(int, input().split())
  ans[i] = Rsub[0] - Lsub[L-1] - Rsub[R-1]


for i in range(Q):
  print(ans[i])

### FIXED CODE ###

N, Q  = map(int, input().split())
S = list(input())
Lsub = [0]
Rsub = [0]
L = 0
R = 0


for k in range(1,N):
  if S[k-1] == "A" and S[k] == "C":
    L += 1
  Lsub.append(L)

for j in range(0,N-1)[::-1]:
  if S[j] == "A" and S[j+1] == "C":
    R += 1
  Rsub.append(R)


for i in range(Q):
  L, R = map(int, input().split())
  print(Rsub[N-1] - Lsub[L-1] - Rsub[N-R])
from collections import Counter as c
l=[input() for _ in range(int(input()))]
m=c(l)
if l[-1]!="Un":
    print("NO")
elif m["A"]==m["Un"] and l[0]=="A":
    y=True
    for i in l:
        if i=="A":
            ca+=1
	elif i=="Un":
	    cu+=1
	if ca!=cu:
	    y=False
	    break
	else:
	    ca=0
	    cu=0
    if y:print("YES")
    else:print("NO")
else:
    print("NO")



### FIXED CODE ###

l=[input() for _ in range(int(input()))]
s=[]

isno=False
for i in l:
    if i=="A":
        s.append(1)
    else:
        try:
            _=s.pop()
        except:
            print("NO")
            isno=True
            break

if not isno and not s:print("YES")
elif not isno and s:print("NO")
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))

A = A1 + A2 + A3
N = int(input())

index = []
for i in range(N):
    index.append(A.index(int(input())))

if (0 in index and 3 in index and 6 in index) or \
   (1 in index and 4 in index and 7 in index) or \
   (2 in index and 5 in index and 8 in index) or \
   (0 in index and 4 in index and 8 in index) or \
   (2 in index and 4 in index and 6 in index) or \
   (3 in index and 4 in index and 5 in index) or \
   (6 in index and 7 in index and 8 in index):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

# 途中
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))

A = A1 + A2 + A3
N = int(input())

index = []
for i in range(N):
    inp = int(input())
    if inp in A:
        index.append(A.index(inp))

if \
   (0 in index and 3 in index and 6 in index) or \
   (1 in index and 4 in index and 7 in index) or \
   (2 in index and 5 in index and 8 in index) or \
   (0 in index and 4 in index and 8 in index) or \
   (2 in index and 4 in index and 6 in index) or \
   (0 in index and 1 in index and 2 in index) or \
   (3 in index and 4 in index and 5 in index) or \
   (6 in index and 7 in index and 8 in index):
    print("Yes")
else:
    print("No")
N = int(input())
S = input()
if S[:(N//2) == S[(N//2+1):]:
     print("Yes")
else:
     print("No")


### FIXED CODE ###

N = int(input())
S = input()
if S[:(N//2)] == S[(N//2):]:
	print("Yes")
else:
	print("No")
n,a,b=map(int,input().split())
lis=""
ans=0
for i in range(n):
 for b in range(a):
  ans+=1
print(ans)

### FIXED CODE ###

s=input()
if s=="AAA" or s=="BBB":
  print("No")
else:
  print("Yes")
H,W = map(int, input().split())
S = [input() for _ in range(H)]

dp = [[10**6]*(H*W) for _ in range(H*W)]
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            continue
        p = H*i+j
        if i > 0 and S[i-1][j] == ".":
            dp[p][p-H] = 1
            dp[p-H][p] = 1
        if i < H-1 and S[i+1][j] == ".":
            dp[p][p+H] = 1
            dp[p+H][p] = 1
        if j > 0 and S[i][j-1] == ".":
            dp[p][p-1] = 1
            dp[p-1][p] = 1
        if j < W-1 and S[i][j+1] == ".":
            dp[p][p+1] = 1
            dp[p+1][p] = 1

for i in range(H*W):
    dp[i][i] = 0
for k in range(H*W):
    for i in range(H*W):
        for j in range(H*W):
            dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j])

ans = 0
for i in range(H*W):
    for j in range(H*W):
        if dp[i][j] == 10**6:
            continue
        ans = max(ans, dp[i][j])
            
print(ans)

### FIXED CODE ###

H,W = map(int, input().split())
S = [input() for _ in range(H)]
        
from collections import deque

ans = 0
inf = 10**12
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            continue
        q = deque()
        q.append((i, j, 0))
        used = [[inf]*W for _ in range(H)]
        used[i][j] = 0
        while q:
            temp = q.popleft()
            k = temp[0]
            l = temp[1]
            d = temp[2]
            if k > 0 and S[k-1][l] == "." and used[k-1][l] > d+1:
                used[k-1][l] = d+1
                q.append((k-1, l, d+1))
            if k < H-1 and S[k+1][l] == "." and used[k+1][l] > d+1:
                used[k+1][l] = d+1
                q.append((k+1, l, d+1))
            if l > 0 and S[k][l-1] == "." and used[k][l-1] > d+1:
                used[k][l-1] = d+1
                q.append((k, l-1, d+1))
            if l < W-1 and S[k][l+1] == "." and used[k][l+1] > d+1:
                used[k][l+1] = d+1
                q.append((k, l+1, d+1))

        for s in range(H):
            for t in range(W):
                if used[s][t] < inf:
                    ans = max(ans, used[s][t])

print(ans)
a = input()
a = int(a)

line = [int(k) for k in input().split()]
b = 0
for k in range(len(line)):
  if line[k] % 2 == 0:
    if not line[k] % 5 == 0 and not line[k] % 3 == 0:
      print("DENIED")
      break
  elif k == a-1:
    print("APPROVED")

### FIXED CODE ###

import collections
a = input().split()
c = list(collections.Counter(a).values())
b = 0
for k in c:
  b += 1
  if k == 2:
    print("Yes")
    break
  elif b == 3:
    print("No")
  elif k == 3:
    print("No")
def primes(n):
    primes = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            primes.append(i)
    return is_prime


Q = int(input())

ps = primes(10000)
like_numbers = [False] * 10001
for i in range(3, 10001, 2):
    if ps[i] and ps[(i + 1) // 2]:
        like_numbers[i] = True

like_numbers_cnt = [0] * 10001

for i in range(1, 10001):
    if like_numbers[i]:
        like_numbers_cnt[i] = like_numbers_cnt[i - 1] + 1
    else:
        like_numbers_cnt[i] = like_numbers_cnt[i - 1]

for _ in range(Q):
    l, r = map(int, input().split())
    print(like_numbers_cnt[r] - like_numbers_cnt[l - 1])


### FIXED CODE ###

def primes(n):
    primes = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            primes.append(i)
    return is_prime


Q = int(input())

ps = primes(100000)
like_numbers = [False] * 100001
for i in range(3, 100001, 2):
    if ps[i] and ps[(i + 1) // 2]:
        like_numbers[i] = True

like_numbers_cnt = [0] * 100001

for i in range(1, 100001):
    if like_numbers[i]:
        like_numbers_cnt[i] = like_numbers_cnt[i - 1] + 1
    else:
        like_numbers_cnt[i] = like_numbers_cnt[i - 1]

for _ in range(Q):
    l, r = map(int, input().split())
    print(like_numbers_cnt[r] - like_numbers_cnt[l - 1])
import numpy as np
MOD = 10**9+7
h, w, k = map(int, input().split())

dp = [[0]*w for _ in range(h+1)]
dp[0][0] = 1

patterns = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]

for i in range(1, h+1):
    # most left
    dp[i][0] = (dp[i-1][0]*patterns[1:][w-2]%MOD + dp[i-1][1]*patterns[w-2]%MOD)%MOD
    for j in range(1, w-1):
        npath = dp[i-1][j-1]*(patterns[j-1]*patterns[1:][w-j-2])%MOD\
                + dp[i-1][j]*(patterns[1:][j-1]*patterns[1:][w-j-2])%MOD\
                + dp[i-1][j+1]*(patterns[1:][j-1]*patterns[w-j-2])%MOD
        dp[i][j] = npath%MOD
    dp[i][w-1] = (dp[i-1][w-2]*patterns[w-2]%MOD + dp[i-1][w-1]*patterns[1:][w-2]%MOD)%MOD

# for p in dp: print(p)

print(dp[-1][k-1])
    


### FIXED CODE ###

MOD = 10**9+7
h, w, k = map(int, input().split())

dp = [[0]*w for _ in range(h+1)]
dp[0][0] = 1

patterns = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]

if w == 1:
    print(1)
    exit()

for i in range(1, h+1):
    # most left
    dp[i][0] = (dp[i-1][0]*patterns[1:][w-2]%MOD + dp[i-1][1]*patterns[w-2]%MOD)%MOD
    for j in range(1, w-1):
        npath = dp[i-1][j-1]*(patterns[j-1]*patterns[1:][w-j-2])%MOD\
                + dp[i-1][j]*(patterns[1:][j-1]*patterns[1:][w-j-2])%MOD\
                + dp[i-1][j+1]*(patterns[1:][j-1]*patterns[w-j-2])%MOD
        dp[i][j] = npath%MOD
    dp[i][w-1] = (dp[i-1][w-2]*patterns[w-2]%MOD + dp[i-1][w-1]*patterns[1:][w-2]%MOD)%MOD

# for p in dp: print(p)

print(dp[-1][k-1])
H, W = (int(i) for i in input().split())
N = int(input())
A = [int(i) for i in input().split()]
C = []
for i in range(N):
  for j in range(A[i]):
    C.append(i+1)
ans = [[0]*W for i in range(H)]
for i in range(H*W):
  y = i // W
  if y%2==0:
    x = i%W
  else:
    x = W-1-i%W
  ans[x][y] = C[i]
for i in range(H):
  ans[i] = [str(a) for a in ans[i]]
  print(" ".join(ans[i]))

### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split()]
c4=0
c2=0
for i in range(N):
  if A[i]%4==0:
    c4+=1
  elif A[i]%2==0:
    c2+=1
if c4:
  a = c4*2+1
else:
  a = 0
if c2>1:
  b = c2
  if a:
    a -= 1
else:
  b = 0
if a+b>=N:
  print("Yes")
else:
  print("No")
a,b=map(int,input().split())
print(max(a,b)+max(min(a,b),max(a,b)-1)

### FIXED CODE ###

a =list(map(int, input().split())) 
print(max(a)+max([min(a),max(a)-1]))
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

n,m = I()
a = [v() for i in range(n)]
b = [v() for i in range(m)]

for j in range(m):
    place = []
    for i in range(n-m):
        if b[j] in a[i]:
            m_place = re.match(b[j],a[i])
            xxx = m_place.span()
            place.append(xxx)
    ans = list(set(place))
    if len(ans) == 1:
        print("Yes")
        sys.exit()

print("No")

### FIXED CODE ###

import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

n,m = I()
a = []
b = []

for _ in range(n):
    a += [list(input())]
for _ in range(m):
    b += [list(input())]

for i in range(n-m+1):
    for j in range(n-m+1):
        if [k[j:m+j] for k in a[i:m+i]] == b:
            print('Yes')
            exit()
print('No')
n,m=map(int,input().split())
lst=[]
L=100000
R=100000
for i in range(m):
  l=int(input())
  r=int(input())
  L=max(L,l)
  R=min(R,r)
print(max(0,R-L+1))

  


### FIXED CODE ###

n,m=map(int,input().split())
l=[]
r=[]
for i in range(m):
  a,b=map(int,input().split())
  l.append(a)
  r.append(b)
lm=max(l)
rm=min(r)
if rm-lm<0:
  print(0)
else:
  print(rm-lm+1)
import numpy as np
from sys import stdin

def main():
    nm = [int(x) for x in stdin.readline().rstrip().split()]
    gate = np.full([nm[1], nm[0]], False)
    
    for i in range(nm[1]):
        g = [int(x) for x in stdin.readline().rstrip().split()]
        for k in range(g[0]-1, g[1]):
            gate[i,k] = True

    count = 0
    for i in range(len(gate[0])):
        tmp = gate[:, i]
        if tmp.all():
            count += 1
        
    print(count)

if __name__ == "__main__":
    main()

### FIXED CODE ###

import numpy as np
from sys import stdin

def main():
    nm = [int(x) for x in stdin.readline().rstrip().split()]
    gate = np.zeros([nm[1], 2], dtype=int)
    
    for i in range(nm[1]):
        g = [int(x) for x in stdin.readline().rstrip().split()]
        gate[i] = g
    
    l_max = np.max(gate[:, 0])
    r_min = np.min(gate[:, 1])
    c = 0
    if l_max <= r_min:
        c = r_min-l_max+1
    print(c)

if __name__ == "__main__":
    main()
cnt = []
tmp = 0

b = str(input())
for i in range(0,len(b)):
  if b[i]=="A" or b[i]=="C" or b[i]=="G" or b[i]=="T":
    tmp=tmp+1
  else:
    cnt.append(tmp)
    tmp=0
print(max(cnt))

### FIXED CODE ###

S = str(input())

cnt = 0
ans = [0]

for i in range(0, len(S)):
  if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
    cnt = cnt + 1
    ans.append(cnt)
  else:
    cnt = 0
print(max(ans))
import itertools
def mark(s, x):
    for i in range(x + x, len(s), x):
        s[i] = False

def sieve(n):
    s = [True] * n
    for x in range(2, int(n**0.5) + 1):
        if s[x]: mark(s, x)
    return [i for i in range(0,n) if s[i] and i > 1]

n = int(input())
A = sieve(55555)
A.remove(2)
A.remove(3)
A.remove(5)
A.remove(7)
B = [2,3,5,7]
C = []
for i in A:
    if len(B) == n:
        break
    B.append(i)
    C = list(itertools.combinations(B,5))
    for j in C:
        if sum(j) in A:
            B.remove(i)
            break
for i in B:
    print(i,end=' ')

### FIXED CODE ###

a,b = map(int ,input().split())
if b < a:
    a -=1
print(a)
N = int(input())
if N % 2 == 0:
    print(int(N / 2))
else:
    print(int((N - 1) / 2 + 1)

### FIXED CODE ###

N = int(input())
if N % 2 == 0:
    print(int(N / 2))
else:
    print(int((N - 1) / 2 + 1))
a, b = map(int, input().split())
n = min(a, b) // 2
t = list(range(1, n+1))
for i in t:
    if i in (-1, 1):
        continue
    if a % i == 0 and b % i == 0:
        for j in t[i:]:
            if j == -1:
                continue
            if j % i == 0:
                t[j-1] = -1
    else:
        t[i-1] = -1
c = sum([1 for i in t if i != -1])
if c:
    print(c)
else:
    print(1)

### FIXED CODE ###

a, b = map(int, input().split())

def getPrimeFactors(x):
    ans = []
    for d in range(2, int(x**0.5)+1):
        while x%d == 0:
            ans.append(d)
            x //= d
    if x != 1:
        ans.append(x)
    return ans

res_a = getPrimeFactors(a)
res_b = getPrimeFactors(b)

res = len(set(res_a) & set(res_b))
print(res + 1)
#!/usr/bin/env python3
import sys
import math

def my_lcm(a: int, b: int):
    return int( abs(a*b) / math.gcd(a, b))

def nr_divide(a: int, b: int, x: int):
    return (int(math.floor(b/x)) - int(math.ceil(a/x))) + 1

def solve(A: int, B: int, C: int, D: int):
    E = my_lcm(C, D)
    N = B - A + 1
    nrC = nr_divide(A, B, C)
    nrD = nr_divide(A, B, D)
    nrE = nr_divide(A, B, E)
    print(N - nrC - nrD + nrE)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(A, B, C, D)
    return

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import math
from fractions import gcd

def my_lcm(a: int, b: int):
    return  abs(a*b) // gcd(a, b)

def nr_divide(a: int, b: int, x: int):
    count = b//x - a//x + 1
    if a % x != 0:
        count -= 1
    return count

def solve(A: int, B: int, C: int, D: int):
    E = my_lcm(C, D)
    N = B - A + 1
    nrC = nr_divide(A, B, C)
    nrD = nr_divide(A, B, D)
    nrE = nr_divide(A, B, E)
    count = N - nrC - nrD + nrE
    print(count)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(A, B, C, D)
    return

if __name__ == '__main__':
    main()
N,M=map(int,input().split())
mod=10**9+7
A=set([int(input()) for i in range(M)])

data=[0 for i in range(N)]
if 1 not in A:
    data[0]=1
if 2 not in A:
    data[1]=1+data[0]


for i in range(2,N):
    if i+1 not in A:
        data[i]=data[i-1]+data[i-2]
        data[i]%=mod

#print(data)

print(data[-1])


### FIXED CODE ###

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

data=[0 for i in range(N)]
if 1 not in A:
    data[0]=1
if N>=2:
    if 2 not in A:
        data[1]=1+data[0]


for i in range(2,N):
    if i+1 not in A:
        data[i]=data[i-1]+data[i-2]
        data[i]%=mod

#print(data)

print(data[-1])
N, T = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x: x[1])

def dfs(i, sum, time, remain):
    global answer
    if i == N or time >= T:
        if time < T and len(remain) >= 1:
            sum += AB[max(remain)][1]
        if sum > answer:
            answer = sum
    else:
        dfs(i+1, sum, time, remain)
        if time < T:
            dfs(i+1, sum + AB[i][1], time + AB[i][0], remain-{i})

answer = 0
dfs(0, 0, 0, set(range(N)))
print(answer)

### FIXED CODE ###

import sys
import numpy as np

n, t = map(int, input().split())
knapsack = np.zeros(t, dtype=np.int64)
cuisines = [tuple(map(int, line.split())) for line in sys.stdin]
cuisines.sort()
tmp_ans = 0
for a, b in cuisines:
    tmp_ans = max(tmp_ans, knapsack.max() + b)
    knapsack[a:] = np.maximum(knapsack[a:], knapsack[:-a] + b)
print(tmp_ans)
import itertools
import numpy as np
N,M,X=map(int, input().split())
book = []
for _ in range(N):
    book.append(list(map(int, input().split())))
book = np.array(book)
money=pow(10,6)
for i in itertools.product([0,1], repeat=N):
    book2=book
    dellist = []
    for n,l in enumerate(i):
        if l==0:
            dellist.append(n)
    book2=np.delete(book2, dellist, 0)
    ansar = np.sum(book2,axis=0)
    if np.sum(ansar[1:]>=X)==M:
        if money>ansar[0]:
            money = ansar[0]
if money == pow(10,6):
    print(-1)
else:
    print(money)

### FIXED CODE ###

import itertools
import numpy as np
N,M,X=map(int, input().split())
book = []
for _ in range(N):
    book.append(list(map(int, input().split())))
book = np.array(book)
money=pow(10,7)
for i in itertools.product([0,1], repeat=N):
    book2=book
    dellist = []
    for n,l in enumerate(i):
        if l==0:
            dellist.append(n)
    book2=np.delete(book2, dellist, 0)
    ansar = np.sum(book2,axis=0)
    if np.sum(ansar[1:]>=X)==M:
        if money>ansar[0]:
            money = ansar[0]
if money == pow(10,7):
    print(-1)
else:
    print(money)
A=int(input())
B=[1]*8
for i in range(2,10):
  for j in range(A+1):
    if j**i <= A:
      B[i-2]= j**i
    else:break
B=B.sort()
print(B[-1])

### FIXED CODE ###

A=int(input())
B=[1]*8
for i in range(2,10):
  for j in range(A+1):
    if j**i <= A:
      B[i-2]= j**i
    else:break
print(max(B))
a = int(input())
b = int(input())

if a > b:
 print('a > b')
elif a < b:
 print ('a < b')
elif a == b:
 print (' a == b')
else:
 print "none"

### FIXED CODE ###

a, b = map(int, input().split())
if a < b:
    print('a < b')
elif a > b:
    print('a > b')
else:
    print('a == b')
timel = int(raw_input())
for gomi in xrange(timel):
 a,b,c = map(lambda x: int(x)**2, raw_input().split())
 if a+b==c or b+c==a or c+a==b:
  print "YES"
 else
  print "NO"

### FIXED CODE ###

timel = int(raw_input())
for gomi in xrange(timel):
 a,b,c = map(lambda x: int(x)**2, raw_input().split())
 if a+b==c or b+c==a or c+a==b:
  print "YES"
 else:
  print "NO"
import heapq
n=int(input())
a=list(map(int,input().split()))
q=a[0:n]
heapq.heapify(q)
p=list(map(lambda x: x*(-1),a[2*n:3*n]))
heapq.heapify(p)
sums=sum(q)+[0]*(n-1)+sum(p)
am=a[n:2*n]
for i in range(0,n):
    heapq.heappush(q,am[i])
    heapq.heappop(q)
    sums[i+1]=sum(q)
for i in range(n-1,-1,-1):
    heapq.heappush(p,(-1)*am[i])
    heapq.heappop(p)
    sums[i]+=sum(p)
print(max(sums))

### FIXED CODE ###

import heapq
n=int(input())
a=list(map(int,input().split()))
q=a[0:n]
sums=[0]*(n+1)
sums[0]=sum(q)
heapq.heapify(q)
am=a[n:2*n]
for i in range(0,n):
    heapq.heappush(q,am[i])
    sums[i+1]=sums[i]+am[i]-heapq.heappop(q)
p=a[2*n:3*n]
p=list(map(lambda x: x*(-1),p))
sump=sum(p)
sums[n]+=sump
heapq.heapify(p)
for i in range(n-1,-1,-1):
    heapq.heappush(p,(-1)*am[i])
    sump=sump-am[i]-heapq.heappop(p)
    sums[i]+=sump
print(max(sums))
from math import gcd
a,b,c,d = map(int, input().split())
c_n = b//c - (a-1)//c
d_n = b//d - (a-1)//d
l = (c*d)//gcd(c,d)
l_n = b//l - (a-1)//l
print(b - a - c_n - d_n + l_n + 1)

### FIXED CODE ###

s = input()
if s[0]==s[1] or s[1]==s[2] or s[2]==s[3]:
    print("Bad")
else:
    print("Good")