Harryxun/stf_run huggingface dataset:
N, M = int(input().split())
A = [int(a) for a input().split()]
tmp = N - sum(A)
if tmp >= 0:
    print(tmp)
else:
    print(-1)


### FIXED CODE ###

N, M = [int(x) for x in input().split()]
A = [int(a) for a in input().split()]
tmp = N - sum(A)
if tmp >= 0:
    print(tmp)
else:
    print(-1)
L, R = map(int, input().split())
ans = []

def calc_mod(x, y):
    return x * y % 2019

left = L % 2019
right = R % 2019

for i in range(left, right):
    for j in range(i+1, right+1):
        ans.append(calc_mod(i, j))

print(min(ans))

### FIXED CODE ###

import sys
L, R = map(int, input().split())
ans = []

def calc_mod(x, y):
    return x * y % 2019

left = L % 2019
right = R % 2019

if R-L > 2019:
    print(0)
    sys.exit(0)

elif left > right:
    print(0)
    sys.exit(0)

elif left==0 or right==0:
    print(0)
    sys.exit(0)

for i in range(left, right):
    for j in range(i+1, right+1):
        ans.append(calc_mod(i, j))

print(min(ans))
def df_search(searchNode,node,sss,i):
    global cnt
    ss=sss+1
    sn=searchNode
    sn.append(i)
    if(hantei==sorted(sn)):
        if(ans==[]):
            cnt+=1
            ans.append(searchNode)
        else:
            for an in ans[:]:
                if(an != searchNode):
                    cnt+=1
                    ans.append(searchNode)
    for i in node:
        if(i not in sn):
            df_search(sn[:],df_dic[i],ss,i)

ans=[]
lis=[]
df_dic=dict()

NODES,EDGE=map(int,input().split())
df_flag = [0 for i in range(NODES)]  # 探索状況[0:未探索, 1:探索済み] 初期値：0
for i in range(EDGE):
    lis.append(list(map(int,input().split())))
    df_dic[i+1]=[]
for i in lis:
    df_dic[i[0]].append(i[1])
    df_dic[i[1]].append(i[0])
cnt=0
hantei=[i for i in range(1,EDGE+1)]
df_search([],df_dic[1],0,1)
print(cnt)

### FIXED CODE ###

N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)
cnt = [0]
def dfs(V, s):
    V[s] = 1
    if sum(V) == N:
        cnt[0] += 1                    
    else:
        for adj in G[s]:
            if V[adj] == 0:             
                dfs(V[:adj] + [1] + V[adj + 1:], adj)  #ここで分岐がたくさん発生する
dfs([0] * N, 0)
print(cnt[0])
n=int(input())
ans=10**100
for i in range(n)
  t=sum(list(map(int,input().split())))
  ans=min(ans,t)
print(ans)

### FIXED CODE ###

n=int(input())
ans=10**100
for i in range(n):
  t=sum(list(map(int,input().split())))
  ans=min(ans,t)
print(ans)
N = int(input())
prod = 1
for j in range(1, N+1):
	prod *= j
print(prod%(1e9+7))

### FIXED CODE ###

import math
print(math.factorial(int(input()))%int(1e9+7))
S=int(input())
y=700+100*o
print(y.count(o)*100+700)

### FIXED CODE ###

S=input()
print(S.count("o")*100+700)
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a
 
#targetまでの素数の数
import math
def sieve_of_eratosthenes2(target):
    dest = int(math.sqrt(target))
    target_list = [i for i in range(2, dest+2) if target%i==0]
    prime_num = 0
 
    while True:
        num_min = min(target_list)
        if num_min > dest:
            prime_num += len(target_list)
            break
        prime_num += 1        
        target_list = [i for i in target_list if i%num_min!=0]
        if target_list==[]:
            break
 
    return prime_num   
 
a, b = map(int, input().split())
gcd = xgcd(a, b)
if gcd == 1:
    print(1)
else:
    ans = sieve_of_eratosthenes2(gcd)    
    print(ans+1)

