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:
from collections import Counter                  
                                                 
n = int(input())                                 
s = [input() for i in range(n)]                  
s_sorted = []                                    
for w in s:                                      
    w_list = [c for c in w]                      
    w_list.sort()                                
    s_sorted.append(''.join(w_list))             
counter = Counter(s_sorted)                      
a = counter.most_common()[0]                     
print(a)                                         
c = a[1]                                         
if c > 0:                                        
    print(c)                                     
else:                                            
    print(0)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
#ABC137C
import copy
import sys
import math

n = int(input())
#tmp = input().split()
#hoge = list(map(lambda a: int(a), tmp))
#k=hoge[0]
#x=hoge[1]

list = [[0 for i in range(26)] for j in range(n)]
#list[0][1]=1
#print(list)

hash=[]
for i in range(0,26):
	hash.append([])

for i in range(0,n):
	tmp=input()
	hoge=0
	for j in range(0,10):
		list[i][ord(tmp[j])-ord("a")]+=1
		hoge+=ord(tmp[j])-ord("a")
	hoge=hoge%26
	hash[hoge].append(i)
#print(hash)

sum=0

for i in range(0,26):
	for j in range(0,len(hash[i])-1):
		for k in range(1,len(hash[i])):
			#print(i)
			#print(hash[i][j])
			#print(hash[i][k])
			for m in range(0,26):
				if(list[hash[i][j]][m]!=list[hash[i][k]][m]):
					break
				elif(m==25):
					sum+=1


#for i in range(0,n-1):
#	for j in range(i+1,n):
#		for k in range(0,26):
#			if(list[i][k]!=list[j][k]):
#				break
#			elif(k==25):
#				sum+=1

print(sum)

#print(list)
#print(list[0][:])

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
b = [''.join(sorted(input())) for i in range(n)]
l = collections.Counter(b)
ll = l.values()
ans = 0
for i in ll:
  if i > 1:
    ans += i*(i-1)//2
  else:
    break
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [input() for _ in range(n)]


def is_anagram(s_i, s_j):
    for k in range(10):
        found = False
        for l in range(10):
            if s_i[k] == s_j[l]:
                found = True
                break
        if not found:
            return False
    return True


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

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())
strList = []
for i in range(N):
    inStr = input()
    inNum = 0
    for j in range(len(inStr)):
        inNum = inNum + ord(inStr[j])-64
    strList.append(inNum)

anaglam = 0

c = collections.Counter(strList)
for i in c.keys():
    anaglam = anaglam + c[i]*(c[i]-1)/2
    
print(str(anaglam)[:-2])

Submission status: Wrong Answer

Solution code:
n=int(input())
S=[]
for i in range(n):
  s=list(input())
  s.sort()
  S.append(s)
S.sort()
S.append(["z" for i in range(11)])
cont=0
for i in range(n-1):
  t=1
  while S[i]==S[i+t]:
    cont+=1
    t+=1
print(cont)
print(S)

Submission status: Wrong Answer

Solution code:
N=int(input())
sn=[list(input()).sort() for _ in range(N)]
print(sn)

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)
counter = 0
for v in no:
  co =result.count(v) 
  counter += co * (co-1) / 2
print(counter)

Submission status: Wrong Answer

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

alphabet = 'abcdefghijklmnopqrstuvwxyz'
h = dict(zip(alphabet,[0] * len(alphabet)))
ans = []

for i in range(n):
  s.append(input())
  h1 = h
  for c in s[i]:
    h1[c] += 1
  ans.append(h1)
  
cnt = 0
for i in range(n):
  for j in range(i+1,n):
    if ans[i] == ans[j]:
      cnt += 1
  
print(cnt)

Submission status: Wrong Answer

Solution code:
N=int(input())
ABCS=[[0 for i in range(28)] for j in range(N)]

for i in range(N):
    S=input()
    for j in range(10):
       #print(S[j:j+1],"a")
        ABCS[i][ord(S[j:j+1])-97]=ABCS[i][ord(S[j:j+1])-97]+1
