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 sys

import sys
a = []
for l in sys.stdin:
    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(item[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 collections  

n = int(input())

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

cnt = 0
for (c, m) in collections.Counter(s).items():
    cnt += m * (m - 1) / 2
    
print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())

d_word={}
count=0

for _ in range(N):
  
  word = "".join(sorted(input()))
  
  if word not in d_word:
    d_word[word]=0
  else:
    d_word[word]+=1
    count+=1

print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

print(n - len(set(s)))

Submission status: Wrong Answer

Solution code:
n = int(input())

l = {}
ans = 0
for i in range(n):
    a = ""
    s = sorted(input())
    for j in range(len(s)):
        a += s[j]
    if a in l:
        ans += l[a]
        l[a] += l[a] + 1
    else:
        l[a] = 0

print(sum(l.values()))

Submission status: Wrong Answer

Solution code:
N = int(input())
s = []
cnt = 0

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

for i in range(N):
    for j in range(i+1, N):
        tmp = s[i]
        for k in range(10):
            tmp = tmp.replace(s[j][k], "") 
        if tmp == "":
            cnt += 1
        else:
            continue

print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = []
cnt = 0

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

for i in range(N):
    for j in range(i+1, N):
        for k in range(len(s[i])):
            tmp = s[i]
            tmp = tmp.replace(s[j][k], "")
        if tmp == "":
            cnt += 1
        else:
            continue
            
print(cnt)

Submission status: Wrong Answer

Solution code:
n=int(input())
ss=[input() for i in range(n)]
d={}
ans=0
for i in ss:
    a=[c for c in ss]
    a.sort()
    a="".join(a)

    if a in d:
        ans+=d[a]
        d[a]+=1
    
    else:
        d[a]=1

print(ans)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
l = [input() for _ in range(n)]
l = [sorted([j for j in i]) for i in l]
l = ["".join(i) for i in l]
al = list(set(l))
ans_dict = {}
ans = 0
for i in l:
    if i in ans_dict:
        ans += ans_dict[i]
        ans_dict[i]+=1
    else:
        ans_dict[i] = 1
    ans = 0

print(ans)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
l = [input() for _ in range(n)]
l = [sorted([j for j in i]) for i in l]
l = ["".join(i) for i in l]
al = list(set(l))
ans_dict = {}
for i in l:
    if i in ans_dict:
        ans_dict[i]+=1
    else:
        ans_dict[i] = 1
    ans = 0
for i in al:
    if ans_dict[i] > 1:
        ans += (math.factorial(ans_dict[i])//math.factorial(2))
    
print(ans)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
l = [input() for _ in range(n)]
l = [[j for j in i] for i in l]
for i in range(n):
    l[i].sort()

l = ["".join(i) for i in l]
al = list(set(l))
ans_dict = {}
for i in l:
    if i in ans_dict:
        ans_dict[i]+=1
    else:
        ans_dict[i] = 1
    ans = 0
for i in al:
    if ans_dict[i] > 1:
        ans += (math.factorial(ans_dict[i])//math.factorial(2))
    
print(ans)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
l = [input() for _ in range(n)]
l = [[j for j in i] for i in l]
for i in range(n):
    l[i].sort()

l = ["".join(i) for i in l]
al = list(set(l))
ans_dict = {}
for i in al:
    ans_dict[i] = 0
for i in l:
    ans_dict[i] += 1
    ans = 0
for i in al:
    if ans_dict[i] > 1:
        ans += (math.factorial(ans_dict[i])//math.factorial(2))
    
print(ans)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
l = [input() for _ in range(n)]
l = [[j for j in i] for i in l]
for i in range(n):
    l[i].sort()

l = ["".join(i) for i in l]
al = list(set(l))
ans_dict = {}
for i in al:
    ans_dict[i] = 0
for i in l:
    ans_dict[i] += 1
    ans = 0
for i in al:
    if ans_dict[i] > 1:
        ans += math.factorial(ans_dict[i]-1)
    
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:
        for i in range(0, len(target) - 1):
            flag = False
            if target.count(target[i]) == item.count(item[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(item[i]):
                flag = True
            else:
                break
        if flag:
            outNum.append(item)
    i1 = i1 + 1
    flag = False
print(outNum)

Submission status: Wrong Answer

Solution code:
N  = int(input())
from collections import Counter

#word = [list(input()) for i in range(N)] 
#print(word)
word2 = [(input())  for i in range(N)]
  

#print(word2)  
ans = Counter(word2)
ans_v = ans.values()
#print(ans)
#import numpy as np
#ans_np = np.array(list(ans_v))
#x = 0
from itertools import combinations
x =[ (len(list(combinations(list('a'*i),2)))) for i in ans_v]
  
  
print(sum(x))

Submission status: Wrong Answer

Solution code:
N=int(input())
t=tuple([''.join(sorted(list(input()))) for _ in range(N)])
Dic = {}
ans = 0
for i in range(N):
    if t[i] in Dic:
        Dic[t[i]]+=1
    else:
        Dic[t[i]]=1
for k in tuple(Dic.keys()):
    ans+=Dic[k]-1

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
t=tuple([''.join(sorted(list(input()))) for _ in range(N)])
print(t)
Dic = {}
ans = 0
for i in range(N):
    if t[i] in Dic:
        Dic[t[i]]+=1
    else:
        Dic[t[i]]=1
for k in tuple(Dic.keys()):
    ans+=Dic[k]-1

print(ans)

Submission status: Wrong Answer

Solution code:

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

dic = set(lista)

print(n-len(dic))

Submission status: Wrong Answer

Solution code:
N = int(input())
slist = [input() for i in range(N)]
setlist = [set(s) for s in slist]
c = 0
for i in range(len(setlist)):
  for j in range(len(setlist)):
    if i>j:
      if setlist[i]==setlist[j]:c+=1    
print(c)

Submission status: Wrong Answer

Solution code:
n = int(input())

l = []
ans = 0
for i in range(n):
    s = sorted(input())
    if s not in l:
        l.append(s)
    else:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
from scipy.misc import comb


def resolve():
    n = int(input())
    ss = []
    for i in range(n):
        ss.append(input())

    sorted_ss = list(map("".join, map(sorted, ss)))
    dic = {}

    for s in sorted_ss:
        dic[s] = dic.get(s, 0) + 1

    count = 0
    for key in dic.keys():
        count += comb(dic[key],2)

    print(int(count))

resolve()

Submission status: Wrong Answer

Solution code:
n = int(input())
strs = ["".join(sorted(list(input()))) for _ in range(n)]
ans = {}
cnt = 0
for i in range(n):
  if strs[i] in ans:
    val = max(ans[strs[i]]+1, 1)
    ans[strs[i]] += val
  else:
    ans[strs[i]] = 0

print(sum(ans.values()))

Submission status: Wrong Answer

Solution code:
N = int(input())
s = [sorted(input(i)) for i in range(N)]
c = len([i for i in range(len(s)) for j in range(len(s[:i])) if s[i] == s[j]])
print(c)

Submission status: Wrong Answer

Solution code:
from itertools import combinations

N = int(input())
s = [sorted(input(i)) for i in range(N)]

c = len([i for i in combinations(s, 2) if i[0] == i[1]])
print(c)

Submission status: Wrong Answer

Solution code:
from collections import Counter
from itertools import combinations

N = int(input())
s = [Counter(input(i)) for i in range(N)]

c = len([i for i in combinations(s, 2) if i[0] == i[1]])
print(c)

Submission status: Wrong Answer

Solution code:
import sys
import bisect
input = sys.stdin.readline
 
def main():
    n=int(input())
    s=[input() for i in range(n)]
    count=0
    
    for i in range(n):
        s[i]=sorted(s[i])
        
    for i in range(n-1):
        s[i].pop(0)
        
    for i in range(n-1):
        for j in range(n-i-1):
            if(s[i]==s[i+j+1]):
                count+=1
    
    print(count)
    
main()

Submission status: Wrong Answer

Solution code:
def solve(string):
    n, *ss = string.split()
    d = {}
    for s in ss:
        s = "".join(sorted(s))
        d[s] = 1 + d[s] if s in d.keys() else 0
    return str(sum([v * (v - 1) // 2 for v in d.values()]))


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))

Submission status: Wrong Answer

Solution code:
def solve(string):
    n, *ss = string.split()
    d = {}
    for s in ss:
        s = "".join(sorted(s))
        d[s] = 1 + d[s] if s in d.keys() else 0
    return str(sum(d.values()))


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))

Submission status: Wrong Answer

Solution code:
count = int(input())

str_data = dict()
result = 0
for i in range(count):
    judge_str = ''.join(sorted(input()))
    if judge_str in str_data:
        str_data['judge_str'] += 1
        result += str_data['judge_str']
    else:
        str_data['judge_str'] = 0
    
print(result)

Submission status: Wrong Answer

Solution code:
from collections import Counter
a = int(input())
l =[]
 
for x in range(a):
    s = sorted(input())
    w = ''.join(s)
    l.append(w)
 
dic = Counter(l)
cnt = 0
 
for k in dic:
    if(dic[k] == 2):
        cnt += 1
    elif(dic[k] > 2):
    	cnt += dic[k]
 
print(cnt)

Submission status: Wrong Answer

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

print(cnt)

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)]
cnt = 0
for i in range(len(dic)-1):
    for j in range(len(dic)-2):
        if dic[i] == dic[j]:
            cnt += 1
print(int(cnt)-len(dic))

Submission status: Wrong Answer

Solution code:
def solve(string):
    n, *ss = string.split()

    d = {}
    for s in ss:
        s = "".join(sorted(s))
        if s in d.keys():
            d[s] = 1 + 2 * d[s]
        else:
            d[s] = 0
    return str(sum(d.values()))


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))

Submission status: Wrong Answer

Solution code:
def solve(string):
    n, *ss = string.split()

    d = {}
    for s in ss:
        s = "".join(sorted(s))
        if s in d.keys():
            d[s] += 1 + d[s]
        else:
            d[s] = 0
    return str(sum([v for v in d.values()]))

if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))