### FIXED CODE ###

def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a


import random
def is_prime(q, k=50):
    q = abs(q)
    if q == 2:
        return True
    if q < 2 or q % 2 == 0:
        return False

    d = (q - 1) >> 1
    while d & 1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1, q - 1)
        t = d
        y = pow(a, t, q)
        while t != q - 1 and y != 1 and y != q - 1:
            y = pow(y, 2, q)
            t <<= 1
        if y != q - 1 and t & 1 == 0:
            return False
    return True

def prime_num(target):
    ra = 2
    prime = 0
    while target>1:
        if target%ra == 0:
            prime += 1
            while target%ra==0:
                target = target//ra
            if is_prime(target):
                prime += 1
                break
        if ra == 2:
            ra += 1
        else:
            ra += 2
    return prime   
        
a, b = map(int, input().split())
gcd = xgcd(a, b)
if gcd == 1:
    print(1)
elif is_prime(gcd):
    print(2)
else:
    ans = prime_num(gcd)    
    print(ans+1)
while True:
    instr = str(bin(int(input())))
    ans = []
    for i in range(len(instr)):
        if instr[-i]=="1": ans.append(1<<i-1)
    print(" ".join(map(lambda x: str(x), ans)))

### FIXED CODE ###

while True:
    try:
        instr = str(bin(int(input())))
        ans = []
        for i in range(len(instr)):
            if instr[-i]=="1": ans.append(1<<i-1)
        print(" ".join(map(lambda x: str(x), ans)))
    except EOFError:
        break
from collections import＊
n,m,*d=map(int,open(0).read().split())
a=Counter(d[:n])
for b,c in zip(d[n::2],d[n+1::2]):a[c]+=b
s=0
for k, v in sorted(a.items())[::-1]:
 if n<v:exit(print(s+k*n))
 n-=v
 s+=k*v

### FIXED CODE ###

from collections import Counter
n, m, *d = map(int, open(0).read().split())
a = Counter(d[:n])
for b, c in zip(d[n::2], d[n+1::2]):
    a[c] += b
ans = 0
for k, v in sorted(a.items())[::-1]:
    if n < v:
        exit(print(ans + k * n))
    n -= v
    ans += k * v
def search_dist(g, dist, e):
    for b, c in g.get(e):
        if dist[b] is not None:
            continue
        dist[b] = dist[e] + c
        search_dist(g, dist, b)

def main():
    g = {}
    N = int(input())
    for _ in range(N-1):
        a, b, c = list(map(int, input().split(' ')))
        g[a] = g.get(a, []) + [(b, c)]
        g[b] = g.get(b, []) + [(a, c)]
    Q, K = list(map(int, input().split(' ')))
    dist = [None]*(N+1)
    dist[K] = 0
    search_dist(g, dist, K)
    cood = []
    for _ in range(Q):
        cood.append(list(map(int, input().split(' '))))

    for x, y in cood:
        print(dist[x]+dist[y])

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
sys.setrecursionlimit(int(1e5+10))

def search_dist(g, dist, e):
    for b, c in g.get(e):
        if dist[b] is not None:
            continue
        dist[b] = dist[e] + c
        search_dist(g, dist, b)

def main():
    g = {}
    N = int(input())
    for i in range(N+1):
        g[i] = []
    for _ in range(N-1):
        a, b, c = list(map(int, input().split(' ')))
        g[a] += [(b, c)]
        g[b] += [(a, c)]
    Q, K = list(map(int, input().split(' ')))
    dist = [None]*(N+1)
    dist[K] = 0
    search_dist(g, dist, K)
    cood = []
    for _ in range(Q):
        cood.append(list(map(int, input().split(' '))))

    for x, y in cood:
        print(dist[x]+dist[y])

if __name__ == '__main__':
    main()