ABCS.sort()
#print(ABCS)
dabu=[None]
ct=0
test=ABCS[0]
for i in range(N):
    if i>0:
        if ABCS[i]==test:
            ct=ct+1
        else:
            dabu.append(ct)
            test=ABCS[i]
            ct=0
kumi=0
for x in dabu:
    if x != None:
        if x==1:
            kumi=kumi+1
        else:
            kumi=kumi+x*(x-1)/2
    
#print(dabu)
print(int(kumi))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

N = int(input())

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

line = defaultdict(int)

for anagram in s:
  a = sorted(anagram)
  line[''.join(a)] += 1

_sum = 0

for i in line:
  if line[i] == 1:
    continue
  elif line[i] == 2:
    _sum += 1
  else:
    _sum += line[i]

print(_sum)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = []
for _ in range(N):
    s.append(input())
    
def uniGram(sentences_String):
    return([sentences_String[0+i:1+i] for i in range(len(sentences_String)-1+1)])
sUniGramed = list(map(uniGram, s))
sSorted = []
for k in range(N):
    sSorted.append(sUniGramed[k].sort())

ans = 0
for i in range(N):
    if sSorted[i] in sSorted[i+1:]:
        ans += 1
    else:
        pass
print(ans)

Submission status: Wrong Answer

Solution code:
def hoge(a,b):
    numA = 0
    numB = 0
    for i in range(10):
        numA += ord(a[i])
        numB += ord(b[i])
    if numA == numB:
        return 1
    else:
        return 0

import itertools
N = int(input())
nums = [input() for _ in range(N)]
c = list(itertools.combinations(nums, 2))
ans = 0
for i in c:
    ans += hoge(i[0],i[1])
print(ans)

Submission status: Wrong Answer

Solution code:
import copy


def main():
    n = int(input())
    s = [["" for j in range(10)] for i in range(n)]
    for i in range(n):
        s[i] = list(input())

    print(int(count_anagram(s[0], s[1:], 0)))


def anagram(list1, list2):
    if not list1:
        return True

    if list1[0] in list2:
        list2.remove(list1[0])
        list1.pop(0)
        return anagram(list1, list2)
    else:
        return False


def count_anagram(s, str_list, total):
    cnt = 0
    for t in str_list:
        u, v = copy.copy(s), copy.copy(t)
        if anagram(u, v):
            str_list.remove(t)
            cnt += 1
    if cnt > 0 :
        total += (cnt+1) * cnt / 2
    
    if str_list:
        return count_anagram(str_list[0], str_list[1:], total)
    else:
        return total
    


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
num = int(input())
char=[] #appendのために宣言が必要
while True:
    try:
        char.append(list(input()))

    except:
        break
new_char=[]
cnt=0
for i in range(num):
	new_char.append(sorted(char[i]))
for x in range(num):
    for y in range(num):
        if new_char[x]==new_char[y] and x!=y:
            cnt = cnt+1
print(cnt)

Submission status: Wrong Answer

Solution code:
def factorial(i):
    ans = 1
    for j in range(1,i+1):
        ans *= j
    return ans

N = int(input())
A = [input() for i in range(N)]
a = []
for i in A:
    b = list(i)
    b.sort()
    a.append(b)

a.sort()
ans = a[0]
count=0
for i in range(1,N):
    ans = a[i]
    for j in range(i,N):
        if ans == a[j]:
            count+=1
print(count)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

n=int(input())
s=[]
li=[]
ans=0
cnt=1

for i in range(n):
  s.append(sorted(input()))
s.sort(key=itemgetter(9,0))
s=s+['']

for i in range(n):
  if s[i]==s[i+1]:
    cnt+=1
  elif cnt>1:
    li.append(int(cnt*(cnt-1)/2))
    cnt=1
  else:
    cnt=1
print(int(sum(li)))

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
s = [input() for i in range(n)]
s_sorted = []
for w in s:
    w_list = [c for c in w]
    w_list.sort()
    s_sorted.append(''.join(w_list))
counter = Counter(s_sorted)
a = counter.most_common()[0]
c = a[1]


