Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

n = list(map(int, input().split()))
a = list(map(int, input().split()))
for i in range(n[1]):
    a[a.index(max(a))]=int(max(a)/2)
print(sum(a))

### FIXED CODE ###

import heapq

N, M= map(int, input().split())
A = list(map(int, input().split()))
a=[-1*i for i in A]
heapq.heapify(a)
for i in range(M):
    m=int(heapq.heappop(a)/2)
    heapq.heappush(a, m)

print(-1*sum(a))
### BUGGY CODE ###

import bisect

N = int(input())
a = list(map(int, input().split()))
to = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v = map(int, input().split())
    to[u - 1].append(v - 1)
    to[v - 1].append(u - 1)


dp = [None] * N

dp[0] = [a[0]]
Q = [0]

while Q:
    u = Q.pop()
    for v in to[u]:
        if dp[v] is not None:
            continue
        dp[v] = [*dp[u]]
        if a[v] > dp[u][-1]:
            dp[v].append(a[v])
        else:
            dp[v][bisect.bisect_left(dp[v], a[v])] = a[v]
        Q.append(v)

for d in dp:
    print(len(d))


### FIXED CODE ###

import bisect
import sys


N = int(input())
a = list(map(int, input().split()))
to = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    to[u].append(v)
    to[v].append(u)
del u, v

ans = [-1] * N


def dfs(v, dp):
    # dp は参照渡し
    if len(dp) == 0 or a[v] > dp[-1]:
        dp.append(a[v])
        back = -1
    else:
        pos = bisect.bisect_left(dp, a[v])
        back = dp[pos]
        dp[pos] = a[v]
    ans[v] = len(dp)

    for u in to[v]:
        if ans[u] == -1:
            dfs(u, dp)
    if back == -1:
        dp.pop()
    else:
        dp[pos] = back


sys.setrecursionlimit(10 ** 6)
dfs(0, [])


for an in ans:
    print(an)
### BUGGY CODE ###

# B - Frog2
import numpy as np

N, K = list(map(int, input().split()))
h = list(map(int, input().split()))
dp = [10**9]*N

dp[0] = 0

for i in range(N-1):
    if i+K+1 <= N-1:
        for j in range(i+1, i+K+1):
            dp[j] = min(dp[j], dp[i]+abs(h[j]-h[i]))
    else:
        for j in range(i+1, N):
            dp[j] = min(dp[j], dp[i]+abs(h[j]-h[i]))
print(dp[N-1])

### FIXED CODE ###

# B - Frog2
import numpy as np

N, K = list(map(int, input().split()))
h = np.array(list(map(int, input().split()))+[0]*K)

dp = np.array([10**9]*(N+K))
dp[0] = 0

for i in range(N):
    dp[i+1:i+K+1] = np.minimum(dp[i+1:i+K+1], dp[i]+abs(h[i+1:i+K+1]-h[i]))
print(dp[N-1])
### BUGGY CODE ###

n, m = map(int, input().split())
h = list(map(int, input().split()))
ab_list = [list(map(int, input().split())) for i in range(m)]
count = 0
good = [i+1 for i in range(n)]
#print(h,ab_list)
for j in range(m):
    if h[ab_list[j][0]-1] <= h[ab_list[j][1]-1]:
        if ab_list[j][0] in good:
            good.remove(ab_list[j][0])
    if h[ab_list[j][0]-1] >= h[ab_list[j][1]-1]:
        if ab_list[j][1] in good:
            good.remove(ab_list[j][1])
    #print(good)
print(len(good))


### FIXED CODE ###

n,m = map(int, input().split())
h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(m)]

good = [1]*n

for comb in ab:
    a = comb[0]-1
    b = comb[1]-1
    if h[a] <= h[b]:
        good[a] = 0
    if h[a] >= h[b]:
        good[b] = 0

ans = sum(good)
print(ans)
### BUGGY CODE ###

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

C = []

for i in range(N):
    for j in range(N):
        if i+1 == A[j]:
            C.append(j+1)
            break

print(' '.join(map(str, C)))


### FIXED CODE ###

import numpy as np

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

C = np.argsort(A) + 1

print(' '.join(map(str, C)))
### BUGGY CODE ###

s = input()

for i in range(len(s)):
  if s[i] == "A":
    st = i+1
    break

for i in range(len(s)):
  if s[::-1][i] == "Z":
    en = len(s)-i
    break

print(en - st + 1)

### FIXED CODE ###

s = input()
sr = s[::-1]

for i in range(len(s)):
  if s[i] == "A" :
    st = i+1
    break

for i in range(len(s)):
  if sr[i] == "Z":
    en = len(s)-i
    break

