Harryxun/stf_run huggingface dataset:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


def popcount(x):
    '''xの立っているビット数をカウントする関数
    (xは64bit整数)'''

    # 2bitごとの組に分け、立っているビット数を2bitで表現する
    x = x - ((x >> 1) & 0x5555555555555555)

    # 4bit整数に 上位2bit + 下位2bit を計算した値を入れる
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)

    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f # 8bitごと
    x = x + (x >> 8) # 16bitごと
    x = x + (x >> 16) # 32bitごと
    x = x + (x >> 32) # 64bitごと = 全部の合計
    return x & 0x0000007f


n = I()
x = S()
cnt = sum([int(i) for i in x])
ret1 = 1
ret2 = 1
rem1 = 0
rem2 = 0
for i in range(n - 1, -1, -1):
    if x[i] == "1":
        rem1 = (rem1 + ret1) % (cnt + 1)
        rem2 = (rem2 + ret2) % (cnt - 1)
    ret1 = ret1 * 2 % (cnt + 1)
    ret2 = ret2 * 2 % (cnt - 1)


for j in range(n):
    ans = 1
    if x[j] == "1":
        r = (rem2 - pow(2, n - 1 - j, cnt - 1)) % (cnt - 1)
        while r:
            r = r % popcount(r)
            ans += 1
        print(ans)
    else:
        r = (rem1 + pow(2, n - 1 - j, cnt + 1)) % (cnt + 1)
        while r:
            r = r % popcount(r)
            ans += 1
        print(ans)

### FIXED CODE ###

N=int(input())
X=input()
Y=int(X,2)
Z=Y
C=X.count('1')
if C==1:
  for i in range(N):
    if X[i]=='1':
      print(0)
    elif i==N-1:
      print(2)
    else:
      print(1)
  exit()
Y,Z=Y%(C+1),Z%(C-1)
def f(x):
  if x==0:
    return 0
  return 1+f(x%bin(x).count('1'))
 
for i in range(N):
  if X[i]=='1':
    print(1+f((Z-pow(2,N-i-1,C-1))%(C-1)))
  else:
    print(1+f((Y+pow(2,N-i-1,C+1))%(C+1)))
r,g,b=map(int,input().spklit())
x=int(r+g+b)
if x%4==0:
  print('YES')
else:
  print('NO')

### FIXED CODE ###

r,g,b=input().split()
x=int(r+g+b)

if x%4==0:
  print('YES')
else:
  print('NO')
x = [int(i) for i in input().split()]
n = x[0]
x.pop(0)

print(x)

M = max(x)
m = min(x)
s = sum(x)

print(m," ",M," ",s)

### FIXED CODE ###

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

M = max(x)
m = min(x)
s = sum(x)

print("{0} {1} {2}".format(m,M,s))
n = int(input())
count = 0
for i in range(1,n+1):
    count = count + i*i
print(count)

### FIXED CODE ###

import math
x,y = map(int,input().split())
if x%y == 0:
    print(-1)
else:
    print(x)
import numpy as np
N,K=input().split()
K=int(K)

A=list(map(int, input().split()))
A=np.array(A)
sort_A=np.sort(A)[::-1]
sort_A=sort_A[K:]

print(np.sum(sort_A))


### FIXED CODE ###

H,A=input().split()
H=int(H)
A=int(A)

count=0
while H>0:
  H=H-A
  count+=1
print(count)
h, w = list(map(int, input().split()))
sharp = 0
data = []
for i in range(h):
    data.append(list(input()))
    sharp += data[i].count('#')
ans = []
def dfs(row, column, count,data):
    if(row > w - 1) or (column > h - 1) or row < 0 or column < 0:
        return

    if data[column][row] == '#':
        return
    data[column][row] = '#'
    if column == h- 1 and row == w - 1:
        count += 1
        ans.append(count)
        return
    else:

        dfs(row + 1, column,     count + 1,data)
        dfs(row,     column + 1, count + 1,data)
        dfs(row - 1, column,     count + 1,data)
        dfs(row,     column - 1, count + 1,data)
        return
dfs(0, 0, 0,data)
print(h * w - sharp - min(ans))


### FIXED CODE ###

import collections
h, w = list(map(int, input().split()))
inf = h * w + 1
sharp = 0
data = []
for i in range(h):
    data.append(list(input()))
    # #の数を数えておく
    sharp += data[i].count('#')

