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 math
import copy

n = int(input())
#k, x = [int(i) for i in input().split()]
#table = [[int(i) for i in input().split()] for j in range(n)]
#table = [list(input()) for n in range(h)]
#s = [int(i) for i in input().split()]
#num = [int(i) for i in range(n)]
#s = [input() for i in range(n)]
#s = input()
#list = list(s)
#dp = [[0 for _ in range(2)] for _ in range(13)]
s = [input() for i in range(n)]

for i in range(n):
    moji = list(map(lambda x:x, s[i]))
    moji.sort()
    s[i] = moji

s.sort()

count=0
i=0
j=1
temp = 0
while(j<n):
    if (s[i] == s[j] and j < n-1) :
        j += 1
    elif(s[i] != s[j] and j < n-1) :
        count += (j-i) * (j-i-1) / 2
        i = j
        j = i+1
    elif(s[i] == s[j] and j == n-1) :
        count += (j-i) * (j-i+1) / 2
        i = j
        j = i + 1
    else :
        i = j
        j = i + 1



print(int(count))

Submission status: Wrong Answer

Solution code:
n=int(input())
ls=[]
for _ in range(n):
    ip=list(input())
    ip.sort()
    a="".join(ip)
    ls.append(a)
ls.sort()
cnt=0
b=ls[0]
for i in range(n-1):
    if b==ls[i] and ls[i]==ls[i+1]:
        cnt+=1
    if b!=ls[i] and ls[i]==ls[i+1]:
        cnt+=2
    b=ls[i]
print(cnt)

Submission status: Wrong Answer

Solution code:
from itertools import combinations


N = int(input())
s = [set(input()) for i in range(N)]
 
a = 0
for i,j in combinations(s,2):
  if i==j:
    a+=1
print(a)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = []

for nn in range(n):
    s.append(sorted(input()))

ans = 0

sorted(s)

l = len(s)


cnt = 0

for ss in range(0, l):
    for sss in range(ss+1, l):
        if s[ss] == s[sss]:
            cnt += 1
        else:
            if cnt != 0:
                ans += (cnt+1)/2
                cnt = 0


print(round(ans))

Submission status: Wrong Answer

Solution code:
n=int(input())
ls=[]
for _ in range(n):
    ip=list(input())
    ip.sort()
    a="".join(ip)
    ls.append(a)
ls.sort()
cnt=0
b=ls[0]
for i in range(n-1):
    if b==ls[i] and ls[i]==ls[i+1]:
        cnt+=1
    if b!=ls[i] and ls[i]==ls[i+1]:
        cnt+=2
    b=ls[i]
print(ls)
print(cnt)

Submission status: Wrong Answer

Solution code:
#import sys
import math

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

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 += comb(v,2,10**9+7)
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = []
num = []
count = 0
for i in range(N):
    S.append(input())
    num.append(1)
    num[i] *= pow(2, S[i].count('a'))
    num[i] *= pow(3, S[i].count('b'))
    num[i] *= pow(5, S[i].count('c'))
    num[i] *= pow(7, S[i].count('d'))
    num[i] *= pow(11, S[i].count('e'))
    num[i] *= pow(13, S[i].count('f'))
    num[i] *= pow(17, S[i].count('g'))
    num[i] *= pow(19, S[i].count('h'))
    num[i] *= pow(23, S[i].count('i'))
    num[i] *= pow(29, S[i].count('j'))
    num[i] *= pow(31, S[i].count('k'))
    num[i] *= pow(37, S[i].count('l'))
    num[i] *= pow(41, S[i].count('m'))
    num[i] *= pow(43, S[i].count('n'))
    num[i] *= pow(47, S[i].count('o'))
    num[i] *= pow(73, S[i].count('p'))
    num[i] *= pow(79, S[i].count('q'))
    num[i] *= pow(83, S[i].count('r'))
    num[i] *= pow(89, S[i].count('s'))
    num[i] *= pow(97, S[i].count('t'))
    num[i] *= pow(101, S[i].count('u'))
    num[i] *= pow(103, S[i].count('v'))
    num[i] *= pow(107, S[i].count('w'))
    num[i] *= pow(109, S[i].count('x'))
    num[i] *= pow(113, S[i].count('y'))
    num[i] *= pow(127, S[i].count('z'))

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