print(en - st + 1)
### BUGGY CODE ###

n=int(input())
s=input()
ans=0
for i in range(n):
    si=s[i]
    for j in range(i+1,n):
        sj=s[j]
        tmp=j-i
        if si==sj:
            pass
        else:
            for k in range(j+1,n):
                sk=s[k]
                if tmp==k-j:
                    continue
                if sk==si or sk==sj:
                    continue
                ans+=1
print(ans)


### FIXED CODE ###

n=int(input())
s=input()
r=s.count("R")
g=s.count("G")
b=s.count("B")
ans=r*g*b
for i in range(n):
    for j in range(n):
        if i+j+j>=n:
            break
        s1=s[i]
        s2=s[i+j]
        s3=s[i+j*2]
        if s1!=s2 and s2!=s3 and s1!=s3:
            ans-=1
print(ans)
### BUGGY CODE ###

n = int(input())
stones = input()

frac = []
for i in range(n+1):
	sum_loss = stones[:i].count("#") + stones[i:].count(".")
	frac.append(sum_loss)
print(min(frac))

### FIXED CODE ###

#毎回関数を呼ぶとおそくなる
n = int(input())
stones = input()
score = stones.count(".")
r = score
for i in range(n):
	if stones[i] == ".":
		r -= 1
	else:
		r += 1
	score = min(r, score)
print(score)
### BUGGY CODE ###

import sys
count = 1
while True:
    x = sys.stdin.readline().strip()
    if x == 0:
        break
    print("Case {}: {}".format(count,x))
    count += 1

### FIXED CODE ###

import sys
count = 1
while True:
    x = sys.stdin.readline().strip()
    if x == "0":
        break
    print("Case {}: {}".format(count,x))
    count += 1
### BUGGY CODE ###

N, M = map(int, input().split())
A = {}
ac = []
for i in range(M):
    p, s = map(str, input().split())
    if int(p) not in ac:
        if int(p) not in A.keys(): 
            if int(p) >0 and int(p) <=N :
                if s == "WA":
                    A[int(p)] =1
                elif s =="AC":
                    A[int(p)] =0
                    ac.append(int(p))
        elif int(p) in A.keys():
            if s == "WA":
                    A[int(p)] +=1
            elif s =="AC":
                    A[int(p)] +=0
                    ac.append(int(p))
        
total=0
count = 0
for k,v in A.items():
    if k in ac:
        count += 1
        total += v
print(count,total)

### FIXED CODE ###

import numpy as np
N, M = map(int, input().split())
AC = np.array([0]*N)
WA = np.array([0]*N)

for i in range(M):
    p, s = map(str, input().split())
    if AC[int(p)-1] == 0 and s =="WA":
        WA[int(p)-1] += 1
    else:
        AC[int(p)-1] = 1
        

print(sum(AC), sum(AC*WA))
### BUGGY CODE ###

n = int(input())
value_list = []

for i in range(n):
    value_list.append(int(input()))

most_max = max(value_list)

for i in range(n):
    if value_list[i] == most_max:
        value_list[i] = 0
        print(max(value_list))
        value_list[i] = most_max
    else:
        print(most_max)

### FIXED CODE ###

n = int(input())
value_list = []

for i in range(n):
    value_list.append(int(input()))

most_max = max(value_list)

if len([i for i, x in enumerate(value_list) if x == most_max]) == 2:
    for i in range(n):
        print(most_max)
else:
    most_max_index = value_list.index(most_max)
    value_list[most_max_index] = 0
    second_max = max(value_list) 
    value_list[most_max_index] = most_max
    
    for i in range(n):
        if value_list[i] == most_max:
            print(second_max)
        else:
            print(most_max)
### BUGGY CODE ###

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

tmp = []
s = 0
for i in a:
    if s + i <= k:
        tmp.append(i)
        s += i
a = tmp
tmp = []
s = 0
for i in b:
    if s + i <= k:
        tmp.append(i)
        s += i
b = tmp
line = b[::-1] + a

ans = 0
left = 0
for left in range(len(line)):
    sum_ = 0
    right = left
    while right < len(line) and sum_ + line[right] <= k:
        sum_ += line[right]
        right += 1
    l = right -left
    if l > ans:
        ans = l
print(ans) 

### FIXED CODE ###

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

tmp = []
s = 0
for i in a:
    if s + i <= k:
        tmp.append(i)
        s += i
    else:
        break
a = tmp
tmp = []
s = 0
for i in b:
    if s + i <= k:
        tmp.append(i)
        s += i
    else:
        break
b = tmp
line = b[::-1] + a

