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 copy

N = int(input())

mys = np.array([list(input().strip()) for i in range(N)])

myss = np.sort(mys)

mys2=[]

for i in range(N):
	mys2.append(''.join(myss[i,:]))
    
mys3 = copy.copy(sorted(mys2))
myset = set(mys3)

mysnp = np.array(mys3)

cnt=0

for ele in myset:
	if np.sum(mysnp==ele) == 2:
		cnt += 1
	elif np.sum(mysnp==ele) == 1:
		cnt +=0
	else:
		cnt +=np.sum(mysnp==ele)
print(cnt)

Submission status: Wrong Answer

Solution code:
n=int(input())
d={}
totl=0

for i in range(n):
  s=list(input())
  s.sort()
  t=''.join(s)
  
  if t in d:
    d[t]+=1
  else:
    d[t]=1

for t in d:
  totl+=d[t]*(d[t]-1)/2

print(totl)

Submission status: Wrong Answer

Solution code:
x = list(map(str, input().split())) #入力

n = int(x[0]) #最初の文字
z = x[1:] #最初の数字削除

# alphabet（list）をカウントする関数
def word_count(alphabet):
    res_dic = {}
    for i in alphabet:
        test = i in res_dic.keys()
        if test == False:
            res_dic[i] = 1
        elif test == True:
            plus = res_dic[i] + 1
            res_dic[i] = plus
    return res_dic

# 全ての文字をカウント
res = []
for i in z:
    alphabet = list(i)
    res.append(word_count(alphabet))

# 全ての組み合わせをチェック
record = []
for i in res:
    for j in res:
        if i == j:
            record.append(1)
        elif i != j :
            record.append(0)

ans = int((sum(record) - n)/2)
print(str(ans))

Submission status: Wrong Answer

Solution code:

N = int(input())
S = []
for i in range(N):
    S.append(input())

kintama = 0
for i in range(len(S)-1):
    A = list(S[i])
    for j in range(i+1,len(S)):
        B = list(S[j])
        if set(A)==set(B):
            kintama += 1

print(kintama)

Submission status: Wrong Answer

Solution code:
x = list(map(str, input().split())) #入力

n = int(x[0]) #最初の文字
z = x[1:] #最初の数字削除

# alphabet（list）をカウントする関数
def word_count(alphabet):
    res_dic = {}
    for i in alphabet:
        test = i in res_dic.keys() 
        if test == False: 
            res_dic[i] = 1
        elif test == True:
            plus = res_dic[i] + 1
            res_dic[i] = plus
    return res_dic

# 全ての文字をカウント
res = []
for i in z:
    alphabet = list(i)
    res.append(word_count(alphabet))

# 全ての組み合わせをチェック
record = []
for i in res:
    for j in res:
        if i == j:
            record.append(1)
        elif i != j :
            record.append(0)

print(int((sum(record) - n)/2))

Submission status: Wrong Answer

Solution code:
x = list(map(str, input().split())) #入力

n = int(x[0]) #最初の文字
z = x[1:] #最初の数字削除

# alphabet（list）をカウントする関数
def word_count(alphabet):
    res_dic = {}
    for i in alphabet:
        test = i in res_dic.keys() 
        if test == False: 
            res_dic[i] = 1
        elif test == True:
            plus = res_dic[i] + 1
            res_dic[i] = plus
    return res_dic

# 全ての文字をカウント
res = []
for i in z:
    alphabet = list(i)
    res.append(word_count(alphabet))

# 全ての組み合わせをチェック
record = []
for i in res:
    for j in res:
        if i == j:
            record.append(1)
        elif i != j :
            record.append(0)

print(4)

Submission status: Wrong Answer

Solution code:
x = list(map(str, input().split())) #入力

n = int(x[0]) #最初の文字
z = x[1:] #最初の数字削除

# alphabet（list）をカウントする関数
def word_count(alphabet):
    res_dic = {}
    for i in alphabet:
        test = i in res_dic.keys() 
        if test == False: 
            res_dic[i] = 1
        elif test == True:
            plus = res_dic[i] + 1
            res_dic[i] = plus
    return res_dic
print(4)

Submission status: Wrong Answer

Solution code:
x = list(map(str, input().split())) #入力

n = int(x[0]) #最初の文字
z = x[1:] #最初の数字削除

