Problem:


Score : 300 points

Problem Statement

We will call a string obtained by arranging the characters contained in a string a in some order, an anagram of a.

For example, greenbin is an anagram of beginner. As seen here, when the same character occurs multiple times, that character must be used that number of times.

Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Constraints

2 \leq N \leq 10^5

s_i is a string of length 10.

Each character in s_i is a lowercase English letter.

s_1, s_2, \ldots, s_N are all distinct.

Input

Input is given from Standard Input in the following format:

N
s_1
s_2
:
s_N

Output

Print the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Sample Input 1

3
acornistnt
peanutbomb
constraint

Sample Output 1

1

s_1 = acornistnt is an anagram of s_3 = constraint. There are no other pairs i, j such that s_i is an anagram of s_j, so the answer is 1.

Sample Input 2

2
oneplustwo
ninemodsix

Sample Output 2

0

If there is no pair i, j such that s_i is an anagram of s_j, print 0.

Sample Input 3

5
abaaaaaaaa
oneplustwo
aaaaaaaaba
twoplusone
aaaabaaaaa

Sample Output 3

4

Note that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.



Sample input:
3
acornistnt
peanutbomb
constraint


Sample output:
1

Submission status: Wrong Answer

Solution code:
import numpy as np
import collections

n = int(input())
moji = [list(map(str,input())) for index in range(n)]
count = int(0)

for index in range(n):
  moji[index].sort()
  moji[index] = "".join(moji[index])

moji.sort()
print(sum(collections.Counter(moji).values())-1)

Submission status: Wrong Answer

Solution code:
import numpy as np
import collections

n = int(input())
moji = [list(map(str,input())) for index in range(n)]
count = int(0)

for index in range(n):
  moji[index].sort()
  moji[index] = "".join(moji[index])

moji.sort()
print(sum(collections.Counter(moji).values()))

Submission status: Wrong Answer

Solution code:
N = int(input())
s = []
for i in range(N):
    a = list(input())
    a.sort()
    s.append("".join(a))

b = len(s)
a = len(set(s))   
 
print(b-a)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = []
for i in range(N):
    a = list(input())
    a.sort()
    s.append("".join(a))
    
print(len(s) - len(set(s)))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = []
new_a = []

for k in range(n):
    a.append(input())

for k in range(n):
    new_a.append( ''.join(list(reversed(a[k]))))

sorted(new_a)

b = 0

for k in range(n-1):
    if(new_a[k] == new_a[k+1]):
        b = b +1

print(b)

Submission status: Wrong Answer

Solution code:
n = int(input())

ss = []
for i in range(n):
	ss.append(sorted(str(input())))

sm = sorted(ss)
c = 0
for i in range(n-1):
	if sm[i] == sm[i+1]:
		c += 1
print(c)

Submission status: Wrong Answer

Solution code:
#from Collections import Counter

N = int(input())
count = 0
word = {}
def str_sort(str):
    f = lambda y: "".join(sorted(map(lambda x: x.replace(' ', '').lower(), y)))
    return f(str)
for _ in range(N):
    sorted_str = str_sort(input())
    if sorted_str not in word:
        word[sorted_str] = [0]
        word[sorted_str].append(1)
    else:
        if word[sorted_str] == 0:
            word[sorted_str][0] = 1
        else:
            word[sorted_str][0] += word[sorted_str][1]
            word[sorted_str][1] += 1
            #word[sorted_str] = word[sorted_str][0] + word[sorted_str][1]
total = sum(
    v[0] for v in word.values()
)
print(word)
print(total)

Submission status: Wrong Answer

Solution code:
#from Collections import Counter

N = int(input())
count = 0
word = {}
def str_sort(str):
    f = lambda y: "".join(sorted(map(lambda x: x.replace(' ', '').lower(), y)))
    return f(str)
for _ in range(N):
    sorted_str = str_sort(input())
    if sorted_str not in word:
        word[sorted_str] = 0
    else:
        if word[sorted_str] == 0:
            word[sorted_str] = 1
        else:
            word[sorted_str] += word[sorted_str] + 1
total = sum(
    v for v in word.values()
)
#print(word)
print(total)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
s = [list(input()) for i in range(n)]
l = [''.join(sorted(i)) for i in s]
c = list(collections.Counter(l).values())
x = sum([i for i in c if i != 1])
print(x - 1) if 0 < x else print(x)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [input() for i in range(n)]
ss = [sorted(s[i]) for i in range(n)]
dic = [''.join(ss[i]) for i in range(n)]
key = [i for i in set(dic)]
cnt = 0
for i in range(len(dic)-1):
    if dic[i] == dic[i+1]:
        cnt += 1
