peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
S = input()
Q = int(input())

left = ''
right = S
for q in range(Q):
    Query = list(map(str, input().split()))
    if Query[0] == '1':
        #反転
        tmp = left
        left = right
        right = tmp
    else:   #Query[0]==2
        if Query[1] == '1':
            #先頭追加
            left += Query[2]
        else:   #Query[1] ==2
            #末尾追加
            right += Query[2]

ans = left[::-1] + right
print(ans)
# Judge status: Wrong Answer
a=list(map(int,input().split()))
b=sum(a)

if b%3==0:
  print('Possible')
else:
  print('Impossible')
# Judge status: Accepted
N = int(input())
D = list(map(int, input().split()))
mod = 998244353
ans = 1
A = [0]*(max(D)+1)
for i in range(N):
  A[D[i]] += 1
if D[0] != 0 or not all(D[1:]) or not all(A):
  print(0)
  exit()
for i in range(1, max(D)+1):
  ans = ans * pow(A[i-1], A[i], mod) % mod
print(ans % mod)
# Judge status: Accepted
from fractions import gcd


def func(A, B):
    ans = (A * B) // gcd(A, B)
    return ans


if __name__ == "__main__":
    A, B = map(int, input().split())
    print(func(A, B))
# Judge status: Accepted
S=input()
K=int(input())

if len(S)==1:
    print(S)
    quit()

i=0
while i<len(S) and i<K:
    if S[i]!="1":
        print(S[i])
        quit()
    i+=1

print(1)
# Judge status: Accepted
import sys


def _s(): return sys.stdin.readline().strip()


def main():
    c = _s()
    return 'A' if 65 <= ord(c) <= 90 else 'a'


if __name__ == "__main__":
    print(main())
# Judge status: Accepted
n = int(input())
arr = list(map(int,input().split()))
if 0 in arr:
    print(0)
else:
    res = 1
    flag = 0
    for i in arr:
        res = res*i
        if res>10**18:
            flag = 1
            break
    if flag==1:
        print(-1)
    else:
        print(res)
# Judge status: Wrong Answer
#!/usr/bin/env python3
import sys
import numpy as np
input = sys.stdin.readline
n=int(input())
A =  list(map(int,input().split()))
B = []
ans = A[0]
for i in range(1,n):
    ans = ans ^ A[i]

for i in range(n):
    B.append(ans ^ A[i])
print(B)
# Judge status: Accepted
n = int(input())
A = list(map(int,input().split()))
A.sort()
if A[0]==0:
    print(0)
    exit()

ans = 1
for i in A:
    ans*=i
    if ans>1e18:
        print(-1)
        exit()

print(ans)
# Judge status: Accepted
a,b=map(int,input().split())
c=(a-1)//(b-1)
while (c+1)*(b-1)<=a-1:
  c+=1
if (a-1)%(b-1)!=0:
  c+=1
print(c)
# Judge status: Accepted
input()
t=s=input()
p,q=o="()"
while o in s:s=s.replace(o,"")
f=s.count
print(p*f(q)+t+q*f(p))
# Judge status: Wrong Answer
def solve(w, h, n, XYA):
    m = [0, w, 0, h]
    for x, y, a in XYA:
        m[a - 1] = x if a <= 2 else y
    return max(0, (m[1] - m[0]) * (m[3] - m[2]))

_w, _h, _n = list(map(int, input().split()))
_XYA = [map(int, input().split()) for _ in range(_n)]
print(solve(_w, _h, _n, _XYA))
# Judge status: Accepted
import sys
n,Y = map(int,input().split())
for x in range(n+1):
    for y in range(n-x+1):
        z = n-(x+y)
        if z >= 0 and 10000*x+5000*y+1000*z == Y:
            print(x,y,z)
            sys.exit()
print(-1,-1,-1)
# Judge status: Accepted
H,N = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(N)]
dp = [float('inf') for i in range(H+1)]
dp[0] = 0
for i in range(N):
    a,b = AB[i]
    for j in range(H+1):
        if j+a > H:
            dp[H] = min(dp[H],dp[j]+b)
        else:
            dp[j+a] = min(dp[j+a],dp[j]+b)