if c-1 > 0:
    print(c-1)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N=int(input())
l=[]
for x in range(0,N):
    l.append(input())
for x in range(0,N):
    l[x]=sorted(list(l[x]))
l=sorted(l)
i=0
x=0
y=0
while i<N:
    for j in range(i+1,N):
        if l[i]==l[j]:
            x=x+1
        else:
            y=y+sum(range(1,x+1))
            i=i+x
            x=0
            break
    i=i+1
print(y)

Submission status: Wrong Answer

Solution code:
n = input()
n = int(n)
total = 0
word = []

for i in range(n):
    word.append(input())

i = 0

while i < len(word):   
    count = 0
    master = list(word[i])
    j = i + 1
    while j < len(word):
        target = list(word[j])
        for k in range(len(master)):
            l = 0
            while l < len(target):
                if master[k] == target[l]:
                    target.pop(l)
                else:
                    l += 1
        if len(target) == 0:
            word.pop(j)
            count += 1
        else:
            j += 1
    i += 1
	
    if count == 1:
        total += 1
    else:
        for a in range(count):
    	    total += a
print(total)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
s = [x for x in [Counter(list(input())) for _ in range(n)]]


alphabet = set('abcdefghijklmnopqrstuvwxyz')
s_list = [''.join([str(s_i[a]) for a in alphabet]) for s_i in s]

for x in s_list:
  print(x)

count = 0
i = 0

for x in s_list:
  i += 1
  temp = s_list[i:]
  hoge = s[i:]
  for y in temp:
    if y == x:
      count += 1
print(count)

Submission status: Wrong Answer

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

    td = {}
    for _ in range(N):
        str = [ci for ci in input()]
        str.sort()
        t = ''.join(str)
        if t not in td.keys():
            td[t] = 0
        else:
            if td[t] == 0:
                td[t] = 1
            else:
                td[t] += td[t] * 2
    count = 0
    for v in td.values():
        count += v
    print(count)


main()

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)
counter = 0
for v in no:
  co =result.count(v) - 1
  counter += co * (co-1) / 2
print(counter)

Submission status: Wrong Answer

Solution code:
import sys
 
Ans = int(0)
N = int(input())
S = []
T = []
U = []
for _ in range(N):
  S.append(str(input()))
T = ['a'] * N  
U = ['a'] * N
 
for i in range(N):
  U[i] = ''.join(sorted(S[i]))
 
T = sorted(U)
 
j = 0
while j < N:
  for k in range(1,N):
    if j + k == N - 1:
      if T[j] != T[j + k]:
        Ans = Ans + 2**(k-1) - 1
      else:
        Ans = Ans + 2**k - 1
        
      print(Ans)
      sys.exit()
      
    if T[j] != T[j + k]:
      Ans = Ans + 2**(k-1) - 1
      a = k
      break
  
  j = j + a
  
print(Ans)

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
s = [str(input()) for s in range(N)]

S = []
for i in range(len(s)):
    foo = list(reversed(s[i]))
    foo.sort()
    S.append(''.join(foo))
ans = []
c = collections.Counter(S)
keys = list(c.keys())
for s in keys:
    ans.append(c[s] - 1)
print(sum(ans))

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
s = [x for x in [Counter(list(input()[:-1])) for _ in range(n)]]


alphabet = set('abcdefghijklmnopqrstuvwxyz')
s_list = [''.join([str(s_i[a]) for a in alphabet]) for s_i in s]

for x in s_list:
  print(x)

count = 0
i = 0

for x in s_list:
  i += 1
  temp = s_list[i:]
  hoge = s[i:]
  for y in temp:
    if y == x:
      count += 1
print(count)

Submission status: Wrong Answer

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

print(len(s) - len(set(s)) + sum(range(1, len(s) - len(set(s)) - 1)))

Submission status: Wrong Answer

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

n = int(input())
s = [list(input().split()[0]) for _ in range(n)]
print(s)
cnt = defaultdict(int)
for i in range(n):
  s[i].sort()
  cnt["".join(s[i])] += 1