# alphabet（list）をカウントする関数
def word_count(alphabet):
    res_dic = {}
    for i in alphabet:
        test = i in res_dic.keys() 
        if test == False: 
            res_dic[i] = 1
        elif test == True:
            plus = res_dic[i] + 1
            res_dic[i] = plus
    return res_dic

# 全ての文字をカウント
res = []
for i in z:
    alphabet = list(i)
    res.append(word_count(alphabet))

# 全ての組み合わせをチェック
record = []
for i in res:
    for j in res:
        if i == j:
            record.append(1)
        elif i != j :
            record.append(0)
ans = int((sum(record) - n)/2)
print(ans)

Submission status: Wrong Answer

Solution code:
print(4)

Submission status: Wrong Answer

Solution code:
x = list(map(str, input().split())) #入力
n = int(x[0]) #最初の文字
z = x[1:] #最初の数字削除

# alphabet（list）をカウントする関数
def word_count(alphabet):
    res_dic = {}
    for i in alphabet:
        test = i in res_dic.keys() 
        if test == False: 
            res_dic[i] = 1
        elif test == True:
            plus = res_dic[i] + 1
            res_dic[i] = plus
    return res_dic

# 全ての文字をカウント
res = []
for i in z:
    alphabet = list(i)
    res.append(word_count(alphabet))

# 全ての組み合わせをチェック
record = []
for i in res:
    for j in res:
        if i == j:
            record.append(1)
        elif i != j :
            record.append(0)

print(int((sum(record) - n)/2))

Submission status: Wrong Answer

Solution code:
x = list(map(str, input().split())) #入力
n = int(x[0]) #最初の文字
z = x[1:] #最初の数字削除

# alphabet（list）をカウントする関数
def word_count(alphabet):
    res_dic = {}
    for i in alphabet:
        test = i in res_dic.keys() 
        if test == False: 
            res_dic[i] = 1
        elif test == True:
            plus = res_dic[i] + 1
            res_dic[i] = plus
    return res_dic

# 全ての文字をカウント
res = []
for i in z:
    alphabet = list(i)
    res.append(word_count(alphabet))

# 全ての組み合わせをチェック
record = []
for i in res:
    for j in res:
        if i == j:
            record.append(1)
        elif i != j :
            record.append(0)

print((sum(record) - n))

Submission status: Wrong Answer

Solution code:
x = list(map(str, input().split())) #入力
n = int(x[0]) #最初の文字
z = x[1:] #最初の数字削除

# alphabet（list）をカウントする関数
def word_count(alphabet):
    res_dic = {}
    for i in alphabet:
        test = i in res_dic.keys() 
        if test == False: 
            res_dic[i] = 1
        elif test == True:
            plus = res_dic[i] + 1
            res_dic[i] = plus
    return res_dic

# 全ての文字をカウント
res = []
for i in z:
    alphabet = list(i)
    res.append(word_count(alphabet))

# 全ての組み合わせをチェック
record = []
for i in res:
    for j in res:
        if i == j:
            record.append(1)
        elif i != j :
            record.append(0)

print((sum(record) - n)/2)

Submission status: Wrong Answer

Solution code:
def abc012(string):
  na = string.count("a")
  nb = string.count("b")
  nc = string.count("c")
  nd = string.count("d")
  ne= string.count("e")
  nf= string.count("f")
  ng= string.count("g")
  nh= string.count("h")
  ni= string.count("i")
  nj= string.count("j")
  nk= string.count("k")
  nl= string.count("l")
  nm= string.count("m")
  nn= string.count("n")
  no= string.count("o")
  np= string.count("p")
  nq= string.count("q")
  nr= string.count("r")
  ns= string.count("s")
  nt= string.count("t")
  nu= string.count("u")
  nv= string.count("v")
  nw= string.count("w")
  nx = string.count("x")
  ny = string.count("y")
  nz = string.count("z")
  n0 = string.count("0")
  n1 = string.count("1")
  n2 = string.count("2")
  n3 = string.count("3")
  n4 = string.count("4")
  n5 = string.count("5")
  n6 = string.count("6")
  n7 = string.count("7")
  n8 = string.count("8")
  n9 = string.count("9")
  return [na,nb,nc,nd,ne,nf,ng,nh,ni,nj,nk,nl,nm,nn,no,np,nq,nr,ns,nt,nu,nv,nw,nx,ny,nz,n0,n1,n2,n3,n4,n5,n6,n7,n8,n9]  


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

for i in range(n):
  s = input()
  slist.append(s)
  
