Harryxun/stf_run huggingface dataset:
import sys
input = sys.stdin.readline
N = int(input())
node = [0 for i in range(N)]

neigh = [[0 for i in range(N)] for j in range(N)]
ans = [0 for i in range(N)]
visited = [0 for i in range(N)]
k = 1
def dfs(neighbor,start,visited,c):
    global k
    if sum(visited) == N:
        return ans
    for i in range(N):
        if visited[i] == 0 and neighbor[start][i] == 1:
            ans[i] = c[k]
            k += 1
            visited[i] = 1
            dfs(neighbor,i,visited,c)
for i in range(N-1):
    ai,bi = map(int,input().split())
    node[ai-1]+= 1
    node[bi-1] += 1
    neigh[ai-1][bi-1] = 1
    neigh[bi-1][ai-1] = 1
c = list(map(int,input().split()))
c.sort(reverse=True)
m = max(node)
nn = node.index(m)
visited[nn] = 1
ans[nn] = max(c)

dfs(neigh,nn,visited,c)
ans2 = ' '.join([str(ans[i]) for i in range(N)])
print(sum(c)-max(c))
print(ans2)


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
N = int(input())


node = [0 for i in range(N)]
neigh = [[] for j in range(N)]
ans = [0 for i in range(N)]
visited = [0 for i in range(N)]
k = 1

for i in range(N-1):
    ai,bi = map(int,input().split())
    node[ai-1] += 1
    node[bi-1] += 1
    neigh[ai-1].append(bi-1)
    neigh[bi-1].append(ai-1)
c = list(map(int,input().split()))
c.sort(reverse=True)
flag = False
def dfs(neighbor,start):
    global flag
    global k
    if sum(visited) == N:
        return 0

    for i in neighbor[start]:
        
        if visited[i] == 0:
            ans[i] = c[k]
            k += 1
            visited[i] = 1
            try:
                dfs(neighbor,i)
            except RuntimeError:
                flag = True
                return 0




m = max(node)
nn = node.index(m)
#nn = [node[i] for i in range(N) if node[i] == m][0]
visited[nn] = 1
ans[nn] = max(c)

dfs(neigh,nn)
"""
if flag:
    print(100)
    print(' '.join([str(i) for i in range(N)]))
    exit()
"""
ans2 = ' '.join([str(ans[i]) for i in range(N)])


print(sum(c)-max(c))
print(ans2)
import sys

input = sys.stdin.readline


def cnt(i, oya_i):
    if len(ko[i]) == 1 and oya_i:
        return 1
    if memo[i][oya_i] != 0:
        return memo[i][oya_i]
    re = 1
    for ko_i in ko[i]:
        if ko_i == oya_i: continue
        re *= (cnt(ko_i, i) + 1)
    memo[i][oya_i] = re
    return re


def f(n, m):
    for _ in range(n - 1):
        x, y = map(int, input().split())
        ko[x] += [y]
        ko[y] += [x]
    for start_i in range(1, n + 1):
        print(cnt(start_i, 0) % m)


n, m = map(int, input().split())
memo = [[0] * (n + 1) for _ in range(n + 1)]
ko = [[] for _ in range(n + 1)]
f(n, m)


### FIXED CODE ###

from collections import *
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

n, m = MI()
to = defaultdict(list)
# dp[u][v] uを根としたときのサブツリーvの値
dp = {}

def dfs(u=0, pu=-1):
    res = 1
    for v in to[u]:
        if v == pu: continue
        res *= dfs(v, u) + 1
        res %= m
    if pu != -1: dp[(pu,u)] = res
    return res