ans = [[inf for i in range(w)] for j in range(h)]
def dfs(row, column, count,data):
    #もし配列の外を参照しているようであれば終了させる
    if(row > w - 1) or (column > h - 1) or ( row < 0 ) or ( column < 0 ):
        return

    if data[column][row] == '#':
        return
    data[column][row] == '#'
    #探索済みなので＃を入れたが、もっと良い方法があるかもしれない
    count += 1
    if row == w - 1 and column == h - 1:
        ans[column][row] = min(count, ans[column][row])
        return
    #その場所がゴールならば終了。ansにそこまでのコストを追加
    ##dataの写しを引数として渡したい。参照渡しか値渡しかを確認
    #+-1ずつ四方向に全探索
    dfs(row + 1, column,     count, data)
    dfs(row,     column + 1, count, data)
    dfs(row - 1, column,     count, data)
    dfs(row,     column - 1, count, data)
def bfs(row, column, count,data):
    becter = [-1,1]
    queue = collections.deque()
    queue.append([column, row,count])
    while len(queue) != 0:
        v = queue.popleft()
        if v[0] < 0 or v[1] < 0 or v[0] >= h or v[1] >= w:
            continue
        if data[v[0]][v[1]] != '#':

            data[v[0]][v[1]] = '#'
            v[2] += 1
            ans[v[0]][v[1]] = min(ans[v[0]][v[1]], v[2])
            queue.append([v[0] + 1, v[1],v[2]])
            queue.append([v[0], v[1] + 1,v[2]])
            queue.append([v[0] - 1, v[1],v[2]])
            queue.append([v[0], v[1] - 1,v[2]])


bfs(0, 0, 0,data)
if ans[-1][-1] == inf:
    print(-1)
    exit()
print(h * w - sharp - ans[-1][-1])
"""
TODO
"""


def substring(s):
    ss = []
    max_ss = len(s) + 1
    for ss_len in range(1, max_ss):
        max_ofs = max_ss - ss_len
        for ofs in range(0, max_ofs):
            c = s[ofs:ss_len + ofs]
            ss.append(c)
    ss = list(set(ss))
    return sorted(ss)


def nth_largest(s, n):
    ss = substring(s)
    return ss[n - 1]


if __name__ == "__main__":
    s = input().rstrip()
    K = int(input().rstrip())
    print(nth_largest(s, K))


### FIXED CODE ###

"""
TODO
"""


def talkable(a, b, c, d):
    if abs(a - c) <= d:
        return True

    if abs(a - b) <= d:
        if abs(b - c) <= d:
            return True

    return False


if __name__ == "__main__":
    a, b, c, d = map(int, input().rstrip().split(' '))
    if talkable(a, b, c, d):
        print('Yes')
    else:
        print('No')
class Solution:
  def solve(self, A, B, C):
    count = 0
    spent = 0
    while B >= 0:
      B -= A
      count += 1
      if count == C:
        return C
    return count

def main():
  A = int(input())
  B = int(input())
  C = int(input())
  print(Solution().solve(A, B, C))
        
if __name__ == "__main__":
   main()

### FIXED CODE ###

class Solution:
  def solve(self, A, B, C):
    count = 0
    while True:
      B -= A
      if B < 0: break
      count += 1
      if count == C: return C
    return count

def main():
  inputs = list(map(int, input().split()))
  A, B, C = inputs
  print(Solution().solve(A, B, C))
        
if __name__ == "__main__":
   main()
T = list(input())

s = T.count('?')

for i in range(s):
    a = T.index('?')
    if a == 0:
        if T[T.index('?')+1] == 'D':
            T[a] = 'P'
        else:
            T[a] = 'D'
    else:
        T[a] = 'D'
print(''.join(T))

### FIXED CODE ###

T = input()

T = T.replace('?', 'D')
	
print(''.join(T))
n,y=map(int,input().split())
#print(n,y)
for i in range(n+1):
    for j in range(n+1-i):
        if 10000*i+5000*j+1000*(n-i-j)==y:
            print(i,j,n-i-j)
            exit()
print(-1,-1,-1)

### FIXED CODE ###

s=list(input())
s[3]='8'
for i in range(len(s)):
    print(s[i],end='')
import math
H,N=map(int,input().split())
A=list(map(int,input().split()))

if H =< sum(A):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

import math
H,N=map(int,input().split())
A=list(map(int,input().split()))

