peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
import bisect

n=int(input())

list_A=sorted(list(input().split(' ')))
list_B=sorted(list(input().split(' ')))
list_C=sorted(list(input().split(' ')))
ans=0
for i in range(len(list_B)):
	a=bisect.bisect_left(list_A, list_B[i])
	b=bisect.bisect_right(list_C, list_B[i])

	ans += a*(n-b)
print(ans)
# Judge status: Accepted
a, b, c = map(int, input().split())
if c >= a and c <= b:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
n =int(input())
a =list(map(int, input().split()))

flg = True

for x in a:
    if x % 2 != 0:
        continue
    if x % 3 != 0 and x % 5 != 0:
        flg = False

if flg:
    print("APPROVED")
else:
    print("DENIED")
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

sum=0
for i in range(N):
    if B[i]<=A[i]:
        sum+=B[i]
    else:
        sum+=A[i]
        B[i]-=A[i]
        sum+=min(A[i+1],B[i])
        A[i+1]-=min(B[i],A[i+1])
print(sum)
# Judge status: Wrong Answer
H,N = map(int,input().split())
magic = []
for _ in range(N):
  A,B = map(int,input().split())
  magic.append([A,B])

best = []
standard = 0
base_A = 0
base_B = 0
for item in magic:
  if item[0]/item[1] >= standard:
    base_A = item[0]
    base_B = item[1]
    standard = item[0]/item[1]
