Harryxun/stf_run huggingface dataset:
import collections
N=int(input())
S=input()
str_list=tuple(S)
result=0
c=collections.Counter(str_list)
RGB_list=c.most_common()
def my_index_multi(A,x):
    return [i for i, _x in enumerate(A) if _x == x]

list1=my_index_multi(str_list,RGB_list[0][0])
list2=my_index_multi(str_list,RGB_list[1][0])
list3=my_index_multi(str_list,RGB_list[2][0])
list23=[]
l_append=list23.append
if RGB_list[2][0]==0 or RGB_list[1][0]==0:
    print(0)
else:
    for i in list3:
        for j in list2:
            l_append([i,j])
    for k in list1:
        for l in list23:
            if k==l[0]*2-l[1] or k==l[1]*2-l[0] or k==(l[0]+l[1])/2:
                result+=1
    print(int(RGB_list[0][1]*RGB_list[1][1]*RGB_list[2][1]-result))

### FIXED CODE ###

def main():
    import collections
    import sys
    sys.setrecursionlimit(5000000)
    input = sys.stdin.readline
    N=int(input())
    S=input()
    if N<=3:
        print(0)
    else:
        str_list=list(S[:N])
        result=0
        c=collections.Counter(str_list)
        RGB_list=c.most_common()

        if len(c)<3:
            print(0)

        else:

            list1=[i for i, x in enumerate(str_list) if x == RGB_list[0][0]]
            list2=[i for i, x in enumerate(str_list) if x == RGB_list[1][0]]
            list3=[i for i, x in enumerate(str_list) if x == RGB_list[2][0]]
            list23=[]

        
            for i in list3:
                for j in list2:
                    list23+=[2*i-j,2*j-i,(i+j)/2]
            c1=collections.Counter(list23)
            for k in list1:
                for l in c1.keys():
                    if k==l:
                        result+=c1[l]
            print(int(RGB_list[0][1]*RGB_list[1][1]*RGB_list[2][1]-result))

if __name__ == '__main__':
    main()
n = int(input())

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

t = max(A)

import math

for i in A:
    t = math.gcd(t, i)
print(t)

### FIXED CODE ###

n = int(input())

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

t = max(A)

from fractions import gcd

for i in A:
    t = gcd(t, i)
print(t)
x, n = [int(i) for i in input().split(' ')]
if n > 0:
    p = [int(i) for i in input().split(' ')]

    p.append(x)
    p.sort()
    i = p.index(x)

    y = x
    double = 0

    for j in range(1, i + 1):
        if i == j:
            low = x - j - 1
        elif not x - j + double == p[i - j]:
            if x == p[i - j]:
                double += 1
            else:
                low = x - j + double
                break
    double = 0
    for j in range(1, len(p) - i + 1):
        if j + i == len(p):
            high = x + j + 1
        elif not x + j - double == p[i + j]:
            if x == p[i + j]:
                double += 1
            else:
                high = x + j - double
                break

    if x - low > high - x:
        print(high)
    else:
        print(low)
else:
    print(x)
    exit()

### FIXED CODE ###

x, n = [int(i) for i in input().split(' ')]

if n:
    p = [int(i) for i in input().split(' ')]
    if x in p:
        for i in range(1, 101):
            if not x - i in p:
                print(x - i)
                exit()
            elif not x + i in p:
                print(x + i)
                exit()
    else:
        print(x)
else:
    print(x)
n=int(input())
s=list(input())
k=int(input())
l=s[k-1]
for i in range(n):
  if s[i]!=l:
    s[i]="*"
print("".join(s))

### FIXED CODE ###

a,b,c=map(int,input().split())
if a<c<b or b<c<a:
    print("Yes")
else:
    print("No")
