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

from functools import reduce
t = int(input())
A = [int(s) for s in input().split(" ")]
ans = reduce(lambda x,y: x*y, A)
print(ans if ans <= 10**18 else -1)

### FIXED CODE ###

from functools import reduce
t = int(input())
A = [int(s) for s in input().split(" ")]
if 0 in A:
    print(0)
else:
    ans = 1
    for k in A:
        ans *= k
        if ans > 10**18:
            ans = -1
            break
    print(ans)
### BUGGY CODE ###

import math
def factorial(x):
    for a in range(-1, 1000000000):
        for b in range(-1, 1000000000):
            check = math.pow(a, 5) - math.pow(b, 5)
            if check == x:
                return f'{a} {b}'
x = int(input())
print(factorial(x))


### FIXED CODE ###

import math
def factorial(x):
    max_num = int(2 * (10 ** 9) ** (1 / 5))
    for a in range(-1 * max_num, max_num):
        for b in range(-1 * max_num, max_num):
            check = math.pow(a, 5) - math.pow(b, 5)
            if check == x:
                return f'{a} {b}'


x = int(input())
print(factorial(x))
### BUGGY CODE ###

l,r = map(int,input().split())
ans = 2019
for i in range(l,r):
    for j in range(i+1,r+1):
        p = (i * j) % 2019
        ans = min(p,ans)
print(ans)

### FIXED CODE ###

l,r = map(int,input().split())
ans = 2019
for i in range(l,r):
    for j in range(i+1,r+1):
        p = (i * j) % 2019
        ans = min(p,ans)
        if ans == 0:
            break
    else:
        continue
    break
print(ans)
### BUGGY CODE ###

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

prod=0

law=10**9+7

for i in range(N):
  for j in range(i+1, N):
    prod=prod+((S[i]%law)*(S[j]%law))%law
    
print(prod%law)

### FIXED CODE ###

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

prod=0

law=10**9+7

sumation=sum(S)

for i in range(N):
  sumation=sumation-S[i]
  prod=prod+(S[i]*sumation)%law

print(prod%law)
### BUGGY CODE ###

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

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

visited = [1]
now = 1
step = 0
for i in range(k):
    now = a[now-1]
    step += 1
    if now not in visited:
        visited.append(now)
    else:
        ind = visited.index(now)
        loop = visited[ind:]
        tmp = (k-step) % len(loop)
        now = loop[tmp]
        break

print(now)


### FIXED CODE ###

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

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

visited = [1]
is_visited = [0] * n
now = 1
step = 0
for i in range(k):
    now = a[now-1]
    step += 1
    if is_visited[now-1] == 0:
        is_visited[now-1] = 1
        visited.append(now)
    else:
        ind = visited.index(now)
        loop = visited[ind:]
        tmp = (k-step) % len(loop)
        now = loop[tmp]
        break

print(now)
### BUGGY CODE ###

import sys, heapq, itertools
input = sys.stdin.readline
inf = float('inf')
N, M, R = map(int, input().split())
r = list(map(lambda x: int(x)-1, input().split()))

sec = [[inf] * N for _ in range(N)]
for i in range(N):
    for j in range(N):
        if i == j:
            sec[i][j] == 0
for abc in [list(map(int, input().split())) for _ in range(M)]: 
    sec[abc[0]-1][abc[1]-1] = abc[2]
    sec[abc[1]-1][abc[0]-1] = abc[2]
def marsh():
    for k in range(N):
        for i in range(N):
            for j in range(N):
                sec[i][j] = min(sec[i][j] , sec[i][k] + sec[k][j])

marsh()
cost = inf
for perm in itertools.permutations(r):
    temp = 0
    for i in range(R-1):
        temp += sec[perm[i]][perm[i+1]]
    if temp < cost:
        cost = temp

print(cost)



### FIXED CODE ###