N=int(input())
A=list(map(int,input().split()))
B=[0]*10
count=0
for i in range(N):
    B[A[i]//400]+=1

for i in range(8):
    if B[i]>=1:
        count+=1

print(count, end=" ")
print(min(count+int(B[8]),8))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
color = [0 for _ in range(8)]
e = 0

for a in A:
    k = a // 400
    if k < 8 and color[k] == 0:
        color[k] += 1
    elif k >= 8:
        e += 1

c = color.count(1)
y = e + c

if c == 0:
    x = 1
else:
    x = c

print(x, y)
num =input()


for i in range(num):
    x = map(float, raw_input().split(' '))

    if x[1]-x[3] == 0 or x[5]-x[7] == 0:
        if x[1]-x[3] == 0 and x[5]-x[7] == 0:
            print 'YES'
        elif:
            print 'NO'
        
    elif (x[0]-x[2])/(x[1]-x[3]) == (x[4]-x[6])/(x[5]-x[7]):
        print 'YES'
    else:
        print 'NO'

### FIXED CODE ###

num =input()


for i in range(num):
    x = map(float, raw_input().split(' '))

    if x[1]-x[3] == 0 or x[5]-x[7] == 0:
        if x[1]-x[3] == 0 and x[5]-x[7] == 0:
            print 'YES'
        else:
            print 'NO'
        
    elif (x[0]-x[2])/(x[1]-x[3]) == (x[4]-x[6])/(x[5]-x[7]):
        print 'YES'
    else:
        print 'NO'
name = input()
print(name(:2))

### FIXED CODE ###

name = input()
print(name[:3])
import math

n = int(input())
A = list(map(int, input().split()))
M = []
for i in range(n):
    target_index = i
    if target_index == 0:
        target = A[1]
    else:
        target = A[0]
    for index, number in enumerate(A):
        if index == target_index:
            continue
        target = math.gcd(target, number)
    M.append(target)
print(max(M))

### FIXED CODE ###

from fractions import gcd

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

L = [0]
for i in range(n):
    L.append(gcd(L[i], A[i]))

R = [0]
for i in range(n-1, -1, -1):
    R.append(gcd(R[(n-1)-i],A[i]))
R.reverse()

M = []

for i in range(n):
    M.append(gcd(L[i],R[i+1]))
    
print(max(M))
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**5]*n
dp[0]=0
for i in range(1,n):
    dp[i]=min(dp[i-j]+abs(h[i-j]-h[i]) for j in range(1,k))
    print(dp[n-1])


### FIXED CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**5]*n
dp[0]=0
for i in range(1,n):
    dp[i]=min(dp[j]+abs(h[j]-h[i]) for j in range(max(0,i-k),i))
print(dp[n-1])
a,b=input().split()
if a<8:
  if b<8:
  print("Yay!")
else:
  print(":(")

### FIXED CODE ###

a,b=input().split()
a=int(a)
b=int(b)
if a<=8:
  if b<=8:
    print("Yay!")
  else:
    print(":(")
else:
  print(":(")
N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()

c = A.pop(0)
l = A.pop()
r = A.pop()
ans = (l-c) + (r-c)

cond = 0
while A:
	if cond % 4 == 0:
		tmp = A.pop(0)
		ans += l - tmp
		l = tmp
		cond += 1 
	elif cond % 4 == 1:
		tmp = A.pop(0)
		ans += r - tmp
		r = tmp
		cond += 1
	elif cond % 4 == 2:
		tmp = A.pop()
		ans += tmp - l
		l = tmp
		cond += 1
	else:
		tmp = A.pop()
		ans += tmp - r
		r = tmp
		cond += 1

print(ans)

### FIXED CODE ###

N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()

l = A.pop()
r = A.pop(0)
ans = abs(l-r)
while A:
	tmp = [abs(l-A[0]),abs(l-A[-1]),abs(r-A[0]),abs(r-A[-1])]
	cond = tmp.index(max(tmp))

	if cond == 0:
		ans += tmp[0]
		l = A.pop(0)
	elif cond == 1:
		ans += tmp[1]
		l = A.pop()
	elif cond == 2:
		ans += tmp[2]
		r = A.pop(0)
	else:
		ans += tmp[3]
		r = A.pop()

