Harryxun/stf_run huggingface dataset:
N = int(input())
A = list(map(int, input().split()))
dif = 0
sum = 0

for i in range(N - 1):
  if A[i] > A[i +1]:
    dif = A[i] - A[i + 1]
    sum += dif
    A[i +1] = A[i + 1] + dif
    
  else:
    
print(sum)


### FIXED CODE ###

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

for i in range(N - 1):
  if A[i] > A[i + 1]:
    dif = A[i] - A[i + 1]
    sum += dif
    A[i +1] = A[i + 1] + dif
    
print(sum)
s=str(input())
s1=str[:5]
s2=str[6:12]
s3=str[14:]
print('{} {} {}'.format(s1,s2,s3))

### FIXED CODE ###

s=str(input())
s1=s[:5]
s2=s[6:13]
s3=s[14:]
print('{} {} {}'.format(s1,s2,s3))
n = int(raw_input())
s = map(int, raw_input().split())
m = int(raw_input())
t = map(int, raw_input().split())

s = list(set(s))
s.sort()
l = s[len(s)]
a = [0 for i in range(l-1)]
for i in s:
    a[i] += 1

count = 0
for i in t:
    if i < l
    count += a[i] 
print count

### FIXED CODE ###

n = int(raw_input())
s = map(int, raw_input().split())
m = int(raw_input())
t = map(int, raw_input().split())

s = list(set(s))
s.sort()
l = len(s)-1

count = 0
for i in t:
    low = 0
    high = l
    while low <= high:
        mid = (low+high)/2
        if s[mid] == i:
            count += 1
            break
        if s[mid] < i:
            low = mid+1
        else:
            high = mid-1

print count
S = input()
T = input()

N = len(T)
count = 0
count_list = []

index_list = []

if len(S)-len(T) != 0:
    for i in range(len(S)-N+1):
        index_list.append(S[0+i:N+i])

    for i in range(len(index_list)):
        count = 0
        for j in range(N):
            if index_list[i][j] == T[j]:
                count +=1
                count_list.append(count)
                
    print(N - max(count_list))
else:
    for i in range(N):
        if S[i] == T[i]:
            count += 1
    print(N - count)

### FIXED CODE ###

S = input()
T = input()

N = len(T)
count = 0
count_list = []
index_list = []

if len(S)-len(T) != 0:
    for i in range(len(S)-N+1):
        index_list.append(S[0+i:N+i])

    for i in range(len(index_list)):
        count = 0
        for j in range(N):
            if index_list[i][j] == T[j]:
                count +=1
        count_list.append(count)
                
    print(N - max(count_list))
else:
    for i in range(N):
        if S[i] == T[i]:
            count += 1
    print(N - count)
N=int(input())
count=1
size=1
p=list(map(int,input().split()))
q=[p[0]]

j=0
while True:
  if j>=N-2:
    break
  while (q[j]-q[j+1])*(q[j+1]-q[j+2])>=0:
    j+=1
  count+=1
  j+=2
print(count)

### FIXED CODE ###

N=int(input())
count=1
size=1
p=list(map(int,input().split()))
q=[p[0]]
for i in range (1,N):
  if p[i]!=p[i-1]:
    q.append(p[i])
    size+=1
j=0
while True:
  if j>=size-2:
    break
  while (q[j]-q[j+1])*(q[j+1]-q[j+2])>=0:
    if j>=size-3:
      count-=1
      break
    j+=1    
  count+=1
  j+=2
print(count)
import math