print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = [0]*(N+1)
for i in range(N):
    tmp = sorted(list(input()))
    s[i] = ''.join(tmp)
s[-1] = 'zzzzzzzzzzz'
s.sort()

ans = 0
for i in range(N):
    k = 1
    while s[i] == s[i+k]:
        ans += 1
        k += 1

Submission status: Wrong Answer

Solution code:
n = int(input())
result = []
for i in range(n):
    s = input()
    s = list(s)
    s.sort()
    result.append(s)
def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]
no = get_unique_list(result)
print(len(result) - len(no))

Submission status: Wrong Answer

Solution code:
from collections import Counter
n=int(input())
strings = []
for i in range(n):
    strings.append(input())
dic = {}
for l in [Counter(s) for s in strings]:
    ll = str(l)
    if ll in dic:
        dic[ll] += 1
    else:
        dic[ll] = 0
res = 0
for k , v in dic.items():
    res += v * (v + 1)/2
print(res)

Submission status: Wrong Answer

Solution code:
n=int(input())  #数値入力 「N」だけの入力のとき
s=[]
cnt=0
for i in range(n):
    s.append(''.join(sorted(input())))
    if i>1:
        if s[i]==s[i-1]:
            cnt+=1

ss=sorted(s)

renzoku=0
for k in range(len(ss)-1):
    #print(ss[k],ss[k+1])
    if ss[k]==ss[k+1]:
        renzoku+=1
    else:
        cnt+= (renzoku+1)*(renzoku)//2
        #print(cnt)
        renzoku=0

cnt+= (renzoku+1)*(renzoku)//2
print(cnt)

Submission status: Wrong Answer

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

t = [0] * n
for i in range(n):
  t[i] = max(l[i])

s = 0
for i in range(n-1):
  for k in range(i+1,n):
    if t[i] == t[k]:
      s +=1

print(s)

Submission status: Wrong Answer

Solution code:


import math


def str_sort(s):
    return ''.join(sorted(s))
    
def combinations_count(n, r):
    if n == 1: return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def is_anagram(s_1, s_2):
    for c in set(s_1):
        char_count_1 = s_1.count(c)
        char_count_2 = s_2.count(c)
        if char_count_1 != char_count_2:
            return False

    return True





N = int(input()) 
S = [str(input()) for i in range(N)] 



S = [str_sort(s) for s in S]

set_S = S

ans = 0


for set_s in set_S:
    set_count = S.count(set_s)
    ans += combinations_count(set_count, 2)


print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
s=[[] for i in range(N)]
for i in range(N):
  si=list(str(input()))
  s[i].extend(si)
ans=0
memo=[[] for i in range(N)]
val=0
for i in range(N):
  if (sorted(s[i]) in memo)==False:
    memo[val]=sorted(s[i])
    val+=1
  else:
    ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [''.join(sorted(list(input()))) for i in range(N)]
b = 0
for i in a:
    b = b + a.count(i)
print(b / 2)

Submission status: Wrong Answer

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

    totals = []
    count = 0
    for _ in range(N):
        inp = input()
        totals.append(sum([ord(ci) for ci in inp]))

    for i, si in enumerate(totals):
        for sj in totals[i+1:]:
            if si == sj:
                count += 1
    print(count)


main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
n = int(input())
l = []
check = []
count = []
for i in range(n):
    tmp = list(input().strip())
    tmp.sort()
    l.append(tmp)

while(len(l)):
    now = len(l)
    tmp = l.pop()
    #print(tmp)
    if tmp in l:
        l = [x for x in l if tmp == x]
        count.append(now -len(l))
#print(count)
        
ans = 0
for i in count:
    cul = (i*(i-1))/2
    if cul == 0:
        cul += 1
    ans += cul
print(int(ans))

Submission status: Wrong Answer

Solution code:
import math