if H <= sum(A):
    print('Yes')
else:
    print('No')
A,B=map(int,input())
A=A*B
print(A)


### FIXED CODE ###

A,B=map(int,input().split())
A=A*B
print(int(A))
n,k = map(int,input().split())
s = input()
li = [0]
count = 1

for i in range(n-1):
    if s[i] != s[i+1]:
        li.append(count)
    count += 1
li.append(count)

m = len(li)

if s[0] == '1':
    t = int(m/2-1)
    if k >= t:
        print(n)
    else:
        max1 = 0
        for i in range(t-k+1):
            max1 = max(li[2*(i+k)+1] - li[2*i],max1)
        print(max1)
else:
    t = int(m/2)
    if k >= t:
        print(n)
    else:
        max1 = li[2*k]
        for i in range(t-k):
            max1 = max(li[2*(i+k+1)] - li[2*i+1],max1)
        print(max1)


### FIXED CODE ###

n,k = map(int,input().split())
s = input()
li = [0]
count = 1

for i in range(n-1):
    if s[i] != s[i+1]:
        li.append(count)
    count += 1
li.append(count)

m = len(li)

if s[0] == '1':
    li.append(li[-1])
    li.append(li[-1])
    t = int(m/2-1)
    if k >= t:
        print(n)
    else:
        max1 = 0
        for i in range(t-k+2):
            max1 = max(li[2*(i+k)+1] - li[2*i],max1)
        print(max1)
else:
    li.append(li[-1])
    t = int(m/2)
    if k >= t:
        print(n)
    else:
        max1 = li[2*k]
        for i in range(t-k):
            max1 = max(li[2*(i+k+1)] - li[2*i+1],max1)
        print(max1)
x=int(input())
y=int(input())
z=int(input())

print(z x y)

### FIXED CODE ###

x,y,z=map(int,input().split())
print(z,x,y)
K,X=map(int,input().split())
C=[i for i in range(X-K+1,X+K)]

print(*C, '')


### FIXED CODE ###

K,X=map(int,input().split())
C=[i for i in range(X-K+1,X+K)]

print(*C)
def get_nagasa(i):
    if nagasa[i] != -1:
        return nagasa[i]
    if ko[i] == []:
        nagasa[i] = 0
        return 0
    re = 0
    for ii in ko[i]:
        p = get_nagasa(ii) + 1
        if p > re:
            re = p
    nagasa[i] = re
    return re

n, m = map(int, input().split())
ko = [[] for _ in range(n)]
nagasa = [-1] * n
for _ in range(m):
    x, y = map(int, input().split())
    ko[x - 1] += [y - 1]
mx = 0
for i in range(n):
    tmp = get_nagasa(i)
    if tmp > mx:
        mx = tmp
print(mx)


### FIXED CODE ###

import sys

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


def get_kyori(i):
    if kos[i] == []:
        kyori[i] = 0
        return 0
    if kyori[i] > -1:
        return kyori[i]
    re = 0
    for ko in kos[i]:
        new = get_kyori(ko) + 1
        if re < new:
            re = new
    kyori[i] = re
    return re


n, m = map(int, input().split())
kos = [[] for _ in range(n + 1)]
kyori = [-1] * (n + 1)
for _ in range(m):
    oya, ko = map(int, input().split())
    kos[oya] += [ko]

for i in range(1, n + 1):
    if kyori[i] == -1:
        kyori[i] = get_kyori(i)

print(max(kyori[1:]))
N, M = lit(map(int, input().split()))
print('Yes' if N == M else 'No')

### FIXED CODE ###

N, M = list(map(int, input().split()))
print('Yes' if N == M else 'No')
import heapq

X, Y, Z, K = map(int, input().split())
A = sorted([int(i) for i in input().split()], reverse=True)
B = sorted([int(i) for i in input().split()], reverse=True)
C = sorted([int(i) for i in input().split()], reverse=True)

heap = []
heapq.heappush(heap, (-(A[0] + B[0] + C[0]), 0, 0, 0))
for _ in range(K):
    p, i, j, k = heapq.heappop(heap)
    heapq.heappush(heap, (-(A[i + 1] + B[j] + C[k]), i + 1, j, k))
    heapq.heappush(heap, (-(A[i] + B[j + 1] + C[k]), i, j + 1, k))
    heapq.heappush(heap, (-(A[i] + B[j] + C[k + 1]), i, j, k + 1))
    print(-p)