ans = 0
right = 0
sum_ = 0
for left in range(len(line)):
    while right < len(line) and sum_ + line[right] <= k:
        sum_ += line[right]
        right += 1
    l = right -left 
    if l > ans:
        ans = l

    if right == left: right += 1
    else: sum_ -= line[left]

print(ans)
### BUGGY CODE ###

S = input()
Q = int(input())
Queries = [input().split() for _ in range(Q)]

need_reverse = False

for q in Queries:
    if q[0] == "1":
        need_reverse = not need_reverse
    else:
        if q[1] == "1":
            if not need_reverse:
                S = q[2] + S
            else:
                S += q[2]
        else:
            if not need_reverse:
                S += q[2]
            else:
                S = q[2] + S

print(S if not need_reverse else S[::-1])


### FIXED CODE ###

from collections import deque

S = deque(input())
Q = int(input())

reverse = False
cnt = 0
for i in range(Q):
    inp = input().split()
    if inp[0] == "1":
        cnt += 1
        reverse = (cnt % 2 != 0)
        #S = S[::-1]
    else:
        f, c = inp[1:]
        if int(f) == 1:
            if reverse:
                S.append(c)
            else:
                S.appendleft(c)
        else:
            if reverse:
                S.appendleft(c)
            else:
                S.append(c)
S = "".join(S)
print(S[::-1] if reverse else S)
### BUGGY CODE ###

#hozon
[N,L] = [int(x) for x in input().split()]
A = {}
B = [0]*N
ANS = {}
count = 0
for i,x in enumerate(input().split()):
    i = int(i)
    x = int(x)
    B[i] = x
    if x in A : A[x] += [i]
    else : A[x] = [i]
for i in sorted(A) :
    for j in A[i] :
        for k in range(L) :
            if j + k not in ANS :
                ANS[j+k] = i
                count += 1
    if count > N * 0.99 : break
        
for i in range(L):
    if i not in ANS : ANS[i] = min(B[:i+1])
for i in range(L,N):
    if i not in ANS : ANS[i] = min(B[i+1-L:i+1])
for i in range(L-1,N-1) : print(ANS[i], end=" ")
print(ANS[N-1])

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
### BUGGY CODE ###

#!/usr/bin/env python3
# Atcoder necoak answer
# https://atcoder.jp/contests/diverta2019/tasks/diverta2019_a
import itertools

intext = input()
[n, k] = map(int, intext.split())

int_list = [v for v in range(1, n+1)]
nk_combis = itertools.combinations(int_list, k)
ans_nk_combis = []

for nk_combi in nk_combis:
    # print(nk_combi) #
    nk_list = list(nk_combi)
    # nk_list.sort()

    prev_item = None
    is_renzoku = True

    for nk_item in nk_list:
        # print(prev_item, nk_item)
        if prev_item == None:
            prev_item = nk_item
            continue
        if prev_item + 1 != nk_item:
            is_renzoku = False
            break
        prev_item = nk_item

    if is_renzoku:
        ans_nk_combis.append(nk_list)

# print(ans_nk_combis)
print(len(ans_nk_combis))


### FIXED CODE ###

#!/usr/bin/env python3
# Atcoder necoak answer
# https://atcoder.jp/contests/diverta2019/tasks/diverta2019_a
import itertools

intext = input()
[n, k] = map(int, intext.split())
print(n-k+1)
### BUGGY CODE ###

import bisect

n = int(input())
d = sorted(list(map(int,input().split())))
m = int(input())
t = sorted(list(map(int,input().split())))

flg = True
for i in range(m):
  if t[-1]>d[-1]:
    flg = False
    break
  else:
    index = bisect.bisect_left(d,t[i])
    if t[i] == d[index]:
      del d[index]
    else:
      flg = False
      break

print('YES' if flg else 'NO')

### FIXED CODE ###

import collections
 
n = int(input())
d = sorted(list(map(int,input().split())))
m = int(input())
t = list(map(int,input().split()))

cd = collections.Counter(d)
ct = collections.Counter(t)

flg = True
for k in ct.items():
  if k[1] > cd[k[0]]:
    flg = False

print('YES' if flg else 'NO')
### BUGGY CODE ###

