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:
N  = int(input())
from collections import Counter
a = []
for i in range(N):
  a.append(str(sorted(list(Counter(input()).items()))))

  
#print(a)
#print(len(a))
count = Counter(a)
#print(count)
b = []
for i in (count.values()):
  if i == 1:
    b.append(i-1)
  elif i == 2:
    b.append(i-1)
  else:
    b.append(i)
    
print(sum(b))

Submission status: Wrong Answer

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

for i, v in enumerate(s_list):
    lists.append(set(list(v)))

t = 0
for i in range(n):
    for j in range(i+1,n):
        if lists[i].issuperset(lists[j]):
            t += 1

print(t)

Submission status: Wrong Answer

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

for i, v in enumerate(s_list):
    lists.append(set(list(v)))

t = 0
for i in range(n):
    for j in range(i+1,n):
        if lists[i].issubset(lists[j]):
            t += 1

print(t)

Submission status: Wrong Answer

Solution code:
N = int(input())

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



for i in range(len(S)):
        S[i]=''.join(sorted(S[i]))

S.sort()

res=0
for i in range(len(S)-1):
        if S[i] == S[i+1]:
                print(S[i])
                res+=1

print(res)

Submission status: Wrong Answer

Solution code:
from collections import Counter
from numpy import cumsum
 
num = int(input())
input = [input() for i in range(num)]
rv = 0
counters = [sorted(Counter(s).elements()) for s in input]
strings = ["".join(s) for s in counters]
counts = list(Counter(strings).values())
for c in counts:
  rv += cumsum(c)
print(rv)

Submission status: Wrong Answer

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

ana = 0
for s1 in S:
    for s2 in S:
        if s1 == s2:
            ana += 1

print((ana - N) / 2)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = [list(input()) for _ in range(N)]
for i in range(N):
    S[i] = sorted(S[i])

count = 0
for i in range(N):
    for j in range(i+1, N):
        if S[i] != S[j]:
            count += j - i
            break

print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())

l = []
cnt = 0

for i in range(n):
    s = str(input())
    sl = ''.join(sorted(s))
    l.append(sl)
    l.sort()

for i in range(n):
    try:
        if l[i] == l[i+1]:
            cnt += 1
            continue
        elif l[i] == l[i-1]:
            cnt += 1
            continue
    except:
        break

print(int(cnt))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

d = defaultdict(lambda: 0)
ans = 0

for i in s:
    d[ frozenset(i) ] += 1