kazu = list(map(abc012,slist))
setkazu = list(map(list,set(map(tuple,kazu))))

print(len(kazu)-len(setkazu))

Submission status: Wrong Answer

Solution code:
n=int(input())
s=[input() for _ in range(n)]
ans=0
for i in range(n-1):
    for j in range(n-i-1):
        if sorted(s[i])==sorted(s[j]):
            ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=[input() for _ in range(n)]
ans=0
for i in range(n):
    for j in range(n-i-1):
        if sorted(s[i])==sorted(s[j]):
            ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
S=[]
for i in range(n):
  S.append(tuple(sorted(input().split())))
print(n-len(set(S)))

Submission status: Wrong Answer

Solution code:
N=int(raw_input())

array=[]
dict=[]
num=0

for i in range(N):
    str = list(raw_input())
    str.sort()
    str = ''.join(str)
    array.append(str)

# print array

dict.append([array[0],0])

for i in range(1,N):
    flag=False
    for j in dict:
        if array[i] == j[0]:
            j[1] += j[1] + 1
            flag=True
            break
        else:
            continue
    if not flag :
        dict.append([array[i], 0])

#    print array[i], dict, num

for i in dict:
    num += i[1]

print num

Submission status: Wrong Answer

Solution code:
# your code goes here
list1 = []
sum1 = 0
a = int(input())
for i in range(a):
	b = input()
	list1.append(b)
for j in range(a):
	for i in range(j):
		if list1[j].count('a')==list1[j-1].count('a') and list1[j-1].count('a')!=0 and list1[j].count('e')==list1[j-1].count('e') and list1[j-1].count('e')!=0:
			sum1 +=1
print(sum1)

Submission status: Wrong Answer

Solution code:
n,*sl, = map(lambda x:''.join(sorted(x)),open(0).read().split())
count = 0
dict = {}
for s in sl:
  if s in dict:
    count += dict[s]
    dict[s] += 1
  else:
    dict[s] = 1

Submission status: Wrong Answer

Solution code:
n = int(input())
li = [sorted(list(input())) for a in range(n)]

ans = 0
le = len(li)
while le > 1:
  t = li[0]
  cnt = 0
  for n, w in reversed(list(enumerate(li[1:]))):
    if t == w:
      cnt += 1
      li.pop(n + 1)
  ans += cnt * (cnt + 1) / 2
  li.pop(0)
  le = len(li)

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
li = [sorted(list(input())) for a in range(n)]
ans = 0
le = len(li)
while le != 0:
  t = li[0]
  cnt = 0
  for n, w in reversed(list(enumerate(li[1:]))):
    if t == w:
      cnt += 1
      li.pop(n + 1)
  ans += cnt * (cnt + 1) / 2
  li.pop(0)
  le = len(li)

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
li = [sorted(list(input())) for a in range(n)]
ans = 0
le = len(li)
while le != 0:
  t = li[0]
  cnt = 0
  for n, w in reversed(list(enumerate(li[1:]))):
    if t == w:
      cnt += 1
      li.pop(n)
  ans += cnt * (cnt + 1) / 2
  li.pop(0)
  le = len(li)

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())  #数値入力 「N」だけの入力のとき
#string_list=[input() for i in range(n)]

counter = 0

for i in range(n):
    string_list= input() 
    new_str = ''.join(sorted(string_list))
    new_str_reverse = new_str[::-1]
    if new_str == new_str_reverse:
       counter += 1  

print(counter)

Submission status: Wrong Answer

Solution code:
n=int(input())  #数値入力 「N」だけの入力のとき
string_list=[input() for i in range(n)]

counter = 0

for i in range(n):
    new_str = ''.join(sorted(string_list))
    new_str_reverse = new_str[::-1]
    if new_str[i] == new_str_reverse[i]:
       counter += 1  

print(counter)

Submission status: Wrong Answer

Solution code:
n=int(input())  #数値入力 「N」だけの入力のとき
string_list=[input() for i in range(n)]

counter = 0

for i in range(n):
    new_str = ''.join(sorted(string_list))
    new_str_reverse = new_str[::-1]
    if new_str == new_str_reverse:
       counter += 1  

print(counter)

Submission status: Wrong Answer

Solution code:
n=int(input())
count={}
for i in range(n):
	sentence=''.join(sorted(input()))
	if sentence not in count:
		count[sentence]=0
	else:
		a=count[sentence]+1
		count[sentence]+=a


print(sum(count.values()))