Answer01 = (H//base_A)*base_B
rest = H%base_A
if rest == 0:
  print(Answer01)
  exit()
addition = 0
lcost = rest+1
for item in magic:
  if item[0]>rest:
    if item[1] < lcost:
      lcost = item[1]
  
print(Answer01+lcost)
# Judge status: Wrong Answer
n = int(input())
x = list(map(int,input().split()))

sort_x = sorted(x)

b1 = sort_x[n//2]
b2 = sort_x[n//2-1]

for i in range(n):
    if x[i]==b1:
        print(b2)
    else:
        print(b1)
# Judge status: Accepted
A, B = map(int, input().split())
S = input()

result = 'Yes'
if '-' in S[:A]:
    result = 'No'
if '-' not in S[A]:
    result = 'No'
if '-' in S[A+1:]:
    result = 'No'

print(result)
# Judge status: Wrong Answer

def myAnswer(N:int,X:list) -> None:
   tmp = X[:]
   tmp.sort()
   B1 = tmp[(N+1)//2]
   B2 = tmp[(N+1)//2 - 1]
   for x in X:
      if(B1 == x):
         print(B2)
      else:
         print(B1)


def modelAnswer():
   return
def main():
   N = int(input())
   X = list(map(int,input().split()))
   myAnswer(N,X)
if __name__ == '__main__':
   main()
# Judge status: Accepted
# # aアリス　　　ｂボブ
# 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("Bob")
# elif b < a:
#     print("Alice")

x, y = map(int, input().split())

L = list(range(2, 14)) + [1]
a = L.index(x)
b = L.index(y)

if a>b:
    print("Alice")
elif b>a:
    print("Bob")
else:
    print("Draw")
# Judge status: Wrong Answer
# input
N = int(input())
CSF = [tuple(map(int, input().split())) for i in range(N - 1)]

# check
T = []
append = T.append
for c, s, f in CSF:
    append(c + s)

    if len(T) > 1:
        for i in range(len(T) - 1):
            if T[i] < s:
                T[i] = c + s
            else:
                T[i] += c

else:
    for t in T + [0]:
        print(t)
# Judge status: Accepted
S = input()
if (S[0:7] == 'keyence') or (S[-7:] == 'keyence'):
  print("YES")
else:
  flag = 0
  for i in range(1,7):
    if S[:i] + S[-(7-i):] == 'keyence':
      print("YES")
      flag=1
      break
  if flag==0:
    print("NO")
# Judge status: Wrong Answer
H1,M1,H2,M2,K = map(int,input().split())
K_time = (H2*60+M2) - (H1*60-M1)
print(K_time - K)
# Judge status: Accepted
# Code for D - Road to Millionaire
# Use input() to fetch data from STDIN
from math import floor
N = int(input())
A = list(map(int, input().split()))

total = 1000
for i in range(0, N - 1):
    if A[i] < A[i+1]:
        total += floor(total / A[i]) * ( A[i + 1] - A[i] )

print(total)
# Judge status: Wrong Answer
H = int(input())
W = int(input())
N = int(input())

a = max(H,W)

x = int(N/a)
print(x)
# Judge status: Accepted
N=int(input())
num=list(map(int,input().split()))
count=0
check=1
for i in range(N):
    if num[i]==check:
        check+=1
    else:   
        count+=1
if check==1:
    print("-1")
else:
    print(count)
# Judge status: Accepted
n,k = map(int,input().split())
l = list(map(int,input().split()))

print(-(-(n-1)//(k-1)))
# Judge status: Accepted
d = {}
for _ in range(int(input())):
    d[input()] = ""
print(len(d))
# Judge status: Accepted
s = input()

l = list(s)
l.sort()
if (l == ["a", "b", "c"]):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
    X=input()
    cunt=0
    cunt_s=0
    for x in X:
        if x=='S':
            cunt_s+=1
        elif cunt_s>0:
            cunt_s-=1
        else:
            cunt+=1
    print(cunt+cunt_s)

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

DP = [-1] * (max(N, K) + 10)
ans = 0
for i in range(1, N+1)[::-1]:
    cnt = 0
    n = i
    while n < K and DP[n] < 0:
        n *= 2
        cnt += 1
    if n < K:
        if DP[n] >= 0:
            DP[i] = (1/2) ** cnt * DP[n]
        else:
            DP[i] = (1 / 2) ** cnt
    else:
        DP[i] = (1/2) ** cnt
    ans += DP[i]
print(ans/N)
# Judge status: Accepted
from math import *
k = int(input())
a, b = map(int, input().split())
for i in range(a, b+1):
	if i%k==0:
		print("OK")
		quit()
print("NG")
# Judge status: Accepted
n = int(input())
ans = 64

while ans > n:
    ans /= 2
    
print(int(ans))
# Judge status: Wrong Answer
N = int(input())

for i in range(2, 10):
  if N % i == 0:
    print('Yes')
    break
else:
  print('No')
# Judge status: Accepted
#!/usr/bin/env python3
import sys
import collections

input = sys.stdin.readline


def ST():
    return input().rstrip()


def I():
    return int(input())


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


def LI():
    return list(MI())


N = I()
A = LI()
A.sort()
cnt = collections.Counter(A)
MAX = A[-1] + 1
# end = A[-1] ** 0.5

for a in A:
    if cnt[a] >= 2:
        del cnt[a]
    for i in range(a * 2, MAX, a):
        del cnt[i]

print(sum(cnt.values()))
# Judge status: Accepted
import bisect
inf = 10**15
mod = 10**9+7
n, m = map(int, input().split())
ken = [[] for i in range(n)]
py = [list(map(int, input().split())) for i in range(m)]
for i in range(m):
    p, y = py[i]
    ken[p-1].append(y)
for tmp in ken:
    tmp.sort()
for i in range(m):
    p, y = py[i]
    ind = bisect.bisect_left(ken[p-1], y)
    print('{ans:06}{anse:06}'.format(ans=p, anse=ind+1))
# Judge status: Wrong Answer
l,h,b = map(int,raw_input().split())
print (l*h)*(b%2)
# Judge status: Accepted
a, b = map(int, input().split())
if a*b%2:
  print("Odd")
else:
  print("Even")
# Judge status: Accepted
import collections 

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

d = collections.Counter(A)

x = sorted([i for i in d.items() if i[1]>1])
if len(x)==0 :
  print(0)
elif x[-1][1] >3 :
  print(x[-1][0]**2)
elif len(x) == 1 :
  print(0)
else:
  print(x[-1][0]*x[-2][0])
# Judge status: Wrong Answer
n, m = map(int, input().split())
student = []
for _ in range(n):
    student.append([int(x) for x in input().split()])
chkpoint = []
for _ in range(m):
    chkpoint.append([int(x) for x in input().split()])

def dist(a, b):
    return abs(a[0] - b[0]) + abs(a[1] - b[1])

for i in range(n):
    minx = 10**8+1
    goto = 0
    for j in range(m):
        tmp = dist(student[i], chkpoint[j])
        if minx > tmp:
            minx = tmp
            goto = j+1
    print(goto)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
ans = 0
for i in range(1,n):
    ans += a[i//2]
print(ans)
# Judge status: Accepted
import sys

input = sys.stdin.readline


def main():
    N, M = map(int, input().split())

    ans = min((2 * N + M) // 4, M // 2)
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
def resolve():
    s=input()
    ans='Yes'
    for i in range(len(s)):
        if i%2==0:
            if s[i]=='L':
                ans='No'
        else:
            if s[i]=='R':
                ans='No'
    print(ans)
resolve()
# Judge status: Accepted
n = int(input())

pwr = 1
for i in range(1, n + 1):
    pwr = (pwr * i) % 1000000007
print(pwr)
# Judge status: Wrong Answer
N=int(input())
S=list(str(input()))
wesr=S[1:].count('W')
east=S[1:].count('E')
ans_min = east
ans = east
for i in range(N-1):
  if S[i]=='W':
    ans+=1
  else:
    if ans>0:
      ans-=1
    else:
      ans=0
  if ans < ans_min:
    ans_min = ans
print(ans_min)
# Judge status: Accepted
s = str(input())

n = len(s)
ans = 'Yes'

for i in range(n//2):
    if s[i] != s[-1-i]:
        ans = 'No'
        break

if ans == 'Yes':
    for j in range(n//2//2):
        if s[j] != s[(n-1)//2 -j -1]:
            ans = 'No'
            break

print(ans)
# Judge status: Wrong Answer
week = ['SUN','MON','TUE','WED','THU','FRI','SAT','SUN']
print(week[week.index(input())+1])
# Judge status: Accepted
N = int(input())

p = [int(x) for x in input().split()]

q = [int(y) for y in range(1, N+1)]

count = 0

for i in range(N):
  if p[i] != q[i]:
    count += 1
    
if count == 0 or count == 2:
  print("YES")
else:
  print("NO")
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
if a==b==c:
  print('No')
else:
  print('Yes')
# Judge status: Accepted
x = int(input())

ans = (x//11)*2
m = x % 11
if m == 0:
    pass
elif m <= 6:
    ans += 1
else:
    ans += 2

print(ans)
# Judge status: Accepted
s = input()
print("Yes" if "9" in s else "No")
# Judge status: Accepted
import sys
from functools import reduce
def input(): return sys.stdin.readline().rstrip()

sys.setrecursionlimit(10 ** 9)
def main():
    _, X = input().split()
    x = sorted(map(int, input().split() + [X]))
    min_x = x[0]
    x = map(lambda a: a - min_x, x[1:])

    def gcd(m, n):
        if n == 0:
            return m
        else:
            return gcd(n, m % n)
    print(reduce(gcd, x))

if __name__ == '__main__':
    main()
# Judge status: Accepted
a,b = map(int,input().split())
c=0
if(a>b):
    c+=a
    a-=1
else:
    c+=b
    b-=1
 
if(a>b):
    c+=a
    a-=1
else:
    c+=b
    b-=1
 
print(c)
# Judge status: Accepted
N = input()
print("Yes" if N[0]==N[1]==N[2] or N[1]==N[2]==N[3] else "No")
# Judge status: Wrong Answer
x,y = map(int,input().split())
if x > y:
    if x < 0 and y < 0:
        print(abs(abs(y)-abs(x))+2)
    if x > 0 and y < 0:
        print(abs(abs(y)-abs(x))+1)
    if x > 0 and y > 0:
        print(abs(abs(y)-abs(x))+2)
elif x < y:
    if x < 0 and y < 0:
        print(abs(abs(y)-abs(x)))
    if x < 0 and y > 0:
        print(abs(abs(y)-abs(x))+1)
    if x > 0 and y > 0:
        print(abs(abs(y)-abs(x)))
# Judge status: Accepted
n=int(input())
a=[list(map(int,input().split()))]
a.append(list(map(int,input().split())))
m=[[0]*n,[0]*n]
#m1=[[0]*n]*2これだとおかしな挙動
m[0][0]=a[0][0]
m[1][0]=m[0][0]+a[1][0]

for i in range(1,n):
    m[0][i]=m[0][i-1]+a[0][i]

for i in range(1,n):
    m[1][i]=max(m[0][i]+a[1][i],m[1][i-1]+a[1][i])

print(m[1][n-1])
# Judge status: Accepted
N, T = map(int, input().split())
C = []
for i in range(N):
  ct = list(map(int, input().split()))
  if ct[1] <= T:
    C.append(ct[0])
print('TLE' if sum(C) == 0 else min(C))
# Judge status: Accepted
s = list(input())
t = list(input())

leng = len(s)
count = 0

for i in range(leng):
    if s[i] != t[i]:
        count += 1

print(count)
# Judge status: Accepted
import math
n = int(input())
a = []
b = []

for i in range(n):
    ai, bi = list(map(int, input().split()))
    a.append(ai)
    b.append(bi)

cur = 0

for i in range(n-1, -1, -1):
    res = (a[i]+cur)/b[i]
    if res % 1 == 0:
        continue

    rem = round((math.ceil(res) - res)*b[i])
    cur += rem

print(cur)
# Judge status: Accepted
import math
from decimal import Decimal, ROUND_DOWN
A,B = map(str,input().split())
A = Decimal(A)
B = Decimal(B)

pro = str(A*B)

print(Decimal(str(pro)).quantize(Decimal('0'), rounding=ROUND_DOWN))
# Judge status: Accepted
import sys
input = sys.stdin.readline

N = int(input())
xy = []
xs = []
ys = []
for _ in range(N):
    x, y = map(int, input().split())
    xy.append([x - y, x + y])
    xs.append(x - y)
    ys.append(x + y)

diff1 = max(xs) - min(xs)
diff2 = max(ys) - min(ys)
ans = max(diff1, diff2)
print(ans)
# Judge status: Accepted
n,x = map(int,input().split())
l = list(map(int,input().split()))
ll = 0
ans = 1

for i in l:
    ll += i
    if x < ll:
        print(ans)
        exit()
    ans += 1
print(ans)
# Judge status: Wrong Answer
a, b, k = map(int, input().split())

h = int((a+b)/2)
c1 = [x for x in range(a, h)]
c2 = [x for x in range(h, b+1)]
for i in range(0, k):
   try:
      print(c1[i])
   except:
      break
for i in reversed(range(1, k+1)):
   try:
      print(c2[-i])
   except:
      pass
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
A_sum=0
for i in range(N):
   if A[i]>B[i]:
      A_sum+=A[i]-B[i]
   elif A[i]<B[i]:
      A_sum-=(B[i]-A[i])//2
if A_sum<=0:
   print("Yes")
else:
   print("No")
# Judge status: Accepted
n = int(input())
s = list(input())
ans = 0
x = 0
for i in s:
    if i == "I":
        x += 1
    else:
        x += -1
    ans = max(ans, x)
print(ans)
# Judge status: Accepted
n , m = map(int, input().split())
id =[]
ch = 1
for i in range(m):
    p , y = map(int, input().split())
    id.append([p,y,i])
id.sort(key = lambda x:(x[0],x[1]))
id.append(['X','X','X'])
for i in range(m):
    id[i][1]=str(ch).zfill(6)
    if id[i][0]==id[i+1][0]:
        ch+=1
    else:
        ch=1
id.pop()
id.sort(key = lambda x:x[2])
for i in range(m):
    s = str(id[i][0]).zfill(6)+id[i][1]
    print(s)
# Judge status: Wrong Answer
s=input()
if(s.upper()):
  print("A")
else:
  print("a")
# Judge status: Accepted
a,b,c = map(int,input().split())

if (a<c and c<b) or (c<a and b<c):
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
from bisect import bisect_left
INF = float("inf")
N = int(input())
L = list(map(lambda x:int(x),input().split())) + [INF]
L.sort()
cnt = 0
print(*L)
for i in range(N-1):
    a = L[i]
    for j in range(i+1,N):
        b = L[j]
        c = bisect_left(L,a+b)
        cnt += max(0,c-j-1)
print(cnt)
# Judge status: Accepted
import sys

input = sys.stdin.readline

def main():
    ans = []
    A, B, C, X, Y = map(int, input().split())
    for i in range(10**5+1):
        ans.append((C*2*i) + (A*max(0, X-i)) + (B*max(0, Y-i)))

    print(min(ans))

if __name__ == '__main__':
    main()
# Judge status: Accepted
from functools import reduce
from fractions import gcd

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

for i in range(A, min(A+K, B+1)):
    print(i)
for i in range(max(A+K, B-K+1), B+1):
    print(i)
# Judge status: Wrong Answer
import math

q, h, s, d = map(int, input().split())
n = int(input())

qq = q
hh = math.ceil(h/2)
ss = math.ceil(s/4)
dd = math.ceil(d/8)

items = [[qq, q, 0.25], [hh, h, 0.5], [ss, s, 1], [dd, d, 2]]
items = sorted(items, key=lambda x: x[0])

ans = 0
while n != 0:
    for item in items:
        if n >= item[2]:
            ans += item[1]
            n -= item[2]
            break

print(ans)
# Judge status: Wrong Answer
X,Y=map(int,input().split())

if X%Y==0:
  ans=-1
else:
  for i in range(1,(10**18)//X+1):
    if i*X%Y!=0:
      print(i*X)
      break
# Judge status: Accepted
a,b,c = map(int, input().split())
print(c, a, b)
# Judge status: Wrong Answer
import math
A, B, H, M = map(int, input().split())
if H==0:
    H = 60
else:
    H *= 5
if M==0:
    M = 60
deg =abs(H-M)*6
cos = math.cos(math.radians(deg))
print(((A**2)+(B**2)-2*A*B*cos)**0.5)
# Judge status: Accepted
N,M = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N):
    A[i] *= -1
import heapq
heapq.heapify(A)
for i in range(M):
    m = heapq.heappop(A)
    heapq.heappush(A,-1*(-m//2))
print(-1*sum(A))
# Judge status: Accepted
n = int(input())
h = list(map(int, input().split()))
ans = []
ans.append(h[0])
for i in range(1, n-1):
    ans.append(min(h[i-1],h[i]))

ans.append(h[-1])


print(sum(ans))
# Judge status: Accepted
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    x, y = map(int, input().split())
    if x % y == 0:
        print(-1)
    else:
        print(x)


if __name__ == '__main__':
    main()
# Judge status: Accepted
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if i*500+j*100+k*50 == x:
        ans += 1
print(ans)
# Judge status: Wrong Answer
a,b,k=map(int,input().split())
lst=[]
for i in range(a,a+k):
  lst.append(i)
  print(i)
for j in range(b-k+1,b+1):
  if j not in lst:
    print(j)
# Judge status: Wrong Answer
x, y = map(int, input().split())
ans = 0
ans += abs(y) - abs(x)
if x < 0:
    ans += 1
if y < 0:
    ans += 1
print(ans)
# Judge status: Accepted
N,K=map(int,input().split())
c=sorted([list(map(int,input().split()))for _ in range(N)])
for a, b in c:
    K-=b
    if K<=0:
        print(a)
        exit()
# Judge status: Accepted
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
q = int(input())
sm = sum(a)
dic = dict(Counter(a))
for _ in range(q):
    b,c = map(int,input().split())
    if b not in dic:
        print(sm)
    else:
        dif = c-b
        sm = sm+dic[b]*dif
        print(sm)
        x = dic[b]
        if c in dic:
            dic[c]+=x
        else:
            dic[c]=x
        dic[b]=0
# Judge status: Wrong Answer
n=int(input())
x=list(map(int,input().split()))
y1=sorted(x)[n//2-1]
y2=sorted(x)[n//2]
for i in range(n):
  print(y2 if x[i]!=y2 else y1)
# Judge status: Wrong Answer
# AtCoder

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

n = len(lst)
diffs = []
for i in range(n):
    dif = 10 - int(str(lst[i])[-1])
    diffs.append(dif)

if sum(diffs) == 50:
    print(sum(lst))
    exit()

mx = max(diffs)
s = []
for i in diffs:
    if i == 10:
        continue
    s.append(i)
print(sum(s)+sum(lst))
# Judge status: Wrong Answer
r, g, b = map(int, input().split())
if ((10 * g + b) % 4 == 0):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
S = input()

if S[0] != "A":
  print("WA")
  exit()
if S[2] != "C":
  print("WA")
  exit()
if S[1]+S[2:] != (S[1]+S[2:]).lower():
  print("WA")
  exit()

print("AC")
# Judge status: Accepted
S = input()

def is_kaibun(s):
    for i in range(len(s) // 2):
        if s[i] != s[-i-1]:
            print('No')
            exit()

N = len(S)
is_kaibun(S)
is_kaibun(S[:(N-1)//2])
is_kaibun(S[(N+3)//2-1:])
print('Yes')
# Judge status: Wrong Answer
import math

k = int(input())
sum = 0
for i in range(1, k):
    for j in range(1, k):
        for m in range(1, k):
            sum += math.gcd(math.gcd(i, j), m)
print(sum)
# Judge status: Accepted
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
X=[A,B,C,D,E]
Y=[]
for i in range(5):
  Y.append((((-1)*X[i])//10)*(-10))

ans=sum(Y)
for i in range(5):
  x=sum(Y)-Y[i]+X[i]
  ans=min(ans,x)
print(ans)
# Judge status: Accepted
A, B, N = map(int, input().split())
x = min(N,B-1)
print(A*x//B-A*(x//B))
# Judge status: Accepted
s = input()
l = len(s)

for i in range(2**(l-1)):
    f = ""
    for j in range(l-1):
        f += s[j]
        if i & (1 << j):
            f += "+"
        else:
            f += "-"
        if j == l-2:
             f += s[l-1]
    if eval(f)==7:
        print(f+"=7")
        break
# Judge status: Wrong Answer
n, q = map(int, input().split())
s = input()

lc = [0]
c = 0
for i in range(n-1):
    if s[i] == "A" and s[i+1] == "C":
        c += 1
    lc.append(c)

print(lc)

for i in range(q):
    l, r = map(int, input().split())
    print(lc[r-1]-lc[l-1])
# Judge status: Accepted
s = sorted(input())
t = sorted(input(), reverse=True)
print("Yes" if s < t else "No")
# Judge status: Wrong Answer
n,m=map(int,input().split())
data=[1]*n
res=[1]+[0]*(n-1)
for i in range(m):
  x,y=map(int,input().split())
  data[x-1]-=1
  data[y-1]+=1
  if data[x-1]==0:
    res[y-1]=res[x-1]
    res[x-1]=0
  else:
    res[y-1]=res[x-1]
ans=0
for i in range(n):
  if data[i]!=0 and res[i]!=0:
    ans+=1
print(ans)
# Judge status: Accepted
from collections import Counter

S = input()

if len(set(S)) == 1:
    print("YES" if len(S) == 1 else "NO")
elif len(set(S)) == 2:
    print("YES" if len(S) <= 2 else "NO")
else:
    c = Counter(S)
    print("YES" if max(c["a"], c["b"], c["c"]) - min(c["a"], c["b"], c["c"]) <= 1 else "NO")
# Judge status: Accepted
s=input()

YYMM=False
MMYY=False

month=[]
for i in range(1,13):
    if len(str(i))==1:
        month.append("0"+str(i))
    else:
        month.append(str(i))

if s[:2] in month:
    MMYY=True

if s[2:] in month:
    YYMM=True

if MMYY is True and YYMM is True:
    print("AMBIGUOUS")
elif  MMYY is True and YYMM is False:
    print("MMYY")
elif  MMYY is False and YYMM is True:
    print("YYMM")
else:
    print("NA")
# Judge status: Accepted
N=int(input())
*X,=map(int,input().split())
s=sorted(X)

t1=s[N//2-1]
t2=s[N//2]

for x in X:
    if x<=t1:
        print(t2)
    else:
        print(t1)
# Judge status: Accepted
n,y=map(int,input().split())
a,b,c=-1,-1,-1
for i in range(n+1):
  for j in range(n+1):
    if 10000*i+5000*j+1000*(n-i-j)==y:
      a=i
      b=j
      c=n-i-j
      break
if c>=0:
  print(a,b,c)
else:
  print("-1 -1 -1")
# Judge status: Accepted
N=int(input())

A=list(map(int,input().split()))
#print(A)

dic={}
for i in range(len(A)):
    if i-A[i] in dic:
        dic[i-A[i]]+=1
    else:
        dic[i-A[i]]=1

ans=0
for i in range(len(A)):
    temp=i+A[i]
    if temp in dic:
        ans+=dic[temp]
        #print(A[i],ans)
    if i-A[i]==i+A[i]:
        ans-=1
print(ans)
# Judge status: Accepted
n,k = map(int,input().split())
print(min(n%k,k-n%k))
# Judge status: Accepted
i = list(map(int, input().split()))
if 10<=i[0]:
  print(i[1])
else:
  print(i[1]+(100*(10-i[0])))
# Judge status: Accepted
N,M = map(int,input().split())
if N==1 and M==1:
    ans = 1
elif N==1 or M==1:
    ans = max(N-2,M-2)
elif N==2 or M==2:
    ans = 0
else:
    ans = N*M-2*(N+M-2)
print(ans)
# Judge status: Accepted
H,N=[int(i) for i in input().split(" ")]
A=[int(i) for i in input().split(" ")]

if(sum(A)>=H):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import sys
X, Y, A, B, C = sys.stdin.readline().split()
X = int(X)
Y = int(Y)
C = int(C)
scoreA = list(map(int, sys.stdin.readline().split()))
scoreB = list(map(int, sys.stdin.readline().split()))
scoreC = list(map(int, sys.stdin.readline().split()))
scoreA.sort(reverse=True)
scoreB.sort(reverse=True)
scoreC.sort(reverse=True)
scoreA = scoreA[:X]
scoreB = scoreB[:Y]
scoreAll = scoreA + scoreB + scoreC
scoreAll.sort(reverse=True)
print(sum(scoreAll[:X+Y]))
# Judge status: Wrong Answer
import sys

N = int(input())
AB = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
AB.sort()

n = N // 2 if N % 2 != 0 else N // 2 - 1
left = AB[n][0]

AB.sort(reverse=True)
right = AB[n][1]

print(right - left + 1)
# Judge status: Wrong Answer
from collections import Counter

N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]

S_cnt = Counter(S)
S_key = S_cnt.keys()
T_cnt = Counter(T)

for key,v in T_cnt.items():
    if not key in S_key:
        continue
    S_cnt[key] -= v
print(max(S_cnt.values()))
# Judge status: Accepted
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
 
a,b=[0],[0]
for i in range(N):
  a.append(a[i] + A[i])
  
  
for i in range(M):
  b.append(b[i] + B[i])
count = 0
j = M
for i in range(N + 1): 
  if a[i]>K:
    break
  while b[j]+a[i]> K :
    j -= 1
  count = max(count, i+j)
print(count)
# Judge status: Wrong Answer
N = 3
print(N *(N + 1) // 2)

N = 10
print(N * (N + 1) // 2)

N = 1
print(N * (N + 1) // 2)
# Judge status: Accepted
N = int(input())
a = list(map(int, input().split()))

final_xor = 0
for i in range(N):
    final_xor = final_xor^a[i]

answer = [final_xor^a[i] for i in range(N)]

print(" ".join((str(n) for n in answer)))
# Judge status: Accepted
n = int(input())
for i in range(1,10):
    for j in range(1,10):
        if i * j == n:
            print('Yes')
            exit(0)
print('No')