print(int(cnt))

Submission status: Wrong Answer

Solution code:
a = int(input())
l = []
for x in range(a):
    s = sorted(input())
    w = ''.join(s)
    l.append(w)

word = set(l)
word = list(word)
count = 0
for w in word:
    if(l.count(w) > 1):
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
Row=int(input())
List=[sorted(input()) for i in range(Row)]


count = 0
for i in List:
    a = ''
    a = List.pop(0)
    if a in List:
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
a = int(input())
l = []
for x in range(a):
    s = sorted(input())
    w = ''.join(s)
    l.append(w)

l.sort()
count = 0
x = 0
for item in l:
    if(x == 0):
        x += 1
        word = item
    else:
        if(word == item):
            x += 1
            count += 1
            word = item
        else:
            x += 1
            word = item

print(count)

Submission status: Wrong Answer

Solution code:
a = int(input())
l = []
for x in range(a):
    s = sorted(input())
    w = ''.join(s)
    l.append(w)

l.sort()
count = 0
x = 0
for item in l:
    if(x == 0):
        x += 1
        word = item
        continue
    else:
        if(word == item):
            x += 1
            count += 1
            word = item
        else:
            x += 1
            word = item

print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
string_list = [input() for i in range(N)]
temp = []
ans = 0

for i in string_list:
    temp.append(sorted(i))

for i in range(len(temp)):
    for j in range(i+1, len(temp)):
        print(temp[i], temp[j])
        if temp[i] == temp[j]:
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = []
for i in range(n):
    l.append(input())

#各要素をソート
# print('sort elements')
for i in range(n):
    # print('sort',i,l[i])
    l[i] = ''.join(sorted(l[i]))
    # print('sorted',l[i])

#リストをソート
# print('sort list')
l.sort()
# print('sorted list')
# print(l)

#個数を調べる 
flag = 0
for i in range(n):
    # print('check',l[i-1],l[i])
    if l[i-1] == l[i]:
        # print('detected',flag)
        flag = flag + 1
        # print('counted',flag)

print(flag)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = [''.join(sorted(input().rstrip())) for _ in range(N)]

print(S)
from collections import Counter