if __name__ == '__main__':
    n = int(input())
    dict_list = []
    for i in range(n):
        dict = {}
        s = input()
        for i in s:
            if i in dict:
                dict[i] = dict[i] + 1
            else:
                dict[i] = 1
        dict_list.append(dict)

    count = 0
    check = [0]*n
    for i in range(n):
        tmp=0
        for j in range(i,n):
            if j > i and check[j] ==0:
                if dict_list[i] == dict_list[j]:
                    check[j]=1
                    tmp=tmp+1
        if tmp >0:
            count = count + math.factorial(tmp)
    print(count)

Submission status: Wrong Answer

Solution code:
def func(str):
  dic = {}
  for c in str:
    if c in dic:
      dic[c] += 1
    else:
      dic[c] = 1
  
  sorted_dic = sorted(dic)
  result = ""
  for d in sorted_dic:
    result += d
  
  return result
    

N = int(input())

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

dic = {}
for str in inputs:
  res = func(str)
  if res in dic:
    if dic[res] == 0:
      dic[res] += 2
    else:
      dic[res] += 1
  else:
    dic[res] = 0

print(sum(dic.values()))

Submission status: Wrong Answer

Solution code:
n = int(input())
seen = []
ans = 0
for i in range(n):
    s = list(input())
    s.sort()
    if s not in seen:
        seen.append(s)
    else:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
ss=[]
n=int(input())
i=0
while i!=n:

    s=list(input())
    s.sort()
    ss.append(s)
    i+=1
ans=0
i=1
ss.sort()
mians=0

s=ss[0]
while i!=n:
    if s==ss[i]:
        ans+=1
        mians+=1

    else:
        while mians!=0:
            mians-=1
            ans+=mians
    s=ss[i]
    i+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
ls=[]
for _ in range(n):
    ip=list(input())
    ip.sort()
    a="".join(ip)
    ls.append(a)
ls.sort()
cnt=0
b=0
for i in range(n-1):
    if b==ls[i] and ls[i]==ls[i+1]:
        cnt+=1
    if b!=ls[i] and ls[i]==ls[i+1]:
        cnt+=2
    b=ls[i]
print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
s=[]
for i in range(n):
    #文字列を追加するか
    b=list(input())
    b.sort()
    mojiretu = ''.join(b)
    if mojiretu not in s:
        s.append(mojiretu)
print(n-len(s))

Submission status: Wrong Answer

Solution code:
import itertools
n = int(input())
s = [set(input()) for _ in range(n)]
cnt = 0
for a, b in itertools.combinations(s, 2):
  if a == b:
    cnt += 1
print(cnt)

Submission status: Wrong Answer

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


n = int(input())
s = []
for i in range(n):
  s.append(input())
h = []
b = 'abcdedfhijklmnopqrstuvwyz'
for i in s:
  a = [0] * 27
  for c,d in enumerate(b):
    a[c] = i.count(d)
  ss = ''
  for j in a:
    ss += str(j)
  h.append(ss)
  
ans = 0
for i in range(len(h)):
  for j in range(i+1, len(h)):
    if h[i] == h[j]:
      ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import collections

def main():
    n = int(input())
    s = [[] for i in range(n)]
    c = [[] for i in range(n)]
    count = 0
    for num,i in enumerate(s):
        s[num] = input()
        c[num] = collections.Counter(i)


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

    print(count)


if __name__ == '__main__' :
    main()

Submission status: Wrong Answer

Solution code:
import  numpy   as  np
N   =   int(input())
A   =   []

counter     =   0

for i in range(N):
    S   =   sorted(input())
    for j in range(len(A)):
        if(A[j] == S):
            counter += 1
            break
    A.append(S)
print(counter)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = []

for i in range(N):
    s = input()
    S.append(''.join(sorted(s)))

S.sort()
count = 0
for i in range(1, len(S)):
    count += 1 if S[i-1]==S[i] else 0

print(count)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    n = int(input())
    dict_list = []
    for i in range(n):
        dict = {}
        s = input()
        for i in s:
            if i in dict:
                dict[i] = dict[i] + 1
            else:
                dict[i] = 1
        dict_list.append(dict)

    count = 0
    check = [0]*n
    for i in range(n):
        for j in range(i,n):
            if j > i and check[j] ==0:
                if dict_list[i] == dict_list[j]:
                    count = count + 1
                    check[j]=1
    print(count)

