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 = ["".join(sorted(input())) for _ in range(N)]
c = Counter(S)
print(c)
print(sum([k*(k-1)//2 for k in c.values()]))

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
S = ["".join(sorted(input()[:-1])) for _ in range(N)]
c = Counter(S)
print(c)
print(sum([k*(k-1)//2 for k in c.values()]))

Submission status: Wrong Answer

Solution code:
from collections import Counter
import sys
input = sys.stdin.readline

N = int(input())
S = ["".join(sorted(input()[:-1])) for _ in range(N)]
c = Counter(S)
print(c)
print(sum([k*(k-1)//2 for k in c.values()]))

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
S = [input() for _ in range(N)]
c = Counter(S)
print(sum([k*(k-1)//2 for k in c.values()]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list()
for i in range(n):
    s.append(list(input()))

t = dict()

for i in range(len(s)):
    s[i].sort()
    k = "".join(s[i])
    if not k in t.keys():
        t[k] = 0
    else:
        t[k] += 1 if t[k] == 0 else t[k] + 1 if t[k] == 1 else t[k]

print(sum(t.values()))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [input() for i in range(n)]
st = []
ans = 0
for i in range(len(s)):
    st.append(list(tuple(s[i])))
    st[i].sort()
    st.sort()
    if st[i - 1] == st[i]:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list()
for i in range(n):
    s.append(list(input()))

t = dict()

for i in range(len(s)):
    s[i].sort()
    k = "".join(s[i])
    if not k in t.keys():
        t[k] = 0
    else:
        t[k] += 1 if t[k] == 0 else t[k] + 1

print(sum(t.values()))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list()
for i in range(n):
    s.append(list(input()))

t = dict()

for i in range(len(s)):
    s[i].sort()
    k = "".join(s[i])
    if not k in t.keys():
        t[k] = 0
    else:
        t[k] += 1

print(sum(t.values()))

Submission status: Wrong Answer

Solution code:
def main(): 
    n = int(input())
    s = [input() for _ in range(n)]
    
    cnt = 0
    for i in range(n-1):
        for j in range(i+1,n):
            t = s[i]
            for _ in range(10):
                if t[-1] in s[j]:
                    t = t[:-1]
                else:
                    break
            else:
                cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

cnt = 0
for m in range(N):
    for n in range(N):
        if m == n:
            continue
        if S[m] == S[n]:
            cnt += 1
        else:
            break

print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    print(cnt)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

    print(cnt)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())
s = [input() for i in range(n)]
s = map(list,s)
lst = []
for i in s:
  i.sort()
  lst.append(''.join(i))
ans = collections.Counter(lst)
ctr = 0
for v in ans.values():
  if v != 1:
    ctr += (v-1)
print(ctr)

Submission status: Wrong Answer

Solution code:
n = int(input())
lis = []
for i in range(n):
    lis.append(input())
d = {}
for x in lis:
    k = "".join(sorted(list(x)))
    d.setdefault(k, 0)
    d[k] += 1
print(sum(d.values()) -1)

Submission status: Wrong Answer

Solution code:
n = int(input())
lis = []
d = {}
for i in range(n):
    k = list(input())
    k.sort()
    k = "".join(k)
    d.setdefault(k, 0)
    d[k] += 1
print(sum(d.values()) -1)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    N = int(input())
    ses = [''.join(sorted(input())) for _ in range(N)]
    count = 0
    ses = list(filter(lambda x: ses.count(x) > 1, ses))
    for i, s in enumerate(ses):
        count += ses.count(s) - 1
        del ses[0]
        
    print(count)

Submission status: Wrong Answer

Solution code:
def searchList(l, s):
    try: return [e[0] for e in l].index(s)
    except: return -1

def makeSortList(n):
    l = []
    for i in range(n):
        strg = "".join(sorted(input()))
        x = searchList(l, strg)
        if x == -1:
            l.append([strg])
            l[x].append(1)
        #l[x].append(i)
        l[x][1] += 1
    return l

def calcAns(l):
    ans = 0
    """
    for e_l in l:
        lngth = len(e_l) - 1
        if lngth > 1:
            ans += lngth * (lngth - 1) / 2
    """
    for e_l in l:
        if 1 < e_l[1]:
            ans += e_l[1] * (e_l[1] - 1) / 2
    return int(ans)

print(calcAns(makeSortList(int(input()))))

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
s = [''.join(sorted(input())) for _ in range(n)]
c = collections.Counter(s)
total = sum(v for v in c.values() if v > 1
)
print(total-1)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
s = [''.join(sorted(input())) for _ in range(n)]
c = collections.Counter(s)
total = sum(
    filter(lambda v: v >= 1, c.values())
)
print(total)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

ctr = Counter()
ans = 0
for si in S:
    x = "".join(sorted(list(si)))
    if x in ctr:
        ans += ctr[si]
    ctr[si] += 1

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

ctr = Counter()
ans = 0
for Si in S:
    x = "".join(sorted(list(Si)))
    if x in ctr:
        ans += ctr[Si]
    ctr[Si] += 1

print(ans)

Submission status: Wrong Answer

Solution code:
a = int(input())

count = 0

list = [str(input()) for i in range(a)]
new_list = [''.join(sorted(i)) for i in list]
ans = []

dic = {}

for i in new_list:
  if i not in dic:
    dic[i] = 0
  else:
    dic[i] += 1

print(sum(dic.values()))

Submission status: Wrong Answer

Solution code:
n = int(input())

li = [input() for i in range(n)]
li = ["".join(sorted(x)) for x in li]

import collections
from collections import deque
a = dict(collections.Counter(li))
b = list(a.values())

lia = [x for x in range(0,100001)]
lib = deque([])
for i in range(len(lia)-1):
    lib.append(lia[i]+lia[i+1])
lib.appendleft(0)

ans = 0
for i in range(len(b)):
    ans += lib[b[i]-1]
print(ans)

Submission status: Wrong Answer

Solution code:
A =[]
c = 0
for i in range(int(input())):
    A.append(sorted(list(input())))
    for j in range(i-1):
        if A[j] == A[i]:
            c += 1
print(c)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
L = [input() for i in range(N)]
L = sorted(list(map("".join, list(map(sorted, list(map(list, L)))))))
c = 0
ans = 0
for j in range(1,N):
    if not L[j] == L[j - 1]:
        if j - c > 2:
            ans += (j - c)*(j - c - 1)/2
        c = j
    elif j + 1 == N:
        ans += (j + 1 - c)*(j - c)/2
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

word_dict = dict()

for i in range(n):
  word_dict.setdefault(string_list[i], 0)
  if word_dict[string_list[i]] == 0:
    word_dict[string_list[i]] = 1
  else:
    word_dict[string_list[i]] += word_dict[string_list[i]]

res = word_dict.values()
print(sum(res) - len(res))

Submission status: Wrong Answer

Solution code:

N = int(input())

S = [''.join(sorted(input())) for _ in range(N)]


cnt = 0

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

Submission status: Wrong Answer

Solution code:
N = int(input())
Dictionary = {}
for i in range(N):
        string = "".join(sorted(input()))
        if string in Dictionary:
                Dictionary[string] += 1
        else:
                Dictionary[string] = 1

ans = 0
for i in Dictionary.values():
        count_tmp = i*(i-1)/2
        ans += count_tmp

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
from heapq import *
sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N = int(input())
    dp = {}
    for _ in range(N):
        str = input()
        str = ''.join(sorted(str.rstrip()))
        if str in dp:
            dp[str] += dp[str]+1
        else:
            dp[str] = 0
    print(sum(list(dp.values())))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
s = collections.Counter(["".join(sorted(input())) for _ in range(n)]).most_common()
print(s)
cnt = 0
for i in s:
    for j in range(1, i[1]):
        cnt += j
print(cnt)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
s = [0]*n
count = 0
each_count = {}

for si in s:
    tmp = list(str(input()))
    tmp.sort()
    si = "".join(tmp)

for si in s:
    if each_count.setdefault(si, 0) == 0:
        each_count[si] = 1
    else:
        count += each_count[si]
        each_count[si] += 1

print(count)

Submission status: Wrong Answer

Solution code:
#137C
N = int(input())
S = []
ans = 0
for i in range(1,N+1):
    S.append("".join(sorted(input())))

sortS = sorted(S)

for k in range(1,N-1):

    if sortS[k] == sortS[k+1] or sortS[k] == sortS[k-1]:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
#137C
N = int(input())
S = []
ans = 0
for i in range(1,N+1):
    S.append("".join(sorted(input())))

sortS = sorted(S)

for k in range(1,N-1):
    if sortS[k] == sortS[k+1] or sortS[k] == sortS[k-1]:
        ans += 1
if sortS[N-2] == sortS[N-1]:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
#137C
N = int(input())
S = []
ans = 0
for i in range(1,N+1):
    S.append("".join(sorted(input())))

sortS = sorted(S)

for k in range(0,N-1):
    if sortS[k] == sortS[k+1]:
        ans += 1
print(ans)

Submission status: Wrong Answer

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

ss = []
cnt = 0
for i in range(N):
    x = "".join(list(s[i]))
    if x in ss:
        cnt += ss.count(x)
    ss.append(x)

print(cnt)

Submission status: Wrong Answer

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

ss = []
cnt = 0
for i in range(N):
    x = list(s[i])
    x.sort()
    y = "".join(x)
    if y in ss:
        cnt += 1
    else:
        ss.append(y)

print(cnt)

Submission status: Wrong Answer

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

ss = []
for i in range(N):
    x = list(s[i])
    x.sort
    y = "".join(x)
    ss.append(y)

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

print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
ans_dict = {}
ans = 0
for i in range(n):
    s = "".join(sorted(input()))
    if s in ans_dict:
        ans_dict[s] += 1
    else:
        ans_dict[s] = 1
print(ans_dict)
for j in ans_dict.values():
    ans += j * (j - 1) // 2
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
 
n = int(input())
array = []

# 並べ替え
for i in range(n):
  array.append(''.join(sorted(input())))

count = 0
for x in range(len(array)):
  for y in range(len(array)):
  	count += 1 if array[y] == array[y-1] else 0

if count > 0:
  count -= 1

print(count - 1)

Submission status: Wrong Answer

Solution code:
a=int(input())
lis=sorted([sorted([f for f in input()]) for i in range(a)])
lis+=["w"]
kari=""
ans=0
cou=1
for i in lis:
  if kari!=i:
    ans+=cou*(cou-1)/2
    cou=1
    kari=i
  else:
    cou+=1
print(ans)

Submission status: Wrong Answer

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

ans = 0

for i in range(0, N):
    S[i] = sorted([i for i in S[i]])
    
A = []
for i in range(0, N):
    if S[i] in A:
        ans += 1
    else:
        A.append(S[i])
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = []
l = 1
z = 0
for i in range(0,N):
    s.append(str(input()))
for i in range(0,N):
    s[i] = ''.join(sorted(s[i]))
s.sort()
for i in range(0,N-1):
    if s[i] == s[i+1]:
        l += 1
    else:
        z += l*(l-1)/2
        l = 1
print(z)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [0] * N
for i in range(N):
  A_temp = input()
  A[i]= sorted([c for c in A_temp])
count = 0

B = sorted(A)
A_unique_count = 1
for i in range(N-1):
  if B[i] != B[i+1]:
    A_unique_count += 1
#print(A_unique_count)
C = 0    
num = 0

print(B)

for i in range(A_unique_count):
#  print( 'i' + str(i))
  C = B.count(B[num])
  num += C
#  print(num)
#  print(C)
  count += C * (C -1 ) / 2

print(int(count))

Submission status: Wrong Answer

Solution code:
n = int(input())
arr = [input() for _ in range(n)]
dict = {}
alpha = "abcdefghijklmnopqrstuvwxyz"

for s in arr:
    count = [0]*26
    for i in range(10):
        for j in range(26):
            if s[i] == alpha[j]:
                count[j] += 1
                break
    count = tuple(count)
    if count not in dict:
        dict[count] = 1
    else:
        dict[count] += 1
ans = 0
for val in dict.values():
    ans += val * ( val - 1 ) / 2
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [0] * N
for i in range(N):
  A_temp = input()
  A[i]= sorted([c for c in A_temp])
count = 0

B = sorted(A)
A_unique_count = 1
for i in range(N-1):
  if B[i] != B[i+1]:
    A_unique_count += 1
print(A_unique_count)
C = 0    
num = 0

print(B)

for i in range(A_unique_count):
  print( 'i' + str(i))
  C = B.count(B[num])
  num += C
  print(num)
  print(C)
  count += C * (C -1 ) / 2

print(int(count))

Submission status: Wrong Answer

Solution code:
n = int(input())
arr = [input() for _ in range(n)]
dict = {}
alpha = "abcdefghijklmnopqrstuvwxyz"

for s in arr:
    count = [0]*26
    for i in range(10):
        for j in range(26):
            if s[i] == alpha[j]:
                count[j] += 1
                break
    count = tuple(count)
    if count not in dict:
        dict[count] = 1
    else:
        dict[count] += 1
ans = 0
for val in dict.values():
    if val > 1:
        ans += val - 1
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [0] * N
for i in range(N):
  A_temp = input()
  A[i]= [c for c in A_temp]

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

print(count)

Submission status: Wrong Answer

Solution code:
n=int(input())
ss=[list(input()) for _ in range(n)]
ss.sort()
ans=[]
for s in ss:
  tmp=''
  s.sort()
  for t in s:
    tmp+=t
  ans.append(tmp)
print(ans)

cnt=0
for uniq in list(set(ans)):
  for i in range(ans.count(uniq)):
    cnt+=i
print(cnt)

Submission status: Wrong Answer

Solution code:
n=int(input())
ss=[list(input()) for _ in range(n)]
ss.sort()
ans=[]
for s in ss:
  tmp=''
  s.sort()
  for t in s:
    tmp+=t
  ans.append(tmp)
print(ans)

cnt=0
for i in range(0,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())
ss=[input() for _ in range(n)]

ans=0
for i in range(1,n):
  flag=0
  for j in range(10):
    if ss[0].count(ss[0][j])!=ss[i].count(ss[0][j]):
      flag=1
      break
  if flag==0:
    ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
ans = 0
l = []
for i in range(n):
    word = input()
    word_counter = Counter(word)
    if word_counter not in l:
        l.append(word_counter)
    else:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
ans = 0
l = []
for i in range(n):
    word = input()
    word_counter = Counter(word)
    if word_counter not in l:
        l.append(word_counter)
    else:
        ans += 1

Submission status: Wrong Answer

Solution code:
import math
import sys
import numpy as np
from collections import defaultdict, deque, Counter 
from itertools import accumulate, product, permutations,combinations, combinations_with_replacement
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd

max_value = 1000000000
min_value = -1000000000
sys.setrecursionlimit(max_value)

N = int(input())
counter = dict()

for i in range(N):
    sorted_str = ''.join(sorted(input()))
    if sorted_str in counter:
        counter[sorted_str] += counter[sorted_str] + 1
    else:
        counter[sorted_str] = 0

value = 0
for v in counter.values():
    value += v
print(value)

Submission status: Wrong Answer

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

for i in range(n):
  for j in range(n):
    if  i != j and i < j and s[i] <= s[j] :
      cnt = cnt + 1
      
print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

def is_annagram(index1, index2):
    for memo in memo_list:
        if index1 in memo and index2 in memo:
            return True

    s1 = str_list[index1]
    s2 = str_list[index2]
    for s in s1:
        if s not in s2:
            return False
        else:
            s2.replace(s, "", 1)

    isMemoUpdate = False
    for memo in memo_list:
        if index1 in memo:
            memo.append(index2)
            isMemoUpdate = True
    if not isMemoUpdate:
        memo_list.append([index1, index2])

    return True

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

Submission status: Wrong Answer

Solution code:
N = int(input())

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

def is_annagram(index1, index2):
    for memo in memo_list:
        if index1 in memo and index2 in memo:
            return True

    s1 = str_list[index1]
    s2 = str_list[index2]
    for s in s1:
        if s not in s2:
            return False
        else:
            s2.replace(s, "", 1)

    isMemoUpdate = False
    for memo in memo_list:
        if index1 in memo:
            memo.append(index2)
    if not isMemoUpdate:
        memo_list.append([index1, index2])

    return True

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

Submission status: Wrong Answer

Solution code:
S_dict = {}
N = int(input())
for _ in range(N):
    s = ''.join(sorted(input()))
    if s not in S_dict.keys():
        S_dict[s] = 0
    else:
        S_dict[s] += S_dict[s] + 1
print(sum(map(int, S_dict.values())))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import itertools

N = int(input())

lst = []
for i in range(N):
    lst.append(''.join(sorted(str(input()))))

cnt = 0

lstloop = list(itertools.combinations(lst, 2)) # 重複なしのループ用リストを作成

for i in lstloop:
    if ( i[0] == lst[1] ):
        cnt += 1

print (cnt)

Submission status: Wrong Answer

Solution code:
i = 0
S = set()
N = int(input())
for _ in range(N):
    s = sorted(input())
    s = ''.join(s)
    if s not in S:
        S.add(s)
    else:
        i+=1
print(i)

Submission status: Wrong Answer

Solution code:
a = int(input())
b = []
strings = ''
ans = 0

for i in range(a):
    check = True
    strings = sorted(list(input()))
    if strings not in b:
      check = False
      b.append(strings)
    if check == True:
      ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools

N = int(input())

lst = []
for i in range(N):
    lst.append(''.join(sorted(str(input()))))

cnt = 0

#重複あり版 permutations
#for i, item in enumerate(lst):
#    print('item1:'+ item)
#    for x, itemckn in enumerate(lst):
#        print('itemc2:'+ itemckn)
#        if ( item == itemckn ):
#            print('    break')
#            break
#        else:
#            for j in itertools.permutations(itemckn):
#                itemck = ''.join(j)
#                if ( item == itemck ):
#                    cnt += 1
#                    break

lstloop = list(itertools.combinations(lst, 2)) # 重複なしのループ用リストを作成

#重複なし版 permutations
#for i, item in enumerate(lstloop):
#    
#    for j in itertools.permutations(item[1]):
#        itemck = ''.join(j)
#        if ( item[0] == itemck ):
#            cnt += 1
#            break

# sortしておけば総当たり不要
for i, item in enumerate(lstloop):
    if ( item[0] == item[1] ):
        cnt += 1
        break

print (cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = [sorted(input()) for _ in range(N)]
strDict = {}
count = 0

for s in S:
    s = s[0]
    if s not in strDict:
        strDict[s] = 1
    else:
        strDict[s] += 1
    
for i in strDict.keys():
    n = strDict[i]
    count += n*(n-1)//2
print(count)

Submission status: Wrong Answer

Solution code:
n=int(input())
d={}
for _ in range(0, n):
  s=input()
  l=list(s)
  l.sort()
  s="".join(l)
  if s in d.keys():
    v=d[s]
    if v == 0:
      d[s]=1
    else:
      d[s]+=v*2
  else:
    d.update({s:0})
print(sum(list(d.values())))

Submission status: Wrong Answer

Solution code:
n=int(input())
s=[""]*n
cnt=0
for i in range(n):
    s[i]=sorted(list(input()))
    for j in range(i-1):
        if s[i]==s[j]:
            cnt+=1
            break
print(cnt)

Submission status: Wrong Answer

Solution code:
from functools import reduce
n = int(input())
s = []
count = 0
for _ in range(n):
    s.append(sorted(input()))
    s[_] = ''.join(s[_]).rstrip('\n')
set_s = set(s)
for i in range(len(set_s)):
    s_count = s.count(list(set_s)[i])
    if s_count > 1:
        count += reduce((lambda x, y: x*y), range(1,s_count+1))
print(count//2)

Submission status: Wrong Answer

Solution code:
N = int(input())

duplicate_ct = 0
count_list = []
for i in range(N):
  sorted_input = ''.join(sorted(input()))
  if sorted_input in count_list:
    ++duplicate_ct
  count_list.append(sorted_input)

print(duplicate_ct)

Submission status: Wrong Answer

Solution code:
N = int(input())

duplicate_ct = 0
count_list = []
for i in range(N):
  sorted_input = ''.join(sorted(input()))
  count_list.append(sorted_input)

for i in range(N):
  count = count_list[i:].count(count_list[i])
  duplicate_ct += count

print(duplicate_ct)

Submission status: Wrong Answer

Solution code:

N = int(input())

duplicate_ct = 0
count_list = []
for i in range(N):
  sorted_input = sorted(input())
  count_list.append(sorted_input)

for i in range(N):
  count = count_list[i:].count(count_list[i])
  duplicate_ct += count

print(duplicate_ct)

Submission status: Wrong Answer

Solution code:
N = int(input())

duplicate_ct = 0
count_list = []
for _ in range(N):
  sorted_input = sorted(input())
  if sorted_input in count_list:
    ++duplicate_ct
  count_list.append(sorted_input)

print(duplicate_ct)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[]
for i in range(n):
  w=list(input())
  l.append(w)
l=sorted(l)
c=0
c1=0
w1=l[0]
for i in range(n):
  if w1==l[i]:
    c1+=0
  else:
    c+=c1*(c1-1)//2
    c1=1
c+=c1*(c1-1)//2
print(c)

Submission status: Wrong Answer

Solution code:
from collections import Counter
import math


def ncr(val):
    if val<2:
        return 0
    else:
        return math.factorial(val)//(math.factorial(2)*math.factorial(val-2))


n = int(input())
s = [sum(map(ord,input())) for i in range(n)]
d,y = dict(Counter(s)),0
for k,v in d.items():
    y += int(ncr(v))
print(int(y))

Submission status: Wrong Answer

Solution code:
from collections import Counter
import math


def ncr(val):
    if val<2:
        return 0
    else:
        return math.factorial(val)//(math.factorial(2)*math.factorial(val-2))


n = int(input())
s = [sum(map(ord,input())) for i in range(n)]
d,y = dict(Counter(s)),0
for k,v in d.items():
    y += ncr(v)
print(y)

Submission status: Wrong Answer

Solution code:
import math
def combo(a):
    return (math.factorial(a))/(math.factorial(a-2)*2)

from collections import Counter
n = int(input())
count = 0
string = [input() for i in range(n)]
string2 = [''.join(sorted(x)) for x in string]

'''for i in range(n-1):
    for j in range(i+1, n):
        if string2[i] == string2[j]:
            count += 1'''
li = Counter(string2)
li1=[[key,value] for key, value in li.items()]
for i in range(len(li1)):
    if li1[i][1] == 1:
        li1[i][1] = 0
for i in range(len(li1)):
    if li1[i][1] != 0:
        li1[i][1] = combo(li1[i][1])
for i in range(len(li1)):
    count += li1[i][1]
print(count)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
count = 0
string = [input() for i in range(n)]
string2 = [''.join(sorted(x)) for x in string]

'''for i in range(n-1):
    for j in range(i+1, n):
        if string2[i] == string2[j]:
            count += 1'''
li = Counter(string2)
li1=[[key,value] for key, value in li.items()]
for i in range(len(li1)):
    if li1[i][1] == 1:
        li1[i][1] = 0
#print(li1)
for i in range(len(li1)):
    count += li1[i][1]
print(0) if count-1<0 else print(count-1)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
count = 0
string = [input() for i in range(n)]
string2 = [''.join(sorted(x)) for x in string]

'''for i in range(n-1):
    for j in range(i+1, n):
        if string2[i] == string2[j]:
            count += 1'''
li = Counter(string2)
li1=[[key,value] for key, value in li.items()]
for i in range(len(li1)):
    if li1[i][1] == 1:
        li1[i][1] = 0
print(li1)
for i in range(len(li1)):
    count += li1[i][1]
print(count-1)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
string = [input() for i in range(n)]
string2 = [''.join(sorted(x)) for x in string]

'''for i in range(n-1):
    for j in range(i+1, n):
        if string2[i] == string2[j]:
            count += 1'''
li = Counter(string2)
li1=[value for key, value in li.items()]
print(li1[0])

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [input() for x in range(n)]
count = 0
d = {}

for i in range(n):
    s1 = list(s[i])
    s1.sort()
    string = "".join(s1)
    if (string not in d.keys()):
        d[string] = 0
    else:
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [input() for x in range(n)]
d = {}

for i in range(n):
    s1 = list(s[i])
    s1.sort()
    string = "".join(s1)
    if (string not in d.keys()):
        d[string] = 0
    else:
        d[string] += 1

count = 0
for j in d.keys():
    count += d[j]

print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
s_list = [list(str(input())) for i in range(n)]

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

Submission status: Wrong Answer

Solution code:
n=int(input())
s = [ str(input()) for _ in range(n)]
s = sorted([sorted(x) for x in s])
pairs = 0
from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

i=0
while i < n-1:
    sames = 0
    for j in range(i+1, n):
        if s[i] == s[j]:
            sames += 1
            continue
        else:
            break
    i += sames + 1
    if sames != 0:
        pairs += combinations_count(sames + 1, 2)
        print(pairs)

print(int(pairs))

Submission status: Wrong Answer

Solution code:
def solve(l:list):
    ans = 0
    for i in range(len(l)):
        for j in range(i):
            if l[i] == l[j]:
                ans += 1
    return ans

def main():
    n = int(input())
    l = [set(list(input())) for i in range(n)]
    print(solve(l))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
s = {}
for _ in range(N):
    b = list(input())
    b.sort()
    c = ''.join(b)
    if not c in s:
        s[c] = 1
    else:
        s[c] += 1

Submission status: Wrong Answer

Solution code:
from collections import Counter
from itertools import combinations

N = int(input())
c = Counter(["".join(sorted(list(input()))) for i in range(N)])
res = 0
for i in c.values():
  if i == 1:
    break
  res += len(list(combinations([0 for n in range(i)],2)))

print(res)