Submission status: Wrong Answer

Solution code:
n = int(input())
data = []
for i in range(n):
    s = list(input())
    s.sort()
    data.append(s)
data.sort()
i=0
j=0
count=0
for i in range(n):
  for j in range(i,n):
    if data[i]==data[j]:
      count=count+1
print(count)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[None for i in range(n)]
for i in range(n):
  l[i]=sorted(input())
l.sort()
l+="l"
print(l)
cnt=1
ans=0
for i in range(n):
  if l[i]!=l[i+1]:
    ans+=(cnt-1)*cnt//2
    cnt=1
    continue
  cnt+=1
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter 
n = int(input())
anagram =[]
ans = 0
for _ in range(n):
    s = ''.join(input())
    anagram.append(s)
count_ana = Counter(anagram)
for v in count_ana.values():
    ans += v * (v + 1) // 2
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
anagram ={}
for _ in range(n):
    s = ''.join(sorted(input()))
    if s in anagram:
        anagram[s] += anagram[s] + 1
    else:
        anagram[s] =0
print(sum(anagram.values()))

Submission status: Wrong Answer

Solution code:
from sys import stdin


def main():
    N = int(stdin.readline())
    s = [stdin.readline().rstrip().split() for _ in range(N)]

    s_flat = [flatten for inner in s for flatten in inner]

    s_dict = {}
    sum = 0

    for S in s_flat:
        new_S = ''.join(sorted(S))
        print(new_S)
        if not s_dict.get(new_S):
            s_dict[new_S] = 1
        else:
            sum += s_dict[new_S]
            s_dict[new_S] = s_dict[new_S] + 1

    print(sum)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[None for i in range(n)]
for i in range(n):
  l[i]=sorted(input())
l.sort()
cnt=0
ans=0
for i in range(n-1):
  if l[i]!=l[i+1]:
    ans+=(cnt-1)*(cnt-2)//2
    cnt=0
    continue
  cnt+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[None for i in range(n)]
for i in range(n):
  l[i]=sorted(input())
l.sort()
cnt=0
for i in range(n-1):
  if l[i]==l[i+1]:
    cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [list(str(input())) for k in range(n)]
s_sorted = list(map(lambda x: sorted(x), s))
ans = 0
for i in range(n):
    counter = s_sorted[0:i+1].count(s_sorted[-1])
    ans += counter - 1
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [list(map(str, input())) for _ in range(n)]
ans = 0

for i in range(n):
    s[i].sort()

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

Submission status: Wrong Answer

Solution code:
N = int(input())
s = [input() for _ in range(N)]
count, result = 0, 0
for i in range(len(s) - 1):
    for v in range(len(s) - count - 1):
        if ''.join(sorted(list(s[i]))) == ''.join(sorted(list(s[v + 1]))) and i != v + 1:
            result = result + 1
        else:
            continue
    count = count + 1
print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())
d = {}
count=0
for i in range(N):
    l = [j for j in input()]
    if l.sort() in d.values():
        count+=1
    else:
        d[i] = l.sort()
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = []
for i in range(n):
  s.append(''.join(sorted(list(input().strip()))))
ans = 0
tmp = 0
ss = sorted(s)
prev = ''
for iss in ss:
  if prev != iss:
    prev = iss
    ans += int((tmp*(tmp+1))/2)
    tmp = 0
  elif prev == iss:
    print("prev :{}, iss :{}".format(prev, iss))
    tmp += 1
if tmp != 0:
  ans += int((tmp*(tmp+1))/2)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = []
for i in range(n):
  s.append(''.join(sorted(list(input().strip()))))
ans = 0
ss = sorted(s)
prev = ''
for iss in ss:
  if prev != iss:
    prev = iss
  elif prev == iss:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = []
for i in range(n):
  s.append(sorted(list(input().strip())))
ans = 0
ss = sorted(s)
prev = []
for i in range(n):
  if prev != ss[i]:
    prev = ss[i]
  elif prev == ss[i]:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
slist = [input() for i in range(N)]

flag = [False] * 10
count = 0
for j in range(N):
    table = {}
    for i in range(97, 97+26):
        table[chr(i)] = 0
    for i in range(10):
        table[slist[j][i]] += 1
    for sousa_num in range(j+1,N,1):
        table_tmp = table
        for i in range(10):
            if table_tmp[slist[sousa_num][i]] > 0:
                table_tmp[slist[sousa_num][i]] -= 1
                flag[i] = True
        if not (False in flag):
            count += 1
            table = {}
            for i in range(97, 97+26):
                table[chr(i)] = 0
            for i in range(10):
                table[slist[j][i]] += 1
        flag = [False] * 10