Submission status: Wrong Answer

Solution code:
from math import factorial
n=int(input())
s=[]
num=0
ans=0
for i in range(n):
    s.append(list(input()))
    s[i].sort()
s.sort()
for i in range(n-1):
    if s[i]==s[i+1]:
        num+=1
    else:
        if num==0:
            continue
        num+=1
        ans+=factorial(num)//2
        num=0
if num!=0:
    num+=1
    ans+=factorial(num)//2
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import combinations

N = int(input())
s = [list(input()) for i in range(N)]
 
a = 0
for i,j in combinations(s,2):
  if set(i) == set(j):
    a+=1
print(a)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [''.join(sorted(list(input()))) for i in range(N)]
b = set(a)
ans = len(a) - len(b)
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools

n = int(input())
s_li = []
for i in range(n):
    s = input()
    s_i = {}
    for j in range(10):
        s_i[s[j]] = 0
    for j in range(10):
        s_i[s[j]] += 1    
    s_li.append(s_i)

ans = 0

for i in range(n):
    for j in range(n):
        if i >= j :
            continue
        if s_li[i] == s_li[j]:
            print(i, j)
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
lis = []
for i in range(n):
  word = str(input())
  lis.append({letter:word.count(letter) for letter in word})
counter = 0
count = 0
while True:
  m = lis.count(lis[count])
  if m > 1:
    counter += (m*(m-1))//2
    lis.remove(lis[count])
  lis.remove(lis[count])
  if len(lis) == 0:
    break
print(counter)

Submission status: Wrong Answer

Solution code:

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

set_list = set(s)

cnt = 0
for j in set_list:
    tmp = s.count(j)
    if tmp >= 2:
        cnt += tmp

if cnt != 0:
    cnt -= 1
print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = [set(input()) for _ in range(N)]
res = 0
for _ in range(N):
    si = S[0]
    S.pop(0)
    for sj in S:
        if si == sj:
            res += 1
print(res)

Submission status: Wrong Answer

Solution code:
def encode(s):
  r = [0]*26
  for n in range(len(s)):
    r[ord(s[n]) - ord('a')] += 1
  return r

N = int(input())

S = []

for n in range(N):
  s = str(input())
  S = S + [encode(s)]

S.sort()

ct = 0
M=1
ps=""
for cs in S:
  if cs==ps:
    M+=1
  else:
    M+=1
    ct += int((M**2-M)/2)
    M=1
    ps=cs
  
print(ct)

Submission status: Wrong Answer

Solution code:
def sumsun(n):
  ret = 0
  for i in range(n,0,-1):
    ret = ret + i
    
  return ret

N = int(input())
# hoge = input().split()
s = []

print(N)
for i in range(N):
  hoge = input()
  s.append("".join(sorted(hoge)))

ans = 0
itr = 0
while(1==1):
  fin = len(s) 
  if fin == 0:
    break
  is_google = s[itr]
  indexes = [i for i, x in enumerate(s) if x == is_google]
  ans = ans + sumsun(len(indexes)-1)
  while indexes:
    s.pop(indexes.pop())
  
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
lists = []
for i in range(n):
    a = input()
    k = []
    for i in range(10):
        k.append(a[i])
    k.sort()
    lists.append(k)
lists.sort()
lists.append([])
count = -1
ans = 0
print(lists)
for i in range(n):
    if lists[i] != lists[i+1]:
        c = i-count
        count = i
        ans += c*(c-1)//2
print(ans)

Submission status: Wrong Answer

Solution code:
import random
K = int(input())
letters = 'abcdefghijklmnopqrstuvwxyz'
for i in range(K):
  print(''.join(random.choice(letters) for _ in range(10)))

Submission status: Wrong Answer

Solution code:
import collections
import math

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

c = 0
for k, v in collections.Counter(s).items():
    if v <= 1:
        continue
    c += (math.factorial(v-1))

print(c)

Submission status: Wrong Answer

Solution code:
N = int(input())

arr = []
for i in range(N):
    arr.append(str(input()))

