Harryxun/stf_run huggingface dataset:
n = int(input())
arr = [int(i) for i in list(input().split())]
def helper(arr):
	if len(arr) <= 1:
		return 0
	if len(arr) == 2:
		return abs(arr[1] - arr[0])
	way1 = abs(arr[-1] - arr[-2]) + helper(arr[:-1])
	way2 = abs(arr[-1] - arr[-3]) + helper(arr[:-2])
	return min(way1, way2 )

# if n == 1:
# 	print(0)
# elif n == 2:
# 	print(abs(arr[1] - arr[0]))
# else:
# 	dp = [0]*n
# 	for i in range(2,len(arr)):
# 		dp[i] = min(dp[i-1] + abs(arr[i] - arr[i-1]), dp[i-2] + abs(arr[i] - arr[i-2]))

# 	print(dp[n-1])
print(helper(arr))

### FIXED CODE ###

n = int(input())
arr = [int(i) for i in list(input().split())]
def helper(arr):
	if len(arr) <= 1:
		return 0
	if len(arr) == 2:
		return abs(arr[1] - arr[0])
	way1 = abs(arr[-1] - arr[-2]) + helper(arr[:-1])
	way2 = abs(arr[-1] - arr[-3]) + helper(arr[:-2])
	return min(way1, way2 )

if n == 1:
	print(0)
elif n == 2:
	print(abs(arr[1] - arr[0]))
else:
	dp = [0]*n
	dp[0] = 0
	dp[1] = abs(arr[1] - arr[0])
	for i in range(2,len(arr)):
		dp[i] = min(dp[i-1] + abs(arr[i] - arr[i-1]), dp[i-2] + abs(arr[i] - arr[i-2]))
	print(dp[n-1])
# print(helper(arr))
a=input()
list=[a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z]
if a not in list:
  print("A")
else:
  print("a")


### FIXED CODE ###

