peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n=int(input())
s=input()
r,g,b=[],[],[]
for i in range(n):
  if s[i]=='R':
    r+=[i+1]
  elif s[i]=='G':
    g+=[i+1]
  elif s[i]=='B':
    b+=[i+1]

ans=len(r)*len(g)*len(b)

for i in range(n-2):
  for dist in range(1,(n-i+1)//2):
    if s[i]!=s[i+dist] and s[i]!=s[i+dist*2] and s[i+dist]!=s[i+dist*2]:
      ans-=1
      

print(ans)
# Judge status: Accepted
x = [int(x) for x in input().split()]
if (sum(x)>21):
      print('bust')
else:
      print('win')
# Judge status: Accepted
N,K = map(int,input().split())
k = []
ans = ""
for i in range(N):
    S = input()
    k.append(S)
k.sort()
for i in range(len(k)):
    ans += k[i]
print(ans)
# Judge status: Accepted
N, M = map(int, input().split())
A = [input() for i in range(N)]
B = [input() for i in range(M)]
check = 0

for i in range(N - M + 1):
    for j in range(N - M + 1):
        bb = []
        for k in range(M):
            bb.append(A[i + k][j:j+M])
        if bb == B:
            check = 1

if check == 1:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    # A:和、B:差
    A = [0] * N
    B = [0] * N
    for i in range(N):
        x, y = map(int, readline().split())
        A[i] = x+y
        B[i] = x-y

    ans = max(max(A)-min(A), max(B)-min(B))
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n = int(input())
mod = 10**9 + 7
print(pow(10,n,mod) - 2*pow(9,n,mod) + pow(8,n,mod))
# Judge status: Accepted



def m():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    for i in range(N-K):
        left = A[i]
        right = A[K+i]
        if left < right:
            print('Yes')
        else:
            print('No')


m()
# Judge status: Accepted
S = input()
s_cnt =0
t_cnt =0

for s in S:
    if s == 'S':
        s_cnt += 1
    if s == 'T':
        t_cnt += 1
        if s_cnt >0:
            t_cnt -= 1
            s_cnt -= 1
print(t_cnt + s_cnt)
# Judge status: Accepted
n=int(input())
a=[0]*n
a[:]=map(int,input().split())
s=sum(a)
r=s
for ii in range(n):
  q=s-2*sum(a[0:ii+1])
  if r>abs(q):
    r=abs(q)
print(r)
# Judge status: Wrong Answer
N = int(input())
A = [list(map(int, input().split())) for i in range(2)]

res = 0
for i in range(N):
    s = 0
    for j in range(i+1):
        s += A[0][j]
        print('j:', s)
    for k in range(i, N):
        s += A[1][k]
        print('i:', s)
    res = max(res, s)
print(res)
# Judge status: Accepted
H = int(input())
n = -1
while H !=0 :
    n +=1
    H = H//2

print(2**(n+1) - 1)
# Judge status: Accepted
N=int(input())
if N >=1000:print('ABD')
else:print('ABC')
# Judge status: Accepted
A, B, C = map(int, input().split())
print(C-(A-B) if (A-B) < C else 0)
# Judge status: Accepted
n,k = map(int,input().split())
h = list(map(int,input().split()))

dp = [float("inf")]*(n)

dp[0] = 0

def chmin(a,b,index):
    if a > b:
        dp[index] = b

for i in range(n-1):
    for j in range(1,k+1):
        chmin(dp[i+j],dp[i] + abs(h[i] - h[i+j]),i+j)
        if i+j >= n-1:
            break
print(dp[n-1])
# Judge status: Wrong Answer
print("YNeos"[eval("2*"+input().replace(" ","-"))%2 > 0::2])
# Judge status: Accepted
N,D = map(int,input().split())

a = [list(map(int,input().split())) for _ in range(N)]

def isSquare(x):
  f = 1
  while f * f <= x:
    if f * f == x:
      return True
    else:
      f += 1
  return False
  
def calcSquareOfDistance(p1,p2,dimension):
  s = 0
  for i in range(dimension):
    s += (p1[i] - p2[i])**2
  return s

def judge(p1,p2,dimension):
  return isSquare(calcSquareOfDistance(p1,p2,dimension))

ans = 0
for i in range(N-1):
  for j in range(i+1,N):
    if judge(a[i],a[j],D):
      ans += 1
print(ans)
# Judge status: Wrong Answer
N = int(input())
C = {}

for i in range(N):
  a, b = map(int,input().split())
  C[b] = a
    
time = 0
D = sorted(C.items())

for i in range(len(D)):
  time += D[i][1]
  if time > D[i][0]:
    print('No')
    break
else:
  print('Yes')
# Judge status: Accepted
L,R,d = map(int,input().split())
cnt = 0

for i in range(L,R + 1):
  if i % d == 0:
    cnt += 1
    
print(cnt)
# Judge status: Accepted
x=int(input())
a=[]
for i in range(220):
  a.append(i**5)
for i in range(220):
  y=a[i]-x
  if y in a:
    print(i,a.index(y))
    break
  elif -y in a:
    print(i,-a.index(-y))
    break
# Judge status: Wrong Answer
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n % i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

N = int(input())
total = 0

for n in range(1, N + 1, 2):
    print(n)
    if len(divisor(n)) == 8:
        total += 1

print(total)
# Judge status: Accepted
#約数の個数の和（１~N）約数そのものを求めないので「速い」
def yakusu_num(N):
    ans =0
    for i in range(1,N+1):
        ans +=N//i #項数
    return ans


# 初期入力
import sys
input = sys.stdin.readline  #文字列では使わない

N = int(input())
ans =yakusu_num(N-1)

print(ans)
# Judge status: Accepted
def main():
    n = int(input())
    alis = list(map(int, input().split()))
    blis = list(map(int, input().split()))
    clis = list(map(int, input().split()))
    ans = 0
    tmp = ""
    for a in alis:
        ans += blis[a-1]
        if tmp == a-1:
            ans += clis[a-2]
        tmp = a
    print(ans)
    
    
if __name__ == "__main__":
    main()
# Judge status: Accepted
from heapq import *
N,M=map(int,input().split())
X=[[] for i in range(M)]
A,B=0,0
for i in range(N):
  A,B=map(int,input().split())
  if A>M:
    continue
  X[-A].append(B)
P=0
Q=[]
heapify(Q)
for i in range(M-1,-1,-1):
  for j in range(len(X[i])):
    heappush(Q,-X[i][j])
  if len(Q):
    P-=heappop(Q)
print(P)
# Judge status: Wrong Answer
N, Q = map(int,input().split())
S = input()
index = []
for i in range(N-1):
  if S[i] =='A' and S[i+1] == 'C':
    index.append(i)

for _ in range(Q):
  l,r = map(int,input().split())
  bottom = -1
  top = -1
  if len(index) != 0:
    for i in range(len(index)):
      if l <= index[i]+1:
        bottom = i
        break
    for j in range(len(index)):
      if index[-(i+1)] < r-1:
        top = len(index) -1 -j
        break
  Answer = 0
  if top >= bottom:
    Answer = top - bottom + 1
  print(Answer)
# Judge status: Accepted
N = int(input())
p_num = list(map(int, input().split()))
ans_list = [0] * N

for i in range(N):
    ans_list[p_num[i] - 1] = i+1

for i in range(N):
    print(ans_list[i])
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline

s = input()
#print(s.replace("?", "D"))


ans = []
for i in s:
    if i == "P":
        ans.append("P")
    else:
        ans.append("D")
print("".join(ans))
# Judge status: Accepted
n=input()
a=len(n)
b=0
for i in range(a):
  b=b+int(n[i])
if b%9==0:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
A_V = input().split()
A = int(A_V[0])
V = int(A_V[1])
B_W = input().split()
B = int(B_W[0])
W = int(B_W[1])
T = int(input())
 
if W - V <= 0:
  print('NO')
elif T < abs(B-A)/(W-V):
  print('NO')
else:
  print('YES')
# Judge status: Accepted
import math
def resolve():
    K = int(input())
    temp = 0
    for i in range(1, K + 1, 1):
        for j in range(1, K + 1, 1):
            for k in range(1, K + 1, 1):
                Result = math.gcd(i, j)
                temp += math.gcd(Result, k)
    print(temp)


resolve()
# Judge status: Accepted
import fractions
N = int(input())

a = list(map(int, input().split()))
ans = a[0]
for i in range(1,N):
    ans = fractions.gcd(ans, a[i])
print(ans)
# Judge status: Accepted
from math import ceil
n=int(input())
A=[int(input()) for _ in range(5)]
print(ceil(n/min(A))+4)
# Judge status: Accepted
S = input()

if S[0] == S[1] == S[2]:
    print("Yes")
elif S[1] == S[2] == S[3]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n,x=map(int,input().split())
a=list(map(int,input().split()))
asum=sum(a)

if a[0]>x:
    a[0]=x
    
for i in range(n-1):
    if a[i]+a[i+1]>x:
        a[i+1]=x-a[i]
        
asum=asum-sum(a)
print(asum)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

ans = 0
target = 1
for i in range(n):
    if a[i] == target:
        target += 1
    else:
        ans += 1

if target == 1:
    print(-1)
else:
    print(ans)
# Judge status: Wrong Answer
_ = input()
input_list = input().split()
input_list = [int(num) for num in input_list]

cnt = 0
while int(sum(input_list) % 2) != 1:
  input_list = [num // 2 for num in input_list]
  cnt+=1
print(cnt)
# Judge status: Wrong Answer
import itertools
n=int(input())
l=list(itertools.permutations(range(1,n+1),n))

a=tuple(map(int,input().split()))
b=tuple(map(int,input().split()))
a_index=0
b_index=0

for i in range(len(l)):
    if l[i]==a:
        a_index=i+1
    elif l[i]==b:
        b_index=i+1
    else:
        continue

result=abs(a_index-b_index)
print(result)
# Judge status: Wrong Answer
import sys

N = int(sys.stdin.readline().strip())
alpha = "abcdefghij"

tmp = ["a"] * N
print("".join(tmp))
for i in range(1, N):
    for j in range(0, N - i):
        tmp[N-j-1] = alpha[i]
        print("".join(tmp))
# Judge status: Wrong Answer
n,k = map(int,input().split())
a = 10**19
if n >= k:
    a=n//k
b=n%k
c=abs(b-k)
l=[n,a,b,c]
print(min(l))
# Judge status: Accepted
n = int(input())
l = list(map(int,input().split()))
import itertools
ans = 0
for i in itertools.combinations(l, 3):
    if abs(i[0]-i[1])<i[2] and i[2] < i[0]+i[1] and i[0]!=i[1] and i[1]!=i[2] and i[2]!=i[0]:
        ans += 1
print(ans)
# Judge status: Accepted
x,y = map(int , input().split())

t = 2
k = 4

flg = "No"
for i in range(x+1):
    if t*i + k*(x-i) == y:
        flg = "Yes"

print(flg)
# Judge status: Accepted
S,W=map(int,input().split())
if S<=W:print('unsafe')
else:print('safe')
# Judge status: Accepted
N, K = map(int, input().split())
ps = input().split()
ans = 0
temp = 0
for i in range(K):
  temp += (1+int(ps[i]))/2
ans = temp
for i in range(N-K):
  temp = temp + (1+int(ps[i+K]))/2 - (1+int(ps[i]))/2
  ans = max(ans, temp)
print(ans)
# Judge status: Accepted
S = list(input())
K = int(input())

for i, s in enumerate(S):
    if s == "a":
        pass
    elif ord('z') - ord(s) + 1 <= K:
        S[i] = 'a'
        K -= ord('z') - ord(s) + 1

K %= 26
S[-1] = chr((ord(S[-1]) - ord('a') + K) % 26 + ord('a'))

print("".join(S))
# Judge status: Wrong Answer
def main():
    length = int(input())
    numbers = list(map(int, input().split()))
    count = [0] * (10 ** 5 + 1)
    for num in numbers:
        count[num] += 1
    answer = 0
    for i in range(1, 10 ** 5 + 1):
        answer = max(answer, sum(count[i:i + 3]))
    print(answer)


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

buy = 0
money = 1000
for i in range(N-1):
    if buy != 0:
        money += buy*A[i]

    if A[i] < A[i+1]:
        buy = money // A[i]
        money -= buy * A[i]

if buy != 0:
    money += buy*A[-1]

print(money)
# Judge status: Accepted
for s in input().split():
  print(s[0],end='')
# Judge status: Accepted
import fractions

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

left = [0]*(N+1)
right = [0]*(N+1)
for i in range(N):
    left[i+1] = (fractions.gcd(left[i],A[i]))
    right[N-i-1] = fractions.gcd(right[N-i],A[N-1-i])

ans = 0
for i in range(N):
    ans = max(ans,fractions.gcd(left[i],right[i+1]))
print(ans)
# Judge status: Accepted
N = int(input())
wordlist = [input() for i in range(N)]

siri = wordlist[0][0]
wordpool = []
import sys

for word in wordlist:
    if word[0] == siri and word not in wordpool:
        siri = word[-1]
        wordpool.append(word)
    else:
        print("No")
        sys.exit()
        
print("Yes")
# Judge status: Accepted
N = int(input())
if(N%1000 != 0):
  print(1000-(N%1000))
else:print(0)
# Judge status: Accepted
data=input().split()
N=int(data[0])
M=int(data[1])
data_gate=[input().split() for i in range(M)]
data_min=[]
data_max=[]
for i in range(M):
    data_min.append(int(data_gate[i][0]))
    data_max.append(int(data_gate[i][1]))
m=max(data_min)
M=min(data_max)
if M>=m:
    ans=M-m+1
else:
    ans=0
print(ans)
# Judge status: Wrong Answer
# coding: utf-8

N, K = map(int,input().split())
A = list(map(int,input().split()))
for i in range(N):
    if A[i] == 1:
        cnt = i
        break

a = cnt + 1
b = N - 1 - i + 1
#print(a, b)
m1 = a // (K - 1)
n1 = a % (K - 1)

m2 = b // (K - 1)
n2 = b % (K - 1)
ans = 0
#print(m1, m2)
ans += m1 + m2
if n1 > 1:
    ans += 1
if n2 > 1:
    ans += 1
if N <= K:
    ans = 1
if K == 2:
    ans = 0
    ans += a - 1
    ans += N - 1 - cnt
print(ans)
# Judge status: Accepted
N,M=list(map(int,input().split()))
l=[list(input()) for i in range(N)]
mini=[list(input()) for i in range(M)]
mini="".join(sum(mini,[]))
for i in range(N-M+1):
   for j in range(N-M+1):
      let=""
      for k in range(i,M+i):
         let+="".join(l[k][j:j+M])
      if mini == let:
         print("Yes")
         exit()
print("No")
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
print("win" if a+b+c==21 else "bust")
# Judge status: Accepted
n=int(input())

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

if 0 in a:
    print(0)
    exit()

ans=1
for aa in a:
    ans*=aa
    if ans>10**18:
        print(-1)
        exit()
print(ans)
# Judge status: Accepted
N,K=map(int,input().split())
A=list(map(int,input().split()))
hyoutei=[0]*(N+1)
for i in range(K,N):#K+1-N
    if A[i]/A[i-K]>1:
        print("Yes")
    else:
        print("No")
# Judge status: Wrong Answer
import sys

n = int(input())
a = input()
s = list(a)

right = 0
left = 0

for i in s:
    if s == "(":
        right+=1
    else:
        left+=1

for _ in range(max(0,left - right)):
    sys.stdout.write("(")
sys.stdout.write(a)
for _ in range(max(0,right - left)):
    sys.stdout.write(")")
# Judge status: Accepted
n, m = map(int, input().split())
list_a = list(map(int, input().split()))

list_sort = sorted(list_a, reverse = True)

if list_sort[m-1] >= sum(list_sort)/(4*m):
  print('Yes')
else:
  print('No')
# Judge status: Accepted
L = list(map(int,list(input())))
print(sum(L))
# Judge status: Accepted
s = str(input())
ans = '2018' + s[4:]
print(ans)
# Judge status: Accepted
import numpy as np
from numba import njit

@njit
def f(A):
  N = len(A)
  cnt = 0
  for i in range(N):
    for j in range(i + 1, N):
      for k in range(j + 1, N):
        cnt += (A[k] < A[i] + A[j])
  return cnt

N = int(input())
A = np.int32(input().split())
A.sort()
print(f(A))
# Judge status: Accepted
n=list(map(int, input().split()))
ans=0
diff=n[1]-n[0]
for i in range(diff):
  ans=i+ans
yuki=ans-n[0]
print(yuki)
# Judge status: Wrong Answer
a,b,c = map(int, input().split())
 
if a==b or b==c or a==c:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
S = int(input())
X1 = (S + 10**9 - 1) // 10**9
X2 = X1 * 10**9 - S
print(X1, 1, X2, 10**9, '0 0')
# Judge status: Accepted
n = int(input())
s_list = [input() for i in range(n)]
print(len(list(set(s_list))))
# Judge status: Wrong Answer
x,a,b = list(map(int,input().split()))
if b < a:
    print("delicious")
elif a < b:
    if b-a <x:
        print("safe")
    else:
        print("dangerous")
# Judge status: Accepted
W,H,x,y = map(int, input().split())

if (W%2==1) or (H%2==1):
    print((W*H)/2,"0")
elif (x == int(W/2)) and (y == int(H/2)):
    print((W*H)/2,"1")
else:
    print((W*H)/2,"0")
# Judge status: Accepted
n = int(input())
ary = list(map(int,input().split()))
money = 1000
kabu = 0

for i in range(n-1):
    if ary[i] < ary[i+1] and money>ary[i]:
        kabu += money//ary[i]
        money -= kabu*ary[i]
    elif ary[i] > ary[i+1]:
        money += kabu*ary[i]
        kabu = 0

print(money+kabu*ary[n-1])
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

ans=0
for i in range (N):
    ans+=min(A[N-i],B[N-1-i])
    if  B[N-i-1]>A[N-i]:
        ans+=min(A[N-i-1],B[N-1-i]-A[N-i])
        A[N-i-1]-=min(A[N-i-1],B[N-1-i]-A[N-1])

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

ans = 1
mode = 0
prev = A[0]

for i in A:
    check = i - prev

    if check == 0:
        pass
    elif check > 0:
        if mode >= 0:
            mode = check
        else:
            ans += 1
            mode = 0
    else:
        # check < 0
        if mode <= 0:
            mode = check
        else:
            ans += 1
            mode = 0

    prev = i

print(ans)
# Judge status: Accepted
def gcd(a, b):
  while b:
    a, b = b, a % b
  return a

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n //= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

A, B = map(int, input().split())
l = prime_decomposition(gcd(A, B))

print(len(set(l))+1)
# Judge status: Accepted
N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

A.append(float("INF"))
AB = [0] * (N+1)
j = 0
for i in range(N):
    while A[j] < B[i]:
        j += 1
        if j == N:
            break
    AB[i+1] = AB[i] + j

ans = 0
B.append(float("INF"))
j = 0
for i in range(N):
    while B[j] < C[i]:
        j += 1
        if j == N:
            break
    ans += AB[j]

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

l, r = 0, 10 ** 9
while r - l > 1:
    x = (l + r) // 2

    cnt = 0
    for i in range(n):
        if a[i] % x == 0:
            cnt += a[i] // x - 1
        else:
            cnt += a[i] // x

    if cnt <= k:
        r = x
    else:
        l = x

print(r)
# Judge status: Wrong Answer
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

ans = n//min(a,b,c,d,e)+5
print(ans)
# Judge status: Accepted
import math
import sys
input = sys.stdin.readline
a, b = map(int, input().split())
if (a < 6):
    cost = 0
elif (a < 13):
    cost = b // 2
else:
    cost = b
print(cost)
# Judge status: Accepted
n,w=map(int,input().split())
dp=[0 for i in range(w+1)]
dp1=dp.copy()
for i in range(1,n+1):

	
    
	a,b=map(int,input().split())
	
	for j in range(1,w+1):
		dp1[j]=dp[j]
		if(a<=j):
			dp1[j]=max(dp1[j],dp[j-a]+b)
	
	dp=dp1.copy()
print(dp[w])
# Judge status: Accepted
S=list(input())

if len(set(S))==1:
  print("No")
else:
  print("Yes")
# Judge status: Accepted
a,b = [int(x) for x in input().split()]

def gcd(a,b):
    while b:
        a,b = b, a%b
    return a

d = gcd(a,b)
pf = {}
for i in range(2, int(d**0.5)+1):
    while d%i == 0:
        pf[i] = pf.get(i,0)+1
        d//=i
if d>1:
    pf[d] = 1
P = list(pf.keys())
print(len(P)+1)
# Judge status: Accepted
n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1, 105):
  for j in range(1, 105):
    for k in range(1, 105):
      v = i * i + j * j + k * k + i * j + j * k + k * i
      if v < 10050:
        ans[v] += 1

for i in range(n):
  print(ans[i + 1])
# Judge status: Wrong Answer
N = int(input())
print(int((N-1)*N/2))
# Judge status: Accepted
n = int(input())
f = False
c = []
d = []
for i in range(n//4+1):
    c.append(i)

for i in range(n//7+1):
    d.append(i)

for i in range(len(c)):
    for j in range(len(d)):
        if c[i]*4+d[j]*7 == n:
            f = True
            break

if f:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
a=input().split(" ")
b=set(a)
print(len(b))
# Judge status: Accepted
def main():
    INF = 10**18
    N,K = map(int,input().split())
    x = list(map(int,input().split()))
    ans = INF
    for i in range(K-1,N):
        ans = min(ans,abs(x[i]-x[i-K+1])+min(abs(0-x[i]),abs(0-x[i-K+1])))
    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
a, b = map(int,input().split())
num = (b-a)+1
if a > 0:
  print("Positive")
elif b < 0 and num%2==0:
  print("Positive")
elif b < 0 and num%2!=0:
  print("Negative")
elif a <= 0 and b >= 0:
  print("Zero")
# Judge status: Accepted
N = int(input())
ans = 0
for n in range(1, N+1):
    if n%2 == 1:
        count = 0
        for i in range(1, n+1):
            if n%i == 0:
                count += 1
        if count == 8:
            ans += 1

print(ans)
# Judge status: Wrong Answer
import bisect
n = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))

ans = 0
for i in b:
  x = bisect.bisect_right(a,i)
  y = bisect.bisect_left(c, i)
  #print(x, y)
  ans = ans+x*(n-y)

print(ans)
# Judge status: Wrong Answer
from collections import defaultdict
n = int(input())
dic = defaultdict(lambda: 51)
memo = 'abcdefghijklmnopqrstuvwxwz'
for i in range(n):
    s = input()
    memo = set(s) & set(memo)
    for m in memo:
        dic[m] = min(dic[m], s.count(m))
ans = ''
for m in sorted(memo):
    ans += m*dic[m]
print(ans)
# Judge status: Accepted
D = int(input())
C = list(map(int, input().split()))
S = []
N = 26
for d in range(D):
    S += [list(map(int, input().split()))]
#print(C)
#print(S)
myans = [d%N for d in range(D)]
for d in range(D):
  print(myans[d]+1)
# Judge status: Wrong Answer
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0

for h in range(0,c):
  for i in range(0,b):
    for j in range(0,a):
      if (x == ((500 * j) + (100 * i) + (50 * h))):
      	cnt = cnt +1

print(cnt)
# Judge status: Accepted
#別解

s = input()


s_new = s[:3] + '8' + s[4:]

print(s_new)
# Judge status: Accepted
a, b, x = map(int, input().split())

if a%x != 0:
    aa = a + (x - a % x)
else: aa = a

ans = (b - aa) // x + 1

print(ans)
# Judge status: Accepted
a = input()
t = "aeiou"

if a in t:
    print('vowel')
else:
    print('consonant')
# Judge status: Accepted
val = list(map(int, input().split()))
val.sort()
cnt = 0
for i in range(2):
    cnt += val[1]
    val[1] -= 1
    val.sort()
print(cnt)
# Judge status: Accepted
N = int(input())
if N%2 == 0:
  print(N//2)
else:
  print(N//2 + 1)
# Judge status: Accepted
X = int(input())
n = 100
i = 0
while n < X:
    n = int(n*1.01)
    i += 1
print(i)
# Judge status: Accepted
N = input()

sum = sum([int(i) for i in N])
if sum % 9 == 0:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
a = [int(i) for i in input().split()]
b = [(int(i)+1)/2 for i in input().split()]

he = sum(b[:a[1]])
maxer = he
for i in range(a[0] - a[1]):
    he -= b[i]
    he += b[i + a[1]]
    maxer = max(he, maxer)

print(maxer)
# Judge status: Accepted


if __name__ == "__main__":
    K, N = map(int, input().split())
    A = list(map(int, input().split()))
    # print(A)
    A_dif = []
    for i in range(len(A)-1):
        # print(A[i + 1])
        # print(A[i])
        A_dif.append(A[i + 1] - A[i])
    A_dif.append((abs(K - A[-1]) + A[0]))
    # print(A_dif)
    A_dif.sort(reverse=True)
    ret = sum(A_dif[1:])
    print(ret)
# Judge status: Wrong Answer
import sys

O = list(input())
E = list(input())
for o, e in zip(O, E):
    sys.stdout.write(o + e)
if len(O) - len(E) == 1:
    sys.stdout.write(E[-1])
print()
# Judge status: Accepted
import collections

N = int(input())
S = list(input() for i in range(N))
S.sort()

common = collections.Counter(S).most_common()
N_common = common[0][1]

candidates = [cand for cand in common if cand[1] == N_common]

for i in sorted(candidates):
    print(i[0])
# Judge status: Accepted
w = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]

s = input()

print(6-w.index(s)+1)
# Judge status: Accepted
LI = lambda: list(map(int, input().split()))

N, D = LI()
XY = [LI() for _ in range(N)]


def main():
    ans = 0
    d2 = D ** 2
    for x, y in XY:
        if x ** 2 + y ** 2 <= d2:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
s=list(input())
n=len(s)
if s[::1] == s[::-1] and s[:((n-1)//2):1]==s[:((n-1)//2):-1] and s[((n+3)//2)-1:n:1]==s[((n+3)//2)-1:n:-1]:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n, *l = map(int, open(0).read().split())
ans = 0
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if(l[i]==l[j] or l[j]==l[k] or l[k]==l[i]): continue
            if(l[i]+l[j]<=l[k] or l[j]+l[k]<=l[i] or l[k]+l[i]<=l[j]): continue
            ans += 1
print(ans)