result = 0
for c in cnt:
  result += len(list(combinations([""] * cnt[c], 2)))
print(result)

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())
strList = []
for i in range(N):
    inStr = input()
    inNum = 0
    for j in range(len(inStr)):
        inNum = inNum + ord(inStr[j])-64
    strList.append(inNum)

anaglam = 0

c = collections.Counter(strList)
for i in c.keys():
    anaglam = anaglam + c[i]*(c[i]-1)/2
    
print(int(anaglam))

Submission status: Wrong Answer

Solution code:
import collections, json

num = int(input())

wordlist = []

for i in range(num):
    wordlist.append(json.dumps(sorted(collections.Counter(input()).items())))

a = collections.Counter(wordlist)

s = list(a.values())

result = 0

for g in s:
    if g != 1:
        result += int(g)

print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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 getNumbers(str_input):
    Numbers = ""
    for i in alfa:
        Numbers += str(str_input.count(i))
        if len(Numbers) == 10:
            break
    return Numbers

N = int(input())
s = [input() for _ in range(N)]
alfa = ["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"]

ans = []
ans_point = [1] * N
for i in range(N):
    s_s = getNumbers(s[i])
    if (s_s in ans) == False:
        ans.append(s_s)
    else:
        ans_point[ans.index(s_s)] += 1

ans_count = 0
for i in range(N):
    if ans_point[i] != 1:
        ans_count += cmb(ans_point[i],2)
    else:
        print(ans_count)
        exit()

print(ans_count)

Submission status: Wrong Answer

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

ss = []
counts_id = []
answer = 0

chars = [x for x in "abcdefghijklmnopqrstuvwxyz"]
num = len(chars)

for i in range(N):
  ss.append(input().strip())
  _count = [0 for _ in range(num)]
  for _s in ss[i]:
    _count[chars.index(_s)] += 1
  
  if i == 0:
    counts_id = [_count]
  else:
    for id in counts_id:
      if id == _count:
        answer += 1
        break
    if _count in counts_id:
      counts_id.append(_count)
    
print(answer)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [input() for i in range(n)]
a = []
import collections
for i in range(len(s)):
    a.append(collections.Counter(s[i]))
count = 0
b = 0
for i in range(len(a)):
    b += 1
    for j in range(b+1, len(a)):
        if a[i] == a[j]:
            count += 1
print(count)

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())
lists = [str(input()) for i in range(n)]

lists2 = ["".join(sorted(i)) for i in lists]
l = collections.Counter(lists2)
c = l.values()
 
print(sum([i * (i - 1)/ 2 for i in c]))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = set()
for i in range(n):
    string = sorted(str(input()))
    string2 = "".join(string)
    s.add(string2)
num = len(s)
if n==num:
    print(0)
else:
    print(n-num+1)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=[[0 for i in range(10)] for j in range(n)]
for i in range(n):
  s[i]=list(input())
  s[i].sort()

sorted(s, key=lambda x: x[0])
  
count=0

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

  

print(count)

Submission status: Wrong Answer

Solution code:
N=int(input())
l=[]
for x in range(0,N):
    l.append(input())
for x in range(0,N):
    l[x]=sorted(list(l[x]))
l=sorted(l)
x=0
y=0
for i in range(0,N):
    for j in range(i+1,N):
        if l[i]==l[j]:
            x=x+1
        else:
            y=y+sum(range(1,x+1))
            i=i+x+1
            x=0
            break
print(y)

Submission status: Wrong Answer

Solution code:
N,*s=open(0).read().split()
N = int(N)
s = [sum(map(ord,s_)) for s_ in s]
cnt = 0
for i in range(N):
  s_ = s.pop(0)
  cnt += (s.count(s_))
print(cnt)

Submission status: Wrong Answer

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

ans = 0
for i in range(N-1):
  for j in range(1,N-i):
    cnt = 0
    for ca in S[i]:
      for cb in S[i+j]:
        if ca == cb:
          cnt += 1
          break
    if cnt == 10:
      ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
 