### FIXED CODE ###

from itertools import product

X, Y, Z, K = map(int, input().split())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

AB = sorted([a + b for a, b in product(A, B)], reverse=True)
ABC = sorted([ab + c for ab, c in product(AB[:max(K, Z)],
                                          sorted(C, reverse=True))],
             reverse=True)
for s in ABC[:K]:
    print(s)
n = int(input())
rlist = []
for i in range(n):
    r = int(input())
    rlist.append(r)
mlist = []
for i in range(n):
    m = rlist[i] - min(rlist[:i])
    mlist.append(m)
mlist.sort()
print(mlist[-1])


### FIXED CODE ###

n = int(input())
rlist = []
for i in range(n):
    r = int(input())
    rlist.append(r)
mlist = [rlist[1] - rlist[0]]
mini = rlist[0]
for i in range(1,n):
    if(rlist[i-1] < mini):
        mini = rlist[i-1]
    m = rlist[i] - mini
    if(m>mlist[-1]):
        mlist.append(m)
print(mlist[-1])
L,R = list(map(int,input().split()))

L_mod = L % 2019
mod_list = []

for i in range(L_mod,L_mod + (R-L) + 1):
  tmp = i % 2019
  if tmp == 0:
    mod_list.append(i % 2019)
    break
  else:
    mod_list.append(i % 2019)

mod_list.sort()
print((mod_list[0] * mod_list[1]) % 2019)

### FIXED CODE ###

L,R = list(map(int,input().split()))

if R - L >= 2018:
  print(0)
else:
  min_mod = 2019
  for i in range(L,R+1):
    for j in range(i+1,R+1):
      tmp = (i * j) % 2019
      if tmp < min_mod:
        min_mod = tmp
  print(min_mod)
x, y = map(int, input().split())
if x == 2 or y == 2:
    print('No')
else:
    m1 = set(1, 3, 5, 7, 8, 10, 12)
    m2 = set(4, 6, 9, 11)
    if (x in m1 and y in m1) or (x in m2 and y in m2):
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

x, y = map(int, input().split())
if x == 2 or y == 2:
    print('No')
else:
    m1 = set([1, 3, 5, 7, 8, 10, 12])
    m2 = set([4, 6, 9, 11])
    if (x in m1 and y in m1) or (x in m2 and y in m2):
        print('Yes')
    else:
        print('No')
import sys
from scipy import special
sys.setrecursionlimit(1000000)
class Node:
    def __init__(self):
        self.next=[]
    def get_data(self,new_next,weight=1):
        self.next.append(new_next)
def BFS(i,depth,K):  
    depth+=1
    tmp=i
    seki=1
    num=len(tmp)
    if depth==1:
        calc=K-1
        diff=0
        #for i in range(calc,max(1,calc-(len(tmp)-diff)),-1):
        seki*=special.perm(calc,num-diff)
        #for i in range(calc,calc-(num-diff),-1):
        #    seki*=i%1000000007
        
    else:
        calc=K-2
        diff=1
        #for i in range(calc,calc-(num-diff),-1):
        #    seki*=i%1000000007
    seki*=special.perm(calc,num-diff)
            
    for each in tmp:
        if not check_node[each]:
            check_node[each]=True
            seki*=BFS(node[each].next,depth,K)%1000000007
    return seki


N,K=list(map(int,input().split()))
node=[Node() for _ in range(N)]
check_node=[False for _ in range(N)]
check_node[0]=True
for i in range(N-1):
    p,n=list(map(int,input().split()))
    node[n-1].get_data(p-1)
    node[p-1].get_data(n-1)
start=0
d=0

com=K*BFS(node[0].next,d,K)
print(int(com)%1000000007)

### FIXED CODE ###

import sys
import math
sys.setrecursionlimit(1000000)
mod=1000000007
class Node:
    def __init__(self):
        self.next=[]
    def get_data(self,new_next,weight=1):
        self.next.append(new_next)
def BFS(i,depth,K):  
    depth+=1
    tmp=i
    seki=1
    num=len(tmp)
    if depth==1:
        calc=K-1
        loop=range(calc,calc-num,-1)
        for i in loop:
            seki*=i%1000000007

        
    else:
        calc=K-2
        num-=1
        if calc>=num:
            seki=cache[num]
        else:
            print(0)
            exit()

            
            
    for each in tmp:
        if not check_node[each]:
            check_node[each]=True
            seki*=BFS(node[each].next,depth,K)%mod
    return seki


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

