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


from scipy.stats import rankdata
N,M = list(map(int,input().split()))

PY = []
P_Y = [[] for i in range(N)]

p_count = [0 for i in range(N)]

for i in range(M):
    p,y = list(map(int,input().split()))
    P_Y[p-1].append(y)
    p_count[p-1]+=1
    PY.append([p,y])
    
import numpy as np

P_Y_arg = []
for i in range(N):
    P_Y_arg.append(rankdata(np.array(P_Y[i])))

    
p_count = [0 for i in range(N)]

for i in range(M):
    ps = str(1000000+PY[i][0])
    ys = str(1000000+int(P_Y_arg[PY[i][0]-1][p_count[PY[i][0]-1]]))
    p_count[PY[i][0]-1]+=1
    print(ps[1:]+ys[1:])
    
    

### FIXED CODE ###

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

PY = []
P_Y = [[] for i in range(N)]

p_count = [0 for i in range(N)]

for i in range(M):
    p,y = list(map(int,input().split()))
    P_Y[p-1].append(y)
    p_count[p-1]+=1
    PY.append([p,y])
    
import numpy as np

P_Y_arg = []
for i in range(N):
    P_Y_arg.append(np.array(P_Y[i]).argsort().argsort())

    
p_count = [0 for i in range(N)]

for i in range(M):
    ps = str(1000000+PY[i][0])
    ys = str(1000000+int(P_Y_arg[PY[i][0]-1][p_count[PY[i][0]-1]])+1)
    p_count[PY[i][0]-1]+=1
    print(ps[1:]+ys[1:])
### BUGGY CODE ###

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

