peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n = int(input())
s = []
for i in range(n):
  s.append(input())
s = sorted(s)
max_count = 1
count = 1
ans = []
for i in range(n-1):
  if s[i] == s[i+1]:
    count += 1
    if count == max_count:
      ans.append(s[i])
    if count > max_count:
      max_count = count
      ans = [s[i]]
  else:
    count = 1
    if max_count == 1:
      ans.append(s[i])
if max_count == 1:
  ans.append(s[n-1])
ans = sorted(ans)
for i in range(len(ans)):
  print(ans[i])
# Judge status: Accepted
n, k = map(int, input().split())
s = input()
score = 0
for i in range(1, len(s)):
    if s[i - 1] == s[i]:
        score += 1

ans = min(n - 1, score + 2 * k)

print(ans)
# Judge status: Accepted
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    S = input().rstrip()

    l_black = 0
    r_white = S.count(".")
    ans = r_white
    for i in range(N):
        if S[i] == "#":
            l_black += 1
        else:
            r_white -= 1
        count = l_black + r_white
        if count < ans:
            ans = count

    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
n=int(input())
s=input()
# 数値(1〜26)→アルファベット(a〜z)
n2a = lambda c: chr(c+64).lower()
al=[]
for i in range(1,27):
  c=s.count(n2a(i))
  if c!=0:
    al.append(c)
ans=0
for i in range(1,2**len(al)):
  b=str(bin(i))
  a=1
  j=1
  while b[-j]!='b':
    if b[-j]=='1':
      a*=al[j-1]
    j+=1
  ans+=a
print(ans)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ca = 0
cb = 0
for aa, bb in zip(a, b):
    if aa < bb:
        cb += (bb - aa)//2
    if bb < aa:
        ca += aa - bb
# print(ca, cb)
if cb >= ca:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
K, X = map(int, input().split())
for i in (X-(K-1), X+K):
  print(i, end=" ")