print(ans)
a,b=[int(i) for i in input().split()]
import math
print(math.gcd(a, b))

### FIXED CODE ###

A, B=[int(i) for i in input().split()]

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(a, b):
	return a * b // gcd (a, b)
  
print(lcm(A,B))
N, A, B, C = map(int,input().split())
ans = [[0, 0, 0, 0]]
for i in range(N): ans = [[p[j] + int(input()) * (i == j) for j in [0, 1, 2]] + [p[3]+(i < 3)] for p in ans for i in range(4)]
print(min(abs(p[0] - A) + abs(p[1] - B) + abs(p[2] - C) + p[3] * 10 - 30 for p in ans if min(p[:3]) > 0))

### FIXED CODE ###

#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18

N, A, B, C = map(int, raw_input().split())
l = [int(input()) for i in range(N)]

ans = 10 ** 12

for i in range(4 ** N):
  S = [0, 0, 0, 0]
  hoge = i
  cost = -30
  for j in range(N):
    S[hoge % 4] += l[j]
    if hoge % 4 < 3:
      cost += 10
    hoge /= 4
  if S[0] * S[1] * S[2] == 0:
    continue
  ans = min(ans, cost + abs(S[0] - A) + abs(S[1] - B) + abs(S[2] - C))

print ans
N = int(input())
A = []
for i in range(2):
    A.append([int(i)for i in input().split()])
ans = 0
for i in range(N):
    ans += A[0][i]
ans += A[1][N-1]
max = ans
for i in range (N-1):
    ans = ans + A[1][i-2] - A[0][i-1]
    if ans > max:
        max = ans

print(max)

### FIXED CODE ###

x = int(input())
y = int(input())
z = int(input())

res = (x-y) % z

print(res)
def main():
    n, m = map(int, input().split())
    a = [input() for i in range(n)]
    b = [input() for i in range(m)]

    for row in range(n - m):
        current_index = 0
        for index in range(m - 1):
            current_index = a[row].find(b[row], index)
            if current_index < 0:
                break

            for i in range(row, n - m):
                if a[i].find(b[i]) != current_index:
                    break
            else:
                print('Yes')
                return

    print('No')


if __name__ == "__main__":

    main()


### FIXED CODE ###

def main():
    n, m = map(int, input().split())
    a = [input() for i in range(n)]
    b = [input() for i in range(m)]

    for row in range(n - m + 1):
        current_index = 0
        for index in range(n - m + 1):
            current_index = a[row].find(b[0], index)
            if current_index < 0:
                break

            for i in range(m):
                if a[row + i].find(b[i], current_index) != current_index:
                    break
            else:
                print('Yes')
                return

    print('No')


if __name__ == "__main__":

    main()
n,m = map(int,input().split())
sc = [list(map(int,input().split())) for _ in range(m)]
ans = 0
num = [0]*n 
if sc[0][1] == 0:
    ans = -1
else:
    for i in range(n):
        if num[sc[i][0]-1] == 0 or num[sc[i][0]-1] == sc[i][1]:
            num[sc[i][0]-1] = sc[i][1]
        else:
            ans = -1
            break
if ans == 0:
    s = int("".join(map(str,num)))
    print(s)
else:
    print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
req = [list(map(int, input().split())) for i in range(m)]
for i in range(10000):
	st = str(i)
	if len(st) != n:
		continue
	ok = True
	for s, c in req:
		if int(st[s-1]) != int(c):
			ok = False
	if ok:
		print(st)
		exit(0)

print(-1)
N,M=map(int,input().split())
mod=10**9+7

#x以下の素数の列挙   
import math
x=math.floor(math.sqrt(10**9))
L=math.floor(math.sqrt(x))#平方根を求める
Primelist=[i for i in range(x+1)]
Primelist[1]=0#素数でないものは0にする.
for i in Primelist:
    if i>L:
        break
    if i==0:
        continue
    for j in range(2*i,x+1,i):
        Primelist[j]=0