count = 0

def sort_str(s):
    return "".join(sorted(list(s)))

for i, item in enumerate(arr):
    s = sort_str(item)
    for j in range(i+1, N):
        print(s, sort_str(arr[j])) 
        if sort_str(arr[j]) == s:
            count += 1

print(count)

Submission status: Wrong Answer

Solution code:
def checkAnagram(str1, str2):
    if (len(str1) != len(str2)):
        return False
    value = 0

    for i in range(0,len(str1)):
        value = value ^ ord(str1[i])
        value = value ^ ord(str2[i])
  
    return value == 0

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

count = 0
for i in range(N-1):
	for j in range(i+1, N):
		if(checkAnagram(V[i], V[j])):
			count += 1

print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = [input() for i in range(n)]
f = [False] * len(l)
r = 0
    
for i in range(n):
    for j in range(i+1, n):
        if f[j]: continue
        anagram = True
        
        for k in range(10):
            t = l[i][k]
            if not (l[i].count(t) == l[j].count(t)):
                anagram = False
                break
        if anagram:
            f[j] = True
            r += 1

print(r)

Submission status: Wrong Answer

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

res = []
for i in l:
    li = list(i)
    li.sort()
    res.append(''.join(li))

a = list(set(res))
t = 0
for i in a:
    t += res.count(i) - 1

print(t)

Submission status: Wrong Answer

Solution code:
n = int(input())
check = [0 for i in range(26 * 11)]
for i in range(n):
    s = input()
    n = 0
    for j in s:
        n += ord(j) - 97
    check[n] += 1
ans = 0
for i in check:
    ans += i*(i-1)/2
print(int(ans))

Submission status: Wrong Answer

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))

n = onem()
a =[]

for i in range(n):
    k = list(input())
    k.sort()
    a.append(k)

a.sort()
b = s(a)

co = 0

for i in range(len(b)):
    co += cmb(b[i][1],2)
print(co)

Submission status: Wrong Answer

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

    strs = []
    for _ in range(N):
        strs.append(input())

    count = 0
    for i, si in enumerate(strs):
        si_total = sum([ord(ci) for ci in si])
        for sj in strs[i+1:]:
            sj_total = sum([ord(cj) for cj in sj])
            if si_total == sj_total:
                count += 1
    print(count)


main()

Submission status: Wrong Answer

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

n = int(input())

dict = {}
for i in range(n):
    s = ''.join(sorted(input()))
    if s in dict:
        dict[s] += dict[s] + 1
    else:
        dict[s] = 0


print(sum(dict.values()))

Submission status: Wrong Answer

Solution code:
n = int(input())
data = []
for _ in range(n):
    d = {}
    line = list(input())
    for let in line:
        if not let in d:
            d[let] = 1
        else:
            d[let] += 1
    data.append(d)

count_data = []
count = {}
index = 0
for i in range(n):
    if not data[i] in count_data:
        count_data.append(data[i])
        count[index] = 0
        index += 1
    else:
        now = count[count_data.index(data[i])]
        count[count_data.index(data[i])] += now + 1


print(sum(count.values()))

Submission status: Wrong Answer

Solution code:
n = int(input())
s=[]
for i in range(n):
    #文字列を追加するか
    b=list(input())
    b.sort
    mojiretu = ''.join(b)
    if mojiretu not in s:
        s.append(mojiretu)
print(len(s))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [input() for _ in range(n)]
ans = 0
exclude = [] # 既に以前に同じアナグラムのものが存在するのでアナグラムを数える必要がない文字列の集合。数字で保存
for i in range(n-1):
  l = list(set(s[i]))
  if i in exclude:
    break # 既にそのアナグラムの文字列がいくつあるかは調べているので不要
  i_count = 1 # i番目の文字列と同じアナグラムが何個存在するか
  for j in range(n):
    if i < j:
      for k in range(len(l)):
        if s[i].count(l[k]) != s[j].count(l[k]):
          break
        if k == len(l)-1:
          exclude.append(j)
          i_count += 1 
  ans += i_count*(i_count-1)//2 # nC2
print(ans)

Submission status: Wrong Answer