a,b,c,d = map(int, input().split())
#print((b//c - (a - 0.1)//c) + (b//d - (a - 0.1)//d) - (b//math.gcd(c,d) - (a - 0.1)//math.gcd(c,d))) 
x = (b//c - (a - 0.1)//c)
y = (b//d - (a - 0.1)//d)
z = (b//((c * d)//math.gcd(c,d)) - (a - 0.1)//((c * d)//math.gcd(c,d)))

print(int((b - a + 1) - (x + y - z)))


### FIXED CODE ###

import fractions

a,b,c,d = map(int, input().split())
x = (b//c - (a - 1)//c)
y = (b//d - (a - 1)//d)
z = (b//((c * d)//fractions.gcd(c,d)) - (a - 1)//((c * d)//fractions.gcd(c,d)))

print(int((b - a + 1) - (x + y - z)))
n=int(input())
X=[]
Y=[]
A=[0]*n
for i in range(n):
  A[i]=int(input())
  a=A[i]
  for j in range(a):
    x=[0]*a
    y=[0]*a
    x[j],y[j]=[int(s) for s in input().split()]
  X.append(x)
  Y.append(y)
  

c=0
for i in range(n):
  l=[1]*n
  for j in range(i,n-i):
    if l[j]==0:continue
    for k in range(len(X[j])):
      b=X[j][k]
      #l[b-1]*
      #b=Y[j][k]
  if c < l.count(1):
    c=l.count(1) 
  
        
  
print(c)  
   

### FIXED CODE ###

n=int(input())
X=[]
Y=[]
A=[0]*n
for i in range(n):
  A[i]=int(input())
  a=A[i]
  x=[0]*a
  y=[0]*a
  for j in range(a):
    x[j],y[j]=[int(s) for s in input().split()]
  X.append(x)
  Y.append(y)
  
s=0
for i in range(2**n):
  c=0
  d=0
  B=[0]*n
  for j in range(n):
    if((i >> j) & 1):
      c=c+1
      B[j]=1
  for k in range(n):
    if B[k]==1:
      for j in range(A[k]):
        if Y[k][j]!=B[X[k][j]-1]:
          d=-1
          break
    if d<0:
      break
  if s<c and d==0:
    s=c
      
      
print(s)
import numpy as np
N, H = map(int, input().split())
A, B = np.array(tuple(tuple(map(int, input().split())) for _ in range(N))).T

m = A.max()
C = B > m
Q, R = np.divmod(H - B[C].sum(), m)

print(C.sum() + Q + bool(R))


### FIXED CODE ###

import numpy as np
N, H = map(int, input().split())
A, B = np.array(tuple(tuple(map(int, input().split())) for _ in range(N))).T

m = A.max()
B.sort()
C = iter(B[B > m][::-1])

count = 0

try:
    while H > 0:
        H -= next(C)
        count += 1
except StopIteration:
    Q, R = divmod(H, m)
    print(count + Q + bool(R))
else:
    print(count)
n, m = map(int, input().split())
if m == 1:
  print(0)
  exit()
x = list(map(int, input().split()))
x.sort()
d = [0]*(m-1)
for i in range(m-1):
  d[i] = x[i+1] - x[i]
d.sort(reverse = True)
sum = sum(d)
for i in range(n-1):
  sum -= d[i]
print(sum)

### FIXED CODE ###

n, m = map(int, input().split())
if m == 1 or n >= m:
  print(0)
else:
  x = list(map(int, input().split()))
  x.sort()
  d = [0]*(m-1)
  for i in range(m-1):
    d[i] = x[i+1] - x[i]
  d.sort(reverse = True)
  sum = sum(d)
  for i in range(n-1):
    sum -= d[i]
  print(sum)
# coding: utf-8
# Here your code !
a=input()
b=a.split(" ")
N=int(b[0])
K=int(b[1])

ans=[]
l=[]
for i in range(N):
    l.append(int(input()))
for w in range(K):
    ans.append(max(l))
print(sum(ans))

### FIXED CODE ###

# coding: utf-8
# Here your code !
a=input()
b=a.split(" ")
N=int(b[0])
K=int(b[1])
ans=[]
c=input()
l=c.split(" ")
l1=map(int,l)
l2=list(l1)
for w in range(K):
    ans.append(max(l2))
    max_idx = l2.index(max(l2))
    del l2[max_idx]
print(sum(ans))
s = input()
t = input()
a = for i in range(len(s)):
  s[i] == t[i]
b = len(t) - len(s) == 1
if a and b:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

s = input()
t = input()

same = 0
for i in range(len(s)):
	if s[i] == t[i]:
		same += 1

if same == len(s) and len(t) - len(s) == 1:
	print("Yes")

else:
	print("No")
from collections import defaultdict
def enumerate_primes(n):
    if n == 1: return []
    primes = [2] + list(range(3, n + 1, 2))
    i, p = 0, 1
    while p * p <= n:
        if primes[i] != 0:
            p = primes[i]
            primes = [prime if (prime % p != 0 or prime == p) else 0 for prime in primes]
        i += 1
    return [p for p in primes if p != 0]

def main():   
    n = int(input())
    A = list(map(int, input().split()))
    primes = enumerate_primes(int(max(A) ** 0.5) + 1)
    d = defaultdict(int)
    for a in A:
        for p in primes:
            if a % p == 0:
                d[p] += 1
    m = max(d.values())
    if m == n:
        print('not coprime')
    elif m >= 2:
        print('setwise coprime')
    else:
        print('pairwise coprime')

if __name__ == '__main__':
    main()



### FIXED CODE ###

from functools import reduce
from math import gcd
def main():   
    n = int(input())
    A = list(map(int, input().split()))
    C = [0] * 1000001
    for a in A: C[a] += 1
    if reduce(gcd, A) != 1:
        print('not coprime')
    elif all(sum(C[i::i]) <= 1 for i in range(2, 1000001)):
        print('pairwise coprime')
    else:
        print('setwise coprime')

if __name__ == '__main__':
    main()
n = int(input())
d,x = map(int,input().split())
li = [int(input()) for i in range(n)]

choco = x
for i in range(n):
  choco += 1 + (d-1)//li[i]
print(choco)

### FIXED CODE ###

a = int(input())
b = min(a,int(input()))
c = int(input())
d = min(c,int(input()))
print(b+d)
n,k=map(int, input().split())
a = list(map(int, input().split()))
a=sorted(a)
if k==0:
    print(max(a))
    exit()

lo=0
hi=2*(10**9)
oldmid=0
while True:
    mid=(hi+lo)//2
    cnt=0
    for i in range(n):
        cnt+=(a[i]*2)//mid
    if cnt>k:
        lo=mid
    elif cnt<=k:
        hi=mid
    if oldmid==mid:
        print(mid//2+mid%2)
        break
    oldmid=mid


### FIXED CODE ###

n,k=map(int, input().split())
a = list(map(int, input().split()))
a=sorted(a,reverse=True)
if k==0:
    print(max(a))
    exit()
import math
lo=0
hi=10**9
oldmid=0
while True:
    mid=(hi+lo)/2
    cnt=0
    for i in range(n):
        cnt+=round(a[i]/mid-0.5)
    if cnt>k:
        lo=mid
    elif cnt<=k:
        hi=mid
    if oldmid-0.000001<=(hi+lo)/2<=oldmid+0.000001:
        print(min(math.ceil(lo), max(a)))
        break
    oldmid=mid
l = list(map(int,input().split()))

for i in range(len(l)):
  if l[i] == 0:
    return i


        

### FIXED CODE ###

l = list(map(int,input().split()))
for i in range(len(l)):
	if l[i] == 0:
		print(i+1)
import sys
input = sys.stdin.readline
ma = lambda : map(int,input().split())
ni = lambda : int(input())
a,b,x = ma

if a<=x and a+b>=x:print("Yes")
else:print("No")


### FIXED CODE ###

import sys
input = sys.stdin.readline
ma = lambda : map(int,input().split())
ni = lambda : int(input())
a,b,x = ma()

if a<=x and a+b>=x:print("YES")
else:print("NO")
import sys
from heapq import *
def input(): return sys.stdin.readline().strip()


def main():
    s = input()
    L = len(s)
    K = int(input())

    initial = []
    for i, c in enumerate(s):
        heappush(initial, (c, i))

    appeared = set([])
    string =[]
    cnt = 0
    while True:
        c, i = heappop(initial)
        for j in range(i + 1, L + 1):
            heappush(string, s[i:j])
        while initial[0][0] == c:
            c, i = heappop(initial)
            for j in range(i + 1, L + 1):
                heappush(string, s[i:j])
        while string:
            ans = heappop(string)
            #print(ans)
            if ans not in appeared:
                cnt += 1
                appeared.add(ans)
            if cnt == K:
                print(ans)
                return


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
from heapq import *
def input(): return sys.stdin.readline().strip()


def main():
    """
    文字列のソートをする際には計算量に要注意！
    数字の大小比較と違って文字列の比較の場合は１文字１文字左から順番に見ないといけない。
    そのため一回の比較でO(比較文字列の長さ)分の計算量がかかる。
    特に長さMの文字列N個をソートするのにかかる時間は
            ❌O(NlogN)
            ⭕️O(MNlogN)

    そこで文字列のソート時には文字数をなるべく小さくするのがポイント。
    今回K<=5なので、「答えはK<=5文字以下になる」のがミソ。
    """

    s = input()
    L = len(s)
    K = int(input())
    string = set([])
    for i in range(L):
        for j in range(i + 1, min(i + K, L) + 1):
            string.add(s[i:j])

    string = list(string)
    heapify(string)
    for _ in range(K):
        ans = heappop(string)
    print(ans)


if __name__ == "__main__":
    main()
input()
li = map(int, input().split())
print(min(li), max(li), sum(li))


### FIXED CODE ###

input()
li = list(map(int, input().split()))
print(min(li), max(li), sum(li))
s = input()
d = {}
for i in s:
  if i in d:
    d[i] += 1
  else:
    d[i] = 1

for key in d:
  if d[key] %2 != 0
  	print("No")
    break


### FIXED CODE ###

flag = 1
s = input()
d = {}
for i in s:
  if i in d:
    d[i] += 1
  else:
    d[i] = 1

for key in d:
    if d[key] %2 != 0:
      flag = 0     
if flag == 0:
    print("No")
else:
    print("Yes")
l=int(input())
x=l/3
#print((l/3)**3)
print(f"{x*x*x:0.9f}")


### FIXED CODE ###

l=float(input())

x=l/3
print((l/3)**3)
#print(f"{x*x*x:0.6f}")
a=int(input())
b=[]
bb=list(input())
for i in bb:
  b.append(i.upper())
c=0
for i in range(a):
  if b[i]=='A':
    if b[i]+b[i+1]+b[i+2]=='ABC':
      c+=1
    else:
      pass
  else:
    pass
print(c)    


### FIXED CODE ###

n=int(input())
s=list(input())
d=0
for i in range(n):
  if n-(i+1)>=2:
    if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
      d+=1
  else:
    pass
print(d)
import sys

print(sys.argv[2])

### FIXED CODE ###

D, T, S = map(int, input().split())
print("Yes" if T * S >= D else "No")
n = int(input())
s = input().replace(".","")
lists = s.split()
print(lists.count("TAKAHASHIKUN")+lists.count("takahashikun")+lists.count("Takahashikun")

### FIXED CODE ###

print("Yes" if len(set(input()))==3 else"No")
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)

def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g

def lcm_core(a,b):
    g = gcd_core(a,b)
    return (a*b)//g

def lcm(arr):
    l = lcm_core(arr[0],arr[1])
    for i in range(2,len(arr)):
        l = lcm_core(l,arr[i])
    return l

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

print(lcm(T))

### FIXED CODE ###

def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)

def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g

def lcm_core(a,b):
    g = gcd_core(a,b)
    return (a*b)//g

def lcm(arr):
    l = lcm_core(arr[0],arr[1])
    for i in range(2,len(arr)):
        l = lcm_core(l,arr[i])
    return l

N = int(input())
T = [int(input()) for _ in range(N)]
if N==1:
    print(T[0])
else:
    print(lcm(T))
N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        w = (N * h * n) / (4 * h * n - N * n - N * h)
        if w > 0 and w % 1 == 0:
            print(h, n, int(w))
            exit()

### FIXED CODE ###

N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        if 4 * h * n - N * n - N * h > 0:
            w = (N * h * n) / (4 * h * n - N * n - N * h)
            if w > 0 and w % 1 == 0:
                print(h, n, int(w))
                exit()
#!/usr/bin/env python3
# atcoder 
# Türkçe konuşyorum
# Türkler var mı
# memnün oldum

K = int(input())
S = input()
slen = len(S)

if(slen >= 100):
    S = S[:99]


if(slen < K):
    print(S)
else: 
    pr = S[:K]
    #
    change = S[K:]
    #print(change)
    for i in range(3):
        change = change.replace(change[i], ".")
    print(pr + change[:3])



### FIXED CODE ###

#!/usr/bin/env python3
# atcoder 
# Türkçe konuşyorum
# Türkler var mı
# memnün oldum

K = int(input())
S = input()



if(len(S) <= K):
    print(S)
else:
    print(S[:K] + '.' * 3)
    #for i in range(3):
    #    change = change.replace(change[i], '.')
    #print(S[:K] + change[:3])
n = int(input())
a_list = list(map(int,input().split()))
print_list = []


# ソートされたリストのインデックスを返す
for i in range(len(s)):
    print(sorted(range(len(s)), key=lambda k:s[k])[i] + 1, end=" ")

### FIXED CODE ###

# ABC 142 C go to school
n = int(input())
s = list(map(int,input().split()))

# ソートされたリストのインデックスを返す
s = sorted(range(len(s)), key=lambda k:s[k])
ans = [x+1 for x in s]
print(*ans)
N = int(input())

odd = 0
even = 0
for i in range(N-1):
	if i % 2 == 0:
		odd += 1
	else:
		even += 1

print(odd/(even + odd))

### FIXED CODE ###

N = int(input())

odd = 0
even = 0
for i in range(N):
	if i % 2 == 0:
		odd += 1
	else:
		even += 1

print(odd/(odd + even))
from collections import defaultdict

S = input()
K = int(input())

alphabet = defaultdict(list)
for i, s in enumerate(S):
    alphabet[s].append(i)

alpha_list = sorted(alphabet.keys())
cand = []
i = 0
while len(cand) < K:
    for j in alphabet[alpha_list[i]]:
        for l in range(1, len(S)-j+1):
            cand.append(S[j:j+l])
    i += 1
cand = sorted(list(set(cand)))
print(cand[K-1])

### FIXED CODE ###

# ABC 097 C

from collections import defaultdict

S = input()
K = int(input())

alphabet = defaultdict(list)
for i, s in enumerate(S):
    alphabet[s].append(i)

alpha_list = sorted(alphabet.keys())
cand = []
i = 0
while len(cand) < K:
    for j in alphabet[alpha_list[i]]:
        if len(S)-j+1 >= K:
            for l in range(1, K+1):
                cand.append(S[j:j+l])
        else:
            for l in range(1, len(S)-j+1):
                cand.append(S[j:j+l])
    cand = list(set(cand))
    if len(cand) >= K:
        break
    i += 1
cand = sorted(cand)
print(cand[K-1])
N = int(input())
 
L = map(int, input().split())
L.sort()
ret = 0
if N >= 3:
  for i in range(N - 2):
    for j in range(i + 1, N - 1):
      if L[i] != L[j]:
        for k in range(j + 1, N):
          if L[i] != L[k] and L[j] != L[k] and L[i] + L[j] > L[k]:
            ret += 1
print(ret)

### FIXED CODE ###

N = int(input())
 
L = list(map(int, input().split()))
L.sort()
ret = 0
if N >= 3:
  for i in range(N - 2):
    for j in range(i + 1, N - 1):
      if L[i] != L[j]:
        for k in range(j + 1, N):
          if L[i] != L[k] and L[j] != L[k] and L[i] + L[j] > L[k]:
            ret += 1
print(ret)
import sympy
a, b = map(int,input().split())
ans = 1
gcd_div = sympy.divisors(sympy.gcd(a, b))[:-1]
for i in gcd_div:
    if sympy.isprime(i) == True:
        ans += 1
print(ans)


### FIXED CODE ###

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

import fractions
a, b = map(int,input().split())

if fractions.gcd(a, b) == 1:
    print(1)
else:
    print(len(factorization(fractions.gcd(a, b))) + 1)
d=int(input())
*c,=map(int, input().split())
s=[]
for _ in range(d):
    *si,=map(int, input().split())
    s.append(si)
#t=[int(input())-1 for _ in range(d)]
last=[-1]*26

ss=0
for i in range(d):
    ind=-1
    smx=-10**10
    for j in range(26):
        ssj=ss+s[j][t[j]]
        for j in range(26):
            if k!=j:
                ssj-= c[k]*(i-last[k])
        if smx<ssj:
            smx=max(ss,smx)
            ind=j
    last[ind]=i
    ss=smx        
    print(j)




### FIXED CODE ###

d=int(input())
*c,=map(int, input().split())
s=[]
for _ in range(d):
    *si,=map(int, input().split())
    s.append(si)

for _ in range(d):
    print(1)
import numpy as np
N=int(input())
X = list(map(int,input().split()))
X.sort()
a=list()
c=N-1
for i in range(X[0],X[c]):
    b=0
    for j in range(0,N):
        if i-X[j]>10**5:
            break
        b+=(i-X[j])**2
    a.append(b)
print(min(a))

### FIXED CODE ###

import numpy as np
N=int(input())
X = list(map(int,input().split()))
X.sort()
a=list()
c=N-1
for i in range(X[0],X[c]+1):
    b=0
    for j in range(0,N):
        if i-X[j]>10**5:
            break
        b+=(i-X[j])**2
    a.append(b)
print(min(a))
# https://atcoder.jp/contests/abc068/tasks/abc068_b


def two_factor(x):
    cnt = 0
    while x % 2 == 0:
        cnt += 1
        x //= 2
    return cnt


N = int(input())
a = map(two_factor, range(1, N + 1))
max_cnt = max(a)
print(list(range(1, N + 1)).index(max_cnt) + 1)


### FIXED CODE ###

# https://atcoder.jp/contests/abc068/tasks/abc068_b


def two_factor(x):
    cnt = 0
    while x % 2 == 0:
        cnt += 1
        x //= 2
    return cnt


N = int(input())
a = list(map(two_factor, range(1, N + 1)))
max_cnt = max(a)
print(a.index(max_cnt) + 1)
import collections
n = int(input())
a = list(map(int, input().split()))
dif = [0] * n
sum_c = 0
for i, v in collections.Counter(a).items():
    if v < 2:
        continue
    val = v * (v - 1) // 2
    dif[i] = 2 * (v - 1) // 2
    sum_c += val
print('\n'.join([int(sum_c - data[i]) for i in a])

### FIXED CODE ###

from collections import Counter

n = int(input())
a = list(map(int, input().split()))
dif = [0] * (n + 1)
sum_c = 0
c = Counter(a)
for i, v in c.items():
    if v < 2:
        continue
    val = v * (v - 1) / 2
    dif[i] = v - 1
    sum_c += val
print('\n'.join([str(int(sum_c - dif[i])) for i in a]))
n = int(input())

def F(a, b):
    return max(len(str(a)), len(str(b)))

ans = 10**10
for i in range(1, n**(1/2)+1):
    j = n / i
    if (n/i)%1 == 0:
        j = n // i
        if ans > F(i, j):
            ans = F(i, j)
        
print(ans)

### FIXED CODE ###

# ABC 057 C - Digits in Multiplication
# 2020/04/07　20:6-
n = int(input())

def F(a, b):
    A = len(str(a))
    B = len(str(b))
    return max(A, B)

ans = 10**12
for i in range(1, int(n**(1/2))+1):
    j = n / i
    if j%1 == 0:
        j = n // i
        if ans > F(i, j):
            ans = F(i, j)
            
print(ans)
from collections import combinations

n = int(input())

count = {x:0 for x in "MARCH"}

for _ in range(n):
  s = input()[0]
  if s in count:
    count[s] += 1

sum_count = 0
for a, b, c in combinations("MARCH", 3):
  sum_count += count[a] * count[b] * count[c]

print(sum_count)

### FIXED CODE ###

from itertools import combinations
 
n = int(input())
 
count = {x:0 for x in "MARCH"}
 
for _ in range(n):
  s = input()[0]
  if s in count:
    count[s] += 1
 
sum_count = 0
for a, b, c in combinations("MARCH", 3):
  sum_count += count[a] * count[b] * count[c]
 
print(sum_count)
from heapq import heapify, heappop, heappush
N=int(input())
A=list(map(int, input().split()))

class MaxHeap:
    def __init__(self, li):
        self.hp = []
        for e in li:
            heappush(self.hp, -e)

    def push(self, x):
        heappush(self.hp, -x)

    def pop(self):
        ret = heappop(self.hp)
        ret *= -1
        return ret

    def seak(self):
        return -self.hp[0]

    def sum(self):
        return -sum(self.hp)

A1=A[:N]
A2=A[N:2*N]
A3=A[2*N:]

heapq.heapify(A1)
A1_sum=sum(A1)
A1_li=[A1_sum]
for a in A2:
  p=heapq.heappushpop(A1,a)
  A1_sum+=a-p
  A1_li.append(A1_sum)
  
A3=MaxHeap(A3)
A3_sum=sum(A3)
A3_li=[A3_sum]
for a in A3[::-1]:
  A3.push(a)
  A3_sum+=a
  p=A3.pop()
  A3_sum-=p
  A3_li.append(A3_sum)
  
A3_li=A3_li[::-1]  
ans=False
for a1, a3 in zip(A1_li, A3_li):
  if not ans:
    ans=a1-a3
  else:
    ans=max(ans, a1-a3)
print(ans)

### FIXED CODE ###

from heapq import heapify, heappop, heappush
N=int(input())
A=list(map(int, input().split()))

class MaxHeap:
    def __init__(self, li):
        self.hp = []
        for e in li:
            heappush(self.hp, -e)

    def push(self, x):
        heappush(self.hp, -x)

    def pop(self):
        ret = heappop(self.hp)
        ret *= -1
        return ret

    def seak(self):
        return -self.hp[0]

    def sum(self):
        return -sum(self.hp)

A1=A[:N]
A2=A[N:2*N]
A3=A[2*N:]

heapify(A1)
A1_sum=sum(A1)
A1_li=[A1_sum]
for a in A2:
  heappush(A1, a)
  p=heappop(A1)
  A1_sum+=a-p
  A1_li.append(A1_sum)
  
A3_sum=sum(A3)
A3=MaxHeap(A3)

A3_li=[A3_sum]
for a in A2[::-1]:
  A3.push(a)
  A3_sum+=a
  p=A3.pop()
  A3_sum-=p
  A3_li.append(A3_sum)
  
A3_li=A3_li[::-1]  
ans=False
for a1, a3 in zip(A1_li, A3_li):
  if not ans:
    ans=a1-a3
  else:
    ans=max(ans, a1-a3)
print(ans)
s,t=map(str,input().split())
print(t+s)


### FIXED CODE ###

a,b,k=map(int,input().split())
if a>k:
  print(str(a-k) + " " + str(b))
else:
  if b-(k-a) < 0:
    print("0 0")
  else:
  	print(str(0) +" " +str(b-(k-a)))
M, d = input().split()
d10 = int(d[0])
d1 = int(d[1])
M = int(M)
ans = 0
import sys
for j in range(2,d10+1):
  for i in range(2,10):
    if 10*j+i>d10*10+d1:
      print(ans)
      sys.exit()
    if M >=j*i:
      ans+=1

### FIXED CODE ###

import sys
M, d = input().split()
if int(d)>=10:
  d10 = int(d[0])
  d1 = int(d[1])
else:
  print(0)
  sys.exit()
M = int(M)
ans = 0
for j in range(2,d10+1):
  for i in range(2,10):
    if 10*j+i>d10*10+d1:
      print(ans)
      sys.exit()
    if M >=j*i:
      ans+=1
print(ans)