print(count)

Submission status: Wrong Answer

Solution code:
x=int(input())
listA=[]
for i in range(x): s=list(input()); s.sort(); listA.append(s)
listB=set(map(tuple, listA))
tt=len(listA)-len(listB)
if tt==0: print(0); 
else: print(tt)

Submission status: Wrong Answer

Solution code:
import sys
import collections

n=int(input())
a=[''.join(sorted(input())) for _ in range(n)]

ans = 0
for v in collections.Counter(a).values():
    if v != 1:
        ans += v - 1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import collections

n=int(input())
a=[''.join(sorted(input())) for _ in range(n)]
 
print(a)

ans = 0
for v in collections.Counter(a).values():
    if v != 1:
        ans += v - 1
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

input_patterns = []

patterns = {}

a_max = ord('z')
a_min = ord('a')


def init_key():
    ini_key = []
    for i in range(26):
        ini_key.append(0)
    return ini_key

for i in range(n):
    val = input()
    input_patterns.append(val)

#input_patterns = ['acornistnt', 'peanutbomb', 'constraint']
    
for inp in input_patterns:
    key = init_key()
    for j in range(len(inp)):
        # make [0, 0, 1, 0, 2, 3, ...]
        #       a  b  c  d  e  f  
        for k in range(26):
            if inp[j] == chr(ord('a') + k):
                key[k] = key[k] + 1
    skey = ''
    for j in range(26):
        skey = skey + str(key[j])

    if skey in patterns:
        pat = patterns[skey] + 1
    else:
        pat = 0
    # patterns['001023...']
    patterns[skey] = pat + 1

result = 0
for p in patterns:
    if patterns[p] > 1:
      result = result + 1

print('{}'.format(result))

Submission status: Wrong Answer

Solution code:
N = int(input())
inlist = []
for i in range(N):
  inputst = input()
  inputstlist = list(inputst)
  inputstlist.sort()
  inlist.append(inputstlist)
inlist.sort()
count=0
for i in range(N):
  skip=0
  for j in range(i+1,N):
    flag1=0
    for k in range(10):
      if inlist[i][k]==inlist[j][k]:
        pass
      else:
        flag1=1
        break
    if flag1==0:
      count+=1
      skip+=1
    else:
      if skip>=1:
        i=i+skip
        count+=((skip-1)+1)*(skip-1)/2
      break
print(count)

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())

SL = []
r = 0
for _ in range(N):
    SL.append(''.join(sorted(input())))

counter = Counter(SL)

cc = sum([v - 1 for k, v in counter.items() if v > 1]) + 1

print(cc)

Submission status: Wrong Answer

Solution code:
from collections import deque

n = int(input())
words = deque()
for i in range(n):
    words.append(input())

unique = {}
count = 0

for word in words:
    sorted_word = sorted(word)
    if ''.join(sorted_word) in unique:
        count += 1
    else:
        unique[''.join(sorted_word)] = 1

print(count)

Submission status: Wrong Answer

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

for i in range(N):
  for j in range(N):
    if i >= j:
      pass
    else:
      if sorted(list(s[i])) == sorted(list(s[j])):
        ans += 1

print(ans)
print(N)
print(s)

Submission status: Wrong Answer

Solution code:
def main():
  n = int(input())
  s = [list(input()) for i in range(n)]
  count = 0
  for j in range(n):
    for i in range(j+1, n):
      count += 1 if set(s[i]) == set(s[j]) else 0
  print(count)


if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
def main():
  n = int(input())
  s = [list(input()) for i in range(n)]
  count = 0
  for j in range(n):
    for i in range(j+1, n):
      if set(s[i]) == set(s[j]):
        count += 1
  print(count)


if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
import collections
def read():
    n = int(input())
    s = []
    for i in range(n):
        s.append(list(input()))

    return (s, n)

(s, n) = read()

for i in range(n):
    s[i].sort()
    s[i] = str(s[i])

count = 0
for i in collections.Counter(s).values():
    if i != 1:
        count = count + i-1

print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [input() for i in range(N)]

mydict = {}