print(dp[-1])
# Judge status: Accepted
from math import gcd

def lcm(a, b):
  return a * b // gcd(a, b)
A, B = map(int, input().split())

print(lcm(A, B))
# Judge status: Wrong Answer
n = list(map(int, input()))

l = [0] * (len(n)+1)
carry = 0
for i, k in enumerate(n):
  if k > 5 - carry:
    l[i+1] = k - 10
    l[i] += 1
    carry = 1
    while l[i] >= 6 - (1 if l[i-1] < 0 else 0):
      l[i] -= 10
      i -= 1
      l[i] += 1
      if i == 0:
        break
  else:
    l[i+1] = k
    carry = 0
print(sum(abs(i) for i in l))
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

length = sum(A)
center = length / 2

now = 0
for i in range(N):
    now += A[i]
    if now == center:
        print(0)
        break
    if now > center:
        print(int(min(now-center, center-now+A[i]) * 2))
        break
# Judge status: Accepted

dd = int(input())
c = list(list(map(int, input().split())))
s = [[0]*26]*dd
v = [[0]*26]*dd
vs = [[0]*26]*dd
ans = [0]*dd
for i in range(dd):
    s[i] = list(list(map(int, input().split())))



for i in range(26):
    for j in range(dd):
        v[j][i]=s[j][i]+c[i]*(j+1)

for i in range(dd):
    maxv = -100000
    for j in range(26):
        if maxv < v[i][j]:
            maxv = v[i][j]
            ans[i]=j+1
for a in ans:
    print(a)
# Judge status: Accepted
N = int(input())
Q = [list(map(int, input().split())) for _ in range(N)]
dp = [[0]*3 for i in range(N)]
dp[0][0] = Q[0][0]
dp[0][1] = Q[0][1]
dp[0][2] = Q[0][2]