if K>2:
    cache=[0 for i in range(K-2)]
    cache[0]=1
    for i in range(1,K-2):
        cache[i]=cache[i-1]*(K-1-i)%mod
    cache.append(cache[-1])
else:
    cache=[1,1]
node=[Node() for _ in range(N)]
check_node=[False for _ in range(N)]
check_node[0]=True
for i in range(N-1):
    p,n=list(map(int,input().split()))
    node[n-1].get_data(p-1)
    node[p-1].get_data(n-1)
start=0
d=0

com=K*BFS(node[0].next,d,K)
print(int(com)%mod)
H, W, D = map(int, input().split())

A = []

for i in range(H):
    l = list(map(int, input().split()))
    for j in range(W):
        A[l[j]] = (i, j)

Q = int(input())

for i in range(Q):
    L, R = map(int, input().split())
    cost = 0
    while L != R:
        start = A[L]
        stop  = A[L+D]
        cost += abs(start[0] - stop[0]) + abs(start[1] - stop[1])
        start = stop
        L += D
    print(cost, flush=True)

### FIXED CODE ###

# speed-test
# https://abc089.contest.atcoder.jp/submissions/2206669

h,w,d = map(int,input().split())
 
dic = {}
for i in range(h):
    a = input().split()
    for j in range(w):
        dic[int(a[j])] = (i+1,j+1)
        
q = int(input())
c = [0]*(h*w+1)
for i in range(d+1,h*w+1):
    pi,pj = dic[i]; qi,qj = dic[i-d]
    c[i] = c[i-d] + abs(pi-qi) + abs(pj-qj)
    
for i in range(q):
    l,r = map(int,input().split())
    print(c[r]-c[l])
a,b,v,w,t = map(int,input().split())

d = abs(b-a)
p = abs(v-w)
i=0
for i in range(t+1):
  if v<=w:
    print("NO")
  elif p*i == d:
    print("YES")
    
  elif p*i < d:
    print("NO")


### FIXED CODE ###

a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if v <= w:
    print('NO')
else:
    if 1 <= (abs(b - a) / (v - w)) <= t:
        print('YES')
    else:
        print('NO')
a = list(map(int, input().split())

a.sort
print(*a)


### FIXED CODE ###

a = list(map(int, input().split()))
a.sort()
print(*a)
import sys


def main():
    process()


def process():
    data = []
    for line in get_data():
        line = line.split()
        if len(line) == 2:
            if line[0] == line[1] == '0':
                data = []
                continue
            H = int(line[0])
            W = int(line[1])
        elif len(line) == 0:
            pass
        else:
            data.append(line[0])
            if len(data) == H:
                field = create_field(H, W)
                print search(H, W, data, field)


def search(H, W, data, field):
    count = 0
    for i in xrange(H):
        for j in xrange(W):
            if field[i][j] == 0:
                continue
            _search(i, j, H, W, data[i][j], data, field)
            count += 1
    return count


def _search(i, j, H, W, cell, data, field):
    field[i][j] = 0
    for a in xrange(i-1, i+2):
        if -1 < a < H:
            pass
        else:
            continue
        for b in xrange(j-1, j+2):
            if -1 < b < W:
                pass
            else:
                continue

            if a != i and b != j:
                continue

            if field[a][b] == 0:
                continue
            if cell == data[a][b]:
                _search(a, b, H, W, cell, data, field)
    return


def create_field(H, W):
    field = []
    for i in xrange(H):
        raw = []
        for j in xrange(W):
            raw.append(1)
        field.append(raw)
    return field


def get_data():
    return [line.strip() for line in sys.stdin.readlines()]


if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000000)


def main():
    solve()


def solve():
    for data in get_dataset():
        print search(data)


def search(data):
    count = 0
    H = len(data)
    W = len(data[0])
    for i in xrange(H):
        for j in xrange(W):
            if data[i][j] == '.':
                continue
            _search(i, j, H, W, data[i][j], data)
            count += 1
    return count


def _search(i, j, H, W, cell, data):
    data[i][j] = '.'
    for a in xrange(i-1, i+2):
        if not -1 < a < H:
            continue
        for b in xrange(j-1, j+2):
            if not -1 < b < W:
                continue

            if a != i and b != j:
                continue

            if data[a][b] == '.':
                continue

            if cell == data[a][b]:
                _search(a, b, H, W, cell, data)
    return