from collections import deque
queue=deque(A)
for i in range(M):
    queue.extend([max(queue)//2])
    queue.remove(max(queue))
print(sum(queue))

### FIXED CODE ###

from heapq import heappop,heappush,heapify
n,m=map(int,input().split())
A=list(map(int,input().split()))
A_m=list(map(lambda x: -x,A))
heapify(A_m)
pop=lambda: -heappop(A_m)
push=lambda x: heappush(A_m,-x)
for _ in range(m):
    x=pop()
    push(x//2)
print(-sum(A_m))
### BUGGY CODE ###

import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
N = I()
A = LI()

i = 10**18
ans = 1
for a in A:
    ans *= a
if ans > i:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
A = LI()
#print(A)
i = 10**18
ans = 1
if min(A) == 0:
    ans = 0
else:
    for a in A:
        ans *= a
        if ans > i:
            ans = -1
            break
print(ans)
### BUGGY CODE ###

import math
from functools import reduce
N = int(input())
def gcd(*numbers):
    return reduce(math.gcd, numbers)
a = 0
for i in range(1,N+1):
    for j in range(1,N+1):
        for k in range(1,N+1):
            a+= gcd(i,j,k)
            #print(i,j,k)
print(a)

### FIXED CODE ###

K =int(input())
l = [0, 1, 9, 30, 76, 141, 267, 400, 624, 885, 1249, 1590, 2208, 2689, 3411, 4248, 5248, 6081, 7485, 8530, 10248, 11889, 13687, 15228, 17988, 20053, 22569, 25242, 28588, 31053, 35463, 38284, 42540, 46581, 50893, 55362, 61824, 65857, 71247, 76884, 84388, 89349, 97881, 103342, 111528, 120141, 128047, 134580, 146316, 154177, 164817, 174438, 185836,194157,207927, 218812, 233268, 245277, 257857, 268182, 288216, 299257, 313635, 330204, 347836, 362973, 383709, 397042, 416448, 434025, 456967, 471948, 499740, 515581, 536073, 559758, 583960, 604833, 633651, 652216, 683712, 709065, 734233, 754734, 793188, 818917, 846603, 874512, 909496, 933081, 977145, 1006126, 1041504, 1073385, 1106467, 1138536, 1187112, 1215145, 1255101, 1295142, 1342852, 1373253, 1422195, 1453816, 1502376, 1553361, 1595437, 1629570, 1691292, 1726717, 1782111, 1827492, 1887772, 1925853, 1986837, 2033674, 2089776, 2145333, 2197483, 2246640, 2332104, 2379085, 2434833, 2490534, 2554600, 2609625, 2693919, 2742052, 2813988, 2875245, 2952085, 3003306, 3096024, 3157249, 3224511, 3306240, 3388576, 3444609, 3533637, 3591322, 3693924, 3767085, 3842623, 3912324, 4027884, 4102093, 4181949, 4270422, 4361548, 4427853, 4548003, 4616104, 4718640, 4812789, 4918561, 5003286, 5131848, 5205481, 5299011, 5392008, 5521384, 5610705, 5739009, 5818390, 5930196, 6052893, 6156139, 6239472, 6402720, 6493681, 6623853, 6741078, 6864016, 6953457, 7094451, 7215016, 7359936, 7475145, 7593865, 7689630, 7886244, 7984165, 8130747, 8253888, 8403448, 8523897, 8684853, 8802826, 8949612, 9105537, 9267595, 9376656, 9574704, 9686065, 9827097, 9997134, 10174780, 10290813,10493367, 10611772,10813692]
print(l[K])
### BUGGY CODE ###

from collections import deque
n, k = map(int, input().split())
P = deque(map(int, input().split()))

s_max = 0
popped = 0
P_max = deque([])
for i in range(k):
    popped = P.popleft()
    P_max.append(popped)
    s_max += popped
s = s_max
# print(s)
P_extracted = deque(list(P_max))
while P != deque([]):
    # print(P_extracted, P, P_max)
    s -= P_extracted.popleft()
    popped = P.popleft()
    s += popped
    # print(s)

    # P_extracted.popleft()
    P_extracted.append(popped)
    # print(P_extracted)
    if s_max < s:
        s_max = s
        P_max = deque(list(P_extracted))
        # print(s_max, P_max)

# print(s_max, P_max)
e = 0
for i in P_max:
    tmp = 0
    for j in range(1, i+1):
        tmp += j / i
    # print(tmp)
    e += tmp
print(e)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def tsum(l, r):
    return (r + l) * (r - l + 1) // 2

def exp(num):
    return tsum(1, num) / num

def solve():
    n, k = MI()
    P = LI()

    E = [0] * n
    pre = 0
    for i in range(n):
        E[i] = pre + exp(P[i])
        pre = E[i]
    # print(E)

    p = E[0]
    mx = E[k-1]
    for j in range(k, n):
        diff = E[j] - E[j-k]
        # print(diff)
        if mx < diff:
            mx = diff
    print(mx)


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

A, B = (int(i) for i in input().split())
def euclid(a, b):
    while b:
        a, b = b, a%b
    return a
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
num = make_divisors(euclid(A,B))
if len(num) <= 2:
  print(len(num))
else:
  total_num  = [0]*len(num)
  for i in range(1,len(num)):
    for j in range(i,len(num)):
      #print(i)
      #print(" "+str(j))
      try:
        #print(i)
        #print(" "+str(j))
        tmp_index = num[i]*num[j]
        total_num[num.index(tmp_index)] = 1
      except:
        #print("NG")
        total_num = total_num
  print(total_num.count(0))

### FIXED CODE ###

A, B = (int(i) for i in input().split())
def euclid(a, b):
    while b:
        a, b = b, a%b
    return a
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table
try:
  print(len(list(set(prime_decomposition(euclid(A,B)))))+1)
except:
  print(1)
### BUGGY CODE ###

def changeStr(in_str, tgt_idx):
    work_str = ""

    # Left
    if tgt_idx != 0:
        work_str = in_str[:tgt_idx]

    # Target
    if in_str[tgt_idx] == "W":
        work_str += "BW"
    else:
        work_str += "WB"
    
    # Right
    if tgt_idx < len(in_str) -2:
        work_str += in_str[tgt_idx+2:]
    
    return work_str

# Input
s = input()

idx = 0
sav_idx = -1
max_idx = -1
cnt = 0
ret_flg = False
while idx < len(s)-1:

    if idx == sav_idx:
        idx += 1
    # BW or WB
    if (s[idx] == "B" and s[idx+1] == "W") or (s[idx] == "W" and s[idx+1] == "B"):
        s = changeStr(s, idx)

        cnt += 1
        sav_idx = idx
        if max_idx < idx:
            max_idx = idx

        idx -= 1
        ret_flg = True
        if idx < 0:
            idx = 0

    # BB or WW
    else:
        if ret_flg == False:
            idx += 1
        else:
            idx = max_idx + 1
            ret_flg = False
# Output
print(cnt)

### FIXED CODE ###

# 2020/05/02
# AtCoder Grand Contest 029 - A

# Input
s = input()

sidx = len(s) - 1
bidx = -1
ans = 0
leftflg = True
while(sidx >= 0):
    # Set Init position of B
    if leftflg and s[sidx] == 'W':
        leftflg = False
        bidx = sidx
    # Put B
    elif s[sidx] == 'B':
        ans = ans + max(0, bidx - sidx) 
        bidx = bidx - 1
        
    sidx = sidx - 1

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

from itertools import accumulate
import sys
input = sys.stdin.readline

def solve(N, X, BLUs):
    vs = [(L*B + U*(X-B), i) for i, (B, L, U) in enumerate(BLUs)]
    vs.sort(reverse=True)

    accVs = list(accumulate([0] + vs, lambda accX, X: accX + X[0]))
    D0 = -sum([L*B for B, L, U in BLUs])

    def isOK(k):
        q = k // X
        r = k % X
        accV1, accV = accVs[q+1], accVs[q]
        for odr, (v, i) in enumerate(vs):
            B, L, U = BLUs[i]
            d = D0
            if odr < q:
                d += accV1 - v
            else:
                d += accV
            if r <= B:
                d += L*r
            else:
                d += L*B + U*(r-B)
            if d >= 0:
                return True
        return False

    ng, ok = -1, N*X
    while abs(ok-ng) > 1:
        mid = (ng+ok) // 2
        if isOK(mid):
            ok = mid
        else:
            ng = mid

    return ok


N, X = map(int, input().split())
BLUs = [tuple(map(int, input().split())) for _ in range(N)]

print(solve(N, X, BLUs))


### FIXED CODE ###

from itertools import accumulate
import sys
input = sys.stdin.readline

def solve():
    N, X = map(int, input().split())
    tests = []
    D0 = 0
    for _ in range(N):
        B, L, U = map(int, input().split())
        v = L*B + U*(X-B)
        tests.append((v, B, L, U))
        D0 -= L*B
    tests.sort(reverse=True)

    accV = 0
    accVs = [0]
    for v, B, L, U in tests:
        accV += v
        accVs.append(accV)

    def isOK(k):
        q = k // X
        r = k % X
        accV = accVs[q+1]
        for v, B, L, U in tests[:q]:
            d = D0 + accV - v
            if r <= B:
                d += L*r
            else:
                d += L*B + U*(r-B)
            if d >= 0:
                return True
        accV = accVs[q]
        for v, B, L, U in tests[q:]:
            d = D0 + accV
            if r <= B:
                d += L*r
            else:
                d += L*B + U*(r-B)
            if d >= 0:
                return True
        return False

    ng, ok = -1, N*X
    while abs(ok-ng) > 1:
        mid = (ng+ok) // 2
        if isOK(mid):
            ok = mid
        else:
            ng = mid

    return ok


print(solve())
### BUGGY CODE ###

n = int(input())
a = list(input())
cnt,box = 0,[]
for i in range(n):
  l = a[:i]
  r = a[i+1:]
  cnt = l.count("W") + r.count("E")
  box.append(cnt)
print(min(box))

### FIXED CODE ###

n = int(input())
a = list(input())
wcnt,ecnt,ans,box = 0,0,0,[]
W = a.count("W")
E = a.count("E")
for i in range(n-1):
  if a[i] == "W":
    box.append(E+wcnt)
    wcnt += 1
    W -= 1
  else:
    box.append(E+wcnt)
    ecnt += 1
    E -= 1
if a[n-1] == "W":
  W -= 1
  box.append(E+wcnt)
  wcnt += 1
else:
  E -= 1
  box.append(E+wcnt)
  ecnt += 1
print(min(box))
### BUGGY CODE ###

import sys
import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
A = np.array([ri() for _ in range(N)])
B = sorted(A)
C = [np.where(B == a)[0][0] for a in A]
answer = sum([i%2==1 and x%2!=1 for i, x in enumerate(C)])
print(answer)
# 41

### FIXED CODE ###

import sys
import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
A = [ri() for _ in range(N)]
B = sorted(A)
B = set(B[1::2])
C = [i%2==1 and a not in B for i, a in enumerate(A)]
print(sum(C))
### BUGGY CODE ###

n = int(input())
num = list(map(int,input().strip().split()))
q = int(input())
for i in range(q):
  b,c = map(int,input().strip().split())
  num = [c if x == b else x for x in num]
  print(sum(num))

### FIXED CODE ###

n = int(input())
num = list(map(int,input().strip().split()))
s = sum(num)
num_dict = {}
for i in num:
  if i in num_dict:
    num_dict[i] += 1
  else:
    num_dict[i] = 1
q = int(input())
for i in range(q):
  b,c = map(int,input().strip().split())
  if c in num_dict:
    if b in num_dict:
      k = num_dict[b]
      num_dict[c] += num_dict[b]
      del num_dict[b]
      if b > c:
        s = s - (b-c)*k
        print(s)
      else:
        s = s + (c-b)*k
        print(s)
    else:
      print(s)
  else:
    if b in num_dict:
      k = num_dict[b]
      num_dict[c] = num_dict[b]
      del num_dict[b]
      if b > c:
        s = s - (b-c)*k
        print(s)
      else:
        s = s + (c-b)*k
        print(s)
    else:
      print(s)
### BUGGY CODE ###

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

for i in range(n):
    s = input()
    if s not in ls:
        ls += [s]

len = len(ls)
print(len)



### FIXED CODE ###

n = int(input())
set = set()
for i in range(n):
    set.add(input())
print(len(set))
### BUGGY CODE ###

h, w, m = map(int, input().split())

bomb = [[False for i in range(w)] for j in range(h)]
cnth = [0 for i in range(h)]
cntw = [0 for i in range(w)]
for i in range(m):
  x, y = map(int, input().split())
  x -= 1
  y -= 1
  cnth[x] += 1
  cntw[y] += 1
  bomb[x][y] = True

ans = 0
tmp = 0
for i in range(h):
  for j in range(w):
    tmp = cnth[i]+cntw[j]
    if bomb[i][j]:
      tmp -= 1
    ans = max(ans, tmp)
print (ans)

### FIXED CODE ###

h, w, m = map(int, input().split())

bomb = []
cnth = [0 for i in range(h)]
cntw = [0 for i in range(w)]
bomh = [set() for i in range(h)]
bomw = [set() for i in range(w)]
for i in range(m):
  x, y = map(int, input().split())
  x -= 1
  y -= 1
  cnth[x] += 1
  cntw[y] += 1
  bomh[x].add(y)
  bomw[y].add(x)
  bomb.append([x,y])
maxh = max(cnth)
maxw = max(cntw)
ans = maxh + maxw - 1

xx = []
yy = []
for i in range(h):
  if maxh == cnth[i]:
    xx.append(i)
for i in range(w):
  if maxw == cntw[i]:
    yy.append(i)

for i in xx:
  for j in yy:
    if j not in bomh[i]:
      print (ans+1)
      exit()
print (ans)
### BUGGY CODE ###

def main():
    import collections as c
    s = input()
    r = [0]*len(s)
    r[0] = int(s[-1])
    for i in range(1,len(s)):
        r[i] = (int(s[-(1+i)])*10**i+ r[i-1]) % 2019
    
    rc = c.Counter(r)
    rl = list(rc.values())
    sum = 0
    for i in rl:
        sum += int(i*(i-1)/2)

    if 0 in rc:
        sum+=1

    print(sum)

main()

### FIXED CODE ###

def main():
    s = list(map(int, list(input())))
    r = [0]*len(s)
    r[0] = int(s[-1])
    for i in range(1,len(s)):
        temp = s[-(1+i)]*pow(10,i,2019)
        r[i] = (temp+r[i-1])%2019

    ans = 0
    cts = [0]*2019
    for i in r:
        ans+=cts[i]
        cts[i]+=1
    
    ans+=cts[0]

    print(ans)

main()
### BUGGY CODE ###

import numpy as np

H, W = map(int, input().split())
b = []
for _ in range(H):
    b.append([0 if i == "#" else H+W for i in list(input())])
a = np.array(b)

for i in range(H - 1):
    a[1:, :] = np.minimum(a[1:, :], a[:-1, :] + 1)
for i in range(H - 1):
    a[:-1, :] = np.minimum(a[:-1, :], a[1:, :] + 1)
for j in range(W - 1):
    a[:, 1:] = np.minimum(a[:,1:], a[:, :-1] + 1)
for j in range(W - 1):
    a[:, :-1] = np.minimum(a[:, :-1], a[:, 1:] + 1)

print(np.max(a))

### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
a = [[0] * W for _ in range(H)]
q = deque([])
for i in range(H):
    s = input()
    for j in range(W):
        if s[j] == '#':
            a[i][j] = 1
            q.appendleft((i, j, 0))

while True:
    try:
        i, j, val = q.pop()
        if i > 0 and a[i - 1][j] == 0:
            q.appendleft((i - 1, j, val + 1))
            a[i - 1][j] = 1
        if i < H - 1 and a[i + 1][j] == 0:
            q.appendleft((i + 1, j, val + 1))
            a[i + 1][j] = 1
        if j > 0 and a[i][j - 1] == 0:
            q.appendleft((i, j - 1, val + 1))
            a[i][j - 1] = 1
        if j < W - 1 and a[i][j + 1] == 0:
            q.appendleft((i, j + 1, val + 1))
            a[i][j + 1] = 1
    except:
        print(val)
        break
### BUGGY CODE ###

def comb(n,r):
    r=min(r,n-r)
    h,k=1,1
    for i in range(1,r+1):
        h*=(n-r+i)
        k*=i
    return h//k
from bisect import bisect_left as bl,bisect_right as br
n=int(input())
l=list(map(int,input().split()))
l.sort()
mm=l[-1];ans=0;p=0
for i in range(max(0,bl(l,l[-1]//2)-2),min(n,l[-1]//2+3)):
    if ans<comb(mm,l[i]):
        ans=comb(mm,l[i])
        p=i
print(mm,l[p])

### FIXED CODE ###

from bisect import bisect_left as bl,bisect_right as br
n=int(input())
l=list(map(int,input().split()))
l.sort()
pre=10**9
mm=l[-1];p=0
for i in range(max(0,bl(l,l[-1]//2)-2),min(n,l[-1]//2+3)):
    if abs(mm/2-l[i])<pre:pre=abs(mm/2-l[i]);p=i
print(mm,l[p])
### BUGGY CODE ###

N=int(input())
A=1
for i in range(N):
  A *= (i+1)
 
# A = (1+N)/2 * N
# print(A)
A %=(10**9+7)
print('%d' %(A))


### FIXED CODE ###

import math
 
N=int(input())
 
A = math.factorial(N)
A %=(10**9+7)

print(A)
### BUGGY CODE ###

r, l = map(int, (input().split()))

ans = 2018

for i in range(r, l):
    for j in range(i+1, l+1):
        ans = min((i * j) % 2019, ans)
    
        if ans == 0:
            break
    
print(ans)


### FIXED CODE ###

r, l = map(int, (input().split()))

ans = 0 if l - r >= 2019 else 2018
max_l = min(l, (r//2019+1)*2019)

for i in range(r, max_l):
    for j in range(i+1, max_l+1):
        ans = min((i * j) % 2019, ans)
    
        if ans == 0:
            break
    
print(ans)
### BUGGY CODE ###

import numpy as np
from scipy.sparse import csr_matrix

def openinput() :
    n, m = map(int, input().split())
    edges = [[] for _ in range(m)]
    for _ in range(m):
        si, ti = map(int, input().split())
        edges[si-1].append(ti-1)
    return n, m, edges

def to_n_expected(edges, num_of_nodes, recursive_depth=0):
    dp_table = np.zeros(num_of_nodes)
    recursive_shotest = np.inf
    for v in reversed(range(n-1)):
        if recursive_depth < 1:
            max_next = max(edges[v], key= lambda x: dp_table[x])
            edges[v].remove(max_next)
            expected = to_n_expected(edges, num_of_nodes, recursive_depth=1)
            edges[v].append(max_next)
            recursive_shotest = min(recursive_shotest, expected)
        
        out_degree = len(edges[v])
        if out_degree > 0:
            dp_table[v] = 1 + sum(dp_table[ne] for ne in edges[v]) / out_degree
        else:
            dp_table[v] = np.inf
    return min(recursive_shotest, dp_table[0])

if __name__ == '__main__':
    n, m, edges = openinput()
    expcted_values = to_n_expected(edges, n)    # O(nm)
    print(expcted_values)

### FIXED CODE ###

# reference: https://www.onakasuitacity.com/abc144-f/

import numpy as np

n, m = map(int, input().split())
outgoing = [[] for _ in range(n)]
incoming = [[] for _ in range(n)]
for _ in range(m):
    si, ti = map(int, input().split())
    outgoing[si-1].append(ti-1)
    incoming[ti-1].append(si-1)


ex_dp = np.zeros(n)
for v in reversed(range(n-1)):   # O(m)
    outgoing_degree = len(outgoing[v])
    ex_dp[v] = 1 + sum(ex_dp[post] for post in outgoing[v])/outgoing_degree if outgoing_degree!=0 else np.inf

p_dp = np.ones(n)
for v in range(1,n):      # O(m)
    p_dp[v] = sum(p_dp[prev]/len(outgoing[prev]) for prev in incoming[v])

min_ex = ex_dp[0]
for v, posts in enumerate(outgoing):      # O(m)
    outgoing_degree = len(outgoing[v])
    if outgoing_degree <= 1:
        continue

    max_post = max(posts, key= lambda pos: ex_dp[pos])
    diff_v_ex = 0
    for w in posts:
        if w == max_post:
            diff_v_ex -= 1/outgoing_degree * ex_dp[w]
        else:
            diff_v_ex += 1/(outgoing_degree*(outgoing_degree-1)) * ex_dp[w]
    min_ex = min(ex_dp[0] + p_dp[v] * diff_v_ex, min_ex)

print(min_ex)
### BUGGY CODE ###

N = int(input())
ss = []

for i in range(N):
    ss.append(sorted(input()))
    
ans = []

for i in ss:
    k = ss.count(i)
    ans.append(k-1)

print(int(sum(ans)/2))


### FIXED CODE ###

N = int(input())
ss = {}
ht = []
ans = 0

for i in range(N):
    s = ''.join(sorted(input()))
    if not s in ss.keys():
        ss[s] = 1
    else:
        ans += ss[s]
        ss[s] += 1

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

import sys
sys.setrecursionlimit(10**7)

def cur(x):
    for i in neighbor[x]:
        ans[i]+=ans[x]
        neighbor[i].remove(x)
        cur(i)

n,q=map(int,input().split())
neighbor=[[]  for _ in range(n+1)]
ans=[0]*(n+1)
for _ in range(n-1):
    a,b=map(int,input().split())
    neighbor[a].append(b)
    neighbor[b].append(a)


for _ in range(q):
    p,x=map(int,input().split())
    ans[p]+=x

cur(1)
print(" ".join(map(str,ans[1:])))


### FIXED CODE ###

n,q=map(int,input().split())
neighbor=[[]  for _ in range(n+1)]
ans=[0]*(n+1)

for _ in range(n-1):
    a,b=map(int,input().split())
    neighbor[a].append(b)
    neighbor[b].append(a)


for _ in range(q):
    p,x=map(int,input().split())
    ans[p]+=x

visit=[True]*(n+1)
tmp=[1]
for x in tmp:
    visit[x]=False
    for y in neighbor[x]:
        if visit[y]:
            tmp.append(y)
            ans[y]+=ans[x]

print(*ans[1:])
### BUGGY CODE ###

N = int(input())
A = [int(input()) for i in range(N)]
for i in range(N):
    x = A.pop(i)
    print(max(A))
    A.insert(i,x)

### FIXED CODE ###

N = int(input())
A = [int(input()) for i in range(N)]
m = max(A)
mindex = A.index(m)
for i in range(N):
    if(i != mindex):
        print(m)
    else:
        pop = A.pop(i)
        print(max(A))
        A.insert(i,pop)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
x = 0
c_lst = []

for i in a:
    c = 0
    for j in a:
        if i == j:
            continue

        c += abs(j-x)
        x = j

    c += abs(x-0)
    c_lst.append(c)
    x = 0

for i in c_lst:
    print(i)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
x = 0
c_lst = []

s = 0
for i in a:
    s += abs(i-x)
    x = i
s += abs(0-x)

b, f = 0, 0

for i in range(len(a)):
    if i == 0:
        f, b = 0, a[i+1]
    elif i == len(a)-1:
        f, b = a[i-1], 0
    else:
        f, b = a[i-1], a[i+1]

    c = s + abs(b-f) - (abs(a[i]-f)+abs(b-a[i]))
    c_lst.append(c)

for i in c_lst:
    print(i)
### BUGGY CODE ###

N = int(input())

Dist = [[0 for i in range(N)] for j in range(N)]
Seen = [-1] * N

for i in range(N-1):
    u, v, w = map(int, input().split())
    Dist[u-1][v-1] = w
    Dist[v-1][u-1] = w

que = [0]
Seen[0] = 0
flag = True
while len(que) != 0:
    if not flag:
        break
    now = que.pop()
    for next in range(N):
        if Dist[now][next] == 0:
            continue
        elif Seen[next] == -1:
            que.insert(0, next)
            if Dist[now][next] % 2 == 0:
                Seen[next] = Seen[now]
            else:
                Seen[next] = 1 - Seen[now]
        elif Seen[next] != -1:
            if Dist[now][next] % 2 == (Seen[now] + Seen[next]) % 2:
                continue
            else:
                flag = False
                break

for i in range(N):
    print(Seen[i])


### FIXED CODE ###

N = int(input())

Dist = [[] for j in range(N)]
Seen = [-1] * N

for i in range(N-1):
    u, v, w = map(int, input().split())
    Dist[u-1].append([v-1, w])
    Dist[v-1].append([u-1, w])

que = [0]
Seen[0] = 0
flag = True
while -1 in Seen:
    now = que.pop()
    for next, distance in Dist[now]:
        if Seen[next] == -1:
            que.insert(0, next)
            if distance % 2 == 0:
                Seen[next] = Seen[now]
            else:
                Seen[next] = 1 - Seen[now]
for i in range(N):
    print(Seen[i])