Primes=[Primelist[j] for j in range(x+1) if Primelist[j]!=0]

#素因数分解
DICT=dict()
i=0
while M!=1:
    if M%Primes[i]==0:
        DICT[i]=DICT.get(i,0)+1
        M=M//Primes[i]
    else:
        i+=1

def Combi2(a,b):#aは大きいが、bは小さいとき
    ANS=1
    for i in range(min(b,a-b)):
        ANS=ANS*(a-i)%mod*pow(b-i,mod-2,mod)%mod

    return ANS%mod


ANS=1
for i in DICT.values():
    ANS=ANS*Combi2(N-1+i,i)%mod

print(ANS)


### FIXED CODE ###

N,M=map(int,input().split())
mod=10**9+7

#x以下の素数の列挙   
import math
x=math.floor(math.sqrt(10**9))
L=math.floor(math.sqrt(x))#平方根を求める
Primelist=[i for i in range(x+1)]
Primelist[1]=0#素数でないものは0にする.
for i in Primelist:
    if i>L:
        break
    if i==0:
        continue
    for j in range(2*i,x+1,i):
        Primelist[j]=0
Primes=[Primelist[j] for j in range(x+1) if Primelist[j]!=0]

#素因数分解
DICT=dict()
i=0
while M!=1:
    if M%Primes[i]==0:
        DICT[i]=DICT.get(i,0)+1
        M=M//Primes[i]
    elif i<len(Primes)-1:
        i+=1
    else:
        DICT[M]=1
        M=1

def Combi2(a,b):#aは大きいが、bは小さいとき
    ANS=1
    for i in range(min(b,a-b)):
        ANS=ANS*(a-i)%mod*pow(b-i,mod-2,mod)%mod

    return ANS%mod


ANS=1
for i in DICT.values():
    ANS=ANS*Combi2(N-1+i,i)%mod

print(ANS)
import math
A,P=map(int, input().split())
print(math.floor((3*a+P)/2))

### FIXED CODE ###

import math
A,P=map(int, input().split())
print(math.floor((3*A+P)/2))
N = int(input_[0])
S=[]

for n in range(N):
    s=input_[n+1]
    S.append(s)
S_set=set(S)

ans='Yes'
if len(S_set) != N:
    ans='No'

for n in range(N-1):
    n_ = n+1
    s_0=S[n][-1]
    s_1=S[n_][0]
    
    if s_0 != s_1:
        ans='No'
print(ans)

### FIXED CODE ###

N = int(input())
S=[]

for n in range(N):
    s=input()
    S.append(s)
S_set=set(S)

ans='Yes'
if len(S_set) != N:
    ans='No'

for n in range(N-1):
    n_ = n+1
    s_0=S[n][-1]
    s_1=S[n_][0]
    
    if s_0 != s_1:
        ans='No'
print(ans)
N, A, B, C, D = [int(i) for i in input().split()]
road = [i for i in list(input())]

for i in range(D-A):
  if (road[A+i-1] == '#') & (road[A+i] == '#'):
    judge = 0
    break
  else:
    judge = 1
if judge == 1:
  if C < D:
    judge = 1
  else:
    for i in range(D-B+1):
      print(B+i)
      if (road[B+i-1] == '.') & (road[B+i] == '.') & (road[B+i+1] == '.'):
        judge = 1
        break
      else:
        judge = 0

if judge == 0:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

N, A, B, C, D = [int(i) for i in input().split()]
road = [i for i in list(input())]

for i in range(D-A):
  if (road[A+i-1] == '#') & (road[A+i] == '#'):
    judge = 0
    break
  else:
    judge = 1
if judge == 1:
  if C < D:
    judge = 1
  else:
    for i in range(D-B+1):
      if (road[B+i-2] == '.') & (road[B+i-1] == '.') & (road[B+i] == '.'):
        judge = 1
        break
      else:
        judge = 0

if judge == 0:
  print("No")
else:
  print("Yes")