counter = Counter(S)
print(counter.values())
answer = sum(x * (x - 1) // 2 for x in counter.values())
print(answer)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = []
for i in range(0, N):
    s.append(input())

for count, i in enumerate(s):
    s[count] = "".join(sorted(i))

ans = []
count = -1 * (len(s)) - 1
for i in s:
    for j in s:
        if(i == j):
            count = count + 1
print(count)

Submission status: Wrong Answer

Solution code:
Ncount = int(input())
strings = []
count_flag = 0
letters = {}
letters_count = []
for i in range(Ncount):
  strings.append(''.join(sorted(input())))

for i in strings:
  if i not in letters:
    letters[i] = 0
  else :
    letters[i] += 1
    letters[i] += letters[i] - 1

for i in letters:
  count_flag += letters[i] 

print(count_flag)

Submission status: Wrong Answer

Solution code:
Ncount = int(input())
strings = []
count_flag = 0
letters = {}
letters_count = []
for i in range(Ncount):
  strings.append(''.join(sorted(input())))
print(strings)
for i in strings:
  if i not in letters:
    letters[i] = 0
  else :
    letters[i] += 1
    letters[i] += letters[i] - 1

for i in letters:
  count_flag += letters[i] 

print(count_flag)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=["".join(sorted(input())) for _ in range(N)]
a=len(S)
SS=set(sorted(S))
b=len(SS)
if a-b>1:
  print(a-b+1)
else:
  print(a-b)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
slist = [Counter(input()) for _ in range(N)]
print(slist)

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

Submission status: Wrong Answer

Solution code:
N=int(input())
S=["".join(sorted(input())) for _ in range(N)]
a=len(S)
SS=set(sorted(S))
b=len(SS)
print(a-b)

Submission status: Wrong Answer

Solution code:
#from Collections import Counter

N = int(input())
count = 0
word = {}
def str_sort(str):
    f = lambda y: "".join(sorted(map(lambda x: x.replace(' ', '').lower(), y)))
    return f(str)
for _ in range(N):
    sorted_str = str_sort(input())
    if sorted_str not in word:
        word[sorted_str] = 0
    else:
        if word[sorted_str] == 0:
            word[sorted_str] = 1
        else:
            word[sorted_str] += word[sorted_str] + 1
total = sum(
    v for v in word.values()
)
print(word)
print(total)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
s = np.array([[str(i) for i in input().split()] for i in range(n)])
s = np.ravel(s)
sorted_list = [''.join(sorted(e)) for e in s]

ans = len(s)-len(set(sorted_list))

print(ans+1 if ans>1 else ans)

Submission status: Wrong Answer

Solution code:
Ncount = int(input())
strings = []
count_flag = 0
letters = {}
letters_count = []
for i in range(Ncount):
  strings.append(''.join(sorted(input())))

for i in strings:
  if i in letters:
    if letters[i] == 0:
      letters[i] += 1
    else:
      letters[i] += letters[i] + 1
  else :
    letters[i] = 0

for i in letters:
  count_flag += letters[i] 

print(count_flag)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
def main():
    N = int(input())
    d = {}
    ans = 0
    for _ in range(N):
        s = "".join(sorted(list(input())))
        if s in d:
            d[s] += 1
            ans+=1
        else:
            d[s] = 0
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
number=int(input())
counter=0
answer=0
y=0
words=[]

for i in range(number):
    List = (input())
    words.append(list(List))

for j in range(number):
    z=0
    for k in range(number):
        
        centence=[]
        centence1=[]

        for g in range(number): 
            centence=words[y]
            centence1=words[z]

        x=-1
        word=[]
        word1=[]

        for f in range(10):
            x=x+1
            word.append(centence[x])
            word1.append(centence1[x])
            
        ab=sorted(word)
        ac=sorted(word1)

Submission status: Wrong Answer

Solution code:
number=int(input())
counter=0
answer=0
y=0
words=[]

for i in range(number):
    List = (input())
    words.append(list(List))

for j in range(number):
    z=0
    for k in range(number):
        
        centence=[]
        centence1=[]

        for g in range(number): 
            centence=words[y]
            centence1=words[z]

        x=-1
        word=[]
        word1=[]

        for f in range(10):
            x=x+1
            word.append(centence[x])
            word1.append(centence1[x])
            
        ab=word.sort()
        ac=word1.sort()
        
        if ab == ac:
            counter=counter+1
        else:
            counter=counter+0

        z=z+1
    y=y+1
answer=counter/2
print(int(answer-number/2))

Submission status: Wrong Answer

Solution code:
N = int(input())
s = []
for i in range(N):
  s.append(sorted(input()))
#lis = list(set(s))
lis = list(map(list, set(map(tuple, s))))
print(lis)
c = 0
for i in range(1,N-1):
    indexes = [k for k, x in enumerate(s[i:]) if x == s[i-1]]
    c += len(indexes)
print(c)

Submission status: Wrong Answer

Solution code:
def is_anagram(s1, s2):
  if all([c in s2 for c in s1]):
    return 1
  return 0

num = int(input())
s1 = input()
s2 = [input() for _ in range(num-1)]

print(sum([is_anagram(s1, s) for s in s2]))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = [""] * N
for n in range(N):
    S[n] = input()
from collections import defaultdict
dct = defaultdict(int)
for s in S:
    sorted_s = "".join(sorted(s))
    dct[sorted_s] += 1
ans = 0
for k,v in dct.items():
    ans += v*(v-1)/2
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = [""] * N
for n in range(N):
    S[n] = input()
from collections import defaultdict
dct = defaultdict(int)
for s in S:
    sorted_s = "".join(sorted(s))
    dct[sorted_s] += 1
ans = 0
for k,v in dct.items():
    ans += v*(v-1)/2

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from sys import stdin

n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip() for _ in range(n)]
new = []
for i in range(n):
    sort = sorted(data[i])
    sorting = "".join(sort)
    new.append(sorting)
new.sort()
score = 0
s = 0
count  = 0
print(new)
while s<n-1:
    daburi = 1
    stop = 0
    for p in range(s,n-1):
        if new[p] == new[p+1] and stop == 0:
            daburi += 1
        else:
            stop += 1
    score += daburi*(daburi-1)//2
    count += daburi
    s = count