Solution code:
import bisect
n = int(input())
words = []
count = 1
total = 0
for i in range(n):
    s = sorted(input())
    bisect.insort_right(words, s, lo=0, hi=len(words))
print(words)
for i in range(1,n):
    if words[i-1] == words[i]:
        count += 1
    elif count != 1:
        total += int(count * (count-1)/2)
        count = 1
    else:
        count = 1
    if i == n - 1 and count != 1:
        total += int(count * (count-1)/2)
    
print(total)

Submission status: Wrong Answer

Solution code:
N = int(input()) 
s = [input() for i in range(N)]
alp=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t',
     'u','v','w','x','y','z']
LIS=[]
for i in range(N):
  ls=[]
  for k in alp:
    n=s[i].count(k)
    ls.append(n)
  LIS.append(ls)
nu=0
for a in range(N):
  for b in range(a+2,N):
    if LIS[a]==LIS[b]:
      nu+=1
    else:
      pass
print(nu)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = []
chars = 'abcdefghijklmnopqrstuvwxyz'

for i in range(N):
    s = input()
    S.append(int(''.join([str(s.count(a)) for a in chars])))

S.sort()
count = 0
for i in range(1, len(S)):
    count += 1 if S[i-1]==S[i] else 0

print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
lis = ["".join(sorted(input())) for _ in range(N)]
lis_A = set(lis)

print(len(lis) - len(lis_A))

Submission status: Wrong Answer

Solution code:
import sys
from math import *
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
li = []
ct = 0
su = 0
alpha2num = lambda c: ord(c) - ord('a') + 1
for i in range(n):
    su = 0
    #li.append("".join(sorted(input())))
    s = input()
    for c in s:
        su += alpha2num(c)
    li.append(su)
for i in range(n):
    for j in range(i+1, n):
        if li[i] == li[j]:
            ct += 1
print(ct)

Submission status: Wrong Answer

Solution code:
num = int(input())
data = []
for _ in range(num):
    data.append(sorted(input()))
data = sorted(data)
print(data)
count = 0
for i in range(num):
    tmp = data[i]
    for j in range(i+1,num):
        if tmp == data[j]:
            count+=1
        else:
            break
print(count)

Submission status: Wrong Answer

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

sum = 0
for i in range(0, len(S)):
  for j in range(i, len(S)):
    if i == j:
      continue
    s1 = set(S[i])
    s2 = set(S[j])
    if s1 == s2 and len(s1) == len(s2):
      sum += 1
print(sum)

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())
s = [0] * N


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


c = collections.Counter(s)

if len(c) ==1:
    print(N)
else:
    print(N-len(c))

Submission status: Wrong Answer

Solution code:
def encode(s):
  r = [0]*26
  for n in range(len(s)):
    r[ord(s[n]) - ord('a')] += 1
  return r

N = int(input())

S = []

for n in range(N):
  s = str(input())
  S = S + [encode(s)]

S.sort()

ct = 0
M=1
ps=""
for cs in S:
  if cs==ps:
    M+=1
  else:
    ct += int((M**2-M)/2)
    M=1
    ps=cs
  
print(ct)

Submission status: Wrong Answer

Solution code:

n = int(input())
s = [list(input()) for i in range(n)]

li = []
for i in s:
    li.append(''.join(sorted(i)))

set_list = set(li)

cnt = 0
for j in set_list:
    tmp = li.count(j)
    if tmp >= 2:
        cnt += tmp

if cnt != 0:
    cnt -= 1
print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())

S = []
k = 0
for i in range(N):
    s = input()
    ss = "".join(sorted(s))
    if ss in S:
        k += 1
    else:
        S.append(ss)

print(k)

Submission status: Wrong Answer

Solution code:
from collections import Counter
import math
n=int(input())
s=[['']*10]*n

def com(n, r):
    if n>=r:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    else:
        return 0
for i in range(n):
    s[i]=list(input())
    s[i].sort()
s=map(tuple,s)
c=dict(Counter(s))
print(c)
x=0
for i in c.values():
    x+=com(i,2)
print(x)

Submission status: Wrong Answer