def main():
    for _ in range(n - 1):
        x, y = map(int1, input().split())
        to[x].append(y)
        to[y].append(x)
    dfs()
    # bfsでdfsとは逆向きのdpを完成させる
    que = deque()
    que.append([0, -1])
    while que:
        u, pu = que.popleft()
        tn = len(to[u])
        # 累積積のための配列
        ll = [0] * tn
        rr = [0] * tn
        # uのサブツリーの値+1を入れる
        for i, v in enumerate(to[u]):
            ll[i] = rr[i] = dp[(u,v)] + 1
        # 左右から累積積を作る
        for i in range(1, tn):
            ll[i] = (ll[i - 1] * ll[i]) % m
            rr[tn - 1 - i] = (rr[tn - i] * rr[tn - 1 - i]) % m
        # 配列の最初or最後のために最後に1を追加
        ll += [1]
        rr += [1]
        # uの子vを根とみたときのサブツリーuの値を求める
        for i, v in enumerate(to[u]):
            if v == pu: continue
            dp[(v,u)] = (ll[i - 1] * rr[i + 1]) % m
            que.append([v, u])
    # p2D(dp)
    # 各頂点について答えを出す
    for u in range(n):
        ans = 1
        for v in to[u]:
            ans = (ans * (dp[(u,v)] + 1)) % m
        print(ans)