s=input()
temp=0
tem=0
tot=0
if len(s)>10**3:
        
    for i in range(len(s)):
        tem=1
        temp=1
        flag=0
        for j in range(i+1,len(s)):
            if s[j]==s[i]:
                temp+=1
            tem+=1
            if temp>(tem//2 ):
                print(i+1,j+1)
                
                flag=1
                tot=1
                break
        if flag:
            break
    if tot==0:
        print("-1 -1")
else:
    for i in range(len(s)-2):
        if s[i]==s[i+1]:
            print(i+1,i+2)
            flag=1
            break
        elif s[i]==s[i+2]:
            print(i+1,i+3)
            flag=1
            break
    if flag==0:
        print("-1 -1")        

### FIXED CODE ###

n=int(input())
print(int(n*(n+1)/2))
while True:
   H, W = map(int, input().split())
   if H == 0 and W == 0:
      break
   for i in range(int(H/2)):
      if W % 2 == 0:
         print("#." * int(W/2))
      else:
         print("#."*int(W/2) + "#")
      if W % 2 == 0
         print(".#" * int(W/2))
      else:
         print(".#"*int(W/2) + ".")
   if H % 2 != 0 
      if W % 2 == 0:
         print("#." * int(W/2))
      else:
         print("#."*int(W/2) + "#")
   print("")


### FIXED CODE ###

while True:
   H, W = map(int, input().split())
   if H == 0 and W == 0:
      break
   for i in range(int(H/2)):
      if W % 2 == 0:
         print("#." * int(W/2))
      else:
         print("#."*int(W/2) + "#")
      if W % 2 == 0:
         print(".#" * int(W/2))
      else:
         print(".#"*int(W/2) + ".")
   if H % 2 != 0:
      if W % 2 == 0:
         print("#." * int(W/2))
      else:
         print("#."*int(W/2) + "#")
   print("")
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines

import numpy as np

N = int(readline())
LR = [tuple(int(x) for x in line.split()) for line in readlines()]

"""
・奇数個のとき：中央にどれかを固定。
・偶数のとき：原点で左右に分けるとしてよい。
・基本的に長さで内側から昇順（奇数のときの中央は謎）。→ソートしてdpできる。
・左に置いた個数をもってdp更新。また、中央を使ったかも同時に持って。
・偶数のときは、中央に1つ置いた状態から始める。
・大きい区間から外側に入れていく。
"""

LR.sort(key = lambda x: -x[1]-x[0])

if N%2 == 1:
    raise Exception

INF = 10**15
dp_0 = np.full(N+1,INF,np.int64) # 左に置いた個数 → コスト。中央未確定。
dp_1 = np.full(N+1,INF,np.int64) # 左に置いた個数 → コスト。中央確定。
if N&1:
    dp_0[0] = 0
else:
    dp_1[0] = 0
for n,(L,R) in enumerate(LR):
    length = R + L
    prev_0 = dp_0
    prev_1 = dp_1
    dp_0 = np.full(N+1,INF,np.int64)
    dp_1 = np.full(N+1,INF,np.int64)
    x = np.arange(n+1,dtype=np.int64) # もともと左側にあった個数
    # 左側に置く場合
    np.minimum(prev_0[:n+1] + R + x * length, dp_0[1:n+2], out=dp_0[1:n+2])
    np.minimum(prev_1[:n+1] + R + x * length, dp_1[1:n+2], out=dp_1[1:n+2])
    # 右側に置く場合
    np.minimum(prev_0[:n+1] + L + (n-x) * length, dp_0[:n+1], out=dp_0[:n+1])
    np.minimum(prev_1[:n+1] + L + (n-x) * length, dp_1[:n+1], out=dp_1[:n+1])
    # 中央に置く場合
    np.minimum(prev_0[:n+1] + (N-1)//2 * length, dp_1[:n+1], out = dp_1[:n+1])

answer = dp_1[N//2]
print(answer)

### FIXED CODE ###

import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines

import numpy as np

N = int(readline())
LR = [tuple(int(x) for x in line.split()) for line in readlines()]

"""
・奇数個のとき：中央にどれかを固定。
・偶数のとき：原点で左右に分けるとしてよい。
・基本的に長さで内側から昇順（奇数のときの中央は謎）。→ソートしてdpできる。
・左に置いた個数をもってdp更新。また、中央を使ったかも同時に持って。
・偶数のときは、中央に1つ置いた状態から始める。
・大きい区間から外側に入れていく。
"""

LR.sort(key = lambda x: -x[1]-x[0])

INF = 10**18
dp_0 = np.full(N+1,INF,np.int64) # 左に置いた個数 → コスト。中央未確定。
dp_1 = np.full(N+1,INF,np.int64) # 左に置いた個数 → コスト。中央確定。
if N&1:
    dp_0[0] = 0
else:
    dp_1[0] = 0
for n,(L,R) in enumerate(LR):
    length = R + L
    prev_0 = dp_0
    prev_1 = dp_1
    dp_0 = np.full(N+1,INF,np.int64)
    dp_1 = np.full(N+1,INF,np.int64)
    x = np.arange(n+1,dtype=np.int64) # もともと左側にあった個数
    # 左側に置く場合
    np.minimum(prev_0[:n+1] + R + x * length, dp_0[1:n+2], out=dp_0[1:n+2])
    np.minimum(prev_1[:n+1] + R + x * length, dp_1[1:n+2], out=dp_1[1:n+2])
    # 右側に置く場合
    np.minimum(prev_0[:n+1] + L + (n-x) * length, dp_0[:n+1], out=dp_0[:n+1])
    np.minimum(prev_1[:n+1] + L + (n-x) * length, dp_1[:n+1], out=dp_1[:n+1])
    # 中央に置く場合
    np.minimum(prev_0[:n+1] + (N-1)//2 * length, dp_1[:n+1], out = dp_1[:n+1])

answer = dp_1[N//2]
print(answer)
LIMIT = 1000000000000001
alphabet = {1:"a", 2:"b", 3:"c", 4:"d", 5:"e", 6: "f", 7:"g", 8:"h", 9:"i", 10:"j", 11:"k",
                12:"l", 13:"m", 14: "n", 15:"o", 16:"p", 17:"q", 18:"r", 19:"s", 20:"t", 21: "u",
                22: "v", 23: "w",  24: "x",  25: "y",  26: "z"}



N = int(input())
answer = ""

while True:
    if N >= 27:
        a = int(N / 26)
        b = int(N % 26)
        answer += alphabet[b]
        N = a
    else:
        answer += alphabet[N]
        break

print(answer[::-1])




### FIXED CODE ###

LIMIT = 1000000000000001
alphabet = {-1: "!", 0: "a", 1:"b", 2:"c", 3:"d", 4:"e", 5:"f", 6: "g", 7:"h", 8:"i", 9:"j", 10:"k", 11:"l",
                12:"m", 13:"n", 14: "o", 15:"p", 16:"q", 17:"r", 18:"s", 19:"t", 20:"u", 21: "v",
                22: "w", 23: "x",  24: "y",  25: "z"}



N = int(input())
answer = ""
# times = 1

while True:
    N = N - 1
    a = int(N / 26)
    b = N % 26
    answer += alphabet[b]
    if a == 0: break
    N = a


print(answer[::-1])
import math

a, b, c, d = (int(i) for i in input().split())

cd = c*d // math.gcd(c,d)
r = b-a+1

min_c = math.ceil(a/c)
max_c = math.floor(b/c)
min_d = math.ceil(a/d)
max_d = math.floor(b/d)
min_cd = math.ceil(a/cd)
max_cd = math.floor(b/cd)

c_num = max_c-min_c+1
d_num = max_d-min_d+1
cd_num = max_cd-min_cd+1

print(r-c_num-d_num+cd_num)


### FIXED CODE ###

import math
# 最大公約数gcd, 
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

# 最小公倍数lcm
def lcm(a, b):
    return (a*b) // gcd(a,b)

a, b, c, d = (int(i) for i in input().split())

cd = lcm(c,d)
r = b-a+1

min_c = a//c + (1 if a%c!=0 else 0)
max_c = b//c
min_d = a//d + (1 if a%d!=0 else 0)
max_d = b//d
min_cd = a//cd + (1 if a%cd!=0 else 0)
max_cd = b//cd

c_num = max_c-min_c+1
d_num = max_d-min_d+1
cd_num = max_cd-min_cd+1

print(r-c_num-d_num+cd_num)
n,x = map(int,input().split())
li = list(map(int,input().split()))

d = 0
ans = 0

for i in range(n):
    if d <= x:
        ans += 1
        d += li[i]
    else
        d += li[i]

return(ans)

### FIXED CODE ###

n, x = map(int,input().split())
li = list(map(int,input().split()))

d = 0
ans = 0

if d <= x:
    ans = 1
else:
    ans = 0

for i in range(n):
    d += li[i]
    if d <= x:
        ans += 1

print(ans)
n = int(input())
a = ''
 
if n == 1:
    print('a')
if n == 26:
    print('z')
else:
    while n > 0:
    	if n%26 == 1:
        	a += 'a'
    	elif n%26 == 2:
        	a += 'b'
    	elif n%26 == 3:
        	a += 'c'
    	elif n%26 == 4:
        	a += 'd'
    	elif n%26 == 5:
        	a += 'e'
    	elif n%26 == 6:
        	a += 'f'
    	elif n%26 == 7:
        	a += 'g'
    	elif n%26 == 8:
        	a += 'h'
    	elif n%26 == 9:
        	a += 'i'
    	elif n%26 == 10:
        	a += 'j'
    	elif n%26 == 11:
        	a += 'k'
    	elif n%26 == 12:
        	a += 'l'
    	elif n%26 == 13:
        	a += 'm'
    	elif n%26 == 14:
        	a += 'n'
    	elif n%26 == 15:
        	a += 'o'
    	elif n%26 == 16:
        	a += 'p'
    	elif n%26 == 17:
        	a += 'q'
    	elif n%26 == 18:
        	a += 'r'
    	elif n%26 == 19:
        	a += 's'
    	elif n%26 == 20:
        	a += 't'
    	elif n%26 == 21:
        	a += 'u'
    	elif n%26 == 22:
        	a += 'v'
    	elif n%26 == 23:
        	a += 'w'
    	elif n%26 == 24:
        	a += 'x'
    	elif n%26 == 25:
        	a += 'y'
    	elif n%26 == 0:
        	a += 'z'
        	n -=26
    	n = int(n / 26)
	a = a[::-1]
	print(a)

### FIXED CODE ###

n = int(input())
a = ''

while n > 0:
    if n%26 == 1:
        a += 'a'
    elif n%26 == 2:
        a += 'b'
    elif n%26 == 3:
        a += 'c'
    elif n%26 == 4:
        a += 'd'
    elif n%26 == 5:
        a += 'e'
    elif n%26 == 6:
        a += 'f'
    elif n%26 == 7:
        a += 'g'
    elif n%26 == 8:
        a += 'h'
    elif n%26 == 9:
        a += 'i'
    elif n%26 == 10:
        a += 'j'
    elif n%26 == 11:
        a += 'k'
    elif n%26 == 12:
        a += 'l'
    elif n%26 == 13:
        a += 'm'
    elif n%26 == 14:
        a += 'n'
    elif n%26 == 15:
        a += 'o'
    elif n%26 == 16:
        a += 'p'
    elif n%26 == 17:
        a += 'q'
    elif n%26 == 18:
        a += 'r'
    elif n%26 == 19:
        a += 's'
    elif n%26 == 20:
        a += 't'
    elif n%26 == 21:
        a += 'u'
    elif n%26 == 22:
        a += 'v'
    elif n%26 == 23:
        a += 'w'
    elif n%26 == 24:
        a += 'x'
    elif n%26 == 25:
        a += 'y'
    elif n%26 == 0:
        a += 'z'
        n -=26
    n = int(n / 26)
a = a[::-1]
print(a)
W,H,x,y,r = map(int, raw_input().split())

if (r =< x =< (W - r)) & (r =< y =< (H - r)):
  print "Yes"
else:
  print "No"

### FIXED CODE ###

W,H,x,y,r = map(int, raw_input().split())

if (r <= x <= (W - r)) and (r <= y <= (H - r)):
  print "Yes"
else:
  print "No"
def power_func(a,n,p):
  bi=str(format(n,"b"))#2進表現に
  res=1
  for i in range(len(bi)):
    res=(res*res) %p
    if bi[i]=="1":
      res=(res*a) %p
  return res

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 998244353
N = 10 ** 6
fact = [1, 1] + [0] * (N-2)
factinv = [1, 1] + [0] * (N-2)
inv = [0, 1] + [0] * (N-2)

for i in range(2, N + 1):
    fact[i] = (fact[i-1] * i) % p
    inv[i] = (-inv[p % i] * (p // i)) % p
    factinv[i] = (factinv[i-1] * inv[i-1]) % p

n, m, k = [int(i) for i in input().split()]

ret = 0
for i in range(k+1):
  ret += ((cmb(n-1, i, p) * m % p) * (power_func(m-1, n-1-i, p))) % p
print(ret % p)


### FIXED CODE ###

def power_func(a,n,p):
  bi=str(format(n,"b"))#2進表現に
  res=1
  for i in range(len(bi)):
    res=(res*res) %p
    if bi[i]=="1":
      res=(res*a) %p
  return res

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 998244353
N = 10 ** 6
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

n, m, k = [int(i) for i in input().split()]

ret = 0
for i in range(k+1):
  ret += ((cmb(n-1, i, p) * m % p) * (power_func(m-1, n-1-i, p))) % p
print(ret % p)
import math

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

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))


### FIXED CODE ###

def g(x, y):
	while y > 0:
		x, y = y, x%y
	return x
def l(x, y):
	return x // g(x, y) * y

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


print(l(a,b))
n,m=map(int,input().split())
if m>=2:
    lists=[]
    for i in range(m):
        a=int(input())
        lists.append(a)

    fiblist=[1,1]
    for j in range(10**5):
        nums=(fiblist[-1]+fiblist[-2])%(10**9+7)
        fiblist.append(nums)
    lists.insert(0,0)
    lists.append(n)
    ans=1
    for i in range(m+1):
        if i==0:
            ans=ans*fiblist[lists[1]-lists[0]-1]
            ans=ans%(10**9+7)
        elif i==m:
            ans=ans*fiblist[lists[m+1]-lists[m]-1]
            ans=ans%(10**9+7)
        elif i!=0 and i!=m:
            if lists[i+1]-lists[i]==1:
                ans=0
                break
            else:
                ans=ans*fiblist[lists[i+1]-lists[i]-2]
                ans=ans%(10**9+7)
    print(ans) 
if m==0:
    print(fib(n))
if m==1:
    print(fib(lists[0]-1)*fib(n-lists[0]-1)%(10**9+7))

### FIXED CODE ###

n,m=map(int,input().split())

lists=[]
for i in range(m):
    a=int(input())
    lists.append(a)

fiblist=[1,1]
for j in range(10**5):
    nums=(fiblist[-1]+fiblist[-2])%(10**9+7)
    fiblist.append(nums)
lists.insert(0,0)
lists.append(n)
ans=1
if m>=2:
    for i in range(m+1):
        if i==0:
            ans=ans*fiblist[lists[1]-lists[0]-1]
            ans=ans%(10**9+7)
        elif i==m:
            ans=ans*fiblist[lists[m+1]-lists[m]-1]
            ans=ans%(10**9+7)
        elif i!=0 and i!=m:
            if lists[i+1]-lists[i]==1:
                ans=0
                break
            else:
                ans=ans*fiblist[lists[i+1]-lists[i]-2]
                ans=ans%(10**9+7)
    print(ans) 
if m==0:
    print(fiblist[n])
if m==1:
    print(fiblist[lists[1]-1]*fiblist[n-lists[1]-1]%(10**9+7))
x, a = map(int, input())
if x < a:
    print(0)
else:
    print(10)

### FIXED CODE ###

x, a = map(int, input().split())
if x < a:
    print(0)
else:
    print(10)
n=int(input())
h=list(map(int,input().split()))
count=flag=0 
for i in range(n): 
      if(h[i]>h[i+1]):
        flag+=1
      else :
        count=flag if(flag>count) else count
        flag=0
print(count)
             
            

### FIXED CODE ###

n = int(input())
x = input().split()
y = [0]
c = 0
for i in range(n-1):
  if int(x[i]) >= int(x[i+1]):
    c = c + 1
  else:
    y.append(c)
    c = 0
y.append(c)
print(max(y))
# coding: utf-8
# Here your code !
import collections
s=int(input())
deq =collections.deque()

for i in range(s):
    n=input().split()
    if n[0]=="insert":
        deq.appendleft(n[1])
    elif n[0]=="delete":
        deq.remove(n[1])
    elif n[0]=="deleteFirst":
        deq.popleft()
    elif n[0]=="deleteLast":
        deq.pop()
        
print(" ".join(list(deq)))

### FIXED CODE ###

# coding: utf-8
# Here your code !
import collections
s=int(input())
deq =collections.deque()

for i in range(s):
    n=input().split()
    if n[0]=="insert":
        deq.appendleft(n[1])
    elif n[0]=="delete":
        try:
            deq.remove(n[1])
        except ValueError:
            pass
    elif n[0]=="deleteFirst":
        deq.popleft()
    elif n[0]=="deleteLast":
        deq.pop()
        
print(" ".join(list(deq)))
# your code goes here
import numpy as np

def a(s, w, ans):
	if(s == ""):
		return ans
	elif(s[-1] == 'B'):
		if(w == 0):
			return a(s[:-1], 0, ans)
		else:
			return a(s[:-1], w, ans+w)
	else:
		return a(s[:-1], w+1, ans)

def main():
	s = input()
	print(a(s, 0, 0))
	
main()

### FIXED CODE ###

# your code goes here
import numpy as np

def main():
	s = input()
	ans = 0
	w = 0
	for i in range(len(s)):
		c = s[len(s)-1-i]
		if(c == 'B'):
			if(w > 0):
				ans += w
		else:
			w += 1
	
	print(ans)
	
main()
import itertools
    k = int(input())
    s = input()
    if len(s) > k:
        s = s[:k] + '...'
    print(s)

if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    k = int(input())
    s = input()
    if len(s) > k:
        s = s[:k] + '...'

    print(s)


if __name__ == '__main__':
    main()
k,s = map(int(),input().split())
a = 0
for x in range(k+1):
  for y in range(k+1):
    for z in range(k+1):
      if x+y+z == s:
        a += 1
        
print(a)
      

### FIXED CODE ###

k,s = map(int,input().split())
a = 0
for x in range(k+1):
  for y in range(k+1):
      if s-(x+y) <= k and s-(x+y) >= 0:
        a += 1
        
print(a)
a, b = map(int, input().split())
if a<=b*2:
    print(0)
else:
    print(a-b*2)a, b = map(int, input().split())


### FIXED CODE ###

a, b = map(int, input().split())
if a<=b*2:
    print(0)
else:
    print(a-b*2)
n=int(input())
A=list(map(int,input().split()))
N=[0]*(10**6)
ans=10**9+7
if len([a for a in A if a==0])==1:
    ans=3
else:
    ans=6

for a in A:
    N[a]+=1
    if a!=0:
        ans*=N[a-1]%mod
        N[a-1]-=1
print(ans)

### FIXED CODE ###

n=int(input())
A=list(map(int,input().split()))
N=[3]+[0]*n
mod=10**9+7
ans=1

for a in A:
    ans*=N[a]
    ans%=mod
    N[a]-=1
    N[a+1]+=1
print(ans)
import numpy as np
N = input()
N = int(N)
Sdict = {}
n_anagram = 0
D = {"a":2, "b":3, "c":5, "d":7, "e":11, "f":13,"g":17, "h":19, "i":23, "j":29, "k":31, "l":37, "m":41, "n":43,
"o":47, "p":53, "q":57, "r":59, "s":61, "t":67, "u":71, "v":73, "w":79, "x":83, "y":87, "z":1}

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

for s in S:
    s = np.prod([D[x] for x in s])
    if s in S:
        n_anagram = n_anagram + S[s]
        S[s] += 1
    else:
        S[s] = 1
    
print(n_anagram)

### FIXED CODE ###

import numpy as np
N = input()
N = int(N)
Sdict = {}
n_anagram = 0
D = {"a":2, "b":3, "c":5, "d":7, "e":11, "f":13,"g":17, "h":19, "i":23, "j":29, "k":31, "l":37, "m":41, "n":43,
"o":47, "p":53, "q":59, "r":61, "s":67, "t":71, "u":73, "v":79, "w":83, "x":89, "y":97, "z":1}

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

for s in S:
    s1 = [D[x] for x in s]
    s2 = np.prod(s1)

    if s2 in Sdict:
        n_anagram = n_anagram + Sdict[s2]
        Sdict[s2] += 1
    else:
        Sdict[s2] = 1
   
print(n_anagram)
# -*- coding:utf-8 -*-

def solve():
    N = int(input())
    S: string = input()

    """
    3桁の数字がijkだとして、それを作れるかを全探索で数えていく
    平均計算量は、(3750*10)*(7500*10)*(15000*10) = O(10**4 * 10**4 * 10**5) = O(10**13)
    """

    ans = 0
    for i in range(0, 10):
        idx = S.find(str(i))  # 平均計算量15000
        if idx == -1:
            continue
        for j in range(0, 10):
            jdx = S[idx+1:].find(str(j))  # 平均計算量7500
            if jdx == -1:
                continue
            for k in range(0, 10):
                if str(k) in S[idx+1+jdx+1:]:  # 平均計算量3750
                    ans += 1

    print(ans)


if __name__ == "__main__":
    solve()


### FIXED CODE ###

# -*- coding:utf-8 -*-

def solve():
    N = int(input())
    S = input()

    """
    3桁の数字がijkだとして、それを作れるかを全探索で数えていく
    平均計算量は、(3750*10)*(7500*10)*(15000*10) = O(10**4 * 10**4 * 10**5) = O(10**13)
    """

    ans = 0
    for i in range(0, 10):
        idx = S.find(str(i))  # 平均計算量15000
        if idx == -1:
            continue
        for j in range(0, 10):
            jdx = S[idx+1:].find(str(j))  # 平均計算量7500
            if jdx == -1:
                continue
            for k in range(0, 10):
                if str(k) in S[idx+1+jdx+1:]:  # 平均計算量3750
                    ans += 1

    print(ans)


if __name__ == "__main__":
    solve()
import math
a,b,h,m=map(int,input().split())
 
dh=30*h+m/2
dm=6*m
 
if dm==dh:
    rad=0
else:
    rad=abs(dm-dh)
    
if rad>180:
    rad=rad-180
    length=math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(rad)))
 
elif 0<rad and rad<180:
    length=math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(rad)))
 
elif rad==180:
    length=a+b
    
else:
    length=abs(a-b)
    
print(length)

### FIXED CODE ###

N=input()
num=len(N)
a={"2","4","5","7","9"}
b={"0","1","6","8"}
c={"3"}
if N[num-1] in a:
    print("hon")
elif N[num-1] in b:
    print("pon")
else:
    print("bon")
N = int(input())
i = int(input())
print(N - i + 1)

### FIXED CODE ###

n, i = list(map(int, input().split()))
print(n - i + 1 )
s=input()
count=0
count_list=[]
seq=["A","T","G","C"]
for base in ref:
    if base in seq:
        count +=1
    else:
        count_list.append(count)
        count = 0
    count_list.append(count)
print(max(count_list))

### FIXED CODE ###

s=input()
count=0
count_list=[]
seq=["A","T","G","C"]
for base in s:
    if base in seq:
        count +=1
    else:
        count_list.append(count)
        count = 0
    count_list.append(count)
print(max(count_list))
import sys
from fractions import gcd
from collections import deque

input = sys.stdin.readline

N = int(input())
a = [int(x) for x in input().rstrip("\n").split()]
q = deque(a)

while len(q) > 1:
    x = q.popleft()
    y = q.popleft()
    z =  fractions.gcd(x, y)
    q.append(z)

ans = q.popleft()
print(ans)

### FIXED CODE ###

import sys
import fractions
from collections import deque

input = sys.stdin.readline

N = int(input())
a = [int(x) for x in input().rstrip("\n").split()]
q = deque(a)

while len(q) > 1:
    x = q.popleft()
    y = q.popleft()
    z =  fractions.gcd(x, y)
    q.append(z)

ans = q.popleft()
print(ans)
from itertools import permutations, tee

N, M = map(int, input().split())
edges = set()
for _ in range(N):
   a, b = map(int, input().split())
   edges.add((a, b))   

def each_cons(iterable):
  a, b = tee(iterable)
  next(b, None)
  return zip(a, b)

cases = list(permutations(range(2, N + 1), N - 1))

count = 0

def is_available(edge):
  return edge in edges or edge[::-1] in edges

for numbers in cases:
  if all(map(is_available, each_cons((1,) + numbers))):
    count += 1
         
print(count)         

### FIXED CODE ###

from itertools import permutations, tee

N, M = map(int, input().split())
edges = set()

for _ in range(M):
    edges.add(tuple(map(int, input().split())))


def each_cons(iterable):
    a, b = tee(iterable)
    next(b, None)
    return zip(a, b)


def is_available(edge):
    return edge in edges or edge[::-1] in edges


cases = permutations(range(2, N + 1), N - 1)

count = 0

for numbers in cases:
    if all(map(is_available, each_cons((1,) + numbers))):
        count += 1


print(count)