for i in d.keys():
    count = int(d[i])
    if count > 1:
        ans += (count * (count - 1)//2)

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

d = defaultdict(lambda: 0)
ans = 0

for i in s:
    d[ frozenset(i) ] += 1

for i in d.keys():
    count = d[i]
    if count > 1:
        ans += (count * (count - 1)//2)

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
count = {}

for idx in range(N):
	s = input()
	allist = [c for c in s]
	allist.sort()
	sortedstr = ''.join(allist)
	count[sortedstr] = count.get(sortedstr, -1) + 1

print(sum(count.values()))

Submission status: Wrong Answer

Solution code:
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    def c(n):
        if n == 1:
            return 0
        else:
            return n * (n - 1) // 2


    N = int(lines.pop(0))
    NLIST = {}
    for i in range(N):
        l = ''.join(sorted(lines.pop(0)))
        print(l)
        if l in NLIST:
            NLIST[l] += 1
        else:
            NLIST[l] = 1

    re = 0
    for n in NLIST.values():
        re += c(n)
    print(re)
lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
dic = {}
def combinations_count(n,r):
    return math.factorial(n) // (math.factorial(n - r)*math.factorial(r))

for index in range(n):
    temp = ''.join(sorted(list(input())))
    #入力された文字列をa-z順にソートし、変数tempに代入
    if temp in dic:
        dic[temp] = dic[temp] + 1
        #すでに同じ文字列の入力があれば、key:tempのvalueに+1
    else:
        dic[temp] = 1
        #新しい文字列の場合は文字列とvalue＝1を辞書に追加
ans = 0
print(dic)

for k in dic.values():
    if k >= 2:
        ans += combinations_count(k,2)
    else:
        ans = ans
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

N = int(sys.stdin.readline().strip())
cnt = {}
for i in range(N):
  a = sys.stdin.readline().strip()
  a = ''.join(sorted(a))
  if a not in cnt:
    cnt[a] = 0
  else:
    cnt[a] += cnt[a] + 1

if len(cnt)==0:
  print(0)
else:
  print(sum([v for v in cnt.values()]))

Submission status: Wrong Answer

Solution code:
import sys

N = int(sys.stdin.readline().strip())
cnt = {}
for i in range(N):
  a = sys.stdin.readline().strip()
  a = ''.join(sorted(a))
  if a not in cnt:
    cnt[a] = 1
  else:
    cnt[a] += 1

if len(cnt)==0:
  print(0)
else:
  print(sum([v for v in cnt.values()])-1)

Submission status: Wrong Answer

Solution code:
import sys

N = int(sys.stdin.readline().strip())
cnt = {}
for i in range(N):
  a = sys.stdin.readline().strip()
  a = ''.join(sorted(a))
  if a not in cnt:
    cnt[a] = 1
  else:
    cnt[a] += 1

if len(cnt)==0:
  print(0)
else:
  print(sum([v-1 for v in cnt.values()]))

Submission status: Wrong Answer

Solution code:
import collections
import math

def combination(n, m):
    return math.factorial(n) / (math.factorial(n - m) * math.factorial(m))

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

ans = 0
Y=[]
for s in S:
    X = []
    for w in s:
        X.append(w)
        X.sort()
        y = ''.join(X)
    Y.append(y)

c = collections.Counter(Y)
C = c.most_common()
len_C = len(C)

print(len_C)
print(C)


for n in range(len_C):
    if C[n][1] > 1:
        ans += combination(C[n][1], 2)
    else:
        pass

print(round(ans))

Submission status: Wrong Answer

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

Y=[]
for s in S:
    X = []
    for w in s:
        X.append(w)
        X.sort()
    Y.append(X)

ans = 0
same_list = []

for n in range(N):
    for i in range(N):
        if i == n:
            pass
        elif same_list.count(Y[i]) >= 1:
            pass
        else:
            if Y[n] == Y[i]:
                ans += 1
                same_list.append(Y[i])
            else:
                pass

print(round(ans))

Submission status: Wrong Answer

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

#N = 2
#S = ['greenbin', 'beginner']

Y=[]
for s in S:
    X = []
    for w in s:
        X.append(w)
        X.sort()
    Y.append(X)

ans_d = 0

for n in range(N):
    for i in range(N):
        if i == n:
            pass
        else:
            if Y[n] == Y[i]:
                ans_d += 1
            else:
                pass

ans = ans_d / 2
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=[''.join(sorted((input()))) for i in range(N)]
P={}
for i in range(N):
    if S[i] in P:
        P[S[i]]+=1
    else:
        P[S[i]]=0
print(sum(P.values()))

Submission status: Wrong Answer

Solution code:
N=int(input())
S=[sorted((input())) for i in range(N)]
P={}
for i in range(N):
    if 'S[i]' in P:
        P['S[i]']+=1
    else:
        P['S[i]']=0
print(sum(P.values()))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 25 08:58:11 2019

@author: avina
"""

n = int(input())
d = {}
for i in range(n):
  a = input();k = 0
  for j in range(10):
    k+= ord(a[j]) - ord('a')
  if k not in d:
    d[k] = 1
  else:
    d[k]+=1
ans = 0
for i in d:
    ans += ((d[i])*(d[i]-1))//2
print(ans)

Submission status: Wrong Answer

Solution code:
import collections
n=int(input())
Words = [input() for t in range(n)]

Words2=[]
for i in Words:
        i=''.join(sorted(i))
        Words2.append(i)

c = collections.Counter(Words2)

values, counts = zip(*c.most_common())

print(counts)

ans=0
for j in counts:
        ans+=j*(j-1)//2
print(ans)

Submission status: Wrong Answer

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

N=int(input())

D={}
ans=0
for i in range(N):
    s =".".join(sorted(input()))
    if s in D.keys():
        D[s]+=1
        ans+=D[s]
    else:
        D[s]=1

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=list(input() for n in range(N))
ans=0

def s(x):
    return set(list(S[x]))

for i in range(N):
    for j in range(1,N-i):
        if s(i)==s(i+j):
            ans+=1

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
cnt = 0
s = []
for i in range(n):
    s1 = sorted(input())
    if s1 in s:
        cnt += 1
    else:
        s.append(s1)
print(cnt)

Submission status: Wrong Answer

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

b = [False] * n
ans = 0
count = 1

def ana(s1, s2):
    b = [False] * len(s1)
    for i in range(len(s1)):
        for j in range(len(s2)):
            if b[j]:
                continue
            if s1[i] == s2[j]:
                b[j] = True
    for i in range(len(s1)):
        if not b[i]:
            return False
    return True

for i in range(n):
    if b[i]:
        continue
    for j in range(i + 1, n):
        if ana(s[i], s[j]):
            count += 1
            b[j] = True
    ans += count * (count - 1) / 2
    count = 1
    b[i] = True

print(int(ans))

Submission status: Wrong Answer

Solution code:
from collections import Counter
# バージョン0.14.0まで scipy.misc.comb()
# バージョン0.14.0から scipy.special.comb()
# from scipy.special import comb
from scipy.misc import comb


def main():
    s = Counter(["".join(sorted(i)) for i in open(0).read().split()[1:]])
    ans = 0
    for v in s.values():
        ans += comb(v, 2)
    print(int(ans))
    return


main()

Submission status: Wrong Answer

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

count = 0
ans = {}
for i in range(N):
  if s[i] in ans:
    ans[s[i]] += int(ans[s[i]]) + 1
  else:
    ans[s[i]] = 0

#print(ans)
for i in ans.values():
  count += int(i)

print(count)

Submission status: Wrong Answer

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

count = 0
ans = {}
for i in range(N):
  if s[i] in ans:
    if int(ans[s[i]]) == 0:
      ans[s[i]] = 1
    else:
      ans[s[i]] += int(ans[s[i]]) *2
  else:
    ans[s[i]] = 0

#print(ans)
for i in ans.values():
  count += int(i)

print(count)

Submission status: Wrong Answer

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

count = 0
ans = {}
for i in range(N):
  if s[i] in ans:
    ans[s[i]] = int(ans[s[i]]) + 1
  else:
    ans[s[i]] = 1

for i in ans.values():
  count += int(i)

print(count)

Submission status: Wrong Answer

Solution code:
n = int(input()) - 1
s = [sorted(input()) for i in range(n)]

j = n
cnt = 0

# print(j)
while j != 0:
    k = j-1
    for i in range(k):
        if s[j-1] == s[i-1]:
            cnt += 1
    j -= 1
print(cnt)

Submission status: Wrong Answer

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

count = {}
for i in s:
  if i in count:
    count[i] += 1
  else:
    count[i] = 1

sum = 0
for v in count.values():
  int(v)
  sum += (v*(v-1)/2)

print(sum)

Submission status: Wrong Answer

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

count = {}
for i in s:
  if i in count:
    count[i] += 1
  else:
    count[i] = 1

sum = 0
for v in count.values():
  int(v)
  sum += (v*(v-1)/2)

print(sum)

Submission status: Wrong Answer

Solution code:
n = int(input())
li,li2 = [],[]
for i in range(n):
    li.append(list(input()))

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

num = 0
i = 0
for i in range(n-1):
    if li[i] == li[i+1]:
        num += 1
        
    else:
        li2.append(num)
        num = 0
else:
    li2.append(num)    
    
print(sum(li2))

Submission status: Wrong Answer

Solution code:
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"]
count=0
vec=[]
N=int(input())
for i in range(N):
    s=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 p in range(10):
        h[f.index(s[p])]+=1
    if h in vec:
        count+=1
    else:
        vec.append(h)
print(count)

Submission status: Wrong Answer

Solution code:
from sys import stdin, setrecursionlimit
setrecursionlimit(10000000)

input = stdin.readline
lmi = lambda: list(map(int, input().split()))
mi = lambda: map(int, input().split())
si = lambda: input().strip('\n')
ssi = lambda: input().strip('\n').split()


n = int(input())
s = set(str(sorted(si())) for i in range(n))
print(n-len(s))

Submission status: Wrong Answer

Solution code:
N = int(input())
d = {}
x = 0
for i in [0]*N:
    s = ''.join(sorted(input()))
    if s in d:
        d[s] += 1
    else:
        d[s] = 0
print(sum(d.values()))

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())

arr = []

for i in range(n):
    arr.append(''.join(sorted(input())))

c = collections.Counter(arr)

ans = 0

for e in c.values():
    tmp = 1
    for ee in range(1, e+1):
        tmp *= ee

    tmp //= 2

    ans += tmp


print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = list([a for a in input()] for _ in range(N))
for b in s:
    b.sort()

count = 0

while len(s) > 0:
    c = s[0]
    print(c)
    del s[0]
    print(s)
    if c in s:
        list = [x for x, y in enumerate(s) if y == c]
        print(list)
        length = len(list)
        print(length)
        count += length

print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = list([a for a in input()] for _ in range(N))
for b in s:
    b.sort()

count = 0

while len(s) > 0:
    c = s[0]
    print(c)
    del s[0]
    print(s)
    if c in s and len(s) > 0:
        list = [x for x, y in enumerate(s) if y == c]
        length = len(list)
        count += length

print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
s_list = []
anagrams = []
ans = 0

for i in range(n):
    s = list(input())
    s_list.append(s)

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

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s_list = []
anagrams = []
ans = 0

for i in range(n):
    s = list(input())
    s = sorted(s)
    s_list.append(s)

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

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s_list = []
anagrams = []
ans = 0

for i in range(n):
    s = list(input())
    s = sorted(s)
    s_list.append(s)

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

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
s=[input() for i in range(N)]
count=0
ans=0
for i in range(N):
  for j in range(1,N-i):
    count=0
    for k in range(10):
      if s[i][k] in s[i+j]:
        count+=1
      else:
        break
    if count==10:
      ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 25 08:58:11 2019

@author: avina
"""

n = int(input())
d = {}
for i in range(n):
  a = input();k = 0
  for j in range(10):
    k+= ord(a[j])
  if k not in d:
    d[k] = 1
  else:
    d[k]+=1
ans = 0
for i in d:
    ans += (d[i])*(d[i]-1)//2
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 25 08:58:11 2019

@author: avina
"""

n = int(input())
d = {}
for i in range(n):
  a = input();k = 0
  for j in range(10):
    k+= ord(a[j]) - 95
  if k not in d:
    d[k] = 1
  else:
    d[k]+=1
ans = 0
for i in d:
    ans += (d[i])*(d[i]-1)//2
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 25 08:58:11 2019

@author: avina
"""

n = int(input())
d = {}
for i in range(n):
  a = input();k = 0
  for j in range(10):
    k+= ord(a[j]) - 95
  if k not in d:
    d[k] = 1
  else:
    d[k]+=1
print(max(d.values())-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
d = {}
for i in range(n):
  a = input();k = 0
  for j in range(10):
    k+= ord(a[j]) - 95
  if k not in d:
    d[k] = 1
  else:
    d[k]+=1
if len(d) == 0:
  print(0)
else:
  print(max(d.values()))

Submission status: Wrong Answer

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

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

# print(s)
print(cnt)

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    s = ["".join(sorted(input())) for _ in range(n)]
    ans = 0
    dic = {}
    for i in s:
        if i not in dic:
            dic[i] = 0
        else:
            dic[i] += 1

    for d in dic.values():
        ans += d
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
S = [input() for i in range(N)]

ctr = Counter()
ans = 0
for s in S:
  a = ''.join(sorted(list(s)))
  if a in ctr:
    ans += ctr[a]

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Sdic = {}
ans = 0

for i in range(N):
    if S[i] not in Sdic:
        Sdic[S[i]] = 1
    else:
        Sdic[S[i]] += 1
        ans += Sdic[S[i]]
print(ans)

Submission status: Wrong Answer

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

Sdic = {}
ans = 0

for i in range(N):
    if S[i] not in Sdic:
        Sdic[S[i]] = 1
    else:
        Sdic[S[i]] += 1
        ans += 1

print(ans)

Submission status: Wrong Answer

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

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

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

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

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
s=[]
count=0
for n in range(N):
    t = ''.join(sorted(input()))
    if t in s:
        count+=1
    else:
        s.append(t)
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = []
s = []
for _ in range(N):
 s=list(input())
 s.sort()
 s="".join(s)
 A.append(s)
ans = 0
for i in A:
    ans += A.count(i)
print((ans-N)/2)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = dict()

for _ in range(n):
  value = input()
  key = ''.join(sorted(value))
  
  if key in s:
    s[key] += s[key] + 1
  else:
    s[key] = 0
          
print(sum(s.values()))

Submission status: Wrong Answer

Solution code:
n = int(input())
#print(n)
s = []
#print(s)
counter = 0
for i in range(n):
  s.append(sorted(input()))
  #print(s[i])
  if s[i] in s[0:i-1]:
    #print(s[i],s.count(s[i]))
    counter += s.count(s[i])-1
    #print('OK counter=',counter)
  #else:
    #print('NO')
print(counter)
#print(s)

Submission status: Wrong Answer

Solution code:
import collections

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

jlist = [collections.Counter(tatelist[i]) for i in range(n)]

count = 0
for i in range(n):
    for j in range(n-i):
        if jlist[i] == jlist[j]:
            count += 1
            
print(count)

Submission status: Wrong Answer

Solution code:
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')


N=int(input())

s=[sorted(input()) for _ in range(N)]
cnt=0

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

print(cnt)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

N=int(input())
dic={}
sum=0
for i in range(N):
    s=list(input())
    s.sort()
    s = "".join(s)
    if s in dic:
        sum+=dic[s]
        dic[s]+=1
    else:
        dic[s]=1
print(dic)

Submission status: Wrong Answer

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

count = 0
t = dict()
for i in range(N):
    if S[i] in t:
        t[S[i]] += 1
    else:
        t[S[i]] = 1
ans = 0
for key in t:
    ans += (t[key]*(t[key]-1))/2


print(ans)

Submission status: Wrong Answer

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

count = 0
J = []
for i in range(N):
    J.append(True)
for i in range(N):
    for j in range(i,N):
        if j != i and S[i] in S[j] and J[j]:
            count += 1
            J[j] = False
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = sorted([input() for _ in range(n)])
ss = [0]*(n+1)
a=0
ans = 0
for i in range(n):
    ss[i]=sorted(s[i])

for i in range(n+1):
    if ss[a]!=ss[i]:
        ans += (ss.count(ss[a])*(ss.count(ss[a])-1)/2)
        a = i
print(int(ans))

Submission status: Wrong Answer

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

L = []

for i in range(0,len(S)):
	L.append(sorted(S[i]))

for i in range(0,len(L)):
	L[i] = ",".join(L[i])

print(L)

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

print(counter)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

for i in range(N):
    tmp = list( input() )
    tmp.sort()
    tmp = ''.join( tmp )
    s.append( tmp )

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

print(count)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N = int(input())
S = defaultdict(int)
for i in range(N):
    S[sum([ord(x) for x in input()])] += 1
print(sum([v * (v - 1) // 2 for v in S.values()]))

Submission status: Wrong Answer

Solution code:
N = int(input())

strings = {}

for _ in range(N):
    s = sorted(list(input()))
    join_s = ''.join(s)
    if join_s in strings:
        strings[join_s] += 1
    else:
        strings[join_s] = 0
        
print(strings)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=[list(input()) for _ in range(n)]
for i in range(n):
	s[i].sort()
count=0
for i in range(n):
	for j in range(n):
		if s[i]==s[j]:
			count+=1
print((count-n)/2)

Submission status: Wrong Answer

Solution code:
#137c
# sys.stdin.readline()
import sys
input = sys.stdin.readline

N = int(input())
A = [str(input()) for _ in range(N-1)]
A = [str[0:10] for str in A]
A.append(str(input()))

sList = []
append = sList.append
ans = 0

for string in A: #2<N<10^5
 
    #辞書化
    dictionarized_string = {letter: string.count(letter) for letter in string}
    ans += sList.count(dictionarized_string)
    append(dictionarized_string)
    
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
strings_list = [sorted(input()) for _ in range(n)]
answer = 0

# todo: リスト内の一致を確認する処理を開始
for l in strings_list:
    if l in strings_list:
        # おそらくカウントするロジックが間違えていて不正解が出ている
        # ここに関しては課題の理解の時点で間違いがあるように感じる
        # todo: ここに関しては出力例を参考に応急処置として実装
        count = strings_list.count(l)
        if count > 2:
            answer += count
        else:
            answer += count - 1
        # todo: アナグラムを計算するロジックなので、一度確認した要素を全て削除する
        while strings_list.count(l) > 0:
            strings_list.remove(l)
print(answer)

Submission status: Wrong Answer

Solution code:
n = int(input())
strings_list = [sorted(input()) for _ in range(n)]
answer = 0

for l in strings_list:
    if l in strings_list:
        count = strings_list.count(l)
        answer += count + 1
        while strings_list.count(l) > 0:
            strings_list.remove(l)
print(answer)

Submission status: Wrong Answer

Solution code:
n = int(input())
strings_list = [sorted(input()) for _ in range(n)]
answer = 0

for l in strings_list:
    if strings_list.count(l) > 0:
        count = strings_list.count(l)
        answer += count
        answer -= 1
    break
print(answer)

Submission status: Wrong Answer

Solution code:
n = int(input())
point = {}
entered = []

for i in range(n):
    string = list(input())
    string.sort()
    string = "".join(string)   
    if string in entered:
        point[string] += 1
    else:
        point[string] = 0
        entered.append(string)
print(sum(point.values()))

Submission status: Wrong Answer

Solution code:
n = int(input())
strings_list = [sorted(input()) for _ in range(n)]
answer = 0

for l in strings_list:
    if l in strings_list:
        count = strings_list.count(l)
        answer += count + 1
    break
print(answer)

Submission status: Wrong Answer

Solution code:
n = int(input())
strings_list = list(input().split())
sorted_strings_list = []
answer = 0
for s in strings_list:
    sorted_strings_list.append(sorted(s))

for s in sorted_strings_list:
    if s in sorted_strings_list:
        count = sorted_strings_list.count(s)
        answer += count
print(answer - 1)

Submission status: Wrong Answer

Solution code:
n = int(input())
strings_list = list(input().split())
sorted_strings_list = []
answer = 0
for s in strings_list:
    sorted_strings_list.append(sorted(s))

for s in sorted_strings_list:
    if s in sorted_strings_list:
        count = sorted_strings_list.count(s)
        answer += count
print(answer - 1)

Submission status: Wrong Answer

Solution code:
n = int(input())
strings_list = list(sorted(input().split()))
answer = 0
for s in strings_list:
    if s in strings_list:
        count = strings_list.count(s)
        answer += count
print(answer)

Submission status: Wrong Answer

Solution code:
n = int(input())
strings_list = list(sorted(input().split()))
answer = 0
for s in strings_list:
    if s in strings_list:
        count = strings_list.count(s)
        answer += count
print(answer - 1)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
S = [input() for i in range(N)]
ctr = Counter()
answer = 0
for s in S:
    a = ''.join(sorted(list(s)))
    print(a)
    if a in ctr:
        answer += ctr[a]
    ctr[a] += 1
print(answer)

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
d = {}
ans = 0
for i in range(N):
    l = ' '.join(sorted(input()))
    if l in d:
        d[l] += 1
        ans += 1
    else:
        d[l] = 1
print(ans)

Submission status: Wrong Answer

Solution code:

N = int(input())
D = {}
L = [[]for _ in range(N)]
count = 0
for i in range(N):
    L[i] = list(input())
    L[i].sort()
    L[i] = tuple(L[i])
    if L[i] in D:
        if D[L[i]] == 0:
            D[L[i]] = D[L[i]] + 1
        D[L[i]] = D[L[i]] + 1
    else:
        D[L[i]] = 0
for key in D:
    count += D[key]

print(count)

Submission status: Wrong Answer

Solution code:

N = int(input())
D = {}
L = [[]for _ in range(N)]
count = 0
for i in range(N):
    L[i] = list(input())
    L[i].sort()
    L[i] = tuple(L[i])
    if L[i] in D:
        if D[L[i]] == 0:
            D[L[i]] = D[L[i]] + 1
        D[L[i]] = D[L[i]] + 1
    else:
        D[L[i]] = 0
for key in D:
    count += D[key]

print(count)
D

Submission status: Wrong Answer

Solution code:

N = int(input())
D = {}
L = [[]for _ in range(N)]
count = 0
for i in range(N):
    L[i] = list(input())
    L[i].sort()
    L[i] = tuple(L[i])
    if L[i] in D:
        D[L[i]] = D[L[i]] + 1
    else:
        D[L[i]] = 0
for key in D:
    #if D[key] != 1:
        count += D[key]

print(count)

Submission status: Wrong Answer

Solution code:

N = int(input())
D = {}
L = [[]for _ in range(N)]
count = 0
for i in range(N):
    L[i] = list(input())
    L[i].sort()
    L[i] = tuple(L[i])
    if L[i] in D:
        D[L[i]] = D[L[i]] + 1
    else:
        D[L[i]] = 1
for key in D:
    if D[key] != 1:
        count += D[key]

print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
D = {}
L = [[]for _ in range(N)]
count = 0
for i in range(N):
    L[i] = list(input())
    L[i].sort()
    L[i] = tuple(L[i])
    if L[i] in D:
        D[L[i]] = D[L[i]] + 1
    else:
        D[L[i]] = 1
for key in D:
    count += D[key]

print(count)