Ans = 0
N = int(input())
S = []
T = []
U = []
for _ in range(N):
  S.append(str(input()))
T = ['a'] * N  
U = ['a'] * N
 
for i in range(N):
  U[i] = ''.join(sorted(S[i]))
 
T = sorted(U)
 
j = 0
while j < N:
  for k in range(1,N):
    if j + k == N - 1:
      if T[j] != T[j + k]:
        Ans = Ans + 2**(k-1) - 1
      else:
        Ans = Ans + 2**k - 1
        
      print(Ans)
      sys.exit()
      
    if T[j] != T[j + k]:
      Ans = Ans + 2**(k-1) - 1
      a = k
      break
  
  j = j + a
  
print(Ans)

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())
#c = 0
#sort_dict = dict()
sort_list = list()
for i in range(n):
  i_sort = "".join(sorted(input()))
  #sort_dict[i] = i_sort
  sort_list.append(i_sort)
  #if not sort_dict[0]:
  #  if sort_dict[i] == sort_dict[i-1]:
  #    c += 1
counts = 0
cc = collections.Counter(sort_list)
#print(cc.most_common())
v, c = zip(*cc.most_common())
#print(c)
for c_ in c:
  if c_ > 1:
    c_ -= 1
    counts += c_
print(counts)

Submission status: Wrong Answer

Solution code:
from collections import Counter

import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n=int(input())
string_list=[Counter(input()) for i in range(n)]
count=0
i2=0
for string1 in string_list:
    string_list.remove(string1)
    i2=i2+1
    if string1 in string_list:
        count=count+combinations_count(string_list.count(string1)+1,2)

print(count)

Submission status: Wrong Answer

Solution code:
N=int(input())
l=[]
for x in range(0,N):
    l.append(input())
for x in range(0,N):
    l[x]=sorted(list(l[x]))
l=sorted(l)
x=0
y=0
for i in range(0,N):
    for j in range(i+1,N):
        if l[i]==l[j]:
            x=x+1
        else:
            y=y+sum(range(1,x+1))
            i=i+x+1
            break
print(y)

Submission status: Wrong Answer

Solution code:
num = int(input())
lists = [sorted(list(input())) for i in range(num)]

for i in range(num):
  lists[i] = ''.join(lists[i])

print(num - len(set(lists)))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [input() for _ in range(n)]
records = [[] for _ in range(n)]


def already_found(i, j):
    return j in records[i]


def is_anagram(s_i, s_j):
    for k in range(10):
        found = False
        for l in range(10):
            if s_i[k] == s_j[l]:
                found = True
                break
        if not found:
            return False
    return True


num = 0
for i in range(n):
    for j in range(i + 1, n):
        if i == j:
            continue
        if already_found(i, j):
            continue
        if is_anagram(s[i], s[j]):
            num += 1
            records[i].append(j)
print(num)

Submission status: Wrong Answer

Solution code:
N   =   int(input())

counter     =   0


A = []

count_list  =   []

frag = 0

for i in range(N):
    frag    =   0
    S   =   input()
    S   = list(S)
    S.sort()
    point   =   ord(S[0]) - ord('a')

    for j in range(len(A)):
        if(A[j] == S):
            count_list[j] += 1
            counter += count_list[j]
            frag = 1
            break 
    if(frag == 0):
        A.append(S)
        count_list.append(0)

print(counter)
print(A)

Submission status: Wrong Answer

Solution code:
N = int(input())
para = [[c for c in input()] for i in range(N)]
print(para)
def check(a,b):

    for i in range(10):
        if a[i] != b[i]:
            return False
    return True
            
a = 0 
for i in range(N):
    b = 0 
    for j in range(i+1,N):
        if check(para[i],para[j]):
            a += 1
            
print(a)

Submission status: Wrong Answer