main()
n,x=map(int,input().split())
if x==1 or x==n:print("No")
else:
  print("Yes")
  b=[0]*n
  b[n//2]=x
  b[n//2-1]=x-1
  b[n//2+1]=x+1
  tor=[i+1 for i in range(n)]
  del tor[x-2:x+1]
  print(tor)
  for i in range(n):
    if b[i]==0:
      b[i]=tor.pop()
  for i in b:
    print(i)


### FIXED CODE ###

N=int(input())
s=input()
t=input()
for i in range(1,N+1)[::-1]:
  if s[N-i:]==t[:i]:
    print(2*N-i)
    exit()
print(2*N)
X, Y, A, B, C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)

a = sorted(P[:X] + Q[:Y])
ans = sum(a)

for i in range(C):
    if a[i] < R[i]:
        ans += R[i] - a[i]

print(ans)

### FIXED CODE ###

X, Y, A, B, C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)

a = sorted(P[:X] + Q[:Y])
ans = sum(a)

for i in range(min(X+Y, C)):
    if a[i] < R[i]:
        ans += R[i] - a[i]

print(ans)
import math

# D - Maximum Average Sets
# 問題URL:http://abc057.contest.atcoder.jp/tasks/abc057_d

# N:商品の数　A個以上B個以下の範囲で選ぶ
N, A, B = map(int, input().split())
# C：最大価値組み合わせ総数
C = 0
# cnt:カウンター
cnt = 0

# 商品価値をリストに入れる
V = [int(value) for value in input().split()]
# 商品価値が高い順に並び替え
V.sort(reverse=True)

# 商品価値が高いものから出来るだけ少なく（＝A個）選ぶのが最も平均価値が高くなる
S = V[0:A]
ave = sum(S) / A
print(ave)

if V[0]== V[A-1]: # もしもA個選んだ中の商品価値が全て同じだったら
    for i in range(N):
        
        # N個の商品の中に最大価値値を持つものがいくつあるか調べる
        if V[0] == V[i]:
            cnt += 1
    
    j = A
    while j <= B and V[-i] == min(S):
        C = C + math.factorial(cnt) / ( math.factorial(cnt - i) * math.factorial(i))
        j += 1
    

else: # 商品価値が均一でなかったのなら
    Vs = V.count(min(S)) # A個選んだ中で最も低い価値を持つ商品は、もともとの商品リストの中にいくつあるか
    Ss = S.count(min(S)) # A個選んだ時中で最も低い価値を持つ商品はいくつあるか
    
    # nCk = n! /( (n-k)! * k! )に基づきCを計算
    C = math.factorial(Vs) / (math.factorial(Vs - Ss) * math.factorial(Ss) )

print(int(C))

### FIXED CODE ###

# 元ソースコード：http://abc057.contest.atcoder.jp/submissions/1183710
# 初心者の実験用です

import math
N,A,B = map(int,input().split())
V = list(map(int,input().split()))
V.sort()
S = V[-A:]
avgmax = sum(S) / A
print(avgmax)
 
Vs = V.count(min(S))
Ss = S.count(min(S))
if min(S) != max(S):
	C = math.factorial(Vs) // (math.factorial(Vs -Ss) * math.factorial(Ss))
	print(C)
else:
	i = A
	C = 0
	while i <= B and V[-i] == min(S):
		c = math.factorial(Vs) // (math.factorial(Vs -i) * math.factorial(i))
		C = C + c
		i = i + 1
	print(C)
x, y, a, b ,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
sm=0
p.sort()
q.sort()
r.sort(reverse=True)

p=p[(a-x):]
q=q[(b-y):]

p_idx=0
q_idx=0
plen=len(p)
qlen=len(q)
for i in range(c):
    #処理が終わる時
    if p[p_idx]>r[i] and q[q_idx]>r[i]:
        break
    #全部入れ替わる
    if p_idx==plen and q_idx==qlen:
        break
    if q_idx==qlen:
        if p[p_idx]>r[i]:
            break
        else:
            p[p_idx]=r[i]
            p_idx+=1
    if p_idx==plen:
        if q[q_idx]>r[i]:
            break
        else:
            q[q_idx]=r[i]
            q_idx+=1
    if p[p_idx]<=q[q_idx]:
        p[p_idx]=r[i]
        p_idx+=1
    if q[q_idx]<=p[p_idx]:
        q[q_idx]=r[i]
        q_idx+=1

ans=sum(p)+sum(q)
print(ans)

### FIXED CODE ###

x, y, a, b ,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
sm=0
p.sort()
q.sort()
r.sort(reverse=True)

p=p[(a-x):]
q=q[(b-y):]
p.extend(q)
p.sort()

idx=0
for i in range(len(p)):
    if p[i]>r[idx]:
        break
    else:
        p[i]=r[idx]
        idx+=1
        if c==idx:
            break

print(sum(p))
N = int(input())

count = 0
for i in range(1,N+1):
  a = [_ for _ in str(i)]
  if len(a)%2=1:
    count += 1

print(count)

### FIXED CODE ###

N = int(input())

count = 0
for i in range(1,N+1):
  a = [_ for _ in str(i)]
  if len(a)%2==1:
    count += 1

print(count)
import sys
def l(s,n):
    o=ord(s)+n
    if not 97<=ord(s)<=122:
        return s
    if 97<=o<=122:
        return chr(o)
    elif o>123:
        return chr(o-26)

for t in sys.stdin:
    s=t[:-1]
    for i in range(1,26):
        e=lambda s:l(s,i)
        if "".join(map(e,"this")) in s:
            break
        if "".join(map(e,"that")) in s:
            break
        if "".join(map(e,"the")) in s:
            break
    print("".join(map(lambda x:l(x,-i),s)))


### FIXED CODE ###

import sys
def l(s,n):
    o=ord(s.lower())
    if not 97<=o<=122:
        return s
    if 97<=o+n<=122:
        if 97<=ord(s)<=122:
            return chr(o+n)
        else:
            return chr(o+n).upper()
    elif o+n>122:
        if 97<=ord(s)<=122:
            return chr(o+n-26)
        else:
            return chr(o+n-26).upper()
    else:
        if 97<=ord(s)<=122:
            return chr(o+n+26)
        else:
            return chr(o+n+26).upper()

for t in sys.stdin:
    s=t[:-1]
    u=s.lower()
    for i in range(0,26):
        cv=lambda y:"".join(map(lambda x:l(x,i),y))
        if cv("this") in u or cv("that") in u or cv("the") in u:
            break
    print("".join(map(lambda x:l(x,-i),s)))
N = int(input())
H = [(int) i for i in input().split()]
moves = []
for i in range(N - 1):
    move = 0
    for j in range(i, N - 1):
        if H[j] >= H[j + 1]:
            move += 1
        else:
            break
    moves.append(move)


### FIXED CODE ###

N = int(input())
H = [int(i) for i in input().split()]
ans, prev, cnt = 0, 0, 0
for h in H:
    if h <= prev:
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0
    prev = h
print(max(ans, cnt))
"""
B - Grid Compression
ex in )
4 4
##.#
....
##.#
.#.#

ex out)
###
###
.##
"""

H, W = map(int, input().split())

matrix = []
for h in range(H):
    line = list(input())
    
    line_num = []
    for part in line:
        line_num.append(part)
    
    matrix.append(line_num)

#print(matrix)

cat = 0
for h in range(H):

    leave = False
    for w in range(W):
        
        # 黒ならのこす
        if matrix[h - cat][w] != ".":
            leave = True
            break
    
    if leave is False:
        matrix.pop(h - cat)
        cat += 1
    else:
        pass
        #print(h, "leave")

#print(matrix)

cat = 0
for w in range(W):

    leave = False
    for h in range(len(matrix)):
        
        # 黒ならのこす
        if matrix[h][w - cat] != ".":
            leave = True
            break
    
    if leave is False:
        cat += 1
        for h in range(len(matrix)):
            matrix[h].pop(w)
    else:
        pass
        #print(w, "leave")


for h in range(len(matrix)):
    line = ""
    for w in range(len(matrix[0])):
        line += matrix[h][w]
    print(line)


### FIXED CODE ###

"""
B - Grid Compression
ex in )
4 4
##.#
....
##.#
.#.#

ex out)
###
###
.##
"""

H, W = map(int, input().split())

matrix = []
for h in range(H):
    line = list(input())
    
    line_num = []
    for part in line:
        line_num.append(part)
    
    matrix.append(line_num)

leave_h = []
for h in range(H):
    for w in range(W):
        # 黒ならのこす
        if matrix[h][w] == "#":
            leave_h.append(h)
            break

leave_w = []
for w in range(W):
    for h in range(len(matrix)):
        
        # 黒ならのこす
        if matrix[h][w] == "#":
            leave_w.append(w)
            break


for h in range(H):
    if h not in leave_h:
        continue

    for w in range(W):
        if w not in leave_w:
            continue

        print(matrix[h][w], end="")
    
    print()
a,b,c = map(int, input().split())
if a <= b <= d:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

a,b,c = map(int, input().split())
if a <= c <= b:
  print('Yes')
else:
  print('No')
N = int(input())
S = input()

dot = S.count(".")
sha = 0
res = 10**9
for i in range(1,N):
    if i == "#":
        sha += 1
    else:
        dot -= 1
    tmp = sha + dot
    res = min(res, tmp)

print(res)

### FIXED CODE ###

a,b,c = map(int, input().split())
if (a <= c and c <= b) or (b <= c and c <= a):
    print("Yes")
else:
    print("No")
def min_k_shift(k, a, N, x, range_min):
    cost = k*x
    for j in range(N):
        cost += range_min[(j-k)%N][j] #min(a[(j-sj)%N] for sj in range(k))
    return cost

N, x = [int(s) for s in raw_input().split()]

a = [int(s) for s in raw_input().split()]

range_min = [[0]*N for st in range(N)]
for st in range(N):
    range_min[st][st] = a[st]

for k in range(1,N):
    for st in range(N):
        range_min[st][(st+k)%N] = min(range_min[st][(st+k-1)%N],a[(st+k)%N])

print(min(min_k_shift(k,a,N,x,range_min) for k in range(N)))

### FIXED CODE ###

a,b,c = sorted(int(s) for s in input().split())

if a % 2 == 0 or b % 2 == 0 or c % 2 == 0:
    print(0)
else:
    print(a*b)
w,h,x,y = map(int, input().split())

    if x > w/2:
        x = w - x
    if y > h/2:
        y = h - y

    # 横
    men1 = w * y
    men2 = w * (h-y)

    # 縦
    men3 = x * h
    men4 = (w-x) * h

    if x == 0 and y ==0 :
        out1 = w * h
        out2 = 1
    else:
        #print("{0} {1} {2} {3}".format(str(men1), str(men2), str(men3), str(men4)))

        if min(men1, men2) == 0:
            out1 = min(men3, men4)
        elif min(men3, men4) == 0:
            out1 = min(men1, men2)
        else:
            out1 = max(min(men1, men2), min(men3, men4))

        if x != 0 and y != 0 and (h / w) == (y / x):
            out1 = w * h / 2

        out2 = 0
        if min(men1, men2) == min(men3, men4):
            out2 = 1
        if x != 0 and y != 0 and (h / w) == (y / x):
            out2 = 1

    print("{0} {1}".format(out1, out2))


### FIXED CODE ###

w,h,x,y = map(int, input().split())
out1 = w * h / 2
out2 = 1 if x == w/2 and y == h/2 else 0
print("{0} {1}".format(str(out1), str(out2)))
import copy

n, m = map(int, input().rstrip().split())
number_list = list(map(int, input().rstrip().split()))
number_list.sort()
match = [2, 5, 5, 4, 5, 6, 3, 7, 6]
new_match = []
answer = []

for i in number_list:
    new_match.append(match[i-1])


for index in range(m):
    value = new_match[index]
    new_match_tmp = copy.copy(new_match)
    new_match_tmp.remove(value)
    maximum = max(new_match_tmp)
    #商と余りを計算
    quotient = int(n / value)
    remainder = n % value
    answer_tmp = [number_list[index]] * quotient
    #余りがあるなら余りをなくすように組み合わせを考える
    if remainder != 0:
        while True:
            quotient -= 1
            remainder += value
            answer_tmp.pop(0)
            if remainder in new_match:
                answer_tmp.append(number_list[new_match.index(remainder)])
                break
            elif remainder > maximum:
                try:
                    minimum = min(new_match_tmp)
                    remainder -= minimum
                    answer_tmp.append(number_list[new_match.index(minimum)])
                except:
                    answer_tmp = []
                    break
            if remainder == n:
                answer_tmp = []
                break

    if len(answer_tmp) != 0:
        answer.append(answer_tmp)

answer.sort(key=lambda x:len(x), reverse=True)
ans = reversed(answer[0])

print(*ans, sep='')
print()


### FIXED CODE ###

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

if b % a == 0:
  print(a+b)
else:
  print(b-a)
class Graph:
    edges = {}

    def append_edge(self, sv, ev, weight = 1):
        if sv in self.edges:
            self.edges[sv].append((ev, weight))
        else:
            self.edges[sv] = [(ev, weight)]

    def bfs(self, sv):
        dist = [0]*len(self.edges.keys())
        q = []
        q.append(sv)
        dist[sv] = 0
        connect_vtxs = []
        while len(q) > 0:
            p = q.pop(0)
            connect_vtxs.append(p)
            for (ev, w) in self.edges[p]:
                if dist[ev] != -1:
                    continue
                q.append(ev)
                dist[ev] = dist[p] + 1
        return dist, connect_vtxs


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

g = Graph()
for i in range(N - 1):
    g.append_edge(i, i + 1)
    g.append_edge(i + 1, i)
g.append_edge(X - 1, Y - 1)
g.append_edge(Y - 1, X - 1)

dist_cnt = [0]*N
for sv in range(N):
    dist, connect_vtxs = g.bfs(sv)
    for j in range(dist.shape[0]):
        if dist[j] == -1: continue
        dist_cnt[dist[j]] += 1

for i in range(N-1):
    print(int(dist_cnt[i+1]/2))


### FIXED CODE ###

K, N = list(map(int, input().split()))
A = list(map(int, input().split()))
A.append(K+A[0])
diff_list = []
for i in range(len(A) - 1):
    diff_list.append(A[i+1]-A[i])
print(K - max(diff_list))
a = map(int, input().split())
print(f'{a * a * 3.1415926}')
print(f'{2 * a * 3.1415926}')



### FIXED CODE ###

r = float(input())
p = 3.141592653589
print(p*r*r, 2*p*r)
from decimal import Decimal
import math 
r =int(input())
R = r*2*math.pi
S = r**2*math.pi
print(R,S)



### FIXED CODE ###

import math 
r =float(input())
R = r*2*3.14159265358979
S = r**2*3.14159265358979
print(S,R)
import math
a,b,c=map(int,input().split())
print("Yes" if math.sqrt(a)+math.sqrt(b)<math.sqrt(c) else "No")

### FIXED CODE ###

a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
n=int(input())
print(a[n-1])
N, K = map(int, input().split())
A=list(map(int,input().split()))
A.sort()
right = A[-1]+1
left = -1
flag = True
while right-left>1 and flag:
    mid = (left+right)//2
    count = 0
    for i in A:
        count += (i-1)//mid
    if count <= K:
        right = mid
    elif count > K:
        left = mid
    else:
        flag = False
print(mid)


### FIXED CODE ###

N, K = map(int, input().split())
A=list(map(int,input().split()))
A.sort()
right = A[-1]+1
left = 0
flag = True
mid = (left+right)//2
minN = right
result = mid
while right-left>1 and flag:
    mid = (left+right)//2
    count = 0
    for i in A:
        count += (i-1)//mid
    if count <= K:
        right = mid
        if minN>mid:
            minN = mid
            result = mid
    elif count > K:
        left = mid
print(result)
X = int(input())
while(1):
    for i in range(2,11):
        f = pow(X,1.0/float(i))
        if(1-f%1<=10**-8):
            print(X)
            exit()
    X-=1


### FIXED CODE ###

X = int(input())
ans=0
for p in range(2,10):
    for b in range(1,32):
        if(b**p <= X and ans < b**p):
            ans = b**p
print(ans)
A, B, K = input().split()

A = int(A)
B = int(B)
K = int(K)

value = []
if A == B:
    value = A
if B <= K:
    value.extend([i for i in range(A, B+1)])

else:
    value.extend([i for i in range(A, A+K)])
    value.extend([i for i in range(B-K+1, B+1)])    


num = list(set(value))
num.sort()
for i in range(len(num)):
    print(num[i])

### FIXED CODE ###

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

value = []

if B - A < K or B <= K:
    value.extend([i for i in range(A, B+1)])
    
else:
    value.extend([i for i in range(A, A+K)])
    value.extend([i for i in range(B-K+1, B+1)])    

num = list(set(value))
num.sort()

for i in range(len(num)):
    print(num[i])
print("ABC"+str(input())

### FIXED CODE ###

s = str(input())
print("ABC"+s)
n,*l=map(int,open(0).read().split())
a=sum(l[i]-i-1for i in range(n))//n
f=lambda x:sum(abs(l[i]-i-1-x)for i in range(n))
print(min(f(a-1),f(a),f(a+1)))

### FIXED CODE ###

n=int(input());print(n*(n%2+1))
A*B

### FIXED CODE ###

x, y = map(int, input().split())
print(x*y)
import copy
from heapq import heappop, heapify, heappush
import math
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
F = [int(i) for i in input().split()]
ans = 0
A.sort(reverse=True)
F.sort()
s = []
for i in range(N):
    s.append([A[i]*F[i], A[i], F[i]])
s.sort(reverse=True, key=lambda x: x[0])

def f(l, T):
    cur = 0
    num = 0
    S = copy.deepcopy(l)
    while cur <= K:
        if len(S) == 0:
            break
        a, b, c = S[num]
        if a <= T:
            break
        cur += math.ceil((a - T)/c)
        num += 1
    if cur <= K:
        return True
    else:
        return False

ok, ng = s[0][0], -1
while abs(ok-ng) > 1:
    mid = (ok+ng)//2
    if f(s, mid) == True:
        ok = mid
    else:
        ng = mid
print(ok)

### FIXED CODE ###

def main():
    import copy
    from heapq import heappop, heapify, heappush
    import math
    N, K = map(int, input().split())
    A = [int(i) for i in input().split()]
    F = [int(i) for i in input().split()]
    ans = 0
    A.sort(reverse=True)
    F.sort()
    s = []
    for i in range(N):
        s.append([A[i]*F[i], A[i], F[i]])
    s.sort(reverse=True, key=lambda x: x[0])

    def f(S, T):
        cur = 0
        num = 0
        while cur <= K:
            if num == N:
                break
            a, b, c = S[num]
            if a <= T:
                break
            cur += math.ceil((a - T)/c)
            num += 1
        if cur <= K:
            return True
        else:
            return False

    ok, ng = s[0][0], -1
    while abs(ok-ng) > 1:
        mid = (ok+ng)//2
        if f(s, mid) == True:
            ok = mid
        else:
            ng = mid
    print(ok)

if __name__ == '__main__':
    main()
Books,Cost,X=None,None,None
DP={}

def getUnderstanding(prev,curr):
    global Books
    L=[]
    for i in range(len(prev)):
        L.append(prev[i]+Books[curr][i])
    return L
def isUnderstandingReached(prev):
    global X
    for u in prev:
        if u<X:
            return False
    return True

def F(curr,prev):
    global Books,Cost,X,DP
    if (curr,tuple(prev)) in DP:
        return DP[(curr,prev)]
    if isUnderstandingReached(prev):
        return 0
    if curr==len(Books):
        return float('inf')
    DP[(curr,tuple(prev))]=min(Cost[curr]+F(curr+1,getUnderstanding(prev,curr)),F(curr+1,prev))
    return DP[(curr,tuple(prev))]

N,M,X=map(int,input().strip().split())
Books=[]
Cost=[]
for i in range(N):
    L=list(map(int,input().strip().split()))
    Books.append(L[1:])
    Cost.append(L[0])
res=F(0,[0]*len(Books[0]))
if res==float('inf'):
    print(-1)
else:
    print(res)

### FIXED CODE ###

Books,Cost,X=None,None,None
DP={}

def getUnderstanding(prev,curr):
    global Books
    L=[]
    for i in range(len(prev)):
        L.append(prev[i]+Books[curr][i])
    return L
def isUnderstandingReached(prev):
    global X
    for u in prev:
        if u<X:
            return False
    return True

def F(curr,prev):
    global Books,Cost,X,DP
    #if (curr,tuple(prev)) in DP:
    #    return DP[(curr,prev)]
    if isUnderstandingReached(prev):
        return 0
    if curr==len(Books):
        return float('inf')
    DP[(curr,tuple(prev))]=min(Cost[curr]+F(curr+1,getUnderstanding(prev,curr)),F(curr+1,prev))
    return DP[(curr,tuple(prev))]

N,M,X=map(int,input().strip().split())
Books=[]
Cost=[]
for i in range(N):
    L=list(map(int,input().strip().split()))
    Books.append(L[1:])
    Cost.append(L[0])
res=F(0,[0]*len(Books[0]))
if res==float('inf'):
    print(-1)
else:
    print(res)
s= input().split()
a=int(s.[0])
b=int(s.[1])
c=int(s.[2])

if((c>b)and(b>a)):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

a,b,c=input().split()

a=int(a)
b=int(b)
c=int(c)

if(c>b>a):
    print("Yes")
else:
    print("No")
n = input()
s = str(input())
k = input()

char = s[k]
result = ""
for x in s:
    if x == char:
        result += char
    else:
        result += "*"
print(result)

### FIXED CODE ###

n = int(input())
s = str(input())
k = int(input())
 
char = s[k-1]
result = ""
for x in s:
    if x == char:
        result += char
    else:
        result += "*"
print(result)
n = int(input())
a = list(map(int, input().split()))
a.sort()
if a[int(n/2 + 1)] == a[int(n/2)]:
    answer = 0
else:
    answer = a[int(n/2)] - a[int(n/2 - 1)]
print(answer)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
a.sort()
answer = a[int(n/2)] - a[int(n/2 - 1)]
print(answer)