for i in range(1, N):
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + Q[i][0]
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + Q[i][1]
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + Q[i][2]
print(max(dp[-1]))
# Judge status: Accepted
import math
x = int(input())
print(((x*360)//math.gcd(x,360))//x)
# Judge status: Accepted
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    S = input()
    n = len(S)+1
    left=[0]*n
    right=[0]*n
    for i,s in enumerate(S):
        if s=='<':
            left[i+1]=left[i]+1
    for i,s in enumerate(S[::-1]):
        if s=='>':
            right[n-i-2]=right[n-i-1]+1
    ret =0
    for i in range(n):
        ret+= max(left[i],right[i])
    print(ret)

if __name__ == '__main__':
    main()
# Judge status: Accepted
import sys
input = sys.stdin.readline

n,m = map(int,input().split())
A = list(map(int,input().split()))
a = 0
s = sum(A)
for i in range(n):
    if A[i] *4*m>= s:
        a += 1
if a >= m:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N = int(input())

for i in range(1, 50001):
    if int(1.08 * i) == N:
        print(i)
        break
else:
    print(":(")
# Judge status: Accepted
a, b = map(int, input().split())

if a == b:
    print('Draw')
elif a == 1:
    print("Alice")
elif b == 1:
    print('Bob')
elif a > b:
    print('Alice')
elif b > a:
    print('Bob')
# Judge status: Accepted
a,b,c = map(int,input().split())
if a+b ==c or b+c ==a or c+a == b:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
C=[]
for _ in range(3):
    a=list(map(int,input().split()))
    b=min(a)
    for i in range(3):
        a[i]-=b
    C.append(a)
if C[0]==C[1] and C[1]==C[2] and C[0]==C[2]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N = int(input())
a = sorted(list(map(int,input().split())),reverse=True)

alice = 0
bob = 0

for i in range(N):
    if i % 2 == 0:
        alice += a[i]
    else:
        bob += a[i]

print(alice - bob)
# Judge status: Accepted
S = int(input())
from math import sqrt, ceil
rtS = sqrt(S)
u = 10 ** 9
ans = [0 for _ in range(6)]
ans[2] = u
ans[3] = 1
ans[5] = ceil(S/u)
ans[4] = ans[5] * u - S
print(*ans)
# Judge status: Accepted
from decimal import Decimal
a, b, c = map(Decimal, input().split())
print('Yes' if a.sqrt() + b.sqrt() < c.sqrt() else 'No')
# Judge status: Accepted
import math
a, b, x = map(int, input().split())
sq = a*a*b/2

if sq >= x:
    A1 = 2*x/(a*b)
    num = math.atan(b/A1)
else:
    B1 = 2*x/a**2 - b
    num = math.atan((b-B1)/a)

print(math.degrees(num))
# Judge status: Accepted
s = input()
ans = ''
while True:
  i = len(s)//2
  if s[0:i]==s[i:-1]:
    ans = s[0:i]+s[i:-1]
    break
  s = s[0:-1]
print(len(ans))
# Judge status: Wrong Answer
#!/usr/bin/env python3
a, b, c = map(int, input().split())
if (a + b + c) % 2 != 1:
    print(-1)
else:
    cnt = 0

    while True:
        if a % 2 or b % 2 or c % 2:
            break
        cnt += 1
        a, b, c = (b + c) // 2, (a + c) // 2, (a + b) // 2
    print(cnt)
# Judge status: Accepted
x,y = map(int,input().split())
cnt = 1
for i in range(x,y+1):
    x = x*2
    if x > y:
        break
    cnt += 1
print(cnt)
# Judge status: Accepted
a,b,c = map(int, input().split())
if a+b >= c:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
a, b, k = map(int, input().split())

num_list = []

for i in range(1,100):
    if a % i == 0 & b % i == 0:
        num_list.append(i)

print(num_list[k-1])
# Judge status: Accepted
n = int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ma=sum(b)
for i in range(0,n-1):
    if a[i+1]-a[i]==1:
        ma+=c[a[i]-1]
print(ma)
# Judge status: Accepted
N = int(input())
P = list( map( int, input().split() ) )
c = 1
m = P[0]

for i in range(1,N):
    if P[i] <= m:
        c += 1
        m = P[i]
        
print(c)
# Judge status: Accepted
a,b=map(int,input().split())
n=list(range(b,b+a))
o=[]
for i in n:
    o.append(abs(i))

del n[o.index(min(o))]

print(sum(n))
# Judge status: Wrong Answer
s=list(input())
li=[]
non=False
for c in s:
  if c in li:
    non=True
    break
    
if non:
  print("yes")
  
else:
  print("no")
# Judge status: Accepted
N = int(input())
L = list(map(int, input().split()))
L.sort()
from bisect import bisect_left
ans = 0

for a in range(0, N-2):
  for b in range(a+1, N-1):
    t = L[a] + L[b]
    idx = bisect_left(L,t)
    ans += max(0, idx-b-1)

print(ans)
# Judge status: Accepted
N = int(input())
T,A = map(int, input().split())
H = [int(i) for i in input().split()]

ans = [float("inf"), 0]
for i,h in enumerate(H):
    tmp = abs(A - (T - h * 0.006))
    if ans[0] > tmp:
        ans = [tmp, i + 1]

print(ans[-1])
# Judge status: Accepted
s = str(input())

list = ['A','C','G','T']

score = 0
tmp = 0
for i in s:
  if(i in list):
    tmp += 1
  else:
    score = max(score,tmp)
    tmp = 0

score = max(score,tmp)
print(score)
# Judge status: Accepted
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools


#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]

x = list(map(int,input().split()))
ans = 0

print(x.index(0)+1)
# Judge status: Wrong Answer
import math
def main():
  x = int(input())
  print(int(math.sqrt(x))*int(math.sqrt(x)))
main()
# Judge status: Accepted
n=int(input())

ans=[0]*(n+1)
for x in range(1,int(n**0.5)+2):
    for y in range(1,int(n**0.5)+2):
        for z in range(1,int(n**0.5)+2):
            if x**2+y**2+z**2+x*y+y*z+z*x<=n:
                ans[x**2+y**2+z**2+x*y+y*z+z*x]+=1

for item in ans[1:]:
    print(item)
# Judge status: Accepted
x,y,z=input().split()
print(z,x,y)
# Judge status: Accepted
n=int(input())

s = ''
for i in range(11):
  if n != 0:
    n -= 1
    s += chr(ord('a') + n % 26)
    n //= 26
print(s[::-1])
# Judge status: Accepted
s = input()
n = len(s)
for i in range(2,n-1,2):
    if s[:(n-i)//2] == s[(n-i)//2:n-i]:
        print(n-i)
        exit()
# Judge status: Accepted
import bisect
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
for i in B:
    a = bisect.bisect_left(A, i)
    b = bisect.bisect_right(C, i)
    ans += a * (N - b)
print(ans)
# Judge status: Accepted
x, y, z = input().split()

print(z, x, y)
# Judge status: Wrong Answer
a, b = map(int, input().split())

if (a * b) % 2 == 1:
    print ('odd')
else:
    print ('even')
# Judge status: Wrong Answer
alp = [chr(i) for i in range(97, 97+26)]
N = int(input())
q = N
s = ""
while True:
  q,m = divmod(q,26)
  s = alp[m - 1] + s
  if q == 0:
    break
print(s)
# Judge status: Wrong Answer
def yakusuu(x):
  kosuu = 0
  for i in range(1,x + 1,1):
    if x % i == 0:
      kosuu += 1
  return kosuu


x = input()
intNum = int(x)

ans = 0

for i in range(1,intNum + 1,1):
  print(i)
  ans += i * yakusuu(i)


print(ans)
# Judge status: Wrong Answer
w = {'SAT': 1, 'MON': 2, 'TUE': 3, 'WED': 4, 'THU': 5, 'FRI': 6, 'SUN': 7}
s = input()
print(w[s])
# Judge status: Wrong Answer
N,K=map(int,input().split())
sum_value = 0
for i in range(1,N+1):
    if(i>=K):
        sum_value = sum_value+1/N
    else:
        for j in range(1,17):
            if(i*(2**j)>=K):
                sum_value=sum_value+((1/N)*(1/(2**j)))
                break
print(sum_value)
# Judge status: Accepted
N = int(input())
A = [int(i) for i in input().split()]

from collections import defaultdict

cnt = defaultdict(int)

for a in A:
    cnt[a] += 1
    cnt[a-1] += 1
    cnt[a+1] += 1

print(max(cnt.values()))
# Judge status: Accepted
A = list(map(int, input().split()))
A.append(sum(A))

ans = False
for i in A:
  if i%3 == 0:
    ans = True
if ans:
  print("Possible")
else:
  print("Impossible")
# Judge status: Wrong Answer
d,t,s = map(int,input().split())
if d / s >= t:
  print("No")
else:
  print("Yes")
# Judge status: Accepted
n,k = map(int,input().split())
h = [int(input()) for _ in range(n)]

#n,k = 7,3
#h = [10,11,12,14,15,20,0]
h.sort()

ans = 10**10
for i in range(n-k+1):
  ans = min(h[i+k-1] - h[i] , ans)

print(ans)
# Judge status: Accepted
from fractions import gcd

n = int(input())
a = [int(i) for i in input().split()]
# 累積 gcd（左と右両方）
left, right = [0] * (n + 1), [0] * (n + 1)
for i in range(n):
    left[i + 1] = gcd(left[i], a[i])
for i in reversed(range(0, n)):
    right[i] = gcd(right[i + 1], a[i])


# 累積
ans = 0
for i in range(n):
    l = left[i]
    r = right[i + 1]
    ans = max(ans, gcd(l, r))
print(ans)
# Judge status: Accepted
d, t, s = map(int, input().split())

dist = t * s

if dist >= d:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a,b,c=map(int,input().split())
if (a**2)+(b**2)==(c**2):
    s=a*b/2
elif (a**2)+(c**2)==(b**2):
    s=a*c/2
elif (b**2)+(c**2)==(a**2):
    s=b*c/2
print(int(s))
# Judge status: Accepted
s = input()
s = s.replace("eraser", "").replace("erase", "").replace("dreamer", "").replace("dream", "")

if len(s) > 0:
    print("NO")
else:
    print("YES")
# Judge status: Accepted
N = int(input())
a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))

maxim = 0
for i in range(N):
    count = 0
    count += sum(a1[:i+1]) + sum(a2[i:])
    if count > maxim:
        maxim = count
print(maxim)
# Judge status: Accepted
n = int(input())
h = list(map(int, input().split()))
c, d = 0, 0
for i in range(n-1):
    if h[i] >= h[i+1]:
        c += 1
    else:
        d = max(c, d)
        c = 0
print(max(c, d))
# Judge status: Wrong Answer
a = [int(j) for i in range(3) for j in input().split(' ')]
n = int(input())
nn = [int(input()) for i in range(n)]

cnt = 0
for ni in nn:
  if ni in a:
    cnt += 1
    a[a.index(ni)] = 0

judge = "No"
for i in range(3):
  if sum(a[i::3])==0 or sum(a[i*3:i*3+3])==0:
    judge = "Yes"
    
if sum(a[::4])==0 or sum(a[2:-1:4])==0:
  judge = "Yes"
  
print(judge)
# Judge status: Wrong Answer
k = int(input())
l, m = map(int, input().split())

if (l-l%k == m):
    print("OK")
elif ((l/k+k)*k <= m):
    print("OK")
else:
    print("NG")
# Judge status: Wrong Answer
A,B,C = map(int,input().split())

maxi=max(A,B,C)
mini=min(A,B,C)
if B!=maxi and B!=mini:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
N, K = map(int, input().split())
x = list(map(int, input().split()))

ans = float('inf')
for l in range(K):
    r = l + K - 1
    if r>=N:
        continue
    ans = min(ans, min(abs(x[l]), abs(x[r])) + x[r] - x[l])
print(ans)
# Judge status: Accepted
A, B, K = map(int, input().split())

for i in range(A, min(B+1, A+K)):
    print(i)

for i in range(max(A+K, B-K+1), B+1):
    print(i)
# Judge status: Accepted
S = input()
if S[0] == S[1] or S[1] == S[2] or S[2] == S[3]:
    print('Bad')

else:
    print('Good')
# Judge status: Accepted
a, b = map(int, input().split())
if a <= 8 and b <= 8:
    print('Yay!')
else:
    print(':(')
# Judge status: Accepted
import heapq
N,M=map(int,input().split())
A=list(map(lambda x:int(x)*(-1),input().split()))

heapq.heapify(A)

def func():
   n=-heapq.heappop(A)
   n//=2
   heapq.heappush(A,-n)

for i in range(M):
   func()

print(-sum(A))
# Judge status: Wrong Answer
import math
N=int(input())
X=math.ceil(N/1.08)
if math.floor(X*1.08)==N:
    print(X)
else:
    print('：（')
# Judge status: Wrong Answer
x = input()
s_count = x.count('S')
t_count = x.count('T')
count = 0
for i in range(len(x)):
    if s_count == 0 or t_count == 0:
        break
    if x[i]=='S':
        s_count -= 1
        if t_count > 0:
            count += 1
    else:
        t_count -= 1
print(len(x)-count*2)
# Judge status: Wrong Answer
import math
n = int(input())
n_list = []
for i in range(1, int(math.sqrt(n))):
    if n % i == 0:
        n_list.append((i, n//i))
sa = 10**13
for x, y in n_list:
    if sa >= abs(x-1)+abs(y-1):
        sa = abs(x-1) + abs(y-1)

print(sa)
# Judge status: Accepted
n,m = map(int, input().split())
if n%2:
    a=1
    b=n
    for i in range(m):
        print(a,b)
        a+=1
        b-=1
else:
    a=1
    b=n
    m2=(m+1)//2
    for i in range(m2):
        print(a,b)
        a+=1
        b-=1
    m3=m-m2
    a=1+m2
    b=n-m2-1
    for i in range(m3):
        print(a,b)
        a+=1
        b-=1
# Judge status: Accepted
def main():
    a, b = map(int, input().split())
    s = input()

    for i in range(a + b + 1):
        if i == a:
            if s[i] != "-":
                print("No")
                exit()
        else:
            if not "0" <= s[i] <= "9":
                print("No")
                exit()
    else:
        print("Yes")


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
import sys
import math

input = sys.stdin.readline
sys.setrecursionlimit(4100000)


def main():
    A, B, H, M = map(int, input().rstrip().split())
    theta_m = 2 * math.pi * M / 60
    theta_h = 2 * math.pi * (H * 60 + M) / (12 * 60)
    theta = (theta_h - theta_m) % math.pi
    ans = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(theta))
    print(theta_m)
    print(theta_h)
    print(theta)
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Accepted
a, b, c, k = list(map(int, input().split()))

c = k- a- b

if c < 0 :
    c = 0
if a > k:
    a = k


print(a -c)
# Judge status: Wrong Answer
n = int(input())

for i in range(1,10):
  r = n%i
  ans = n//i
  if r == 0:
    if ans <= 9:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
# Judge status: Accepted
n = int(input())
b = list(map(int, input().split()))
print(b[0] + b[-1] + sum([min(b[i], b[i + 1]) for i in range(n - 2)]))
# Judge status: Wrong Answer
n,m=map(int,input().split())
kouho=[i for i in range(1,m+1)]
for i in range(n):
    x=list(map(int, input().split()))
    a=x[1:]
    for i in kouho:
        if not i in a:kouho.remove(i)
print(len(kouho))
# Judge status: Wrong Answer
x,k,d= map(int, input().split())

if abs(x) >= k*d:
    print(abs(x)-k*d)
elif abs(x)%d==0:
    if (int(abs(x)/d)+1000000000000000-k)%2==0:
        print(0)
    else:
        print(d)

else:
    print((abs(x)+(1000000000000000-k)*d)%d)
# Judge status: Accepted
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]

AB.sort(key=lambda ab: ab[1])

cnt = 0
for a, b in AB:
    if cnt + a <= b:
        cnt += a
    else:
        print("No")
        exit()
print("Yes")
# Judge status: Wrong Answer
import sys
n=int(input())
p=list(map(int,input().split()))
q=sorted(p)
for i in range(n-1):
  for j in range(i,n):
    s=p[i]
    p[i]=p[j]
    p[j]=s
    if p==q:
      print("YES")
      sys.exit()
    s=p[i]
    p[i]=p[j]
    p[j]=s
      
print("N0")
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
A.append(0)
i=0
ans=1
d=0
while i<N:
  b=A[i]
  c=0
  while i<N and b==A[i]:
    i+=1
    c+=1
  if 2<=c<=3:
    d+=1
    ans*=b
    if d==2:
      break
  elif 4<=c:
    if d==0:
      ans*=b*b
      d=2
      break
    else:
      ans*=b
      d+=1
      break
if d!=2:
  print(0)
else:
  print(ans)
# Judge status: Accepted
s=list(input())

memo = []

for i in s:
    memo.append(int(i))

ans = max(sum(memo),(memo[0]-1)+(len(memo)-1)*9)

print(ans)
# Judge status: Accepted
def main():
    A, B, C = map(int, input().split())
    if (A == 5 and B == 7 and C == 5) or (A == 7 and B == 5 and C == 5) or (A == 5 and B == 5 and C ==7):
        print('YES')
    else:
        print('NO')
main()
# Judge status: Accepted
n=int(input())
a={}
for i in range(n):
    key=input()
    if key in a:
        a[key]+=1
    else:
        a[key]=1
b=max(list(a.values()))
c=[]
for k,v in a.items():
    if v==b:
        c.append(k)
c=sorted(c)
for i in range(len(c)):
    print(c[i])
# Judge status: Accepted
N = str(input())

if "9" in N:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
words=["eraser","erase","dreamer","dream"]
S=input()
for i in range(0,4):
    S=S.replace(words[i],"",)
if S=="":
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N = int(input())
a = list(map(int, input().split()))
f = None
count = 1
for i in range(N - 1):
    if f is None:
        if a[i] < a[i + 1]:
            f = 1
        elif a[i] > a[i + 1]:
            f = -1
        continue

    if (f == 1 and a[i] > a[i + 1]) or (f == -1 and a[i] < a[i + 1]):
        count += 1
        f = None

print(count)
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline

S = input().rstrip()
trimed_S = S[3:-2].replace('C', '', 1)

ans = 'AC'
if S[0] != 'A':
  ans = 'WA'
elif not trimed_S.islower() or len(S) - len(trimed_S) != 1:
  ans = 'WA'

print(ans)
# Judge status: Accepted
h,w = map(int,input().split())

s = (h * w) // 2

if (h==1) or (w==1):
    t = 1
elif (h*w) % 2 == 0:
        t = s
elif (h*w) % 2 == 1:
        t = s+1

print (t)
# Judge status: Accepted
S = int(input())
mod = 10**9+7

dp = [0 for _ in range(S+1)]
dp[0] = 1

for i in range(3, S+1):
    dp[i] = dp[i-1]+dp[i-3]
    dp[i] = dp[i]%mod
print(dp[-1])
# Judge status: Accepted
h,n = map(int, input().split())

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

result="No"
s = 0
for i in a:
    s += i
    if s >= h:
        result = "Yes"
        break

print(result)
# Judge status: Accepted
N = int(input())
L = [int(i) for i in input().split()]
L.sort()

M = L.pop()
if M < sum(L):
    print('Yes')
else:
    print('No')
# Judge status: Accepted

N, A, B = map(int,input().split(" "))
ans = 0
diff = abs(A-B)

if diff % 2 == 0:
    ans = diff // 2
else:
    edge = min(A-1, N-B) + 1
    edge += (B-A-1)//2
    ans = edge

print(ans)
# Judge status: Accepted
X = int(input())
K =[400,600,800,1000,1200,1400,1600,1800,9999]
for k in range(8):
    if K[k]<=X and K[k+1]>X:
        print(8-k)
        break
# Judge status: Accepted
#!/usr/bin/env python

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

if a*b*c%2 == 0:
    print(0)
    exit()

print(min(a*b, b*c, a*c))
# Judge status: Accepted
import itertools
n,m,q = map(int,input().split())
target = [list(map(int,input().split())) for _ in range(q)]
ans = 0
for A in itertools.combinations_with_replacement(range(1,m+1),n):
  count = sum([abcd[3] for abcd in target if A[abcd[1]-1] - A[abcd[0]-1] == abcd[2]])
  ans = max(ans,count)
print(ans)
# Judge status: Accepted
# coding: utf-8


def main():
    S = input()
    ans = 0
    a, b = '', ''

    for s in S:
        a += s
        if a != b:
            ans += 1
            b = a
            a = ''

    print(ans)

if __name__ == "__main__":
    main()
# Judge status: Accepted
n=int(input())
s,rem=input(),0
ans = s.count('R') * s.count('B') * s.count('G')

for i in range(1, (n-1) // 2 + 1):
  for j in range(i*2, n):
    if s[j]+s[j-i]+s[j-2*i] in ("RGB","RBG","GRB","GBR","BGR","BRG"):
      rem += 1
    
print(ans - rem)
# Judge status: Wrong Answer
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
ret, tmp_temp = 1, h[0]
for i, height in enumerate(h):
    x = t - height*0.006
    if abs(a-x) <= a-tmp_temp:
        tmp_temp = x
        ret = i+1
print(ret)
# Judge status: Accepted
import math
a, b = map(int, input().split())
print(math.ceil((a+b) / 2))
# Judge status: Accepted
N=int(input())
A=list(map(int, input().split()))

mon=1000
for i in range(1,N):
    if A[i]>A[i-1]:
        mon=mon//A[i-1]*A[i]+mon%A[i-1]

print(mon)