def main():
  s = input()
  if s == 'ABC':
    print('ARC')
  else:
    print('ABC')


  print(ans)

if __name__ == '__main__':
  main()


### FIXED CODE ###

def main():
  s = input()
  if s == 'ABC':
    print('ARC')
  else:
    print('ABC')


if __name__ == '__main__':
  main()
n, C = map(int, input().split())
cq = [[] for _ in range(C)]

for _ in range(n):
    s, t, c = tuple(map(int, input().split()))
    if cq[c-1]:
        fs, ft = cq[c-1][-1]
        if ft != s:
            cq[c-1].append([s, t])
        else:
            cq[c-1][-1] = [fs, t]
    else:
        cq[c-1].append([s, t])

R = [0] * (2*10**5+1)
for qq in cq:
    for s, t in qq:
        R[2*s-1] += 1
        R[2*t+1] -= 1

from itertools import accumulate
CR = list(accumulate(R))

print(max(CR))

### FIXED CODE ###

n, C = map(int, input().split())
cq = [[] for _ in range(C)]
stc = [tuple(map(int, input().split())) for _ in range(n)]
stc = sorted(stc, key=lambda x: x[0])

for s, t, c in stc:
    c -= 1
    if cq[c]:
        fs, ft = cq[c][-1]
        if ft != s:
            cq[c].append([s, t])
        else:
            cq[c][-1] = [fs, t]
    else:
        cq[c].append([s, t])

R = [0] * (2*10**5+2)
for qq in cq:
    for s, t in qq:
        R[2*s-1] += 1
        R[2*t+1] -= 1

from itertools import accumulate
CR = list(accumulate(R))
print(max(CR))
While True:
  s = raw_input().split()
  a = int(s[0])
  op = s[1]
  b = int(s[2])
  if op == '+':
    print a+b
  elif op == '-':
    print a-b
  elif op == '*':
    print a*b
  elif op == '/':
    print a/b
  elif op == '?':
    break

### FIXED CODE ###

while True:
  s = raw_input().split()
  a = int(s[0])
  op = s[1]
  b = int(s[2])
  if op == '?':
    break
  elif op == '+':
    print (a+b)
  elif op == '-':
    print (a-b)
  elif op == '*':
    print (a*b)
  elif op == '/':
    print (a/b)
import numpy as np
room, route_count = map(int,input().split())
route = np.array([list(map(int,input().split())) for _ in range(route_count)])
 
object_nums = [1]
ans = np.array([0]*(room-1))
 
def mem_ans(ans, object_num, next_nums):
    mask_array = np.zeros(room-1, dtype=bool)
    mask_array[next_nums-2] = True
    ans[(ans==0) & mask_array] = object_num
    return ans
 
for object_num in object_nums:
    object_num_mask = np.any(route==object_num, axis=1)
    object_rows = route[object_num_mask]
    route = route[~object_num_mask]
    next_nums = object_rows[object_rows!=object_num]
    if next_nums is not None:
        ans = mem_ans(ans, object_num, next_nums)
        object_nums.extend(next_nums)
    else:
        break
 
if 0 in set(ans):
  print('No')
else:
  print('Yes')
  for i in ans:
    print(i)

### FIXED CODE ###

import networkx as nx
room, route_count = map(int,input().split())
route = [list(map(int,input().split())) for _ in range(route_count)]

G = nx.Graph()
G.add_nodes_from(range(1,room+1))
G.add_edges_from(route)
pre = nx.predecessor(G, 1)

print('Yes')
for i in range(2,room+1):
  print(pre[i][0])