def get_dataset():
    dataset = []
    while True:
        line = raw_input().rstrip().split()
        H = int(line[0])
        if H == 0:
            break

        data = []
        for i in xrange(H):
            data.append(list(raw_input().rstrip()))
        dataset.append(data)
    return dataset


if __name__ == '__main__':
    main()
import sys
input = sys.stdin.readline

S = input()
l = len(S)
no_zero_dic = {}
dp = [[0 for _ in range(2019)] for i in range(l)]
ans = 0
for i in range(l):
    s = int(S[i])
    no_zero_dic[s] = 1
    _x = set(no_zero_dic.keys())
    for j in _x:
        k = (10 * j + s) % 2019
        dp[i][k] = dp[i-1][j]
        if dp[i-1][j] > 0:
            no_zero_dic[k] = 1
        if k == 0:
            ans += dp[i][k]
    dp[i][s] += 1


print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline

S = input().strip()
l = len(S)
dic = {0:[-1]}
ans = 0
base = 1
mod = 0
for i in range(0, l):
    base = (10 * base) % 2019
    s = base * int(S[l-1-i]) + mod
    mod = s % 2019
    if mod in dic:
        dic[mod].append(i)
    else:
        dic[mod] = [i]

for key, val in dic.items():
    v_len = len(val)
    ans += (v_len * (v_len -1))// 2

print(ans)
s = input()
if s <= 2019/04/30:
  print("Heisei")
else:
  print("TBD")

### FIXED CODE ###

s = input()
if s <= "2019/04/30":
  print("Heisei")
else:
  print("TBD")
a=input()
b=input()

if len(a)>len(b):
    print("GREATER")
elif len(a)<len(b):
    print("LESS")
else:
    for i in range(len(a)):
        if a[i]>b[i]:
            print("GRATER")
            exit()
        elif a[i]<b[i]:
            print("LESS")
            exit()
print("EQUAL")

### FIXED CODE ###

a,b,c=input().split()
print(a[0].upper()+b[0].upper()+c[0].upper())
rows = int(input())
L = [input() for i in range(rows)]

s = L[0]
S = list(s)
t = L[1]
T = list(t)

N = len[S]
i = 1

while N != i:
    if S[i] != T[i]:
        S[i] = T[i]
        i += 1

### FIXED CODE ###

s,t = input(), input()

S = list(s)
T = list(t)

N = len(s) - 1
i = 0
counter = 0

while N + 1 != i:
    if S[i] != T[i]:
        S[i] = T[i]
        counter += 1
    i += 1

print(counter)
a=list(map(int,input().split())).sort()
print(a[2]*10+a[1]+a[0])


### FIXED CODE ###

a=list(map(int,input().split()))
a.sort()
print(a[2]*10+a[1]+a[0])
import itertools
n,m,x = map(int,input().split())
book = []
for _ in range(n):
    book.append(list(map(int,input().split())))

buy = list(itertools.product([0,1],repeat=m))

money = []

for i in range(len(buy)):
    algo = [0 for _ in range(m)]
    money_tmp = 0
    #j冊目の本
    for j in range(len(buy[i])):
        for k in range(m):
            algo[j] += book[k][j+1] * buy[i][k]
        money_tmp += book[j][0]*buy[i][j]
    algo.sort()
    if algo[0] >= x:
        money.append(money_tmp)
if len(money) > 0:    
    print(min(money))
else:
    print(-1)

### FIXED CODE ###

#ABC167-C
import itertools
flg = True
n,m,x = map(int,input().split())
algo = []
tmp = []
for _ in range(n):
    algo.append(list(map(int,input().split())))
    
book = list(itertools.product([0,1],repeat=n))
abi = [0 for _ in range(m)]

for pattern in book:
    #値の初期化
    abi = [0 for _ in range(m)]
    money = 0
    flg = True
    
    for i in range(len(pattern)):
        for j in range(m):
            abi[j] += algo[i][j+1] * pattern[i]
        money += algo[i][0] * pattern[i]
        
    abi_min = [p for p in abi if p < x]
        
    if len(abi_min) != 0:
        flg = False
    if flg:
        tmp.append(money)

if len(tmp) > 0:
    print(min(tmp))
else:
    print(-1)