class DoblyLinkedList:
    class node:
        def __init__(self, pre, val, nex):
            self.val = val
            self.pre = pre
            self.nex = nex

    def __init__(self, num):
        self.elements = {0: self.node(None, num, None)}
        self.top = 0
        self.bottom = 0
        self.cnt = 0

    def push_top(self, val):
        self.cnt += 1
        self.elements[self.top].pre = self.cnt
        node = self.node(None, val, self.top)
        self.elements[self.cnt] = node
        self.top = self.cnt

    def push_bottom(self, val):
        self.cnt += 1
        self.elements[self.bottom].nex = self.cnt
        node = self.node(self.bottom, val, None)
        self.elements[self.cnt] = node
        self.bottom = self.cnt

    @staticmethod
    def from_str(s):
        ret = DoblyLinkedList(s[0])
        for v in s[1:]:
            ret.push_bottom(v)
        return ret

    def to_str(self):
        cur = self.top
        val = self.elements[self.top].val
        while self.elements[cur].nex is not None:
            val += self.elements[self.elements[cur].nex].val
            cur = self.elements[cur].nex
        return val


def main():
    s = input()
    d = DoblyLinkedList.from_str(s)
    q = int(input())
    swapped = 0
    for _ in range(q):
        query = input()
        if len(query) == 1:
            swapped = 1 - swapped
            continue
        _, f, c = query.split()
        if swapped:
            if f == '1':
                d.push_bottom(c)
            else:
                d.push_top(c)
        else:
            if f == '1':
                d.push_top(c)
            else:
                d.push_bottom(c)



    if swapped:
        print(d.to_str()[::-1])
    else:
        print(d.to_str())


if __name__ == '__main__':
    main()



### FIXED CODE ###


def main():
    s = input()
    q = int(input())
    bottom = ''
    top = ''
    swapped = 0
    for _ in range(q):
        query = input()
        if len(query) == 1:
            swapped = 1 - swapped
            continue
        _, f, c = query.split()
        if swapped:
            if f == '1':
                bottom += c
            else:
                top += c
        else:
            if f == '1':
                top += c
            else:
                bottom += c

    if swapped:
        print(bottom[::-1] + s[::-1] + top)
    else:
        print(top[::-1]+s+bottom)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

N, X = map(int, input().split())
S = list(map(int, input().split()))

numbers = S[:]

def dps(numbers, x):
    if len(numbers) == 1:
        return x % numbers[0]
    
    ret = 0
    for i, n in enumerate(numbers):
        x_mod = x % n
        if x_mod == 0:
            ret += x_mod
        ret += dps(numbers[0:i] + numbers[i+1:], x_mod)
    return ret
        
ans = dps(numbers, X)
ans = ans % (10 ** 9 + 7)
print(ans)

### FIXED CODE ###

N, X = map(int, input().split())
S = list(map(int, input().split()))

MOD = 1000000007
numbers = S[:]
numbers.sort(reverse=True)


dp = {X: 1}

for i, n in enumerate(numbers):
    tmp_dp = {}
    for k, v in dp.items():
        if k < n:
            tmp_dp[k] = (tmp_dp.get(k,0)+v*(N-i))
        else:
            tmp_dp[k]=(tmp_dp.get(k,0)+v*(N-i-1)) 
            tmp_dp[k%n]=(tmp_dp.get(k%n,0)+v) 
    dp = tmp_dp.copy()
        
ans = 0
for k, v in dp.items():
    ans += k *  v

print(ans % MOD)
### BUGGY CODE ###

N = int(input())

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

count = 0
for i in range(N-1):
    for j in range(i+1, N):
        if abs(i-j) == A[i] + A[j]:
            count += 1
            
print(count)

### FIXED CODE ###

import collections
N = int(input())

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

plus = [0] * (N-1)
for i in range(N-1):
  plus[i] = i + A[i]

minus = [0] * (N-1)
for j in range(1, N):
  minus[j-1] = j - A[j]

sum = 0
c = dict(collections.Counter(minus))
for i in range(N-1):
  sum += c.get(plus[i], 0)
  c[minus[i]] -= 1

print(sum)
### BUGGY CODE ###


import math
from collections import defaultdict