print(score)

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())

    s = list(''.join(sorted(input()[:])) for i in range(n))

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

    print(count)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
anagrams = ["".join(sorted(input())) for i in range(n)]
from collections import defaultdict
d = defaultdict(int)
for i in range(n):
    d[anagrams[i]] += 1
from scipy.misc import comb
cnt=0
for k, v in d.items():
    cnt+=comb(v, 2, exact=True)
cnt

Submission status: Wrong Answer

Solution code:
import collections
n=int(input())
s=[''.join(sorted(input())) for i in range(n)]
s_cnt=collections.Counter(s)
cnt=0
for i in s_cnt.values():
  if i>1:
    cnt+=i
if cnt>0:
  print(cnt-1)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())

words = []

for iter in range(n):
  words.append(''.join(sorted(input())))

print(np.int64(len(words)) - np.int64(len(list(set(words)))))

Submission status: Wrong Answer

Solution code:
n = int(input())

words = []

for iter in range(n):
  words.append(''.join(sorted(input())))

print(len(words) - len(list(set(words))))

Submission status: Wrong Answer

Solution code:
N = int(input())
s = [input() for i in range(N)]
d = {}
for i in s:
    c = ''.join(sorted(i))
    if not c in  d.keys():
        d[c] = 0
    d[c] += d[c]
    e = d.values()
f = 0
for _ in e:
    f += _ - 1
if f>= 0:
    print(f)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = [input() for i in range(N)]
d = {}
for i in s:
    c = ''.join(sorted(i))
    if not c in  d.keys():
        d[c] = 0
    d[c] += 1
    e = d.values()
f = 0
for _ in e:
    f += _ - 1
if f>= 0:
    print(f)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = [input() for i in range(N)]
d = {}
for i in s:
    c = ''.join(sorted(i))
    if not c in  d.keys():
        d[c] = 0
    d[c] += 1
    e = d.values()
f = 0
for _ in e:

    f += _ - 1
if f  > 0:
    print(f)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = [input() for i in range(N)]
d = {}
for i in s:
    c = ''.join(sorted(i))
    if not c in  d.keys():
        d[c] = 0
    d[c] += 1
    e = d.values()
f = 0
for _ in e:

    f += _ - 1
print(f)

Submission status: Wrong Answer

Solution code:
import collections
import sys


scan = sys.stdin.readline

def count_abc(string):
  alphabet = dict.fromkeys("abcdefghijklmnopqrstuvwxyz",0)
  
  for char in string:
    num = alphabet[char]
    alphabet[char] = num + 1
  
  c_str = ""
  for k, v in alphabet.items():
    c_str += k
    c_str += str(v)
  
  return c_str


def main():
  n = int(scan().rstrip())
  s = [scan().rstrip() for _ in range(n)]
  
  s_c = [count_abc(st) for st in s]
  
  c_dict = collections.Counter(s_c)
  
  print(max(c_dict.values()))

  
if __name__ == "__main__":
  main()

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[]
D=[]
count=0
for i in range(N):
    S=''.join(sorted(input()))
    A.append(S)

for s in A:
    if s in D:
        count+=1
    else:
        D.append(s)
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
L = [list(map(str, input().split())) for i in range(N)]

SET=list(map(lambda x: ''.join(sorted(' '.join(x))), L))
cnt=N-len(set(SET))

print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [input() for i in range(n)]
t = {}
cnt = 0
for i in s:
    tmp = "".join(sorted(list(i)))
    if tmp in t:
        cnt += t[tmp]
        t[tmp] += t[tmp]
    else:
        t[tmp] = 1
    
print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())

ans = 0
diclist = []
analist =[]

i=1
while i < N+1:
  temp = list(input())
  temp.sort()
  i += 1
  if temp in diclist:
    ans += 1
    if temp in analist:
      pass
    else:
      analist.append(temp)
  else:
    diclist.append(temp)
    
ans += len(analist) -1
print(max(0,ans))

Submission status: Wrong Answer

Solution code:
N = int(input())

ans = 0
diclist = []
analist =[]

i=1
while i < N+1:
  temp = list(input())
  temp.sort()
  i += 1
  if temp in diclist:
    ans += 1
    if temp in analist:
      pass
    else:
      analist.append(temp)
  else:
    diclist.append(temp)
    
ans += len(analist) -1
print(ans)

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
s = []
for i in range(N):
  word = input()
  s.append(word)

c = collections.Counter(s)