for i in range(N):
  a[i] = list(a[i])
  b = a[i].sort()
  tmp = ','.join(a[i]).strip(',')

  if tmp in mydict:
    mydict[tmp] += int(mydict[tmp]) + 1
  else:
    mydict[tmp] = 0


num = 0

for j in mydict:
  num += int(mydict[j])

print(num)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
n = int(input())
s = [''.join(sorted(input())) for i in range(n)]
dd = defaultdict(int)
for i in range(n):
  dd[s[i]] += 1
c = 0
print(dd)
for i in dd.values():
  c += i * (i-1) // 2
print(c)

Submission status: Wrong Answer

Solution code:

import bisect
import collections
import itertools


def getint(): return int(input())
def getints(): return list(map(int, input().split()))
def getint2d(rows): return [getints() for _ in range(rows)]
def getgrid(rows): return [input() for _ in range(rows)]
def array1d(n, value): return [value for _ in range(n)]
def array2d(n, m, value): return [array1d(m, value) for _ in range(n)]

def to_int():
    s = sorted(input())
    res = 0
    for c in s:
        c = ord(c)
        res = (res * 13 + c) % 10**9+7
    return res

n=getint()
values = [to_int() for _ in range(n)]

cnt = collections.Counter()

for v in values:
    cnt[v] += 1

res = 0
for m in cnt.values():
    res += m * (m - 1) // 2

print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = list(input().split())

for i in range(0, len(s)):
    s[i] = sorted(s[i])
    s[i] = ''.join(s[i])

s = sorted(s)

tmp_count = 1
count = 0
for i in range(0, len(s)-1):
    if s[i] == s[i+1]:
        tmp_count += 1
    else:
        count += tmp_count * (tmp_count - 1) // 2
        tmp_count = 1
count += tmp_count * (tmp_count - 1) // 2
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = list(input().split())
# for i in range(0, len(s)):
#     print(s[i])

for i in range(0, len(s)):
    s[i] = sorted(s[i])
    s[i] = ''.join(s[i])

# for i in range(0, len(s)):
#     print(s[i])

s = sorted(s)
# print(*s)

tmp_count = 1
count = 0
for i in range(0, len(s)-1):
    if s[i] == s[i+1]:
        tmp_count += 1
    else:
        count += tmp_count * (tmp_count - 1) / 2
        tmp_count = 1
count += tmp_count * (tmp_count - 1) / 2
print(int(count))

Submission status: Wrong Answer

Solution code:
N = int(input())
s = list(input().split())
# for i in range(0, len(s)):
#     print(s[i])

for i in range(0, len(s)):
    s[i] = sorted(s[i])
    s[i] = ''.join(s[i])

# for i in range(0, len(s)):
#     print(s[i])

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

print(count)

Submission status: Wrong Answer

Solution code:
a = int(input())
t = [input() for i in range(a)]
cnt = 0
dict = {}
for i in range(a):
    src = "".join(sorted(t[i]))
    if src in dict.keys():
        dict[src] += 1
    else:
        dict[src] = 0
ans = 0
for a in dict.values():
    ans += a*(a+1)/2
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

a = []
for l in sys.stdin:
    if l == '\n':
        break
    else :
        a.append(l)

target = a[int(a[0])]
num = 0
for i in range(1, len(a) - 1):
    for j in range(i + 1, len(a)):
        flag = False
        iStrSorted = ''.join(sorted(a[i]))
        print(iStrSorted)
        jStrSorted = ''.join(sorted(a[j]))
        print(jStrSorted)
        if iStrSorted==jStrSorted:
            flag = True
        else:
            flag = False
        if flag:
            num = num + 1
print(num)

Submission status: Wrong Answer

Solution code:
N = int(input())
S=[]
for n in range(N):
    S.append(input())
Sdict = {}
for s in S:
    lists = list(s)
    listss = sorted(lists)
    listsss = ''.join(listss)
    if Sdict.get(listsss) == None:
        Sdict[listsss] = 0
    else:
        Sdict[listsss] += 1
print(sum(Sdict.values()))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

def my_sort(word):
    sorted_word_list = sorted(word)
    sorted_word = ""
    for letter in sorted_word_list:
        sorted_word += letter
    return sorted_word

n = int(input())
words = {}
for i in range(n):
    word = my_sort(input())
    if word in words.keys():
        words[word] += (words[word]+1)
    else:
        words[word] = 0

print(sum(words.values()))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

def my_sort(word):
    sorted_word_list = sorted(word)
    sorted_word = ""
    for letter in sorted_word_list:
        sorted_word += letter
    return sorted_word