def factorization(x, d):
    """
    素因数分解する
    かつ途中結果を利用して計算を効率よく行いたい

    fa(x) をxの素因数分解とする ; a^x * b^y * ...
    例えばxが2で割り切れるとすると、
    fa(x) = 2 * fa(x // 2) = ... = 2 * .... * fa(1)
    となるため、計算過程を覚えておいて、逆算することで
    xを試し割りする途中の値についても素因数分解をえる
    """
    if x == 1:
        # d[1]はすでに格納済みの想定
        return d

    calc = [(1, x)]
    found = False
    for t in range(2, math.floor(math.sqrt(x)) + 1):
        if found:
            break
        
        while x % t == 0:
            calc.append((t, x // t))
            x //= t
            if x in d:
                found = True
                break

    if not found and x > 1:
        calc.append((x, 1))

    while len(calc) > 1:
        c, b = calc.pop()
        y = c * b
        d[y] = d[b].copy()
        d[y][c] += 1
    return d


def divisors(fact):
    values = fact.values()
    ans = 1
    for v in values:
        ans *= (v + 1)
    return ans


def submit():
    n = int(input())
    d = {1: defaultdict(int)}

    ans = 0
    while n > 1:
        if n not in d:
            d = factorization(n, d)
        
        ans += n * divisors(d[n])
        n -= 1
    print(ans + 1)


if __name__ == "__main__":
    submit()
    

### FIXED CODE ###



def submit():
    n = int(input())
    d = [1 for _ in range(n + 1)]
    d[0] = 0

    # エラトステネスの篩風
    for i in range(2, n + 1):
        coef = 1
        while i * coef <= n:
            d[i * coef] += 1
            coef += 1

    ans = 0
    for k in range(1, n + 1):
        ans += k * d[k]

    print(ans)


if __name__ == "__main__":
    submit()
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
b = [None] * n
b[0] = str(a.index(1) + 1)
for i in range(1, n):
    b[i] = str(a.index(i + 1) + 1)
print(" ".join(b))


### FIXED CODE ###

import sys
import collections
import bisect


def main():
    n = int(input())
    A = list(map(int, input().split()))
    B = [0] * n
    for i in range(n):
        B[A[i] - 1] = str(i + 1)
    print(" ".join(B))


if __name__ == '__main__':
    main()
### BUGGY CODE ###

import sys
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def solve():
    n, m, d = getList()
    if d == 0:
        each = n
    else:
        each = (n - d) * 2
    igai = pow(n, m-2)
    all = each * igai * (m-1)
    ans = all/pow(n,m)

    print(ans)
def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()

### FIXED CODE ###

import sys
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def solve():
    n, m, d = getList()
    if d == 0:
        each = n
    else:
        each = (n - d) * 2
    # igai = pow(n, m-2)
    all = each * (m-1) / (n * n)
    ans = all

    print(ans)
def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()
### BUGGY CODE ###

n=int(input())
r=sorted(list(map(int,input().split())))
m=int(input())
d=sorted(list(map(int,input().split())))

for item in d:
  if item in r:
    r.remove(item)
  else:
    print("NO")
    exit()
print("YES")


### FIXED CODE ###

import collections

a=int(input())
b=collections.Counter(list(map(int,input().split())))
c=int(input())
d=collections.Counter(list(map(int,input().split())))
e=set(d)

for item in e:
  if d[item]>b[item]:
    print("NO")
    exit()
    
print("YES")
### BUGGY CODE ###

from fractions import gcd
from functools import reduce
from collections import deque

N = int(input())

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

def check(inf):
  return reduce(gcd, inf)
m=0
for i in range(N):
  x = line.pop()
  g = check(line)
  if g>m:
    m = g
  line.appendleft(x)

print(m)

### FIXED CODE ###

from fractions import gcd
from collections import deque

N = int(input())
A = [int(a) for a in input().split()]
L = deque([0])
R = deque([0])

for i in range(N):
  L.append(gcd(L[i],A[i]))
for i in range(N)[::-1]:
  R.appendleft(gcd(R[0],A[i]))

ans = []
for i in range(N):
  ans += [gcd(L[i], R[i+1])]
print(max(ans))
### BUGGY CODE ###

n = int(input())
l = list("")
for i in range(n):
    l.append(input())
s = list(set(l))
s.sort()
max = 0
a = list("")
for i in range(len(s)):
    c = l.count(s[i])
    a.append(c)
    if c > max:
        max = c
for i in range(len(s)):
    if a[i] == max:
        print(s[i])

### FIXED CODE ###

from collections import Counter

n = int(input())
l = list("")
for i in range(n):
    l.append(input())
c = Counter(l)
c = c.most_common()
max = c[0][1]
a = list("")
for i in range(len(c)):
    if c[i][1] == max:
        a.append(c[i][0])
    else:
        break
a.sort()
for i in range(len(a)):
    print(a[i])
### BUGGY CODE ###

N = int(input())
anagram = [None]*N

ans = 0
for i in range(N):
    anagram[i] = "".join(sorted(input()))

for i in range(N):
    for j in range(i+1, N):
        if anagram[i] == anagram[j]:
            ans += 1

print(ans)

### FIXED CODE ###

N = int(input())
anagram = {}

ans = 0
for i in range(N):
    tmp = str(sorted(input()))
    if tmp in anagram:
        ans += anagram[tmp]
        anagram[tmp] += 1
    else:
        anagram[tmp] = 1

print(ans)