Solution code:
import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
"""

if __name__ == "__main__":
    n = int(sys.stdin.readline())
    s = list(sys.stdin.readlines())
    # new_s=sorted(s)
    char_list=[]
    dic ={}
    for i in s:
        i = i.replace('\n','')
        new_s=sorted(i)
        new_s = ''.join(new_s)
        if new_s not in dic:
            dic[new_s] = 1
        else:
            dic[new_s] += 1
        # char_list.append(new_s)
    # print(char_list)
    # print(dic)
    ans = sum(v for v in dic.values() if v >= 2)
    if ans ==0:
        print(ans)
    else:
        print(ans -1)

    # c = 0
    # for j in range(n):
    #     if char_list[j] in char_list[j+1:]:
    #         c+=char_list[j+1:].count(char_list[j])
    # print(c)

Submission status: Wrong Answer

Solution code:
N=int(input())
slist=[]
ans=0
for s in range(N):
	slist+=[input()]

for p in range(N):
	for q in range(p+1,N):
		if set(slist[p])==set(slist[q]):ans+=1

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [input() for i in range(n)]
t = []
a = 0

for i in range(n):
    t.append(sorted(s[i]))
  
for j in range(n-1): 
    for k in range(j+1,n-1):
        if t[j] == t[k+1]:
            a += 1
                
print(a)

Submission status: Wrong Answer

Solution code:
N = int(input())
lst = []
for i in range(N):
  #in_pu = input()
  #l = list(in_pu)
  lst.append(list(input()))
count = 0
index = 0
s = list(map(set, lst))

for i in range(len(lst)):
  i_set = set(lst[i])
  if i_set in s[0:i]+s[i+1:len(s)]:
    count = count + 1
    
print(count)

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())
#c = 0
#sort_dict = dict()
sort_list = list()
for i in range(n):
  i_sort = "".join(sorted(input()))
  #sort_dict[i] = i_sort
  sort_list.append(i_sort)
  #if not sort_dict[0]:
  #  if sort_dict[i] == sort_dict[i-1]:
  #    c += 1
counts = 0
cc = collections.Counter(sort_list)
#print(cc.most_common())
v, c = zip(*cc.most_common())
#print(c)
for c_ in c:
  if c_ != 1:
    c_ -= 1
    counts += c_
print(counts)

Submission status: Wrong Answer

Solution code:
a=int(input())
f=["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"]
g=[]
for p in range (0,a):
    b=input()
    h=[0,0,0,0,0,0,0,0,0,0,0,0,0,
       0,0,0,0,0,0,0,0,0,0,0,0,0]
    for q in range (0,10):
        c=b[q]
        for r in range (0,26):
            if c==f[r]:
                h[r]+=1
    g.append(h)

i=tuple(g)


x=0
for s in range (0,a):
    for t in range (s,a-1):
        g=list(i)
        k=g.pop(s)
        l=g
        if k in l:
             x+=1
    g=list(i)
print(x)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

ans = 0

s = np.sort(np.array(sraw), axis=0).tolist()
#print(s)

l = len(s)

for ss in range(0, l):
    fl = 0
    #print("")
    for sss in range(ss+1, l):
        #print("{0} {1}".format(s[ss],s[sss]))
        if s[ss] == s[sss]:
            ans += 1
            fl = 1

        elif fl == 1:

            break


print(ans)

Submission status: Wrong Answer

Solution code:
import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
"""

if __name__ == "__main__":
    n = int(sys.stdin.readline())
    s = list(sys.stdin.readlines())
    # new_s=sorted(s)
    char_list=[]
    dic ={}
    for i in s:
        i = i.replace('\n','')
        new_s=sorted(i)
        new_s = ''.join(new_s)
        if new_s not in dic:
            dic[new_s] = 1
        else:
            dic[new_s] += 1
        # char_list.append(new_s)
    # print(char_list)
    print(dic)
    ans = sum(v for v in dic.values() if v >= 2)
    if ans ==0:
        print(ans)
    else:
        print(ans -1)

    # c = 0
    # for j in range(n):
    #     if char_list[j] in char_list[j+1:]:
    #         c+=char_list[j+1:].count(char_list[j])
    # print(c)

Submission status: Wrong Answer

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