n = int(input())
words = {}
for i in range(n):
    word = my_sort(input())
    if word in words.keys():
        words[word] += words[word]+1
    else:
        words[word] = 0

print(sum(words.values()))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

def my_sort(word):
    sorted_word_list = sorted(word)
    sorted_word = ""
    for letter in sorted_word_list:
        sorted_word += letter
    return sorted_word

n = int(input())
words = {}
for i in range(n):
    word = my_sort(input())
    if word in words.keys():
        words[word] += 1
    else:
        words[word] = 0

print(sum(words.values()))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

n = int(input())
words = []
for i in range(n):
    words.append(sorted(input()))

counter = 0
for i in range(n):
    if (words[i] in words[(i+1):n]):
        counter += 1

print(counter)

Submission status: Wrong Answer

Solution code:
n = int(input())
arr=[]
for i in range(n):
  s1 = input()
  s1 = ''.join(sorted(s1))
  arr.append(s1)
  
sarr = list(set(arr))
cnt=0
for i in sarr:
  for j in arr:
    if i == j:
      cnt+=1
      
print(cnt-len(sarr))

Submission status: Wrong Answer

Solution code:
n = int(input())
arr=[]
for i in range(n):
  s1 = input()
  s1 = ''.join(sorted(s1))
  arr.append(s1)
  
sarr = list(set(arr))
cnt=0
for  i  in sarr:
  cnt+=(arr.count(i)-1)
  
print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
arr=[]
for i in range(n):
  s1 = input()
  s1 = ''.join(sorted(s1))
  arr.append(s1)
  
sarr = list(set(arr))
cnt=0
for  i  in sarr:
  cnt+=arr.count(i)
  
print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
map = {}
for i in range(n):
  str = ''.join(sorted(input()))
  print(str)
  if str in map:
    map[str] += 1
  else:
    map[str] = 1

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

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

a = []
for l in sys.stdin:
    if l == '\n':
        break
    else :
        a.append(l)

target = a[int(a[0])]

outNum = []
i1 = 0
for item in a:
    if i1 != 0 and i1 != int(a[0]):
        for i in range(0, len(target) - 1):
            flag = False
            if target.count(target[i]) == item.count(target[i]):
                flag = True
            else:
                break
        if flag:
            outNum.append(item)
    i1 = i1 + 1
    flag = False
print(len(outNum))

Submission status: Wrong Answer

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

s = [sorted(str(i)) for i in s]
print(s)
for i in range(N):
    for j in range(i+1, N):
        if s[i] == s[j]:
            count += 1
print(count)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
word_l = list()
for _ in range(n):
  word = ''.join(sorted(list(input())))
  word_l.append(word)
  
word_counter = Counter(word_l)
print('{}'.format(sum(word_counter.values()) - len(word_counter)))

Submission status: Wrong Answer

Solution code:
import sys

a = []
for l in sys.stdin:
    if l == '\n':
        break
    else :
        a.append(l)

target = a[int(a[0])]
print(target)

outNum = []
i1 = 0
for item in a:
    if i1 != 0:
        for i in range(0, len(target) - 1):
            flag = False
            if target.count(target[i]) == item.count(target[i]):
                print(item)
                flag = True
            else:
                break
        if flag:
            outNum.append(item)
    i1 = i1 + 1
    flag = False
print(len(outNum))

Submission status: Wrong Answer

Solution code:
import sys

a = []
for l in sys.stdin:
    if l == '\n':
        break
    else :
        a.append(l)

target = a[int(a[0])-1]

outNum = []
i1 = 0
for item in a:
    if i1 != 0:
        for i in range(0, len(target) - 1):
            flag = False
            if target.count(target[i]) == item.count(target[i]):
                flag = True
            else:
                break
        if flag:
            outNum.append(item)
    i1 = i1 + 1
    flag = False
print(len(outNum))

Submission status: Wrong Answer

Solution code:
import sys

a = []
for l in sys.stdin:
    if l == '\n':
        break
    else :
        a.append(l)

target = a[int(a[0])]

outNum = []
i1 = 0
for item in a:
    if i1 != 0:
        for i in range(0, len(target) - 1):
            flag = False
            if target.count(target[i]) == item.count(target[i]):
                flag = True
            else:
                break
        if flag:
            outNum.append(item)
    i1 = i1 + 1
    flag = False
print(len(outNum))