sum = 0
for value in c.values():
  sum += (value * (value-1) / 2)

print(int(sum))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = []
cnt = []
for i in range(n):
  s_ = list(str(input()))
  s_.sort()
  if s_ in s:
    cnt[s.index(s_)] += 1
  else:
    s.append(s_)
    cnt.append(0)

print(sum(cnt))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [input() for i in range(n)]
b = sorted(["".join(sorted(s[i])) for i in range(n)])
cnt = 0
start = 0
for i in range(1, n):
    if b[i - 1] != b[i] or i == n - 1:
        j = i - start
        start = i - 1
        if j > 1:
            cnt += j * (j - 1) // 2
print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = 0
s = []
cnt = []
for i in range(n):
  s_ = list(str(input()))
  s_.sort()
  if s_ in s:
    cnt[s.index(s_)] += 1
  else:
    s.append(s_)
    cnt.append(0)

print(sum(cnt))

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = 0
s = []
cnt = []
for i in range(n):
  s_ = list(str(input()))
  s_.sort()
  if s_ in s:
    cnt[s.index(s_)] += 1
  else:
    s.append(s_)
    cnt.append(1)

print(sum(cnt))

Submission status: Wrong Answer

Solution code:
N = input()
N = int(N)

s = []

for i in range(N) :
  s.append(input())
  print(s[i])

list_s = []

for i in range(N) :
  list_s.append(list(s[i]))
  list_s[i].sort()

count = 0  

joint_s = []

for i in range(N) :
  joint = ''
  for j in list_s[i] :
    joint += j
  joint_s.append(joint)
    

for i in range(N) :
  for j in range(N - i - 1) :
    if joint_s[i] == joint_s[i + j + 1] :
      count = count + 1

print(count)  
#print(list_s)
#print(joint_s)

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
s = []
for i in range(N):
  word = input()
  word_num = 0
  for j in range(10):
    #print(ord(word[j]))
    #ord('a')= 97 
    #97引いたやつ乗
    word_num += int(10^(ord(word[j])-97))

  s.append(word_num)
  #s.append(input())

#sortする
s.sort()

c = collections.Counter(s)
#print(c)

#c.keys() 
#c.values()

sum = 0
for value in c.values():
  sum += (value * (value-1) / 2)

print(int(sum))

Submission status: Wrong Answer

Solution code:
N = int(input())

ans = 0

diclist = []

i=1
while i < N+1:
  temp = list(input())
  temp.sort()
  i += 1
  if temp in diclist:
    ans += 1
  else:
    diclist.append(temp)
    
    
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [input() for i in range(n)]
t = []
cnt = 0
for i in s:
    t.append(sorted(list(i)))
t.sort()
for i in t:
    t.remove(i)
    for j in t:
        for k in range(10):
            if i[k] == j[k]:
              if k == 9:
                    cnt+=1
            else:
                break
print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = [list(input()) for _ in range(N)]
S = []
for i in range(N):
    S.append("".join(sorted(s[i])))
print(S)

cnt = 0
for i in range(N):
    cnt += S.count(S[i]) - 1
print(cnt / 2)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
s = [input() for i in range(n)]
b = sorted(["".join(sorted(s[i])) for i in range(n)])
b = np.unique(b)
print(n-len(b))

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
s = []
for i in range(N):
  word = input()
  word_num = 0
  for j in range(10):
    #print(ord(word[j]))
    word_num += ord(word[j])

  s.append(word_num)
  #s.append(input())

#sortする
s.sort()

c = collections.Counter(s)
#print(c)

#c.keys() 
#c.values()

sum = 0
for value in c.values():
  sum += (value * (value-1) / 2)

print(int(sum))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = [''.join(sorted(input())) for _ in range(N)]
D = {}
count = 0
for s in S :
    if s in D :
        D[s] =  D[s] + 1
    else :
        D[s] = 0
V = list(D.values())
print(sum(V))