dens = 0
ans_water = 0
ans_sugar = 0
for i in range(31):
    for j in range((F-(100*A*i))//(100*B)+1):
        for k in range((F-(100*A*i)-(100*B*j))//C+1):
            for l in range((F-(100*A*i)-(100*B*j)-(100*C*k))//D+1):
                water = 100*A*i+100*B*j
                sugar = C*k+D*l
                if i==j==0:
                    break
                if water+sugar <= F and sugar <= E*(A*i+B*j):
                    if dens<sugar/(sugar+water):
                        dens = sugar/(sugar+water)
                        ans_water = water
                        ans_sugar = sugar
print(ans_water+ans_sugar, ans_sugar)

### FIXED CODE ###

A, B, C, D, E, F = map(int, input().split())
dens = 0
ans_water = 100*min(A, B)
ans_sugar = 0
for i in range(31):
    for j in range((F-(100*A*i))//(100*B)+1):
        for k in range((F-(100*A*i)-(100*B*j))//C+1):
            for l in range((F-(100*A*i)-(100*B*j)-(C*k))//D+1):
                water = 100*A*i+100*B*j
                sugar = C*k+D*l
                if water == 0:
                    break
                if sugar <= E*(A*i+B*j):
                    if dens<sugar/(sugar+water):
                        dens = sugar/(sugar+water)
                        ans_water = water
                        ans_sugar = sugar
print(ans_water+ans_sugar, ans_sugar)
import numpy as np
N = int(input())
x = np.array(sorted(list(map(int, input().split()))))

s = []
for p in range(x[0],x[-1]):
    s.append(np.sum((x-p)*(x-p)))
    
print(min(s))

### FIXED CODE ###

import numpy as np
N = int(input())
x = np.array(sorted(list(map(int, input().split()))),dtype = 'int64')

s = []
for p in range(x[0],x[-1]+1):
    s.append(np.sum((x-p)*(x-p)))
    
print(min(s))
S = input()
if S[3] == S[4] and S[5] == S[6]:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

S = input()
if S[2] == S[3] and S[4] == S[5]:
  print('Yes')
else:
  print('No')
import numpy
a = np.array([i for i in range(1, int(input())+1)])
print(a[np.where((a % 3 != 0) & (a % 5 !=0))].sum())

### FIXED CODE ###

import numpy as np
a = np.array([i for i in range(1, int(input())+1)])
print(a[np.where((a % 3 != 0) & (a % 5 !=0))].sum())
X, A = map(int, input().split())
if x < A:
    print(0)
else:
    print(10)

### FIXED CODE ###

x,A = map(int,input().split())
if x < A:
    print(0)
else:
    print(10)
def my_index(l, x, default=0):
    if x in l:
        return l.index(x)
    else:
        return default


T=list("keyence")
x=0
j=0
S=input()
if my_index(S,"k")==0:
  for i in range(len(S)):
    if S[i]==T[j]:
      x=x+1
      j=j+1
    else:
      continue
  if x==7:
    print("YES")
  else:
    print("NO")
else:
  for i in range(int(my_index(S,"k")),int(my_index(S,"k"))+7):
    if S[i]==T[i]:
      x=x+1
    if x==7:
      print("YES")
    else:
      print("NO")

### FIXED CODE ###

A=["k","e","y","e","n","c","e"]
f=-1;p=0;q=0;r=0
S=list(map(str,input()))
if S[0:7]==A or S[len(S)-7:len(S)]==A:
  f=1
else:
  if S[0]!=A[0]:
    f=0
  else:    
    for i in range(len(S)):
      if S[i]==A[i]:
        p=p+1
      else:
        if A[0:p]+S[len(S)-(len(A)-p):len(S)]==A:
          #print(A[0:p]+S[len(S)-(len(A)-p):len(S)])
          f=1
          break
        else:
          f=0
          break
print("YES" if f==1 else "NO")
s=input()
l=s.find("S")
r=s.rfind("T")
if l==-1 or r==-1:
    print(len(s))
else:
    rest=l+len(s)-r-1
    s=s[l:r+1]
    from collections import Counter
    s=list(Counter(s).values())
    print(rest+abs(s[0]-s[1]))

### FIXED CODE ###

s=input()
ss=0
tt=0
for i in range(len(s)):
    if s[i]=="S":
        ss+=1
    if s[i]=="T" and tt<ss:
        tt+=1
print(len(s)-2*tt)