import sys, heapq, itertools
input = sys.stdin.readline
inf = float('inf')
N, M, R = map(int, input().split())
r = list(map(lambda x: int(x)-1, input().split()))

sec = [[inf] * N for _ in range(N)]
for i in range(N):
    for j in range(N):
        if i == j:
            sec[i][j] == 0
for abc in [list(map(int, input().split())) for _ in range(M)]: 
    sec[abc[0]-1][abc[1]-1] = abc[2]
    sec[abc[1]-1][abc[0]-1] = abc[2]
def marsh():
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if sec[i][j] > sec[i][k] + sec[k][j]:
                    sec[i][j] = sec[i][k] + sec[k][j]
marsh()
cost = inf
for perm in itertools.permutations(r):
    temp = 0
    for i in range(R-1):
        temp += sec[perm[i]][perm[i+1]]
    if temp < cost:
        cost = temp

print(cost)
### BUGGY CODE ###

X,Y=map(int,input().split())

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

Z=((X+Y)//3)

if (X+Y)%3==0 and abs(X-Y)<=Z:
  ans=cmb(Z, X-Z)
  print(ans%(10**9+7))
else:
  print(0)

### FIXED CODE ###

X,Y=map(int,input().split())

def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod

Z=((X+Y)//3)

if (X+Y)%3==0 and abs(X-Y)<=Z:
  ans=(comb(Z, X-Z,(10**9+7)))
  print(ans)
else:
  print(0)
### BUGGY CODE ###

from collections import deque
n,x,y,z = map(int,input().split())
mod = 10**9+7
ma = max(x,y,z)

def f(a):
    s = 0
    for e in a:
        s += int(e)
    ind = 0
    while s >= x+y+z:
        s -= int(a[ind])
        ind += 1
    
    ind2 = -1
    for i in range(len(a)-1,ind-1,-1):
        if int(a[i]) > ma:
            ind2 = i
            break
    return a[max(ind,ind2):]

def judge(s):
    sx = 0
    px = -1
    for i in range(len(s)-1,-1,-1):
        sx += int(s[i])
        if sx == x:
            px = i
            break
    if px == -1:
        return True
    
    sy = 0
    py = -1
    for i in range(px-1,-1,-1):
        sy += int(s[i])
        if sy == y:
            py = i
            break
    if py == -1:
        return True
    
    sz = 0
    for i in range(py-1,-1,-1):
        sz += int(s[i])
        if sz == z:
            return False
    return True

d = [{},{'':1}]
sample = ('1','2','3','4','5','6','7','8')

for i in range(n):
    d[i%2] = {}
    for plus in sample:
        for e in d[(i+1)%2]:
            if judge(e+plus):
                new = f(e+plus)
                pl = d[(i+1)%2][e]
                if plus == '8':
                    pl = pl*3%mod
                if new in d[i%2]:
                    d[i%2][new] = (d[i%2][new]+pl)%mod
                else:
                    d[i%2][new] = pl
res = 0
for e in d[(n+1)%2].values():
    res = (res+e)%mod
print((pow(10,n,mod)-res)%mod)



### FIXED CODE ###

mod = 10**9+7
n, x, y, z = map(int,input().split())
xyz = 2**(x+y+z-1) + 2**(y+z-1) + 2**(z-1)
w = 2**(x+y+z-1)
dp = [[0]*w for _ in range(n+1)]
dp[0][0] = 1

for i in range(n):
    for j in range(w):
        for k in range(1,11):
            nj = ((j+j+1)<<(k-1))
            if nj&xyz != xyz:
                dp[i+1][nj%w] = (dp[i+1][nj%w]+dp[i][j])%mod

print((pow(10,n,mod)-sum(dp[-1])%mod)%mod)
### BUGGY CODE ###

def my_solve(string):
    x, y, z, k, *abc = map(int, string.split())
    a, b, c = abc[:x], abc[x:x + y], abc[x + y:]
    ab = sorted([_a + _b for _b in b for _a in a])[-k:]
    *abc, = map(str, sorted([_ab + _c for _c in c for _ab in ab], reverse=True)[:k])
    return "\n".join(abc)


def solve(string):
    x, y, z, k, *abc = map(int, string.split())
    a, b, c = map(sorted, [abc[:x], abc[x:x + y], abc[x + y:]])
    ans = []
    for ia, _a in enumerate(a[::-1], start=1):
        for ib, _b in enumerate(b[::-1], start=1):
            for ic, _c in enumerate(c[::-1], start=1):
                if ia * ib * ic <= k:
                    ans.append(_a + _b + _c)
                else:
                    break
    return "\n".join(list(map(str, sorted(ans, reverse=True)[:k])))


if __name__ == '__main__':
    print(solve('\n'.join([input() for _ in range(4)])))


### FIXED CODE ###

def solve(string):
    x, y, z, k, *abc = map(int, string.split())
    a = abc[:x]
    b = abc[x:x + y]
    c = abc[x + y:]
    ab = sorted([_a + _b for _b in b for _a in a])[-k:]
    *abc, = map(str, sorted([_ab + _c for _c in c for _ab in ab], reverse=True)[:k])
    return "\n".join(abc)


if __name__ == '__main__':
    print(solve('\n'.join([input() for _ in range(4)])))
### BUGGY CODE ###

r, g, b, n = map(int, input().split())
r_num = n // r
g_num = n // g
b_num = n // b
count = 0
for i in range(r_num+1):
    r_remain = n - r * i
    if r_remain == 0:
        count += 1
    else:
        for j in range(g_num+1):
            g_remain = r_remain - g * j
            if g_remain == 0:
                count += 1
            elif g_remain > 0:
                if g_remain % b == 0:
                    count += 1
print(count)

### FIXED CODE ###

r, g, b, n = map(int, input().split())
count = 0
for i in range(0, n+1, r):
    rem = n-i
    for j in range(0, rem+1, g):
        if (rem-j)%b==0:
            count += 1
print(count)
### BUGGY CODE ###

from itertools import product

N = int(input())
XYP = [tuple(map(int, input().split())) for _ in range(N)]
X = [x for x, _, _ in XYP]
Y = [y for _, y, _ in XYP]
INF = 10**18

def calcCost(AP, A):
    ret = [[INF] * N for _ in range(1 << N)]
    for state in range(1 << N):
        useA = [a for i, a in enumerate(A) if (state & (1 << i)) != 0]
        for i, (a, p) in enumerate(AP):
            cost = abs(a)
            for z in useA:
                cost = min(cost, abs(a - z))
            ret[state][i] = cost * p
    return ret

costX = calcCost([(x, p) for x, _, p in XYP], X)
costY = calcCost([(y, p) for _, y, p in XYP], Y)

def makeState(state, sign):
    ret = 0
    for s in state:
        ret <<= 1
        if s == sign:
            ret |= 1
    return ret

ans = [INF] * (N + 1)
for state in product((0, 1, 2), repeat=N):
    stateX = 0
    stateY = 0
    M = N
    for s in state:
        stateX <<= 1
        stateY <<= 1
        if s == 0: M -= 1
        if s == 1: stateX |= 1
        if s == 2: stateY |= 1

    cx = costX[stateX]
    cy = costY[stateY]

    cost = 0
    for i in range(N):
        cost += min(cx[i], cy[i])

    if ans[M] > cost:
        ans[M] = cost

print(*ans, sep='\n')


### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline
from numba import njit
import numpy as np
INF = 10**18

@njit('(i8, i8[:,:])')
def solve(N, XYP):
    X = XYP[:, 0]
    Y = XYP[:, 1]

    def calcCost(sign, A):
        ret = np.ones((1 << N, N), dtype=np.int64) * INF
        for state in range(1 << N):
            useA = [a for i, a in enumerate(A) if (state & (1 << i)) != 0]
            for i in range(N):
                xyp = XYP[i]
                cost = abs(xyp[sign])
                for z in useA:
                    cost = min(cost, abs(xyp[sign] - z))
                ret[state][i] = cost * xyp[2]
        return ret

    costX = calcCost(0, X)
    costY = calcCost(1, Y)
    ans = np.ones(N + 1, dtype=np.int64) * INF

    for state in range(pow(3, N)):
        stateX = 0
        stateY = 0
        M = N
        for _ in range(N):
            state, r = divmod(state, 3)
            stateX <<= 1
            stateY <<= 1
            if r == 0: M -= 1
            if r == 1: stateX |= 1
            if r == 2: stateY |= 1

        cx, cy = costX[stateX], costY[stateY]
        cost = 0
        for i in range(N):
            cost += min(cx[i], cy[i])
        ans[M] = min(ans[M], cost)

    for a in ans:
        print(a)

def sol():
    N = int(input())
    XYP = np.asarray([list(map(int, input().split())) for _ in range(N)])
    solve(N, XYP)

sol()
### BUGGY CODE ###

import itertools
import numpy as np
import math

# print('input >>')
N = int(input())
towns = []
for _ in range(N):
    x, y = map(int,(input().split()))
    towns.append(np.array([x,y]))

sum = 0
perms = itertools.permutations(towns, N)

for path in perms:
    distance = 0
    for i in range(len(path) - 1):
        distance += np.linalg.norm(path[i]-path[i + 1])
    sum += distance

# print('----------output----------')
print(sum / math.factorial(N))

### FIXED CODE ###

import itertools
import numpy as np
import math

# print('input >>')
N = int(input())
towns = []
for _ in range(N):
    x, y = map(int,(input().split()))
    towns.append(np.array([x,y]))

sum = 0
perms = itertools.permutations(range(N), N)

distances = [[0] * N for _ in range(N)]

for i in range(N):
    for j in range(N):
        distances[i][j] = np.linalg.norm(towns[i]-towns[j])

sum = 0
for p in perms:
    distance = 0
    for i in range(N-1):
        distance += distances[p[i]][p[i + 1]]
    sum += distance

# print('----------output----------')
print(sum / math.factorial(N))
### BUGGY CODE ###

# https://atcoder.jp/contests/keyence2020/tasks/keyence2020_b

N = int(input())
X, L = [], []

for i in range(N):
    x, l = list(map(int, input().split()))
    X.append([x, l])
    X.sort(key=lambda x: x[0], reverse=False)

L = [x[1] for x in X]
X = [x[0] for x in X]

ans = 0
cur = -float('inf')
for i in range(N):
    if (cur <= X[i] - L[i]):
        ans += 1
        cur = X[i] + L[i]
print(ans)

### FIXED CODE ###

import sys
N = int(input())
a = sorted([(x + l, x - l) for x, l in (map(int, l.split()) for l in sys.stdin)])

last = a[0][0]
ans = 1

for r, l in a[1:]:
    if last <= l:
        ans += 1
        last = r

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

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

cnt = 0

while(True):
  for idata in b:
    if ((idata % 2 ) == 0):
      continue
    else:
      break
      
print(cnt)

### FIXED CODE ###

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

cnt = 0
endflag = False

while(True):
  for i in range(0,a):
    if ((b[i] %2 ) == 0):
      b[i] = b[i] / 2
    else:
      endflag = True
      break
  if (endflag):
    break
  cnt = cnt + 1

print(cnt)
### BUGGY CODE ###

def compare(a, A):
    R=0
    for i in range(0, len(A)):
        if(a==A[i]):
            R+=1
        elif(a<A[i]):
            break
    return R

def result(R,a):
    if(R==a):
        return 0
    elif(a<R):
        return R-a
    return R

N = int(input())

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

R=0
T=compare(a[0],a)
R+=result(T,a[0])

for i in range(1, N):
    if(a[i] != a[i-1]):
        C=compare(a[i],a[T:])
        R+=result(C,a[i])
        T+=C

print(R)


### FIXED CODE ###

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

a.sort()
a.append(0)

T=[]
j=0
t=0
s=0
for i in range(N):
    j+=1
    if a[i] != a[i+1]:
        if j-s > a[i]:
            t+=(j-s)-a[i]
        elif j-s < a[i]:
            t += j-s
        s=j

print(t)
### BUGGY CODE ###

N, A, B = input().split()
N = int(N)
A = int(A)
B = int(B)

cnt=0
ans=0

while cnt<N:
    if cnt%(A+B)<A:
        cnt+=1
        ans+=1
    else:
        cnt+=1
        
print(ans)

### FIXED CODE ###

N, A, B = input().split()
N = int(N)
A = int(A)
B = int(B)
ans=0

if N%(A+B)<=A:
    ans = N//(A+B) * A + N%(A+B)
else:
    ans = N//(A+B) * A + A

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

from collections import deque
K = int(input())

q = deque()
q.append((1, 1, 1))
used = set()
while True:
    x, y, k = q.popleft()
    if (x, y, k) in used:
        continue
    else:
        used.add((x, y, k))
    # print(x, y, k)
    if k % K == 0:
        print(x)
        break
    q.appendleft((x, 0, k*10%K))
    if (y + 1) % 10 == 0:
        q.appendleft((x, 0, k+1))
    else:
        q.append((x+1, y+1, k+1))


### FIXED CODE ###

from collections import deque
K = int(input())

q = deque()
q.append((1, 1, 1))
used = set()
while True:
    x, y, k = q.popleft()
    if k % K == 0:
        print(x)
        break
    if (x, 0, k*10%K) in used:
        continue
    else:
        used.add((x, 0, k*10%K))
    q.appendleft((x, 0, k*10%K))
    if (y + 1) % 10 == 0:
        q.appendleft((x, 0, k+1))
    else:
        q.append((x+1, y+1, k+1))
### BUGGY CODE ###

N = int(input())
A = (list(map(int, input().split(' '))))
D = [0]*(pow(10,6)+1)
ans = 0
for i in A:
    D[i] += 1
for i in set(A):
    flg = True
    if D[i] > 1:
        continue
    for j in range(1,int(pow(i,0.5))+2):
        if not i%j:
            if D[j] and i != j:
                flg = False
                break
            if j != i//j and D[i//j] and i//j != i:
                    flg = False
                    break
    if flg:
        ans += 1
print(ans)

### FIXED CODE ###

from collections import Counter
N = int(input())
A = Counter(list(map(int,input().split(' '))))
ans = 0
m = max(A.keys())
L = [1]*(10**6+1)
for i in sorted(A.keys()):
    if not L[i]:
        continue
    if A[i] == 1:
        ans += 1
    for j in range(i,m+1,i):
        L[j] = 0
print(ans)
### BUGGY CODE ###

import heapq

n,m,s=map(int,input().split())
path=[[] for _ in range(n+1)]
coin=[(0,0)]
time=[float("inf") for _ in range(n+1)]
time[0]=0
queue=[]
A=0
for i in range(m):
    u,v,a,b=map(int,input().split())
    A=max(a,A)
    path[u].append((v,a,b))
    path[v].append((u,a,b))

for i in range(n):
    c,d=map(int,input().split())
    coin.append((c,d))

heapq.heappush(queue,(0,s,1,1))
while len(queue)!=0:
    t,c,v,d=heapq.heappop(queue)
    if time[v]>t:
        time[v]=t
    for nv,na,nb in path[v]:
        if na>c:
            continue
        else:
            heapq.heappush(queue,(t+nb,c-na,nv,d+1))
    if c > (n-d)*A:
        continue
    else:
        heapq.heappush(queue,(t+coin[v][1],c+coin[v][0],v,d))
    
print(*time[2:],sep="\n")

### FIXED CODE ###

import heapq

n,m,s=map(int,input().split())
limit=2500
s=min(s,limit)
path=[[] for _ in range(n+1)]
coin=[(0,0)]
time=[[float("inf") for _ in range(limit+1)] for _ in range(n+1)]
queue=[]

for i in range(m):
    u,v,a,b=map(int,input().split())
    path[u].append((v,a,b))
    path[v].append((u,a,b))

for i in range(n):
    c,d=map(int,input().split())
    coin.append((c,d))

time[1][s]=0
heapq.heappush(queue,(0,1,s))

while len(queue)!=0:
    t,v,c=heapq.heappop(queue)
    for nv,na,nb in path[v]:
        if na>c:
            continue
        elif time[nv][c-na]<=t+nb:
            continue
        else:
            time[nv][c-na]=t+nb
            heapq.heappush(queue,(t+nb,nv,c-na))

    nc=min(c+coin[v][0],limit)
    nt=t+coin[v][1]
    if time[v][nc]<=nt:
        continue
    else:
        time[v][nc]=nt
        heapq.heappush(queue,(nt,v,nc))
    
for i in range(2,n+1):
    print(min(time[i]))
### BUGGY CODE ###

N = int(input())
A = input().split()

for i in range(1,N+1):
    print(A.count(str(i)))

### FIXED CODE ###

N = int(input())
A = input().split()

import collections
c = collections.Counter(A)

for i in range(1,N+1):
    print(c[str(i)])
### BUGGY CODE ###

def solve(N):
    answer = 0
    for i in range(N):
        answer += i
    return answer


if __name__ == '__main__':
    N = int(input())

    answer = solve(N)
    print(answer)


### FIXED CODE ###

def solve(N):
    return (N * (N - 1)) // 2
 
 
if __name__ == '__main__':
    N = int(input())
 
    answer = solve(N)
    print(int(answer))
### BUGGY CODE ###

S = input()
Q = int(input())
reverseCount = 0
for _ in range(Q):
    query = input()
    if len(query) == 1:
        reverseCount += 1
    else:
        _, F, C = query.split(" ")
        if (F == "1" and reverseCount % 2 == 0) or (F == "2" and reverseCount % 2 == 1):
            S = C + S
        else:
            S = S + C
if reverseCount % 2 == 0:
    print(S)
else:
    print(S[::-1])


### FIXED CODE ###

S = input()
Q = int(input())
reverseCount = 0
pre = ""
pro = ""
for _ in range(Q):
    query = input()
    if len(query) == 1:
        reverseCount += 1
    else:
        _, F, C = query.split(" ")
        if (int(F) + reverseCount) % 2 == 1:
            pre = C + pre
        else:
            pro = pro + C
S = pre + S + pro
if reverseCount % 2 == 0:
    print(S)
else:
    print(S[::-1])
### BUGGY CODE ###

n,k = map(int,input().split())
s = []
count = 0
last = 1
for i in input():
    if i=='1':
        if last==1:
            count+=1
        else:
            s.append(count)
            count=1
        last = 1
    else:
        if last==0:
            count+=1
        else:
            s.append(count)
            count=1
        last = 0
s.append(count)
if last=='0':
    s.append(0)

k = min(k,len(s)//2)
ans = 0
for j in range(len(s)//2-k+1):
    ans = max(ans,sum(s[j*2:(j+k)*2+1]))
print(ans)

### FIXED CODE ###

#ABC124 D-Handstand
n,k = map(int,input().split())
s = []
count = 0
last = 1
for i in input():
    if i=='1':
        if last==1:
            count+=1
        else:
            s.append(count)
            count=1
        last = 1
    else:
        if last==0:
            count+=1
        else:
            s.append(count)
            count=1
        last = 0
s.append(count)
if last==0:
    s.append(0)

k = min(k,len(s)//2)
ans = 0

for j in range(len(s)//2-k+1):
    if j==0:
        now = sum(s[:k*2+1])
        ans = now
    else:
        now = now-s[j*2-1]-s[j*2-2]+s[(j+k)*2]+s[(j+k)*2-1]
        ans = max(ans,now) 
print(ans)
### BUGGY CODE ###

from math import sqrt

x = int(input())
xr = int(sqrt(x))

l=[1]
for i in range(1,xr+1):
    t=[]
    for j in range(2,xr):
        if i**j <= x:
            t.append(i**j)
        else:
            break
    l = l+t
l = list(set(l))
l.sort()


left=0
right=len(l)
center=0

while left < right:
    center = (left+right)//2
    if l[center] == x:
        break
    elif l[center] < x:
        left = center
    else:
        right = center

print(l[center])

### FIXED CODE ###

from math import sqrt

x = int(input())
xr = int(sqrt(x))

l=[1]
for i in range(1,xr+1):
    t=[]
    for j in range(2,xr):
        if i**j <= x:
            t.append(i**j)
        else:
            break
    l = l+t
l = list(set(l))
l.sort()


left=0
right=len(l)
center=0

while left < right:
    center = (left+right)//2
    if l[center] == x:
        break
    elif l[center] < x:
        left = center+1
    else:
        right = center

print(l[center])
### BUGGY CODE ###

from collections import defaultdict as d
p=d(str)
n=int(input())
print(0, flush = True)
s = input()
if s == "Vacant": exit()
else:
    print(n-1,flush=True)
    t=input()
    if t == "Vacant": exit()
    else:
        p[0]=s
        p[n-1]=t
        l=0
        r=n-1
        while r-l>0:
            g=(l+r)//2
            if p[l]=="":
                print(l, flush = True)
                s = input()
                p[l]=s
                if s == "Vacant": exit()
                else:
                    s=p[l]
            if p[g]=="":
                print(g, flush = True)
                t = input()
                p[g]=t
                if t == "Vacant": exit()
                else:
                    t=p[g]
            if ((g-l)%2!=0 and s!=t) or ((g-l)%2!=1 and s==t):
                l=g
            else:
                r=g
        if p[l]=="":
            print(l, flush = True)
            s = input()
            if s == "Vacant": exit()
        if p[r]=="":
            print(r, flush = True)
            t = input()
            if t == "Vacant": exit()


### FIXED CODE ###

from collections import defaultdict as d
p=d(str)
n=int(input())
print(0, flush = True)
s = input()
if s == "Vacant": exit()
else:
    p[0]=s
    p[n]=s
    l=0
    r=n
    while 1:
        g=(l+r)//2
        print(g, flush = True)
        s = input()
        p[g]=s
        if s == "Vacant": break
        else:
            t=p[l]
            if ((g-l)%2!=0 and s!=t) or ((g-l)%2!=1 and s==t):
                l=g
            else:
                r=g
### BUGGY CODE ###

n = (int)(input())
s = [input() for i in range(n)]
count = [[0 for i in range(26)] for j in range(n)]
for i in range(n):
  for j in range(10):
    count[i][ord(s[i][j]) - 97] += 1
#print(*count)

ans = 0
for i in range(n - 1):
  for j in range(i + 1, n):
    if count[i] == count[j]:
      ans += 1
print(ans)

### FIXED CODE ###

n = (int)(input())
s = sorted([sorted(list(input())) for i in range(n)])
 
ans = 0
temp = 1
for i in range(n - 1):
  if s[i] == s[i + 1]:
    temp += 1
  else:
    if temp != 1:
      ans += temp * (temp - 1) // 2
      temp = 1
else:
  if temp != 1:
    ans += temp * (temp - 1) // 2
    temp = 1
print(ans)