# #import sys
# # import math
#
# def modc(a, b, m):
#     c = 1
#     for i in range(b):
#         c = c * (a - i) % m
#         c = c * modinv(i + 1, m) % m
#     return c
#
#
# def egcd(a, b):
#     (x, lastx) = (0, 1)
#     (y, lasty) = (1, 0)
#     while b != 0:
#         q = a // b
#         (a, b) = (b, a % b)
#         (x, lastx) = (lastx - q * x, x)
#         (y, lasty) = (lasty - q * y, y)
#     return (lastx, lasty, a)
#
#
# def modinv(a, m):
#     (inv, q, gcd_val) = egcd(a, m)
#     return inv % m
#
# N = int(input())
# #A, B = list(map(int,input().split()))
# S = [''.join(sorted(input())) for _ in range(N)]
# D = {}
# for s in S :
#     if s in D :
#         D[s] += 1
#     else :
#         D[s] = 1
# V = list(D.values())
#
# count = 0
# for v in V :
#     if v == 1 :
#         count += 0
#     elif v == 2 :
#         count += 1
#     elif v >= 3 :
#         count += modc(v, 2, 2 ** 63 - 1)
# print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = [''.join(sorted(input())) for _ in range(N)]
D = {}
count = 0
for s in S :
    if s in D :
        D[s] +=  D[s] + 1
    else :
        D[s] = 0
V = list(D.values())
print(sum(V))

# #import sys
# # import math
#
# def modc(a, b, m):
#     c = 1
#     for i in range(b):
#         c = c * (a - i) % m
#         c = c * modinv(i + 1, m) % m
#     return c
#
#
# def egcd(a, b):
#     (x, lastx) = (0, 1)
#     (y, lasty) = (1, 0)
#     while b != 0:
#         q = a // b
#         (a, b) = (b, a % b)
#         (x, lastx) = (lastx - q * x, x)
#         (y, lasty) = (lasty - q * y, y)
#     return (lastx, lasty, a)
#
#
# def modinv(a, m):
#     (inv, q, gcd_val) = egcd(a, m)
#     return inv % m
#
# N = int(input())
# #A, B = list(map(int,input().split()))
# S = [''.join(sorted(input())) for _ in range(N)]
# D = {}
# for s in S :
#     if s in D :
#         D[s] += 1
#     else :
#         D[s] = 1
# V = list(D.values())
#
# count = 0
# for v in V :
#     if v == 1 :
#         count += 0
#     elif v == 2 :
#         count += 1
#     elif v >= 3 :
#         count += modc(v, 2, 2 ** 63 - 1)
# print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
array = ["".join(sorted(input())) for x in range(n)]
set_array = set()
for i in array:
  set_array.add(i)
print(len(array) - len(set_array))

Submission status: Wrong Answer

Solution code:
N = int(input())
wordl = {}
ans = 1

for i in range(N):
    w = input()
    wl = []
    for j in range(10):
        wl.append(w[j])
    wl.sort()
    w2 = ' '
    for p in range(10):
        w2 += wl[p]
    if w2 in wordl:
        ans += 1
    else:
        wordl[w2] = 0

print(ans)

'''
#アルゴリズムはあってるがLTE
N = int(input())
wordl = []

for i in range(N):
    w = input()
    wl = []
    for j in range(10):
        wl.append(w[j])
    wl.sort()
    w2 = ' '
    for p in range(10):
        w2 += wl[p]
    wordl.append(w2)
wordl.sort()
#print(wordl)

ans = 0
for k in range(N):
    for q in range(k+1,N):
        if wordl[k] == wordl[q]:
            ans += 1
        else:
            break

print(ans)
'''

Submission status: Wrong Answer

Solution code:
s = input().split()
n=int(s[0])
d={}
count=[0]*n
for i in range(n):
    s = input().split()
    l=sorted(s[0])
    l=''.join(l)
    p = d.setdefault(l,i)
    if p<i:

        count[p]=count[p]*2+1
print(sum(count))

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
s_dict = {}
for i in range(N):
    s=sorted(input())
    s = ''.join(s)
    if s in s_dict:
        s_dict[s] += 1 + s_dict[s]
    else:
        s_dict[s] = 0
print(sum(s_dict.values()))

Submission status: Wrong Answer

Solution code:
n = int(input())
array = [sorted(input()) for x in range(n)]
print(len(array) )

Submission status: Wrong Answer

Solution code:
n = int(input())
array = [sorted(input()) for x in range(n)]
print(1)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = input()

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())
b = []
a = ''
for i in range(n):
    a = input()
    b.append(sorted(a))
i = 0
j = 0
ans = 0
count = 1
while i < len(b):
    j = i + 1
    count = 1
    while j < len(b):
        if b[i] == b[j]:
            ans += count
            count += 1
            del b[j]
        j += 1
    i += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N = input()