# Judge status: Wrong Answer
h, a = map(int, input().split())
print((h+1)//a)
# Judge status: Accepted
import numpy as np
def solve(n, x, y):
    x = np.asarray(x)
    y = np.asarray(y)
    z = x + y
    w = x - y
    return max(np.max(z) - np.min(z), np.max(w) - np.min(w))

n = int(input())
x, y = zip(*[map(int, input().split()) for i in range(n)])
print(solve(n, x, y))
# Judge status: Wrong Answer
a,b = input().split()
n = int(a+b)
for i in range(n):
  b = i**2
  if i ==n:
    print('Yes')
    break
  elif i > n:
    print('No')
    break
# Judge status: Accepted
n = int(input())
m=list(map(int,input().split()))
m.sort(reverse=True)
k=0
for i in range((n+1)//2-1):
    k+=m[i]

for i in range(1,(n+1)//2):
    k+=m[i]

if n%2==0:
    k+=m[(n+1)//2-1]
print(k)
# Judge status: Accepted
import math
n = int(input())
tra = [int(input()) for i in range(5)]
print(math.ceil(n/min(tra))+4)
# Judge status: Accepted
def YY(x):
    if 1<=x and x<=12:
        return True
    else:
        return False
S=input()
A=int(S[0:2])
B=int(S[2:4])
if YY(A) and YY(B):
    print("AMBIGUOUS")
elif YY(A):
    print("MMYY")
elif YY(B):
    print("YYMM")
else:
    print("NA")
# Judge status: Accepted
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    S = [0] * (N+1)
    for i in range(N):
        S[i+1] = S[i] + A[i]
    ans = 10**19
    for i in range(1, N):
        a = S[i] - S[0]
        b = S[N] - S[i]
        ans = min(ans, abs(a-b))
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Accepted
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

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

replace = []
for _ in range(M):
    B, C = map(int, input().split())
    replace.append([C, B])

replace.sort(reverse=True)
replace = deque(replace)

while replace and replace[0][0] > A[0]:
    i = heappop(A)
    heappush(A, replace[0][0])
    replace[0][1] -= 1
    if replace[0][1] == 0:
        replace.popleft()

print(sum(A))
# Judge status: Wrong Answer
a, b, c = map(int, input().split())

k = int(input())

for i in range(k):
    if a < b and b < c:
        print('Yes')
        exit()
    elif a > b:
        b = 2 * b
    elif b > c:
        c = 2 * c
    # print(a, b, c)

if a < b and b < c:
    print('Yes')
    exit()

print('No')
# Judge status: Wrong Answer
s = str(input())
k = int(input())
i = 0
n = s[0]
m = len(s)
while (i < m):
  if int(s[i]) ** 2 >= k:
    n = s[i]
    break
  else:
    k -= int(s[i])
  i += 1
print(n)
# Judge status: Accepted
import numpy as np

N=int(input())
num_list=[]
while True:
    try:
        num_list.append(list(map(int,input().split())))

    except:
        break;

sum_list=[]
for k in range(N):
  sum_list.append(sum(num_list[0][0:k+1])+sum(num_list[1][k:N+1]))
          
print(max(sum_list))
# Judge status: Accepted
O = input()
E = input()

for i in range(len(E)):
    print(O[i],end="")
    print(E[i],end="")

if len(O)>len(E):
    print(O[-1])
# Judge status: Accepted
n = input()
print(n.replace('?','D'))
# Judge status: Accepted
def resolve():
    A, B = map(int, input().split())
    print(B if A>=13 else B//2 if 6<=A<=12 else "0")
resolve()
# Judge status: Wrong Answer
X,Y,sX,sY = list(map(int,input().split()))
ans = ""
ans += "U" * (abs(Y-sY)*2+2)
ans += "D" * (abs(Y-sY)*2+2)
ans += "R" * (abs(X-sX)*2+2)
ans += "L" * (abs(X-sX)*2+2)
print(ans)
# Judge status: Wrong Answer
s = sorted(list(set(list(input()))))
i = 0
while i < 25 and chr(i+97)==s[i]:
    i += 1
if i<25:
    print(chr(i+97))
else:
    print("None")
# Judge status: Wrong Answer
from collections import Counter


def main():
    n, m = map(int, input().split())
    ABs = [list(map(int, input().split())) for _ in range(m)]
    ABs = [b for a in ABs for b in a]
    anss = Counter(ABs)
    for ans in anss.values():
        print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
N,L=map(int,input().split())
l=[]

for i in range(1,N+1):
    l.append(i)
for i in range(len(l)):

    (l[i])=L+(i+1)-1

if l[0]>0 and l[len(l)-1]>0:
    l.remove(l[0])
elif l[0]<0 and l[len(l)-1]<0:
    l.remove(l[len(l)-1])
else:
    l.remove(0) 

print(sum(l))
# Judge status: Wrong Answer
N, M = map(int, input().split())
S = []
for i in range(N):
  a, b = map(int, input().split())
  S.append([a, b])

S.sort(key=lambda x: x[0])
price = 0
count = 0
for s in S:
  if count + s[1] < M:
    price += s[0] * s[1]
    count += s[1]
  else:
    price += s[0] * (M - s[1])
    break

print(price)
# Judge status: Wrong Answer
a,b,c,k = map(int,input().split())
ans=0
if a>=k:
    ans=a
else:
    k-=a
    if b>=k:
        ans=a
    else:
        k-=b
        ans=a-k
print(ans)
# Judge status: Accepted
S = input()

s1 = S[0]
s2 = S[1]
s3 = S[2]

if s1 == s2 and s2 == s3 and s3 == s1:
    print('No')
else:
    print('Yes')
# Judge status: Accepted
N = input()
a = list(map(int, input().split()))
answer = 0
a.sort()
a_count = [0 for _ in range(10 ** 5 + 10)]
for x in a:
  a_count[x] += 1
for i in range(1, 10 ** 5 + 5):
  answer = max(answer, a_count[i - 1] + a_count[i] + a_count[i + 1])
print(answer)
# Judge status: Accepted
n, c, k = map(int, input().split())
from collections import deque

t = [int(input()) for _ in range(n)]
t.sort()
t=deque(t)

ans = 1
bus=t[0]+k
cnt = 0

while t:
    i=t.popleft()
    if i>bus:
        bus=i+k
        ans+=1
        cnt=1
    elif cnt==c:
        bus=i+k
        ans+=1
        cnt=1
    else:
        cnt+=1

print(ans)
# Judge status: Accepted
n=int(input())
s=input()
t=input()
c=0
for i in range(n):
    if s[-i-1:]==t[:i+1]:
        c=i+1

ans=2*n-c
print(ans)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
l=[0]*n
for i in reversed(range(1,n+1)):
    x=0
    if n//i>1:
        for j in range(1,n//i):
            x+=l[(j+1)*i-1]
        if (x%2)==a[i-1]:
            l[i-1]=0
        else:
            l[i-1]=1
    else:
        l[i-1]=a[i-1]
m=l.count(1)
print(m)
for i in range(n):
    if l[i]==1:
        print(i+1)
# Judge status: Accepted
def resolve():
    '''
    code here
    '''
    N, K = [int(item) for item in input().split()]
    As = [int(item) for item in input().split()]

    if K == 2:
        print(N-1)
    elif N == K:
        print(1)
    else:
        if (N-1) % (K-1) == 0:
            print((N-1)//(K-1))
        else:
            print((N-1)//(K-1) + 1)

if __name__ == "__main__":
    resolve()
# Judge status: Accepted
N = int(input())
B = list(map(int, input().split()))

# A_1 <= B_1
# A_2 <= min(B_1, B_2)
# A_3 <= min(B_2, B_3)
# A_(N-1) <= min(B_(N-2), B_(N-1))
# A_N <= B_(N-1)
# ans = B_1 + min(B_1, B_2) + ... + min(B__(N-2), B_(N-1)) + B_(N-1)
 
ans = 0
for i in range(N):
  if i == 0: ans += B[0]
  elif i == N-1: ans += B[N-2]
  else: ans += min(B[i-1], B[i])

print(ans)
# Judge status: Accepted
N=int(input())
S=input()
rgb={"R":0,"G":0,"B":0}
for s in S:
    rgb[s]+=1
sum=rgb["R"]*rgb["G"]*rgb["B"]

for i in range(0,N-2):
    for interval in range(1,(N-i+1)//2):
        if S[i]!=S[i+interval] and S[i+interval]!=S[i+2*interval] and S[i]!=S[i+2*interval]:
            sum-=1
print(sum)
# Judge status: Wrong Answer
X = list(map(int, input().split()))
H = X[0]
A = X[2:]
if sum(A)>=H:
    print('Yes')
else:
    print("No")
# Judge status: Wrong Answer
n,x,y=map(int,input().split())
x-=1; y-=1
C=[0]*(n-1)

for i in range(n):
  for j in range(i+1,n):
    d=min(j-i,abs(x-i)+abs(y-j)+1)
    C[d]+=1

print(*C)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
x = [0 for _ in range(31)]
for ai in a:
  i = 0
  while ai > 0:
    if ai%2 == 1:
      x[i] += 1
    ai = ai//2
    i += 1
for i in range(31):
  x[i] = x[i]%2
for ai in a:
  s = 0
  for i in range(31):
    if ai%2 == 1:
      if x[i] == 0:
        s += 2**i
    else:
      if x[i] == 1:
        s += 2**i
    ai = ai//2
  print(s)
# Judge status: Accepted
# -*- coding: utf-8 -*-
"""
Created on Thu May  7 22:30:26 2020

@author: shinba
"""

from operator import itemgetter

N = int(input())

data = {}

for i in range(N):
    string = input()
    if string in data:
        data[string] += 1
    else:
        data[string] = 1

s = sorted(data.items(),key=itemgetter(1),reverse = True)

M = s[0][1]

ans = [s[0][0]]
for i in range(1,len(s)):
    if s[i][1] == M:
        ans.append(s[i][0])
    else:
        break

ans.sort()

for i in ans:
    print(i)
# Judge status: Wrong Answer
n,m = map(int,input().split())
ans = 0
re = m - 2*n
if re > 0:
    ans += n
    ans += re//4
else:
    ans += n
    

print(ans)
# Judge status: Wrong Answer
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    s, t = input().split()
    print(s + t)

if __name__ == '__main__':
    main()
# Judge status: Accepted
def solution():
    a, b, c, d = map(int, input().split())
    while True:
        c -= b
        if c <= 0:
            print('Yes')
            return
        a -= d
        if a <= 0:
            print('No')
            return

solution()
# Judge status: Accepted
n,m = map(int,input().split())

if n == 1 and m == 1:
    print(1)
elif n >= 2 and m >= 2:
    print((n-2)*(m-2))
elif n == 1:
    print(m-2)
else :
    print(n-2)
# Judge status: Wrong Answer
a = input().split()

n = int(a[0])
k = int(a[1])

d = input()
d = int(d)

print(n-d)
# Judge status: Accepted
n = int(input())
a = [[0, 0, 0]]
for _ in range(n):
  a.append(list(map(int, input().split())))

flag = 0
for i in range(n):
  delta = a[i+1][0]-a[i][0]
  distance = abs(a[i+1][1]-a[i][1]) + abs(a[i+1][2]-a[i][2])
  if delta < distance or delta%2 != distance%2:
    flag = 1
    break
    
if flag == 1:
  print("No")
else:
  print("Yes")
# Judge status: Accepted
n = int(input())
h = list(map(int, input().split()))

ans = 0
prev = h[0]
c = 0
for i in range(1, n):
    if prev >= h[i]:
        c += 1
    else:
        c = 0
    prev = h[i]
    ans = max(ans, c)
print(ans)
# Judge status: Wrong Answer
def f(x):
    sum = 0
    for i in str(x):
        sum += int(i)
    return sum
n = int(input())
aim = 1000000000
for i in range(2,n):
    sum = f(i)+f(n-i)
    aim = min(aim,sum)
print(aim)
# Judge status: Accepted
import sys
n=int(input())
num=1
ans=0
while num<=n:
  count=0
  for i in range(num):
    i+=1
    if num%i == 0: count+=1
  if count == 8: ans+=1
  num+=2
print(ans)
# Judge status: Wrong Answer
k = int(input())
s = list(input())
if k>=len(s):
    print(s)
else:
    for i in range (k):
        print(s[i])
    print("...")
# Judge status: Wrong Answer
S=input()
S2=S[:(len(S))//2]
while len(S)>=2:
    S=S[:-2]
    S2=S2[:-1]
    if S==S2+S2:
        print(len(S),S,S2)
# Judge status: Wrong Answer
sx, sy, tx, ty = map(int, input().split())

ans = (abs(tx - sx)  * 'R') + (abs(ty - sy) * 'U')
ans += ((abs(tx - sx) * 'L') + (abs(ty - sy) * 'D'))
ans += 'L' + ((abs(ty - sy) + 1) * 'U') + ((abs(tx - sx) + 1) * 'R') + 'D'
ans += 'D' + ((abs(tx - sy) + 1) * 'R') + ((abs(ty - sy) + 1) * 'U') + 'L'
print(ans)
# Judge status: Accepted
N = int(input())

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


MAX = max(A)

if A.count(MAX) != 1:
  for _ in range(N):
    print(MAX)

  
else:

  two = sorted(set(A))[-2]
  for i in range(N):
    if A[i] == MAX :
      print(two)
    else:
      print(MAX)
# Judge status: Wrong Answer
l = [7,5,5]
a = list(map(int, input().split()))
a.sort()
if a == l:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
S = input()
N = len(S)
C = [0 for i in range(2019)]
C[0] = 1
now = 0
for i in range(N):
    now += int(S[-i-1])*(10**(i%2019))
    now %= 2019
    C[now] += 1
ans = 0
for i in range(2019):
    ans += C[i]*(C[i]-1)//2
print(ans)
# Judge status: Accepted
n, c, k, *t = map(int, open(0).read().split())
t.sort()
tmp = 0
cnt = 0
limit = t[0] + k
for time in t:
    if tmp == c or time > limit:
        limit = time + k
        tmp = 1
        cnt += 1
    else:
        tmp += 1
if tmp != 0:
    print(cnt + 1)
else:
    print(cnt)
# Judge status: Wrong Answer
n,m = map(int,input().split())
print(n,m)
if n == m :
    print("Yes")
else :
    print("No")
# Judge status: Accepted
import sys

def main():
    tmp = input().replace('\n','').split(' ')[0]
    res = int(tmp)//2 + int(tmp)%2
    print(res)
if __name__ == '__main__':
    input = sys.stdin.readline
    main()
# Judge status: Wrong Answer
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
C = len(c)

# Bを中心に考える
for i in b:
    ans += (bisect.bisect(a,i-1))*(C-bisect.bisect(c,i+1))

print(ans)
# Judge status: Wrong Answer
xy = [int(x) for x in input().split()]
X = xy[0]
Y = xy[1]
if Y%2 == 0 and 2*X< Y and Y<4*X:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
(x,y) = input().split(" ")
x = int(x)
y = int(y)
if y % 2 == 1 or y > x * 4 or y < x * 2:
    print("No")
else:
    print("Yes")
# Judge status: Accepted
n = int(input())
if n%2:
    h = n//2
else:
    h = n//2+1
count=0
for i in range(h+1,0,-1):
    judge = n//i
    if n%i == 0:
        count=count+judge-1
    else:count += judge
for i in range(h+2,n):
    count+=1

print(count)
# Judge status: Wrong Answer
import math
N, K = map(int, input().split())
arr = list(map(int, input().split()))

if N == K:
    print(1)
    exit()

mae = arr.index(1)
usiro = len(arr)-1-arr.index(1)
ans = math.ceil(mae/(K-1))+math.ceil(usiro/(K-1))

if arr[0] ==1 or arr[-1] ==1:
    print(ans-1)
    exit()
else:
    print(ans)
# Judge status: Accepted
def resolve():    
    import heapq
    n,m=map(int,input().split())
    ab=[list(map(int,input().split())) for _ in range(n)]
    b=[[] for _ in range(10**5+1)]
    for i,j in ab:
        b[i].append(-j)
    q=[]
    ans=0
    for i in range(1,m+1):
        for j in b[i]:
            heapq.heappush(q,j)
        if q:
            ans+=heapq.heappop(q)
    print(-ans)
        
if __name__ == '__main__':
    resolve()
# Judge status: Accepted
di = {'Sunny':'Cloudy','Cloudy':'Rainy','Rainy':'Sunny'}

print(di[input()])
# Judge status: Accepted
if max(map(int,input().split()))<=8:
  print("Yay!")
else:
  print(":(")
# Judge status: Accepted
N = int(input())
S = input()
a = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]

for s in S:
    tmp = int(a.index(s))
    tmp = tmp + N
    print(a[tmp % 26], end="")
# Judge status: Accepted
S = int(input())

if S == 1 or S ==2:
  print(0)
elif S == 3 or S == 4 or S == 5:
  print(1)
else:
  #初期化
  dp = [0]*S
  dp[2] = 1
  dp[3] = 1
  dp[4] = 1
  dp_S = 0
  #dp
  for i in range(5,S):
    dp_S += dp[i-3] 
    dp[i] = 1+dp_S

  print(dp[S-1]%1000000007)
# Judge status: Accepted
a,b=map(int,input().split());print([a-1,a][b>=a])
# Judge status: Wrong Answer
n,m = map(int,input().split())
A = list(map(int,input().split()))
sum = 0
for i in A:
  sum += i
A.sort()
if A[n-1] > sum/(4*m):
  print("Yes")
else:
  print("No")
# Judge status: Accepted
import math
a,b,c=map(int,input().split())
if c-a-b<0:
    print("No")
    exit()
if 4*a*b < (c-a-b)**2:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a=list(map(int,input().split()))
k=int(input())
a.sort()
print(a[0]+a[1]+a[2]*pow(2,k))
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)[::-1]
cnt = 0
res = 0
for i in range(1, n * 3 + 1, 2):
    cnt += 1
    res += a[i]
    if cnt >= n:
        break
print(res)
# Judge status: Accepted
s = input()
n = len(s)

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

print(int(count / 2))
# Judge status: Accepted
import math
a, b, c, d = map(int, input().split())

def f(a, b, c):
    return b // c - (a + c - 1) // c + 1 

c_num = f(a, b, c)
d_num = f(a, b, d)

cp = c
dp = d
mod = 1
while mod > 0:
    mod = cp % dp
    cp = dp
    dp = mod

cd_num =  f(a, b, (c * d) // cp)
print(b - a + 1 - c_num - d_num + cd_num)
# Judge status: Accepted
n = int(input())
s = input()
t = input()
ans = ""
for i in range(n):
    if s[i] == t[0]:
        if s[i:] == t[:n-i]:
            ans = s[:i]+t
            break
if ans == "": ans = s+t
print(len(ans))
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
ans=100000000
for i in range(-100,101):
    now=0
    for k in a:
        now+=(i-k)*(i-k)
    ans=min(ans,now)
print(ans)
# Judge status: Wrong Answer
n,k = map(int,input().split())
s = input()
edge,inside,cnt,ix = 0,0,0,0
if s[0]=='R' or s[-1]=='R':
  edge += 1
temp = ''
#print(ix)
s += 'L'
for i in range(n+1):
  if i!=n:
    if temp=='R' and s[i]=='L':
      inside += 1
    elif temp==s[i]:
      cnt += 1
  temp = s[i]
print(inside,cnt,edge)
if inside>=k:
  print(min(k*2+cnt,n-1))
else:
  print(min(inside*2+edge+cnt,n-1))
# Judge status: Accepted
import math

n=int(input())
a=[int(x) for x in input().rstrip().split()]

ans=a[0]
for i in range(1,n):
  ans=math.gcd(ans,a[i])
print(ans)
# Judge status: Accepted
[n,m] = [int(i) for i in input().split()]
if n * 2 >= m:
    print(m // 2)
else:
    if m >= 2:
        ans = n
        m = max(m - n * 2,0)
        ans += m//4
        print(ans)
    else:
        print(0)
# Judge status: Accepted
from collections import deque
import sys
K = int(input())
q = deque([1,2,3,4,5,6,7,8,9])
num = 0
if K<=9:
    print(q[K-1])
    sys.exit()
for i in range(10**5):
    p = q.popleft()
    num += 1
    if num == K:
        print(p)
    if p%10 != 0:
        q.append(p*10+p%10-1)
    q.append(p*10+p%10)
    if p%10 != 9:
        q.append(p*10+p%10+1)
# Judge status: Accepted
n = int(input())
#a, b, h, m = map(int, input().split())
#al = list(map(int, input().split()))
#al=[list(input()) for i in range(h)]

l = 1
total = 26

while n > total:
    l += 1
    total += 26**l

last = total-26**l
v = n-last-1

ans = ''
# 26進数だと見立てて計算
for i in range(l):
    c = v % 26
    ans += chr(ord('a')+c)
    v = v//26
print("".join(ans[::-1]))
# Judge status: Wrong Answer
N,M = map(int,input().split())

A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

for i in range(N-M+1):
    for h in range(N-M+1):
        cnt = 0
        for k in range(M):
            for j in range(M):
                if A[i+k][h+j] != B[k][j]:
                    cnt += 1
        if cnt == 0:
            break
if cnt == 0:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a = int(input())
if a >= 30:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
N = int(input())
#N = map(int,input().split())
A = list(map(int,input().split()))
A.sort()

count = 0
for i in range(1, N):
    B = A[:i]
    a = A[i]
    bit = 0
    for b in B:
        if a%b == 0:
            bit = 1
            break
    if bit == 0:
        count+=1
if A[0] not in A[1:]:
    count+=1
print(count)
# Judge status: Accepted
n = int(input())
numbers = list(map(int, input().split()))

def div(x):#各要素を2で割って返す関数
    return x/2

count = 0
while 1:
    flag = 0
    for num in numbers:
        if num % 2:#2で割り切れない
            flag=1
            break
    if flag==1:
        break
    count += 1
    numbers = list(map(div,numbers))

print(count)
# Judge status: Accepted
S = input()

O = S.count("0")
I = S.count("1")

diff = abs(O-I)

print(len(S)-diff)
# Judge status: Accepted
s = int(input())

ans, num = [0, 0, 10 ** 9, 1], 10 ** 9
if s % num == 0:
    ans += [0, s // num]
elif s % num != 0:
    ans += [abs(s % num - num), s // num + 1]
print(*ans)
# Judge status: Accepted
N=int(input())
S=input()
from collections import Counter
C=Counter(S)
ans=C['R']*C['G']*C['B']
for i in range(N):
    for j in range(i+1,N):
        if j+(j-i) >= N: break
        if S[i] != S[j] and S[j] != S[j+(j-i)] and S[i] != S[j+(j-i)]:
            ans-=1
print(ans)
# Judge status: Accepted
n = int(input())
A = sorted(list(map(int,input().split())))
ans = 1
for i in A:
    ans = ans*i
    if 10**18 < ans:
        print (-1)
        exit ()
print (ans)
# Judge status: Accepted
c = input()
print("vowel" if c=='a'or c=='i' or c=='u' or c=='e' or c=='o' else "consonant")
# Judge status: Accepted
n = int(input())
ls = list(map(int,input().split()))
min = ls[0]
k = 1
for i in range(1,n):
    if ls[i] < min:
        min = ls[i]
        k += 1
print(k)
# Judge status: Wrong Answer
X = list(map(int,list(input())))

for i in range(2**4):
  ans =[]
  for j in range(4):
    d = X[j]*(-1)**((i >>j)&1)
    ans.append(d)
  if sum(ans) == 7:
    for i,a in enumerate(ans):
      if a>=0 and i>0:
        print("+",end="")
      print(a,end="")
    print("=7")
    exit()
# Judge status: Accepted
s = input()

ans = 'Good'

for i in range(len(s)-1):
    if s[i] == s[i+1]:
        ans='Bad'

print(ans)
# Judge status: Accepted
input()
r = 1
for x in input().split():
  r = max(-1, r * int(x))
  if r > 1e18:
    r = -1
print(r)
# Judge status: Accepted
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n-k):
  print(['No','Yes'][a[i+k]>a[i]])
# Judge status: Accepted
s = input()

hitachi = 'hi'

for i in range(5):
    if s == hitachi:
        print('Yes')
        exit()
    hitachi += 'hi'

print('No')
# Judge status: Accepted
n = int(input())
argList = list(map(int, input().split()))
ret = argList[0]
#print(argList[0])
for i in range(1,len(argList)):
    #print(min(argList[i-1],argList[i]))
    ret += min(argList[i-1],argList[i])
ret += argList[-1]
#print(argList[-1])
print(ret)
# Judge status: Accepted
a, b = map(int, input().split())
if max(a, b) <= 8: print("Yay!")
else: print(":(")
# Judge status: Accepted
x,k,d = map(int, input().split())

x = abs(x)
div,mod = divmod(x,d)

cnt = min(k,div)
k -= cnt
ans = x - cnt * d

if k > 0:
    ans -= (k%2) * d

print(abs(ans))
# Judge status: Accepted
N=int(input())
S=input()
d = [0]*(N+1) # d[i]: Sの最初のi文字における
              # "(" - ")"
for i in range(1, N+1):
    d[i] = S[:i].count("(") - S[:i].count(")")
x = min(d)
# x = 0 かつ d[N]=0ならよい
if x == 0 and d[N] == 0:
    print(S)
    exit()

ans = "("*abs(x) + S + ")"*(d[N]+abs(x))
print(ans)
# Judge status: Accepted
sixexp=[6**i for i in range(1,7)]
nineexp=[9**i for i in range(1,6)]
lis=[1]+sixexp+nineexp

n=int(input())

dp=[1000000 for i in range (n+1)]
dp[0]=0

for i in range(1,n+1):
    for j in lis:
        if i-j>=0:
            dp[i]=min(dp[i],dp[i-j]+1)

print(dp[n])