peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
q, h, s, d = map(int, input().split())
n = int(input())
m = min(4 * q, 2 * h, s)
if d / 2 < m:
    print((n // 2) * d + m)
else:
    print(n * m)
# Judge status: Accepted
N = int(input())
X = list(map(int, input().split()))

mid1, mid2 = sorted(X)[N//2-1:N//2+1]
smid1 = str(mid1)
smid2 = str(mid2)
print('\n'.join(smid1 if xi>mid1 else smid2 for xi in X))
# Judge status: Accepted
#A
L, R, d = list(map(int, input().split()))

count = 0
for i in range(L, R+1):
    if i % d == 0:
        count += 1

print(count)
# Judge status: Accepted
N=int(input())
a=list(map(int,input().split()))
arr=[]
for A in a:
    if A%2==0:
        arr.append(A)
    else:
        pass

for n in arr:
    if n%3==0 or n%5==0:
        pass
    else:
        print('DENIED')
        exit()
print('APPROVED')
# Judge status: Accepted
n=int(input())
l=sorted(list(map(int,input().split())),reverse=0)
print(sum(l[n::2]))
# Judge status: Wrong Answer
k = int(input())
a, b = list(map(int, input().split()))
x = 0
f = False
while x < b:
    if a <= x <= b:
        f = True
        break
    else:
        x += k

print('OK') if f else print('NG')
# Judge status: Wrong Answer
l,r,d = map(int, input().split())
count = 0

for x in range(1, 100):
    if x >= l and x <= r and x % d == 0:
        count += 1
print(count)
# Judge status: Accepted
from collections import Counter

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

c = Counter(A)
hen = [key for key, val in c.items() if val > 1]

l = max(hen) if hen else 0
if l != 0:
    if c[l] > 3:
        s = l
    else:
        hen.remove(l)
        s = max(hen) if hen else 0
else:
    s = 0

print(l * s)
# Judge status: Wrong Answer
from copy import deepcopy


def main():
    n = int(input())
    x = list(map(int, input().split()))
    y = deepcopy(x)
    y.sort()
    median = y[n // 2]
    next_median = y[n // 2 - 1]
    for xx in x:
        if xx <= median:
            print(next_median)
        else:
            print(median)


if __name__ == '__main__':
    main()
# Judge status: Accepted
from math import factorial
from collections import Counter
p=10**9+7

N=int(input())
S=input()
T=list(S)
d=dict(Counter(T))

var=1
for num in d:
  var = var*(d[num]+1) %p

print(var-1)
# Judge status: Accepted
N,M = map(int,input().split())
like_count = [0 for m in range(M)]
for n in range(N):
  temp = [int(i) for i in input().split()]
  for i,t in enumerate(temp):
    if i == 0:
      pass
    else:
      like_count[t-1] += 1
ans = 0
for like in like_count:
  if like == N:
    ans += 1
print(ans)
# Judge status: Wrong Answer
import math
N = int(input())

# 素数がどうか判定
flag = 0
for i in range(2, int(math.sqrt(N)), 1):
  if N % i == 0:
    flag = 1
    break
if flag == 0:
  print(N-1)
else:
  res = 0
  idx = int(math.sqrt(N))
  for i in range(idx, 0, -1):
    if N % i == 0:
      res = i + int(N/i) - 2
      print(res)
      break
# Judge status: Accepted


import math


def submit():
    n = int(input())

    min_manhattan = float('inf')
    for x in range(1, math.ceil(math.sqrt(n)) + 1):
        q, mod = divmod(n, x)
        if mod:
            continue

        if x + q < min_manhattan:
            min_manhattan = x + q

    print(min_manhattan - 2)


if __name__ == "__main__":
    submit()
# Judge status: Wrong Answer
a,b=map(int,input().split())
ab=a+b
if ab>24:
    print(ab-24)
else:
    print(ab)
# Judge status: Accepted
k,a,b = map(int,input().split())
if a+2>=b:
  print(1+k)
else:
  #bisできるセット
  q = (k-a+1)//2
  if q ==0:
    print(1+k)
  else:
    print(1+(k-2*q)+q*(b-a))
# Judge status: Accepted
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]
cd = [list(map(int, input().split())) for i in range(m)]

for i in ab:
    ans = []
    for j in cd:
        kyori = abs(i[0]-j[0]) + abs(i[1]-j[1])
        ans.append(kyori)
    print(ans.index(min(ans))+1)
# Judge status: Accepted
a,b,t=map(int,input().split())
print(b*(t//a))
# Judge status: Accepted
o = list(input())
e = list(input())
ans = ''
for i in range(len(e)):
    ans+=o.pop(0)
    ans+=e.pop(0)
if o:
    ans+=o.pop(0)
print(ans)
# Judge status: Accepted
X, A, B = map(int, input().split())

if B <= A:
    print('delicious')
elif B <= A + X:
    print('safe')
else:
    print('dangerous')
# Judge status: Accepted
x=int(input())
if x>=30:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
import sys
sys.setrecursionlimit(10**6)

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

for i in a2e:
    for j in a2e:
        if abs(i-j) > k:
            print(':(')
            break
    else:
        continue
    break
else:
    print('Yay!')
# Judge status: Wrong Answer
N,P = map(int,input().split())
A = list(map(int,input().split()))

odd = 0
for v in A:
    if  v % 2:
        odd += 1 
even = N-odd

ans = (2**even)*(2**(odd-1))

print(ans)
# Judge status: Wrong Answer
def main():
    D, T, S = map(int, input().split())
    B = D / S
    if B > T:
        print("NO")
    else:
        print("Yes")
if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())
ans = 10 ** 9
for i in range(1,N // 2 + 1):
  A = list(map(int,list(str(i))))
  B = list(map(int,list(str(N - i))))
  ans = min(ans, sum(A) + sum(B))
print(ans)
# Judge status: Wrong Answer
N = int(input())
P = list(map(int, input().split()))
mx = P[0]
ans = 0
for p in P:
    if mx >= p:
        ans += 1
    else:
        mx = p
print(ans)
# Judge status: Accepted
x=int(input())

coin_1=0
coin_5=0
coin_500=0

def registar(nyukin,coin):
    oturi=nyukin-coin*int(nyukin/coin)
    return oturi,int(nyukin/coin)

x,coin_500=registar(x,500)
#print(coin_500)
x,coin_5=registar(x,5)
x,coin_1=registar(x,1)

#print(coin_500,coin_5,coin_1)
uresisa=coin_500*1000+coin_5*5
print(uresisa)
# Judge status: Accepted
A = input().split()
print(A[0][0] + A[1][0] + A[2][0])
# Judge status: Accepted
N, M = map(int, input().split())
A = list(set(map(int, input().split())))

def gcd(m, n):
    if n == 0:
        return m
    return gcd(n, m % n)

LCM = A[0]
for a in A:
    LCM = LCM * a // gcd(LCM, a)

K = max(A)
for X in range(K // 2, M + 1, K):
    for a in A:
        if (X - a // 2) % a != 0:
            break
    else:
        print((M - X) // LCM + 1)
        exit()
print(0)
# Judge status: Accepted
import os, sys, re, math

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

sa = sorted(A, reverse=True)

for a in A:
    print(sa[1] if a == sa[0] else sa[0])
# Judge status: Accepted
N=int(input())
P=list(map(int,input().split()))

ans=0
m=float("inf")
for i in range(N):
  if P[i]<m:
    ans+=1
    m=P[i]
    
print(ans)
# Judge status: Accepted
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pri = lambda x: print(*x, sep='\n')

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

L.sort()
val = L[0] + L[1] + L[2]*pow(2, K)
print(val)
# Judge status: Wrong Answer
n = int(input())

al = [int(input()) for _ in range(n)]

ans = 0
for i in range(n-1):
    rest = ((al[i] + al[i+1]) // 2) * 2
    ans += rest
    for j in range(2):
        if al[i+j] >= rest:
            al[i+j] -= rest
            break
        else:
            rest -= al[i+j]
            al[i+j] = 0


print(ans//2)
# Judge status: Accepted
n, k = map(int, input().split())
aaa = list(map(int, input().split()))
cnt = 1
b = n - k
while b > 0:
    b -= k - 1
    cnt += 1
print(cnt)
# Judge status: Accepted
#!/usr/bin/env python3

N = int(input())
d = {}
for i in range(N):
    a = int(input())
    if a in d and d[a]:
        d[a] = 0
    else:
        d[a] = 1
cnt = 0
for a in d:
    if d[a]:
        cnt += 1
print(cnt)
# Judge status: Wrong Answer
S = input()
a = S.count('N')
b = S.count('S')
c = S.count('E') 
d = S.count('W')

if a*b > 0 and c==0 and d==0:
  print('Yes')
elif c*d >0 and a==0 and b==0:
  print('Yes')
elif a==0 and b==0 and c==0 and d==0:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
print('Yes') if '7' in input() else print('No')
# Judge status: Wrong Answer
import math
N_ = N = int(input())
div = {}
for i in range(2, int(math.sqrt(N))+1):
    while N % i == 0:
        N //= i
        if i in div:
            div[i] += 1
        else:
            div[i] = 1
    if N == 1:
        break
if len(div) == 0:
    div[N_] = 1
ans = 0
for v in div.values():
    i = 1
    while v >= i:
        v -= i
        i += 1
        ans += 1
print(ans)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))

num = len(a)
four = 0
two = 0
one = 0
for i in range(num):
  if a[i]%4 == 0:
    four += 1
  elif a[i]%2 == 0 and a[i]%4 != 0:
    two += 1
  elif a[i]%2 != 0:
    one += 1

if four + 1 >= two//2 + two%2 + one:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
r, g, b = map(int, input().split())
if (r * 100 + g * 10 + b) % 4 == 0:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n,m=map(int,input().split())
if n==1 and m==1:
    print(1)
elif n==1 or m==1:
    p=max(n,m)
    print(p-2)
else:
    print((n-2)*(m-2))
# Judge status: Accepted
def main():
    x = int(input())
    res_1 = x // 500
    y = x % 500
    res_2 = y // 5
    res = res_1 * 1000 + res_2 * 5
    print(res)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
import math
X, K, D = map(int,input().split())
X = math.fabs(X)
ans = 0
E = X//D
if E > K:
    ans = X - K * D
elif K%2 == E%2:
    ans = X-E*D
else:
    ans = -X+(E+1)*D
print(ans)
# Judge status: Wrong Answer
def main():
    n = int(input())
    score = [[], []]
    minus = float("inf")
    for _ in range(n):
        s = int(input())
        if s % 10 == 0:
            score[0].append(s)
        else:
            score[1].append(s)
            minus = min(minus, s)
    answer = sum(score[0])
    if answer % 10 == 0:
        answer -= minus
    answer += sum(score[1])
    print(max(answer, 0))


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
s = [0] * n
for i in range(n):
    s[a[i]-1] += i+1 
print(s)
# Judge status: Accepted
N = int(input())
S = input()

R = S.count('R')
G = S.count('G')
B = S.count('B')

ans = R * G * B

for i in range(N-1):
  for d in range(1, N):
    j = i + d
    k = j + d
    if j >= N or k >= N:
      break
    if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
        ans -= 1
        
print(ans)
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N = input()
    rep = int('1' * len(N))
    ans = rep
    while ans < int(N):
        ans += rep
    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())
W = list(map(int, input().split())) 

S1 = 0
S2 = 0
ans = 10**18

for i in range(N):
    S1 = W[:i+1]
    S2 = W[i+1:]
    ans = min(ans, abs(sum(S1)-sum(S2)))
print(ans)
# Judge status: Accepted
n=int(input())
s=input()
r=s.count('R')
g=s.count('G')
b=s.count('B')
ans=r*g*b

for i in range(n-2):
    for j in range(i+1 , n-1):
        k=2*j-i
        if k <= n-1:
            if s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]:
                ans-=1
print(ans)
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


N, M = readnums()

'''
N:M = 1:2が理想
N + x: M -2x = 1:2
2N+2x = M-2x
M-2N=4x
'''

x = (M - 2 * N) // 4
print(N + x)
# Judge status: Wrong Answer
import io
import os

from collections import Counter, defaultdict, deque


def solve(A, B, C, K):
    k = 0
    while A >= B:
        B *= 2
        k += 1
    while B >= C:
        C *= 2
        k += 1
    if k <= K:
        return "YES"
    return "NO"


if __name__ == "__main__":
    input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
    A, B, C = [int(x) for x in input().split()]
    K, = [int(x) for x in input().split()]  

    ans = solve(A, B, C, K)
    
    print(ans)
# Judge status: Accepted
x,a,b = map(int, input().split())

if b-a <=0:
    print("delicious")
    
elif 0 < b-a <= x:
    print("safe")
elif x < b-a:
    print("dangerous")
# Judge status: Wrong Answer
s = input()

def dfs( i, sums, s1 ):
    if i == 3:
        if sums == 7:
             print(s1 + "=7")
    else:
        dfs( i + 1, sums + int( s[i+1] ), "{}+{}".format( s1, s[ i  + 1 ] ))
        dfs( i + 1, sums  - int( s[i+1] ), "{} -{}".format( s1, s[ i  + 1 ] ))

dfs(0, int( s[0]), s[0])
# Judge status: Wrong Answer
a,b,x = map(int,input().split())

if a == 0:
  print((b//x)-(a//x)+1)
else:
  print((b//x)-(a//x))
# Judge status: Accepted
N, M = map(int, input().split())
A = list(map(int, input().split()))

for i in A:
    N -= i

if N >= 0:
    print(N)
else:
    print(-1)
# Judge status: Wrong Answer
a,m=map(int,input().split())
if a==m:
  print(a*m)
else:
  print(a*m-1)
# Judge status: Accepted
n,m = map(int,input().split())
if n == 2 or m == 2:
  print(0)
elif n == 1:
  if m == 1:
    print(1)
  else:
    print(m-2)
elif m == 1:
  if n == 1:
    print(1)
  else:
    print(n-2)
else:
  print((n-2)*(m-2))
# Judge status: Accepted
def abc155_b():
    N = int(input())
    A = list(map(int, input().split()))
    result = 'APPROVED'

    evens = [i for i in A if i % 2 == 0]
    for i in evens:
        if (i % 3 != 0) and (i % 5 != 0):
            result = 'DENIED'

    print(result)


##########
if __name__ == "__main__":
    abc155_b()
# Judge status: Accepted
N,A,B,C,D = map(int,input().split())
S = input()

flg = 0
cnt = 0
S_ac = S[A:C]
S_bd = S[B:D]

if '##' in S_ac or '##' in S_bd:
    flg = 1

if D < C and flg == 0:
    S = S[B-2:D+1]
    if '...' not in S:
        flg = 1

if flg == 1:
    print('No')
else:
    print('Yes')
# Judge status: Accepted
import fractions
a,b = map(int,input().split())

def prime_factorize(n):
	L = []
	while n % 2 == 0:
		L.append(2)
		n //= 2
	f = 3
	while f * f <= n:
		if n % f == 0:
			L.append(f)
			n //= f
		else:
			f += 2
	if n != 1:
		L.append(n)
	return L

print(len(set(prime_factorize(fractions.gcd(a,b))))+1)
# Judge status: Accepted
x = int(input())
if x % 1000 == 0:
  print(x%1000)
else:
  print((x//1000+1)*1000-x)
# Judge status: Accepted
c = [list(map(int,input().split())) for _ in range(3)]
a = [0]*3
b = c[0]
a[1] = c[1][0]-b[0]
a[2] = c[2][0]-b[0]
flag = False
ans = "Yes"
for i in range(3):
    if flag:
        break
    for j in range(3):
        if c[i][j] != a[i]+b[j]:
            ans = "No"
            flag = True
            break
print(ans)
# Judge status: Accepted
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    a, b, c = map(int, input().split())

    for i in range(a, a * b + 1, a):
        if i % b == c:
            print("YES")
            break
    else:
        print("NO")


if __name__ == '__main__':
    resolve()
# Judge status: Wrong Answer
S = input()
if S.count('N') == S.count('S') and S.count('W') == S.count('E'):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
s = int(input())
if s == 10**18:
    print(0, 0, 10**9, 0, 1, 10**9)
    exit()
q, r = divmod(s, 10**9)
print(0, 0, 10**9, 10**9-r, 1, q+1)
# Judge status: Accepted
n, m = map(int, input().split())
p, y = zip(*[map(int, input().split()) for _ in range(m)])

city_data = {}
for i in range(m):
    city_data[i] = [p[i], y[i], None]

cities = list(city_data.keys())
cities.sort(key=lambda city: city_data[city])

pref = None
for city in cities:
    if city_data[city][0] == pref:
        yidx += 1
    else:
        yidx = 1
        pref = city_data[city][0]
    city_data[city][2] = '{:06d}{:06d}'.format(pref, yidx)

for i in range(m):
    print(city_data[i][2])
# Judge status: Accepted
N = int(input())
data = list(map(int, input().split()))

data = data[0::2]

cnt = 0

for i in data:
  if i % 2 == 1:
    cnt += 1
    
print(cnt)
# Judge status: Accepted
n = int(input())
a = []
from collections import Counter
for _ in range(n):
    a.append(int(input()))
    
a = a + [0]
    
ans = 0
for i in range(n):
    ans += a[i] // 2
    a[i] %= 2
    if a[i] == 1 and a[i+1] >= 1:
        ans += 1
        a[i] = 0
        a[i+1] -= 1
        
print(ans)
# Judge status: Wrong Answer
target = 10 ** 9 + 7

N = int(input())

# 全ての整数のリスト作成
int_list = list(input().split())
int_list = [int(n) for n in int_list]

int_sum = sum(int_list) % target

sum_result = 0
for num in int_list:
    sum_result += num * ((int_sum - num) % target)
    if sum_result >= 10**9+7:
        sum_result = sum_result % target
print(int(sum_result/2))
# Judge status: Accepted
d,t,s = map(int,input().split())
if d / s <= t:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
from collections import defaultdict

d = defaultdict(int)

n = int(input())

for i in range(1, n+1):
    start = str(i)[0]
    end = str(i)[-1]
    d[(start, end)] += 1

L = list(d.items())

ans = 0

for (start, end), i in L:
    ans += i * d[(end, start)]

print(ans)
# Judge status: Wrong Answer
import collections
a=input()
b=[]

for i in a:
  b.append(i)
  
b.sort()
c=collections.Counter(b)
c=list(c.values())

for i in range(len(c)):
  if int(c[i])%2==0:
    q=0
  else:
    q=1
    
if q==0:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
k=int(input())
if k%2==0:
  print(k//2*k//2)
else:
  print(k//2*(k//2+1))
# Judge status: Accepted
N = int(input())
cc = list(map(int,input().split()))
count = 0
for i in range(N):
  for j in range(i+1,N):
    for k in range(j+1,N):
      if cc[i] != cc[j] and cc[i] != cc[k] and cc[j] != cc[k]:
        if cc[i] + cc[j] > cc[k] and cc[j] + cc[k] > cc[i] and cc[i] + cc[k] > cc[j]:
          count += 1
print(count)
# Judge status: Wrong Answer
def resolve():
	n = int(input())
	ans = 1
	for i in range(1, n+1):
		ans *= i
		ans %= (10**9 + 7)
	print(ans)
resolve()
# Judge status: Accepted
from math import ceil

n=int(input())
lst=[]
ans=[]

for i in range(n-1):
    x,y,z=map(int,input().split())
    lst.append([x,y,z])


for i in range(n-1):
    pin=0
    for c,s,f in lst[i:]:
        xxx=max(ceil((pin-s)/f),0)
        pin=s+xxx*f+c
    
    ans.append(pin)


for i in ans:
    print(i)

print(0)
# Judge status: Accepted
n,k=map(int,input().split())
if n<k:
  k=n
h=list(map(int,input().split()))
h.append(0)
h.sort()
for i in range(k):
  h.pop(-1)
print(sum(h))
# Judge status: Wrong Answer
import numpy as np

n,k = map(int,input().split())
a = np.array(list(map(int,input().split())))

temp = np.prod(a[0:k])
for i in range(n-k):
    next_temp = (temp * a[i+k])/a[i]
    if temp < next_temp:
        print("Yes")
    else:
        print("No")
    
    temp = next_temp
# Judge status: Accepted
from collections import defaultdict
def main():
    n, x, y = map(int, input().split())
    ans = defaultdict(int)
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            l = min(abs(i - j), abs(i - x) + abs(y - j) + 1, abs(i - y) + abs(x - j) + 1)
            ans[l] += 1
    [print(ans[i]) for i in range(1, n)]

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
[d,t,s] = [int(i) for i in input().split()]
if d // s > t:
    print("No")
else:
    print("Yes")
# Judge status: Accepted
N = int(input())-1
az = "abcdefghijklmnopqrstuvwxyz"
ans = []
while N >= 0:
    ans.append(az[N % 26])
    N //= 26
    N -= 1
ans.reverse()
print("".join(ans))
# Judge status: Wrong Answer
a,b,c,x,y  = map(int,input().split())
if a+b > c*2:
    mmm = min(x,y)
    aaa = max(x,y)
    if x >= y:
        print(c*2*mmm + a*(aaa-mmm))
    elif x < y:
        print(c*2*mmm + b*(aaa-mmm))
else:
    print(a*x + b*y)
# Judge status: Wrong Answer
import math
A, B, C = map(int, input().split())
if (math.sqrt(A) + math.sqrt(B)) < math.sqrt(C):
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n = int(input())

print((10 ** n - (9 ** n + 9 ** n - 8 ** n)) % (10 ** 9 + 7))
# Judge status: Wrong Answer
W,H = map(int,input().split())
ans = 10**30
for i in range(1,W):
    a = H*i
    w = W - i
    b = max((w//2)*H,w*(H//2))
    c = w*H - b
    x = max(a,b,c) - min(a,b,c)
    ans = min(ans,x)
for i in range(1,H):
    a = W*i
    h = H - i
    b = max((W//2)*h,W*(h//2))
    c = h*W - b
    x = max(a,b,c) - min(a,b,c)
    ans = min(ans,x)
print(ans)
# Judge status: Wrong Answer
from collections import deque

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

graph = [[] for _ in range(n+1)]

for i in range(m):
 a, b = map(int, input().split())
 graph[a].append(b)
 graph[b].append(a)

dist = [-1] * (n+1)
dist[0] = 0
dist[1] = 0

d = deque()
d.append(1)

while d:
 v = d.popleft()
 for i in graph[v]:
   if dist[i] != -1:
     continue
   dist[i] = dist[v] + 1
   d.append(i)

ans = dist[2:]
print("Yes")
print(*ans, sep="\n")
# Judge status: Wrong Answer
H1, M1, H2, M2, K = list(map(int, input().split()))
print(H1, M1)
# Judge status: Wrong Answer
import sys
input =sys.stdin.readline

N=int(input().rstrip('\n'))
As=[int(x) for x in input().rstrip('\n').split()]
As_s=sorted(As)
print(sum(As_s[1:]))
# Judge status: Wrong Answer
N,M = map(int, input().split())

wa_counter = [ 0 for i in range(N)]
ac_flag = [ 0 for i in range(N)]

for i in range(M):
  P_num, outcome = map(str, input().split())
  if ac_flag[int(P_num)-1] == 0:
    if outcome == "AC":
      ac_flag[int(P_num)-1] = 1
    else:
      wa_counter[int(P_num)-1] += 1
  else:
    pass
    
print(sum(ac_flag), sum(wa_counter))
# Judge status: Accepted
n, q = map(int, input().split())
s = input()
l = [0 for i in range(q)]
r = [0 for i in range(q)]
for i in range(q):
  l[i], r[i] = map(int, input().split())
ac = [0, 0]
for i in range(len(s) - 1):
  x = 1 if s[i:i+2] == 'AC' else 0
  ac.append(ac[i + 1] + x)
for i in range(q):
  print(ac[r[i]] - ac[l[i]])
# Judge status: Wrong Answer
#134_E
n=int(input())
a=[int(input()) for _ in range(n)]

tmp=0
cnt=0
for i in range(n-1,-1,-1):
    if a[i]>=tmp:
        cnt+=1
        tmp=a[i]
print(cnt)
# Judge status: Wrong Answer
def main():
	n = list(str(input()))

	n_s = sorted(n)
	if n_s[0] == n_s[1] and n_s[2] == n_s[3]:
		print("Yes")
	else:
		print("No")

 
if __name__ == '__main__':
	main()
# Judge status: Accepted
t=input()
n=len(t)
ans=0
s=0
for i in range(n):
    if t[i]=="S":
        s+=1
    if s>0 and t[i]=="T":
        ans+=1
        s-=1
print(n-2*ans)
# Judge status: Accepted
def jumpCost(array):
    size = len(array)

    memo = [99999999999] * (size)

    memo[0] = 0

    for i in range(size):
        j = i+1

        while j < i + 2 + 1 and j < size:
            memo[j] = min(memo[j], memo[i] + abs(array[i] - array[j]))

            j += 1

    return memo[size - 1]


if __name__ == '__main__':
    n = int(input())

    a = list(map(int, input().rstrip().split()))
    print(jumpCost(a))
# Judge status: Accepted
A, B, C, K =map(int, input().split())

ans = 0
ans = min(A, K)
K -= ans
K -= min(B,K)
ans -= min(C, K)

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

if n == len(set(A)):
  print('YES')
else:
  print('NO')
# Judge status: Accepted
# -*- coding: utf-8 -*-

S = input().strip()

max_cnt=0
cnt=0
for i in range(len(S)):
    
    if S[i] in "ACGT":
        cnt += 1
    else:
        max_cnt = max(max_cnt,cnt)
        cnt = 0

max_cnt = max(max_cnt,cnt)
print(max_cnt)
# Judge status: Accepted
n,k = map(int,input().split())
a = list(map(int,input().split()))

for i in range(n-k):
    if a[i] < a[i+k]:
        print("Yes")  
    elif a[i] >= a[i+k]:
        print("No")
# Judge status: Accepted
import math
n = int(input())
p = list((map(int,input().split())))
ch = 0
ans = 0
for i in range(n):
    if p[i]==i+1:
        ch+=1
    if p[i]!=i+1:
        if ch ==1:
            ans+=1
        if ch >1:
            ans+=math.ceil(ch/2)
        ch = 0
if ch ==1:
    ans+=1
if ch >1:
    ans+=math.ceil(ch/2)
print(ans)
# Judge status: Wrong Answer
n = int(input())
if n % 2 == 1:
  print("0")
else:
    m = n/2
    count = 0
    i = 1
    while m >= 5 ** i:
      count += (m // (5 ** i))
      i += 1
    print(int(count))