N = int(N)
S = []
n_anagram = 0
for i in range(N):
    s = set(input())
    n_anagram= n_anagram + len([x for x in S if s == x])
    S.append(s)
print(n_anagram)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = []
for i in range(N):
  word = input()
  word_num = 0
  for j in range(10):
    #print(ord(word[j]))
    word_num += ord(word[j])

  s.append(word_num)
  #s.append(input())

#sortする
s.sort()

same = 0
con_same = 1
for i in range(N-1):
  if s[i] == s[i+1]:
    #same += 1
    con_same += 1
  else:
    same += (con_same * (con_same - 1) /2)
    con_same = 1

same += (con_same * (con_same - 1) /2)

#print(max_same)
print(int(same))

Submission status: Wrong Answer

Solution code:
N = int(input())

sList = [0 for _ in range(N)]

for i in range(N) :
    s = list(input())
    s.sort()
    sList[i] = s

confilm = [False for _ in range(N)]

ans = 0
for i in range(N) :
    if confilm[i] :
        continue
    confilm[i] = True
    count = 1
    for j in range(i + 1, N) :
        if sList[i] == sList[j] :
            confilm[j] = True
            count += 1
    ans += count * (count - 1) // 2

print('ans')

Submission status: Wrong Answer

Solution code:
N = int(input())
word = [input() for i in range(N)]
sorted_word = [tuple(sorted(list(word[i]))) for i in range(N)]
dict_word = {sorted_word[i]:0 for i in range(N)}
ans = 0

def sum_all(x):
  for i in range(x+1):
    y = 0
    y += i
  return y

for i in range(N):
  if sorted_word[i] in sorted_word[i+1:]:
    dict_word[sorted_word[i]] += 1
    
for value in dict_word.values():
  ans += sum_all(value)
  
print(ans)

Submission status: Wrong Answer

Solution code:
num = int(input())
words = []
answer = 0

for i in range(num):
  words.append(sorted(list(input())))
words.sort(key=lambda x:x[0])
for i in range(num - 1):
  q = 0
  for j in range(num -i - 1):
    if q >0 and words[i][9] != words[j + 1 + i][9]:
      break
    if words[i] == words[j + 1 + i]:
      answer += 1
      q += 1
    
    
print(answer)

Submission status: Wrong Answer

Solution code:
num = int(input())
words = []
answer = 0

for i in range(num):
  words.append(sorted(list(input())))
words.sort(key=lambda x:x[0])
for i in range(num):
  q = 0
  for j in range(num -i - 1):
    if q >0 and words[i] != words[j + 1 + i]:
      break
    if words[i] == words[j + 1 + i]:
      answer += 1
      q += 1
    
    
print(answer)

Submission status: Wrong Answer

Solution code:
num = int(input())
words = []
answer = 0

for i in range(num):
  words.append(sorted(list(input())))
words.sort(key=lambda x:x[0])

for i in range(num):
  q = 0
  for j in range(num -i - 1):
    p = 0
    if q >0 and words[i] != words[j + 1 + i]:
      break
    if words[i] == words[j + 1 + i]:
      answer += 1
      q += 1
    
    
print(answer)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = []
for i in range(N):
  word = input()
  word_num = 0
  for j in range(10):
    #print(ord(word[j]))
    word_num += ord(word[j])

  s.append(word_num)
  #s.append(input())

#sortする
s.sort()

same = 0
max_same = 0
for i in range(N-1):
  if s[i] == s[i+1]:
    same += 1
    if same >= max_same :
      max_same = same 
  else:
    same = 0

print(max_same)

Submission status: Wrong Answer

Solution code:
N = int(input())
words = []
for _ in range(N):
    w = input()
    words.append("".join(sorted(w)))
words_distinct = list(set(words))
def combination(n):
    if n < 2:
        return 0
    elif n == 2:
        return 1
    ret = 1
    for _ in range(n-2):
        ret *= n
        n -= 1
    return ret
anaglam_combinations = sum([combination(words.count(i)) for i in words_distinct])
print(anaglam_combinations)

Submission status: Wrong Answer

Solution code:
import copy
N = int(input())
word = [input() for i in range(N)]
sorted_word = [sorted(list(word[i])) for i in range(N)]
copy_word = copy.copy(sorted_word)
count = 0
for i in range(N-1):
  copy_word.remove(sorted_word[i])
  if sorted_word[i] in copy_word:
    count += 1
print(count)