n = int(input())
s = [input().split()[0] for _ in range(n)]
cnt = defaultdict(int)
for i in range(n):
    list(s[i]).sort()
    cnt["".join(s[i])] += 1
result = 0
for c in cnt:
    result += len(list(combinations([""] * cnt[c], 2)))
print(result)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

n=int(input())
s=[]
li=[]
ans=0
cnt=1

for i in range(n):
  s.append(sorted(input()))
s.sort(key=itemgetter(1,0))
s=s+['a']

for i in range(n):
  if s[i]==s[i+1]:
    cnt+=1
  elif cnt>1:
    li.append(int(cnt*(cnt-1)/2))
    cnt=1
  else:
    cnt=1
print(int(sum(li)))

Submission status: Wrong Answer

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

ss = []
counts_id = []
answer = 0

chars = [x for x in "abcdefghijklmnopqrstuvwxyz"]
num = len(chars)

for i in range(N):
  ss.append(input().strip())
  _count = [0 for _ in range(num)]
  for _s in ss[i]:
    _count[chars.index(_s)] += 1
  
  if i == 0:
    counts_id = [_count]
  else:
    for id in counts_id:
      if id == _count:
        answer += 1
        break
      else:
        counts_id.append(_count)
    
print(answer)

Submission status: Wrong Answer

Solution code:
N = int(input())
ss = [input() for i in range(N)]
tt = ['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']
bb = ['']*N

for i in range(len(tt)):
  for j in range(N):
    u = ss[j].count(tt[i])
    bb[j] += str(u)
    
    
dd = []
for i in range(int(N/2)):
  dd.append(bb.count(bb[i]))
  if(dd[i] == 1):
    dd[i] = 0
  elif (dd[i] == 2):
    dd[i] = 1

print(sum(dd))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = []
cnt = 0
h = []
x = 0
g = 0

for z in range(n) :
    g = 0
    s.append((list(input())))
    for w in range(10) :
        g = ord(s[z][w]) + g
    h.append(g)

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

print(cnt)

Submission status: Wrong Answer

Solution code:
from collections import Counter
ans = 0
s = []
N = int(input())
for i in range(N):
	tmp = []
	string = input()
	for st in string:
		tmp.append(st)
	s.append(tmp)

for m in s:
	for n in s:
		if Counter(n)==Counter(m) and m != n:
			ans+=1
			s.remove(n)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

line = []

for anagram in s:
  a = sorted(anagram)
  line.append(''.join(a))

after = (set(line))

_sum = 0
for i in after:
  c = line.count(i)
  if c == 2:
    _sum += 1
  elif c == 1:
    continue
  else:
    _sum += c

print(_sum)

Submission status: Wrong Answer

Solution code:
N = int(input())
list = ["".join(sorted(input())) for i in range(N)]
count = 0
print(list)
res = [[e, list.count(e)] for e in set(list) if list.count(e) > 1]
for r in res:
    count += (r[1] * (r[1] - 1)) / 2

print(int(count))

Submission status: Wrong Answer

Solution code:
def factorial(i):
    ans = 1
    for j in range(1,i+1):
        ans *= j
    return ans

N = int(input())
A = [input() for i in range(N)]
a = []
for i in A:
    b = list(i)
    b.sort()
    a.append(b)

a.sort()
d=[]
for i in a:
    if a.count(i)==1:
        continue
    d.append(a.count(i))

count = 0
for i in d:
    if i > 2:
        count += factorial(i) // (factorial(i - 2) * factorial(2))
    elif i == 2:
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
dicts = {}
for _ in range(N):
    s = "".join(sorted(set(input())))
    if s not in dicts:
        dicts[s] = 1
    else:
        dicts[s] += 1
print(sum([n*(n-1)//2 for n in list(dicts.values()) if 0<n]))
print("")

Submission status: Wrong Answer

Solution code:
N,*s=open(0).read().split()
N = int(N)
s = [sum(map(ord,s_)) for s_ in s]
cnt = 0
for i in range(N):
  cnt += (s[i:].count(s[i])-1)
print(cnt)