Solution code:
N= int(input())
s = [''.join(sorted(list(input()))) for i in range(N)]

result = [x for x in set(s) if s.count(x) >1]
print(len(result))

Submission status: Wrong Answer

Solution code:
import itertools
n = int(input())
s = [input() for _ in range(n)]
cnt = 0
for a, b in itertools.combinations(s, 2):
  if set(a) == set(b):
    cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from fractions import Fraction

def Com(n, k):
    p, q = 1, 1
    for i in range(n-k+1, n+1):
        p *= i
    for i in range(2, k+1):
        q *= i
    return p//q

ans = 0
N = int(input())
s = Counter([tuple(sorted(Counter(input()))) for i in range(N)])
for c in s:
    if s[c] > 1:
        ans += Com(s[c], 2)
print(ans)

Submission status: Wrong Answer

Solution code:
import collections
import math

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

c = 0
for k, v in collections.Counter(s).items():
    c += (math.factorial(v) // 2)

print(c)

Submission status: Wrong Answer

Solution code:
from collections import Counter
from itertools import combinations
n = int(input())
lst = [str(Counter(input()).values()) for i in range(n)]
#lst2 = 1#Counter(lst)
#for i in len(lst):
#  print(i.values)
cnt = 0
for i in Counter(lst).values():
  cnt += len(list(combinations(list(range(i)),2)))
"""
for i in range(len(lst)-1):
  for j in range(i+1,len(lst)):
    #print(0)
    if lst[i]==lst[j]:
      cnt += 1
"""
print(cnt)

Submission status: Wrong Answer

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

n = int(input())
strlist = []
for i in range(n):
    strlist.append(list(str(input())))
    
count = 0
for i in range(n):
    for j in range(i+1, n):
        if(set(strlist[i]) == set(strlist[j])):
            count += 1
print(count)

Submission status: Wrong Answer

Solution code:

n = int(input())
s = [list(input()) for i in range(n)]

li = []
for i in s:
    li.append(''.join(sorted(i)))

set_list = set(li)

cnt = 0
for j in set_list:
    tmp = li.count(j)
    if tmp >= 2:
        cnt += tmp

print(cnt-1)

Submission status: Wrong Answer

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

count=0
tmp = S[0]
for i in S[1:]:
    if tmp==i:
        count+=1
    tmp = i
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
import math
S = []
for i in range(N):
    s = sorted(list(input()))
    S.append(''.join(s))
S.sort()
cnt = 1
ans = 0
for i in range(1, N):
    if S[i] == S[i-1]:
        cnt+=1
    else:
        ans+=math.factorial(cnt)//2
        cnt = 1
ans+=math.factorial(cnt)//2
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
s_list = [input() for _ in range(N)]

from collections import Counter
new_s = []
for i, s in enumerate(s_list):
    new_s.append(Counter(sorted(list(s))))

match = []
M=[i for i in range(N)]
center = int(N/2)
count = 0
if N%2==0:
    for i in range(N-1):
        match.append([(M[0+i],M[-1-i]) for i in range(center)])
        M = M[:1] + M[2:] + M[1:2]
else:
    for i in range(N):
        match.append([(M[i],M[-i+1]) for i in range(1,center+1)])
        M = M[1:] + M[:1]
for m in match:
    if new_s[m[0][0]] == new_s[m[0][1]]:
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = [[c for c in input()] for i in range(N)]
dic={}
for i in range(len(S)):
    S[i].sort()
    S[i] = str(S[i])
    if S[i] in dic:
        dic[S[i]] +=1
    else:
        dic[S[i]] = 1
comb=0
for i in range(len(dic.keys())):
    if dic[S[i]] !=0:
        comb = comb +  dic[S[i]]*(dic[S[i]]-1)/2
print(int(comb))

Submission status: Wrong Answer

Solution code:
n=int(input())
ls=[]
for _ in range(n):
    ip=list(input())
    ip.sort()
    a="".join(ip)
    ls.append(a)
ls.sort()
cnt=0
for i in range(n-1):
    if ls[i]==ls[i+1]:
        cnt+=1
if ls[n-2]==ls[n-1]:
    cnt+=1

print(cnt)