Submission status: Wrong Answer

Solution code:
def solve(string):
    n, *ss = string.split()

    d = {}
    for s in ss:
        s = "".join(sorted(s))
        if s in d.keys():
            d[s] += 1 + d[s]
        else:
            d[s] = 0
    return str(sum(d.values()))


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))

Submission status: Wrong Answer

Solution code:
def solve(string):
    n, *ss = string.split()

    d = {}
    for s in ss:
        s = "".join(sorted(s))
        if s in d.keys():
            d[s] += 1 + d[s]
        d.setdefault(s, 0)
    return str(sum(d.values()))


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict


def solve(string):
    n, *s = string.split()
    d = defaultdict(int)
    for _s in s:
        d["".join(sorted(_s))] += 1
    return str(sum([v * (v - 1) // 2 for v in d.values() if v > 1]))


if __name__ == '__main__':
    print(solve(input()))

Submission status: Wrong Answer

Solution code:
N = int(input())

tarList = []

for i in range(N):
	tarList.append(input())
 
unqwList = set(tarList[0])

wrongCtr = 0
ans = 0

for i in range(1,N):
	for x in unqwList:
		if tarList[i].count(x) !=  tarList[0].count(x):
			wrongCtr += 1
	if wrongCtr == 0:
		ans += 1
	wrongCtr = 0

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

tarList = []

for i in range(N):
	tarList.append(input())
 
unqwList = set(tarList[0])

ans = 0

for i in range(1,N):
	for x in unqwList:
		if tarList[i].count(x) !=  tarList[0].count(x):
			break;
	ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

tarList = []

for i in range(N):
	tarList.append(input())
 
unqwList = set(tarList[0])

ans = 0

for i in range(1,N):
	for x in unqwList:
		if tarList[i].count(x) ==  tarList[0].count(x):
			ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
dict= {}
for i in range(n):
  temp = ''.join(sorted(input()))
  if temp in dict:
    dict[temp] += 1
  else:
    dict.update([(temp, 0)])
print(sum(dict.values()))

Submission status: Wrong Answer

Solution code:
def main():
	n = int(input())
	sl=[]
#	for i in range(n):
#		sl.append(list(input()))
#	for s in sl:
#		s.sort()
	sl=["".join(sorted(input())) for _ in range(n)]
	sl.sort()
	b=""
	l=1
	ans=0
	for i in range(1,n):
		if sl[i]==b:
			l+=1
			if i==n-1 and l >1:
				ans+=l*(l-1)/2
		else:
			if l>1:
				ans+=l*(l-1)/2
			b=sl[i]
			l=1
	print (int(ans))

main()

Submission status: Wrong Answer

Solution code:
n = int(input())
l = [str(input()) for _ in range(n)]
# l = set(l)

m = [-1]*n
ans = 0

for i in range(n-1):
  if m[i] >= 0:
    continue
  else:
    si = l[i]
    m[i] = i
    temp  = 0
    for j in range(i+1, n):
      if m[j] >= 0:
        continue
      else:
        sj = l[j]
        for k in range(10):
          sj = sj.replace(si[k], '', 1)
        if sj == '':
          temp += 1
  ans += temp*(temp-1)*2

print(ans)

Submission status: Wrong Answer

Solution code:
#k,x = map(int, input().split())
N = int(input())

words = list(map(lambda word: input(), range(N)))

letter_lists = []
for word in words:
  letter_lists.append(sorted(word))

count = 0
for i,l in enumerate(letter_lists):
  if l in letter_lists:
    print(letter_lists.count(l)-1)
    break

Submission status: Wrong Answer

Solution code:
N = int(input())
s_list=[]
for i in range(N):
    s_list.append(sorted(list(input())))
set_list=list(map(list, set(map(tuple, s_list))))

import math

count=0
for element in set_list:
    many = s_list.count(element)
    if many>1:
        count+=math.factorial(many-1)

print(count)

Submission status: Wrong Answer

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

sList = []

for n in range(0, N):
    string = list(input())
    sList.append(string)
    sList[n].sort()
    print(sList[n])

for i in range(0, N - 1):
    for j in range(i + 1, N):
        if sList[i] == sList[j]:
            cnt += 1
print(cnt)

Submission status: Wrong Answer

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

for _ in range(N):
    s_list.append(input())
    
count=0
for i in range(N):
    for j in range(i+1,N):
        s1=[]
        s2=[]
        for k in range(10):
            s1.append(s_list[i][k])
            s2.append(s_list[j][k])
            
        print(sorted(s1),sorted(s2))
        if sorted(s1)==sorted(s2):
            count+=1
print(count)

Submission status: Wrong Answer

Solution code:
def ana(l,s):
    for i in l:
        if i ==s:
            return True
    return False
l=[]
num=int(input())
l.append("".join(sorted(input())))
ll=[]

for _ in range(num-1):
    s=input()
    if ana(l,"".join(sorted(s))) ==True:
        ll.append(s)
    l.append("".join(sorted(s)))

print(len(ll))

Submission status: Wrong Answer

Solution code:
n = int(input())
arr = [input() for i in range(n)]
listarr = [[arr[i][j] for j in range(10)] for i in range(n)]
for i in range(n):
    listarr[i].sort()
tuplearrsort = [tuple(listarr[i]) for i in range(n)]
dic = {}

for i in range(n):
    if tuplearrsort[i] in dic:
        dic[tuplearrsort[i]] += 1
    else:
        dic[tuplearrsort[i]] = 1
      
count = 0
for key in dic:
    if dic[key] == 1:
        count += 1
    else:
        count += (dic[key] * (dic[key]-1)) // 2
    
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
arr = [input() for i in range(n)]
listarr = [[arr[i][j] for j in range(10)] for i in range(n)]
for i in range(n):
    listarr[i].sort()
tuplearrsort = [tuple(listarr[i]) for i in range(n)]
dic = {}

for i in range(n):
    if tuplearrsort[i] in dic:
        dic[tuplearrsort[i]] += (dic[tuplearrsort[i]] + 1)
    else:
        dic[tuplearrsort[i]] = 0
      
count = 0
for i in dic:
    count += dic[i]
    
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
arr = [input() for i in range(n)]
listarr = [[arr[i][j] for j in range(10)] for i in range(n)]
for i in range(n):
    listarr[i].sort()
tuplearrsort = [tuple(listarr[i]) for i in range(n)]
dic = {}

for i in range(n):
    if tuplearrsort[i] in dic:
        dic[tuplearrsort[i]] += 1
    else:
        dic[tuplearrsort[i]] = 0
      
count = 0
for i in dic:
    count += dic[i]
    
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = [sorted(str(input())) for _ in range(N)]
S.sort()

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

L = []
c = 1
for i in range(N):
    if i == 0:
        pass
    else:
        if S[i-1]==S[i]:
            c += 1
            if i == N-1:
                L.append(c)
        else:
            if c >= 2:
                L.append(c)
            c = 0
res = 0
for x in L:
    res += cmb(x,2)
print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = [sorted(str(input())) for _ in range(N)]
S.sort()

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

L = []
c = 1
for i in range(N):
    if i == 0:
        pass
    else:
        if S[i-1]==S[i]:
            c += 1
            if i == N-1:
                c += 1
                L.append(c)
        else:
            if c > 1:
                L.append(c)
            c = 0
res = 0
for x in L:
    res += cmb(x,2)
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())

S = []
ans = 0

for i in range(N):
    S.append(input())

for j in range(N-1):
    for k in range(j+1,N):
        if set(S[j]) == set(S[k]):
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
class z:
    c=0
    def zadd(self, a,b):
        if a==b:self.c+=1

n=int(input())
ss = [set(list(input())) for i in range(n)]
c=z()
[c.zadd(ss[i], ss[ii]) for i in range(n) for ii in range(i+1,n,1)]
print(c.c)

Submission status: Wrong Answer

Solution code:
def z(a,b):
    if a==b:
        return 1
    else:
        return 0

n=int(input())
ss=[]
ss = [set(list(input())) for i in range(n)]
print(sum([z(ss[i], ss[ii]) for i in range(n) for ii in range(i+1,n,1)]))

Submission status: Wrong Answer

Solution code:

n=int(input())
ss=[]
ss = [set(list(input())) for i in range(n)]
c=0
for i in range(n):
    for ii in range(i+1, n, 1):
        if ss[i]==ss[ii]:c+=1
print(c)

Submission status: Wrong Answer

Solution code:
n=int(input())
ss=[]
for i in range(n):
    ss.append(set(list(input())))
c=0
for i in range(n):
    for ii in range(i+1, n, 1):
        if ss[i]==ss[ii]:c+=1
print(c)

Submission status: Wrong Answer

Solution code:
n=int(input())
ss=[]
for i in range(n):
    ss.append(set([x for x in input()]))
c=0
for i in range(n):
    for ii in range(i+1, n, 1):
        if ss[i]==ss[ii]:c+=1
print(c)

Submission status: Wrong Answer

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

count = 0

dict = {}

for i in range(N):
  charList = list(strList[i])
  charList.sort()
  key = "".join(charList)
  if not key in dict:
    dict[key] = 1
  else:
    dict[key] += 1  

# dictが持つvalue値を要素にfor文で回す
count = 0;
for v in dict.values():
  count += (v * (v-1) / 2)
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
d = {}
for i in range(n):
    s = ''.join(sorted(input()))
    if s in d.keys():
        d[s] += 1+d[s]
    d.setdefault(s, 0)
print(sum(d.values()))

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
N = int(input())
S = [list(input()) for i in range(N)]

for l in range(N):
  S[l].sort()
S.sort(key = itemgetter(0))

for k in range(N):
  S[k] = ''.join(S[k])
ans = 0

for j in range(N-1):
  for m in range(j+1,N):
    if S[j] == S[m]:
      ans += 1
    else:
      break

print(ans)

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
A = []
B=[]
ans=0
for i in range(N):
    x=collections.Counter(list(input()))
    if x in A:
      ii=A.index(x)
      B[ii]+=B[ii]
    else:
      A.append(x)
      B.append(1)
print(sum(B)-len(B))

Submission status: Wrong Answer

Solution code:
N = int(input())

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

for j in range(N):
  S[j].sort()
  S[j] = ''.join(S[j])

ans = 0  

for k in range(N):
  for l in range(k+1,N):
    print(k, l)
    if k < l:
      if S[k] == S[l]:
        print(True)
        ans += 1
  
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import bisect
input = sys.stdin.readline

N = int(input())
L = [input().strip() for _ in range(N)]

m = [0 for _ in range(N)]
for i in range(N):
    m[i] = sum([ord(v) for v in L[i]])

mm = {}
for i in range(N):
    if mm.get(m[i]) == None:
        mm[m[i]] = 0
    mm[m[i]] += 1

ans = 0
for v in mm.values():
    if v != 1:
        ans += v * (v - 1) // 2

print(ans)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

N = int(input())
S = []
for i in range(N):
  S.append(list(input()))
for i in range(N):
  S[i] = sorted(S[i])
S.sort(key=itemgetter(1,0))

c = 0
for i in range(N):
  for j in range(N-i-1):
    if S[i] == S[i+j+1]:
      c += 1
    else:
      break
print(c)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=["".join(sorted(input())) for _ in range(N)]
dic={}
for s in S:
  if s not in dic:
    dic.setdefault(s,1)
  else:
    dic[s]+=dic[s]
li=list(dic.values())
print(sum(li)-len(li))

Submission status: Wrong Answer

Solution code:
N=int(input())
S=["".join(sorted(input())) for _ in range(N)]
dic={}
for s in S:
  if s not in dic:
    dic.setdefault(s,1)
  else:
    dic[s]+=dic[s]
print(dic)
li=list(dic.values())
print(sum(li)-len(li))

Submission status: Wrong Answer

Solution code:
from collections import Counter
a = int(input())
l =[]

for x in range(a):
    s = sorted(input())
    w = ''.join(s)
    l.append(w)

dic = Counter(l)
cnt = 0

for k in dic:
    if(dic[k] > 1):
        cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
from collections import Counter


def compare(s1, s2):
    k2s = s2.keys()
    for k1 in s1.keys():
        if k1 in k2s:
            if s1[k1] == s2[k1]:
                return True

    return False
        

def check(s1, s2, i, j, memo):
    if memo[i] == -1:
        if memo[j] == -1:
            if compare(s1, s2):
                memo[i] = i
                memo[j] = i
                return 1
            else:
                return 0
        else:
            return 0
    else:
        if memo[j] == -1:
            if compare(s1, s2):
                memo[j] = i
                return 1
        elif memo[i] == memo[j]:
            return 1

    return 0


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

    S = []
    for _ in range(N):
        s = input()
        S.append(Counter(s))

    ans = 0
    memo = [-1 for i in range(N)]
    for i in range(N):
        for j in range(i+1, N):
            if len(S[i]) == len(S[j]):
                ans += check(S[i], S[j], i, j, memo)

    print(ans)


main()

Submission status: Wrong Answer

Solution code:
N=int(input())
ls=[]
n=0
for i in range(N):
    str1=''.join(sorted(input()))
    ls.count(str1)
    ls.append(str1)
print(n)

Submission status: Wrong Answer

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

ss = list(set(s))

res = 0
for ssi in ss:
    res += s.count(ssi) - 1
    
print(res)

Submission status: Wrong Answer

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

ss = list(set(s))

res = 0
for ssi in ss:
    res += s.count(ssi) - 1
    
print(res)

Submission status: Wrong Answer

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

s = sum(s, [])
ss = list(set(s))

res = 0
for ssi in ss:
    res += s.count(ssi) - 1
    
print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
str = [[input(),0] for i in range(N)]
count = 0

for i in range(N):
  for j in range(10):
    str[i][1] += ord(str[i][0][j])
  
for i in range(N-1):
  for j in range(i+1,N):
    if str[i][1] == str[j][1]:
      count += 1

print(count)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
import sys
readline = sys.stdin.readline

N = int(input())

result = 0
d = defaultdict(int)
for _ in range(N):
    s = input()
    s = ''.join(sorted(s))
    if s in d:
        d[s] += (d[s] + 1)
    else:
        d[s] = 0
print(sum([v for k, v in d.items()]))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

N = int(input())

result = 0
d = defaultdict(int)
for _ in range(N):
    s = input()
    s = ''.join(sorted(s))
    if s in d:
        d[s] += (d[s] + 1)
    else:
        d[s] = 0
print(sum([v for k, v in d.items()]))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

N = int(input())

result = 0
d = defaultdict(int)
for _ in range(N):
    s = input()
    s = str(sorted(s))
    if s in d:
        d[s] += (d[s] + 1)
    else:
        d[s] = 0
print(sum([v for k, v in d.items()]))

Submission status: Wrong Answer

Solution code:
import collections

n = int(input(""))
x = []
for i in range(n):
    x.append(input(""))
xx = [[]]
for i in range(n):
    tmp = list(x[i])
    tmp.sort()
    xx.append(tmp)
xx.remove(xx[0])

ans_array = []
for i in range(n):
    tmp = ""
    for j in range(10):
        tmp += xx[i][j]
    ans_array.append(tmp)
ans_dic = collections.Counter(ans_array)
ans = 0
for k in ans_dic.keys():
    if ans_dic[k] == 2:
        ans += ans_dic[k]-1
    elif ans_dic[k] >= 3:
        ans += ans_dic[k]

print(ans)

Submission status: Wrong Answer

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

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

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

print(new_a)
new_a.sort()
print(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:
def clc(num):
  return 1+num*(num-1)/2 +num-1

n =int(input())
cnt=0
pr=0
s=[None]*n
ans=[0]*n
for i in range(n):
  s[i]=sorted(input())
s.sort()
for j in range(0, n-1, 1):
  if s[j] == s[j+1]:
    ans[cnt] += 1
  else:
    cnt +=1
clcnums = [clc(n) for n in ans if n!= 0]
print(sum(clcnums))

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()

for index in collections.Counter(moji).values():
  n = index - 1
  count += n*(1+n)/2

print(count)

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(collections.Counter(moji))

for index in collections.Counter(moji).values():
  n = index - 1
  count += n*(1+n)/2

print(count)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
s = [input() for i in range(n)]
cnt = 0
for i in range(1,n):
    for l in range(i-1):
        if Counter(s[i]) == Counter(s[l]):
            cnt += 1
print(cnt)