a = input()
print('a' if a.islower() else 'A')
def main():
    a,b,c,d,e,f = map(int,input().split())
    ans = []
    for i in range(f//a//100+1):
        for j in range((f-100*a*i)//b//100+1):
            if a*i*100+b*j*100 < f:
                ans.append([i,j])
    ans = ans[1:]
    D = 0
    for an in ans:
        m = a*100*an[0] + b*100*an[1]
        slv = e*m//100
        M = 0
        for i in range(min(f-m,slv)//c+1):
            for j in range((min(f-m,slv)-c*i)//d+1):
                if i*c+d*j <= min(slv,f-m):
                    if M < i*c+d*j:
                        M = i*c+d*j
        den = M/(m+M)
        if den>D:
            D = den
            A = [m+M,M]
    print(' '.join([str(a) for a in A]))

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    a,b,c,d,e,f = map(int,input().split())
    ans = []
    for i in range(f//a//100+1):
        for j in range((f-100*a*i)//b//100+1):
            if a*i*100+b*j*100 < f:
                ans.append([i,j])
    ans = ans[1:]
    D = 0
    A = [0,0]
    for an in ans:
        m = a*100*an[0] + b*100*an[1]
        slv = e*m//100
        M = 0
        for i in range(min(f-m,slv)//c+1):
            for j in range((min(f-m,slv)-c*i)//d+1):
                if i*c+d*j <= min(slv,f-m):
                    if M < i*c+d*j:
                        M = i*c+d*j
        den = M/(m+M)
        if den>=D:
            D = den
            A = [m+M,M]
    print(' '.join([str(a) for a in A]))

if __name__ == "__main__":
    main()
a,b,c=map(int, input().split())
if (a*b)%2==0:
  print('Even')
esle:
  print('odd')

### FIXED CODE ###

a,b=map(int,input().split())
if (a*b)%2==0:
  print("Even")
else:
  print("Odd")
while True :
  H,W = map(int,input().split())
  if W == 0 and H == 0 :
    break
  for i in range(H) : 
      if i == 0 or i == H-1 :       
        print('#'*W)
      else  :
        print('#' + '.'*(W-2) + '#')
   print('')


### FIXED CODE ###

while True :
  H,W = map(int,input().split())
  if W == 0 and H == 0 :
    break
  for i in range(H) : 
      if i == 0 or i == H-1 :       
        print('#'*W)
      else  :
        print('#' + '.'*(W-2) + '#')
  print('')
from math import ceil

H, N = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
dp = [[0 for i in range(N)] for j in range(H+1)]

for i in range(1, H+1):
    a = AB[-1][0]
    b = AB[-1][1]
    dp[i][N-1] = ceil(i / a)*b

for j in range(0, N-1)[::-1]:
    for i in range(1, H+1):
        a = AB[j][0]
        b = AB[j][1]
        x_list = []
        for k in range(0, int(ceil(i/a))+1):
            new_i = i - a*k
            x = dp[new_i][j+1] + b*k
            x_list.append(x)
        dp[i][j] = min(x_list)

print(dp[H][0])


### FIXED CODE ###

INF = 10**9

H, N = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
dp = [INF for i in range(H+1)]

dp[0] = 0

for i in range(N):
    a = AB[i][0]
    b = AB[i][1]
    for j in range(H+1):
        next_j = min(j+a, H)
        dp[next_j] = min(dp[next_j], dp[j]+b)

print(dp[H])
A,B,C = map(int,input().split())
print( C + B - A if c + B - A >= 0 else 0)

### FIXED CODE ###

A,B,C = map(int,input().split())
print( C + B - A if C + B - A >= 0 else 0)
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
x=[[0 for i in range(3)] for j in range(3)]
N=int(input())
if N>=3:
  for i in range(N):
    b=int(input())
    for j in range(3):
      if A[j]==b:
        x[0][j]=1
      elif B[j]==b:
        x[1][j]=1
      elif C[j]==b:
        x[2][j]=1
  flag=0
  if x[0][0]==1:
    if x[0][1]==1 and x[0][2]==1:
      flag=1
    elif x[1][0]==1 and x[2][0]==1:
      flag=1
    elif x[1][1]==1 and x[2][2]==1:
      flag=1
  if x[1][1]==1:
    if x[0][1]==1 and x[2][1]==1:
      flag=1
    elif x[1][0]==1 and x[2][0]==1:
      flag=1
    elif x[0][2]==1 and x[2][0]==1:
      flag=1
  if x[2][2]==1:
    if x[2][0]==1 and x[2][1]==1:
      flag=1
    elif x[0][2]==1 and x[1][2]==1:
      flag=1
  if flag==1:
    print("Yes")
  else:
    print("No")
  #print(x)
else:
  print("No")

### FIXED CODE ###

N=int(input())

print(N//2+N%2)
# ABC 130: B – Bounding
n, x = [int(s) for s in input().split()]
l = [int(s) for s in input().split()]

d = 0
times = 0

while d <= x and times <= n:
    d += l[times]
    times += 1

print(times)

### FIXED CODE ###

# ABC 130: B – Bounding
N, X = map(int, input().split())
L = [int(s) for s in input().split()]

D = [0]

for i in range(N):
    D.append(D[i] + L[i])

print(len([d for d in D if d <= X]))
import math

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

A,B=map(int,input().split())
print(lcm(A,B))

### FIXED CODE ###

def gcd(x,y):
    while y!=0:
        x,y=y,x%y
    return x

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

A,B=map(int,input().split())
print(int(lcm(A,B)))
h,w,k=map(int,input().split())
table=[]
cntr=[]
cntc=[]
for i in range(h):
  row=str(input())
  table.append(row)
  cntr.append(row.count('#'))

for i in range(w):
  b_num=0
  for j in range(h):
    if table[j][i]=="#":
      b_num+=1
  cntc.append(b_num)
total=sum(cntr)
def myfunc(r,c):
    if r==0 and c==0:
        return 0
    elif r==0:
        return cntc[c-1]
    elif c==0:
        return cntr[r-1]
    else:
        return (cntr[r-1] + cntc[c-1]) if table[r-1][c-1]!="#" else (cntr[r-1] + cntc[c-1]-1)
ans=0    
for i in range(h):
    for j in range(i+1,h,1):
        if k == total-(cntr[i]+cntr[j]):
            ans+=1
for i in range(w):
    for j in range(i+1,h,1):
        if k == total-(cntc[i]+cntc[j]):
            ans+=1
for i in range(h+1):
    for j in range(w+1):
        #print(myfunc(i,j))
        if k==(total-myfunc(i,j)):
            ans+=1
print(ans)

### FIXED CODE ###

h,w,k=map(int,input().split())
table=[]
for i in range(h):
  row=str(input())
  table.append(row)

ans = 0
for maskR in range(1 << h):
    for maskC in range(1 << w):
        black = 0
        for i in range(h):
            for j in range(w):
                if ((maskR >> i) & 1) == 0 and ((maskC >> j) & 1) == 0 and table[i][j] == '#': 
                    black = black + 1
        if black == k: 
            ans = ans + 1
print(ans)
import math
a,b,c,d=map(int,input().split())
def k(n):
    aa=n//c
    bb=n//d
    f=n//((c*d)//math.gcd(c,d))
    return n-aa-bb+f
print(k(b)-k(a-1))

### FIXED CODE ###

from fractions import gcd
A,B,C,D = map(int,input().split())
def f(n):
    x = n//C
    y = n//D
    z = n//(C*D//gcd(C,D))
    return n - x - y + z

print(f(B) - f(A-1))
N = int(input())

if N % 2 == 1:
    print(0)
else:
    N = N//2
    ans = 0
    while N != 0:
        ans += N // 5
        N = N // 5
        
print(ans)

### FIXED CODE ###

N = int(input())

if N % 2 == 1:
    ans = 0
else:
    N = N//2
    ans = 0
    while N != 0:
        ans += N // 5
        N = N // 5
        
print(ans)
import math
t1,t2=map(int,input().split())
a1,a2=map(int,input().split())
b1,b2=map(int,input().split())
dis=abs(a1-b1)*t1
oi=abs(a2-b2)*t2
if oi==0:
    print("infinity")
else:
    print(math.ceil(dis/abs(oi-dis))

### FIXED CODE ###


#atcoder 
t1,t2=map(int,input().split())
a1,a2=map(int,input().split())
b1,b2=map(int,input().split())

d1=a1-b1
d2=a2-b2

if d1*d2>0:
    print(0)
else:
    if d1>0 and d2<0:
        plus=d1*t1+d2*t2
        if plus>0:
            print(0)
        elif plus==0:
            print("infinity")
        elif plus<0:
            d=-plus
            k=d1*t1
            if k%d==0:
                print(2*k//d)
            else:
                print(2*(k//d)+1)
    else:
        d1=-d1
        d2=-d2
        plus=d1*t1+d2*t2
        if plus>0:
            print(0)
        elif plus==0:
            print("infinity")
        elif plus<0:
            d=-plus
            k=d1*t1
            if k%d==0:
                print(2*k//d)
            else:
                print(2*(k//d)+1)
#import math
from functools import reduce

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

def gcds(nums):
    return reduce(gcd, nums)

a = int(input())
a = [int(i) for i in input().split()]

ans = 0
for i in range(len(a)):
    aa = a[:i] + a[(i+1):]
    if ans < gcd(aa):
        ans = gcd(aa)
print(ans)

### FIXED CODE ###

import sys
from functools import reduce

input = sys.stdin.readline

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

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


ans = 0
l = [0]*(n+1)
r = [0]*(n+1)
for i in range(n):
    l[i+1] = gcd(l[i], a[i])
    r[n-i-1] = gcd(r[n-i], a[n-i-1])
for i in range(n):
    ans = max(ans, gcd(l[i], r[i+1]))
print(ans)
S = input().split
T = input().split
count = 0
for i in range(3):
    if S[i] == T[i]:
        ++count
print(count)

### FIXED CODE ###

S = input()
T = input()
count = 0
for i in range(3):
    if S[i] == T[i]:
        count = count + 1
print(count)
from collections import Counter

N = int(input())

def solve():
    memo = Counter()
    for x in range(1, N):
        for y in range(x, N):
            res = x * x + y * y + x * y
            if res >= N:
                return
            for z in range(y, N):
                if x == y == z:
                    cnt = 1
                elif x < y < z:
                    cnt = 6
                else:
                    cnt = 3
                memo[res + z * z + y * z + x * z] += cnt

C = solve()
for i in range(1, N + 1):
    print(C[i])

### FIXED CODE ###

N = int(input())

ans = [0] * (N + 1)
for x in range(1, 105):
    for y in range(1, 105):
        for z in range(1, 105):
            v = x * x + y * y + z * z + x * y + y * z + z * x
            if v <= N:
                ans[v] += 1

for i in range(1, N + 1):
    print(ans[i])
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, M = map(int, input().split())

m = map(int,read().split())
ST = zip(m,m)
 
edge_out = [[] for i in range(N)] #edge_out[i]はiから出ている道
edge_in = [[] for i in range(N + 1)] # edge_in[i]はiに行く道
 
for s,t in ST:
    edge_out[s].append(t)
    edge_in[t].append(s)
    

edge_sum = [len(edge_out[i]) for i in range(N)] # edge_sum[i] = iから出ている道の本数

dp = [0.0]*(N + 1) # dp[i]はiからNへの距離の期待値
dp[N - 1] = 1.0
# 道を塞がない場合
for i in range(N - 2, 0, - 1):
    dp[i] = 1 + sum(dp[j] for j in edge_out[i])/edge_sum[i]
    
p_to_i = [0]*(N + 1) # p_to_i[i]は1から各iへ到達する確率
p_to_i[1] = 1
for i in range(2, N + 1):
    p_to_i[i] = sum(p_to_i[j]/edge_sum[j] for j in edge_in[i])


t = 0

for i in range(1, N - 1):
    if edge_sum[i] == 1:
        continue
        # iから出ている道の先にある部屋のうち、その部屋からNまでの距離の期待値が最も大きいものへ通ずる道を塞ぐ
    t = max(t, p_to_i[i]*(dp[i] - 1- ((dp[i] - 1)*edge_sum[i] - max(dp[j] for j in edge_out[i]))/(edge_sum[i] - 1)))
    
print(dp[1] - t)

### FIXED CODE ###

N, M = map(int, input().split())
edge_out = [[] for i in range(N)] #edge_out[i]はiから出ている道
edge_in = [[] for i in range(N + 1)] # edge_in[i]はiに行く道
for i in range(M):
    s, t = map(int, input().split())
    edge_out[s].append(t)
    edge_in[t].append(s)

edge_sum = [len(edge_out[i]) for i in range(N)] # edge_sum[i] = iから出ている道の本数

dp = [0.0]*(N + 1) # dp[i]はiからNへの距離の期待値
dp[N - 1] = 1.0
# 道を塞がない場合
for i in range(N - 2, 0, - 1):
    dp[i] = 1 + sum(dp[j] for j in edge_out[i])/edge_sum[i]
    
p_to_i = [0]*(N + 1) # p_to_i[i]は1から各iへ到達する確率
p_to_i[1] = 1
for i in range(2, N + 1):
    p_to_i[i] = sum(p_to_i[j]/edge_sum[j] for j in edge_in[i])


t = 0

for i in range(1, N - 1):
    if edge_sum[i] == 1:
        continue
        # iから出ている道の先にある部屋のうち、その部屋からNまでの距離の期待値が最も大きいものへ通ずる道を塞ぐ
    t = max(t, p_to_i[i]*(dp[i] - 1- ((dp[i] - 1)*edge_sum[i] - max(dp[j] for j in edge_out[i]))/(edge_sum[i] - 1)))
    
print(dp[1] - t)
A , B = map ( int , input ( )  . split( ) )

if A , B <= 9 :
print ( A * B )

else:
print ( -1 )
  

### FIXED CODE ###

A , B = map ( int , input ( )  . split( ) )
 
if ( A<= 9 and B <= 9) :
    print ( A * B )
else:
    print ( -1 )
import math
from sys import stdin,stdout
#% 998244353
from heapq import heapify,heappop,heappush
import collections

n,k=list(map(int,stdin.readline().split()))
a=list(map(int,stdin.readline().split()))


for i in range(min(k,math.log(n))):
    #nw=[0]*n
    pr=[0]*n
    for x,d in enumerate(a):
        if d==0:
            pr[x]+=1
            if x!=n-1:
                pr[x+1]-=1
            continue
        l=math.floor(x-d)
        r=math.floor(x+d)
        l=max(0,l)
        r=min(n-1,r)
        pr[l]+=1
        if r!=n-1:
            pr[r+1]-=1
    
    for m in range(1,n):
        pr[m]+=pr[m-1]
    
    a[:]=pr


        

for i in a:
    print(i,end=" ")

### FIXED CODE ###

import math
from sys import stdin,stdout
#% 998244353
from heapq import heapify,heappop,heappush
import collections

n,k=list(map(int,stdin.readline().split()))
a=list(map(int,stdin.readline().split()))


for i in range(min(k,100)):
    #nw=[0]*n
    pr=[0]*n
    for x,d in enumerate(a):
        if d==0:
            pr[x]+=1
            if x!=n-1:
                pr[x+1]-=1
            continue
        l=math.floor(x-d)
        r=math.floor(x+d)
        l=max(0,l)
        r=min(n-1,r)
        pr[l]+=1
        if r!=n-1:
            pr[r+1]-=1
    
    for m in range(1,n):
        pr[m]+=pr[m-1]
    
    a[:]=pr


        

for i in a:
    print(i,end=" ")
import math
import decimal
A,B=input().split()
print(Decimal(A)*Decimal(B)//1)

### FIXED CODE ###

A,B=input().split()
A=int(A)
B=int(B[0])*100+int(B[2:4])
C=A*B
if len(str(C))<3:
  print(0)
else:
  print(int(str(C)[0:len(str(C))-2]))
line = raw_input()
lines = line.split()
a = int(lines[0])
b = int(lines[1])
res = 0
if a > b:
  res = a + a - 1
elif b > a:
  res = b + b - 1
else:
  res = a + b

print(res)

### FIXED CODE ###

line = input()
lines = line.split()
a = int(lines[0])
b = int(lines[1])
res = 0
if a > b:
  res = a + a - 1
elif b > a:
  res = b + b - 1
else:
  res = a + b

print(res)
s=list(map(str,input().split()))
t=list(map(str,input().split()))
c=0
for i in range(3):
  if s[i]==t[i]:
    c=c+1
print(c)

### FIXED CODE ###

s=str(input())
t=str(input())
s=[i for i in s]
t=[i for i in t]
c=0
for i in range(3):
  if s[i]==t[i]:
    c=c+1
print(c)
N, M = [int(x) for x in input().split()]                                                                             │
                                                                                                                     │
likes = [0 for x in range(M)]                                                                                        │
                                                                                                                     │
for n in range(N):                                                                                                   │
    s = [int(x) for x in input().split()]                                                                            │
    K = s[0]                                                                                                         │
    for k in range(K):                                                                                               │
        likes[s[1+k] - 1] += 1                                                                                       │
                                                                                                                     │
print(likes.count(N))

### FIXED CODE ###

N, M = [int(x) for x in input().split()]

likes = [0 for x in range(M)]

for n in range(N):
    s = [int(x) for x in input().split()]
    K = s[0]
    for k in range(K):
        likes[s[1+k] - 1] += 1

print(likes.count(N))
N = int(input())
L = [i for i in range(1, N+1) if i % 2 != 0]
ans = 0
if N < 105:
    print(0)
    sys.exit(0)
for num in L:
    counter = 1
    for i in range(1, num//2):
        if num % i == 0:
            counter += 1
    if counter == 8:
        ans += 1
print(ans)

### FIXED CODE ###

import sys
N = int(input())
L = [i for i in range(1, N+1) if i % 2 != 0]
ans = 0
if N < 105:
    print(0)
    sys.exit(0)
for num in L:
    counter = 1
    for i in range(1, num//2):
        if num % i == 0:
            counter += 1
    if counter == 8:
        ans += 1
print(ans)
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import itertools
input()
lis = list(itertools.product([False,True],repeat=10))
for s in sys.stdin:
  d = map( int, s.split() )
  flag = False
  for e in lis:
    lis_r = []
    lis_l = []
    for i in range(10):
      if e[i]:
        lis_r.append(d[i])
      else:
        lis_l.append(d[i])
    f_r = sorted(lis_r)
    f_l = sorted(lis_l)
    if f_r == lis_r and f_l == lis_l:
      flag = True
      break
  if flag:
    print "YES"
  else:
    print "NO"

### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

n = input()
for s in xrange(n):
  d = map( int, raw_input().split() )
  a = b = 0
  flag = True
  for e in d:
    if a < e: a = e
    elif b < e: b = e
    else: flag = False
  if flag: print "YES"
  else: print "NO"
m,f,r=map(int,input().split())
if m==-1 or f==-1 or m+f<30:
    print('F')
elif m==f==r==-1:
    break
elif m+f>=80:
    print('A')
elif 65<=m+f<80:
    print('B')
elif 50<=m+f<65 or r>=50:
    print('C')
else:
    print('D')

### FIXED CODE ###

p=print
while 1:
    m,f,r=map(int,input().split())
    x=m+f
    if m==f==r==-1:break
    elif m==-1 or f==-1 or x<30:p('F')
    elif x>=80:p('A')
    elif 65<=x<80:p('B')
    elif 50<=x<65 or r>=50:p('C')
    else:p('D')
#!/usr/bin/env python3
import sys
from itertools import accumulate
MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):
    aa = list(accumulate(A))
    print(aa)
    x = sum(A)
    print(x)

    ans = 0

    for i in range(N):
        ans += A[i]*(aa[N-1]-aa[i])%MOD
        ans %= MOD
    return print(ans)


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


### FIXED CODE ###

D, T, S = map(int, input().split())

a = T * S - D
if a >= 0:
    print('Yes')
else:
    print('No')
s = input()
ns = [int(i) for i in s.rsplit()]
print(math.ceil(ns[1]/ns[0]))

### FIXED CODE ###

n = int(input())

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

x = 0
y = 0

for i in range(1, n):
    if(a[i] <= a[i-1]):
        y +=1
    else:
        x = max(x,y)
        y = 0

print(max(x,y))
N=int(input())
A=list(mao(int,input().split()))
ans=1
for i in range(N):
  ans*=i
if ans > 10**18:
  print(-1)
else:
  print(ans)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
if 0 in A:
    print(0)
else:
    ans=1
    for i in range(N):
        ans*=A[i]
        if ans >10**18:
            break
    if ans > 10**18:
      print(-1)
    else:
      print(ans)
from math import gcd

n = int(input())

print(2*n//gcd(2,n))

### FIXED CODE ###

n = int(input())

if n%2 == 0:
    print(n)
else:
    print(n*2)
from functools import lru_cache

n = int(input())
list1 = [''.join(sorted(input())) for i in range(n)]
dict1 = dict()
cout = 0
@lru_cache(maxsize = None)
def func(s):
	if s == 2:
		return 1 #2個の場合は1パターン
	return s-1 + func(s-1)

for i in range(n):
	if list1[i] in dict1:
		dict1[list1[i]] += 1
	else:
		dict1[list1[i]] = 1

for i in dict1:
	if dict1[i] != 1:
		cout += func(dict1[i])

print(cout)

### FIXED CODE ###

from functools import lru_cache
import sys
sys.setrecursionlimit(1000000)
n = int(input())
list1 = [''.join(sorted(input())) for i in range(n)]
dict1 = dict()
cout = 0
@lru_cache(maxsize = None)
def func(s):
	if s == 2:
		return 1 #2個の場合は1パターン
	return s-1 + func(s-1)

for i in range(n):
	if list1[i] in dict1:
		dict1[list1[i]] += 1
	else:
		dict1[list1[i]] = 1

for i in dict1:
	if dict1[i] != 1:
		cout += func(dict1[i])

print(cout)
from math import gcd
A, B, C, D = map(int, input().split())
A-=1
lcm=C*D//gcd(C,D)
#B以下の個数
b = B-(B//C)-(B//D)+B//lcm
#A以下の個数
a = A-(A//C)-(A//D)+A//lcm
print(b-a)


### FIXED CODE ###

from fractions import gcd
A, B, C, D = map(int, input().split())
A-=1
lcm=C*D//gcd(C,D)
#B以下の個数
b = B-(B//C)-(B//D)+B//lcm
#A以下の個数
a = A-(A//C)-(A//D)+A//lcm
print(b-a)
N = int(input())

print((N*(N-1))/2)

### FIXED CODE ###

ss = input()
tt = input()

c = 0
for s, t in zip(ss, tt):
    if s == t and (s == 'R' or s == 'C' or s == 'S'):
       c += 1

print(c)
n,k=map(int,input().split())
*p,=map(int,input().split())
*c,=map(int,input().split())

ans=-10**20
for i in range(n):
    loop=1
    j=p[i]-1
    acm=[c[j]]
    while j!=i:
        j=p[j]-1
        acm.append(acm[-1]+c[j])
        loop+=1
    
    if acm[-1]>0:
        if k<loop:
            cur=max(acm[:k])
        else:
            cur=(k//loop)*acm[-1]
            cur=max(cur,cur+max(acm[:k%loop]))
    else:
        cur=max(acm[:min(k,loop)])
    
    ans=max(cur,ans)

print(ans)

### FIXED CODE ###

n,k=map(int,input().split())
*p,=map(int,input().split())
*c,=map(int,input().split())

ans=-10**20
for i in range(n):
    loop=1
    j=p[i]-1
    acm=[c[j]]
    while j!=i:
        j=p[j]-1
        acm.append(acm[-1]+c[j])
        loop+=1
    
    if acm[-1]>0:
        if k<=loop:
            cur=max(acm[:k])
        else:
            cur=(k//loop)*acm[-1]
            if k%loop>0:
                cur=max(cur,cur+max(acm[:k%loop]))
            else:
                cur-=acm[-1]
                cur+=max(acm)
    else:
        cur=max(acm[:min(k,loop)])
    
    ans=max(cur,ans)
    
print(ans)
N, A, B =map(int(), input().split())
ans = 0
for i in range(1, N+1):
    if A <= sum(list(map(int, list(str(i))))) <= B:
        ans += i
print(ans)

### FIXED CODE ###

n, a, b = map(int, input().split())
ans = 0
for i in range(n+1):
  if a <= sum(list(map(int, list(str(i))))) <= b:
    ans += i
print(ans)
n=input()
l=list(map(int,input().split()))
ans=0
while all(i%2==0 for i in l):
  l[i/2 for i in l]
  ans+=1
print(ans)

### FIXED CODE ###

input()
A=list(map(int,input().split()))
ans=0
while all(a%2==0 for a in A):
    A=[a/2 for a in A]
    ans+=1
print(ans)
import itertools

n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))

ls = list(itertools.permutations(range(n))) #順列生成
# 絶対値absで辞書順のpからqをひく
print(abs(ls.index(p)-ls.index(q)))

### FIXED CODE ###

import itertools

n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))
# 多分1~4で3!の順列になる
ls = list(itertools.permutations(range(1,n+1))) #順列生成
# 絶対値absで辞書順のpからqをひく
print(abs(ls.index(p)-ls.index(q)))