TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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.

Submission attempts (in order):
import math

n=int(input())

dic={}
for i in range(n):
    s=''.join(sorted(input()))
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
ans=0
for n in dic.values():
    ans += math.factorial(n) // (math.factorial(n-2) * math.factorial(2))

print(ans)


import math

n=int(input())

dic={}
for i in range(n):
    s=''.join(sorted(input()))
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
ans=0
for n in dic.values():
    if n>2:
        ans += math.factorial(n) // (math.factorial(n-2) * math.factorial(2))

print(ans)


import math

n=int(input())

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

ans=0
for n in dic.values():
    if n>1:
        ans += math.factorial(n) // (math.factorial(n-2) * math.factorial(2))


print(ans)


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)


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)


n=int(input())
ss=[input() for _ in range(n)]

samedic={}
for s in ss:
  sort_s=''.join(sorted(list(s)))
  if sort_s in samedic:
    samedic[sort_s]+=1
  else:
    samedic[sort_s]=1

ans=0
for v in samedic.values():
  ans+=((v-1)*1)*(v/2)
print(int(ans))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import math
n = int(input())
s = [list(input()) for S in range(n)]
cnt = 0
for i in range(n):
	s[i].sort()
duplicated_data = [tuple(d) for d in s]
unique_data = set(duplicated_data)
s_set = [list(d) for d in unique_data]
print(s_set)
for j in range(len(s_set)):
	if s.count(s_set[j]) >= 2:
		k = s.count(s_set[j])
		cnt += math.factorial(k)//(math.factorial(k-2)*math.factorial(2))
print(cnt)

n = int(input())


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

######################


s_dict = {}
for i in range(n):
	if s[i] in s_dict:
		s_dict[s[i]] += 1
	else:
		s_dict[s[i]] = 1
		
		
ans = 0

for j in s_dict.values():
	ans += j*(j-1)//2
	
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n=int(input())
s=[input() for _ in range(n)]

lis=[collections.Counter(list(s[i])) for i in range(n)]
cnt=0
for i in range(n):
    for j in range(i+1,n):
        if lis[i].items()==lis[j].items(): cnt+=1
print(cnt)

n = int(input())
d = {}
for i in range(n):
    s = sorted(list(input()))   
    s = ''.join(s)
    d[s] = d.get(s, 0) + 1

cnt = 0
for k,v in d.items():
    if v >= 2:
        cnt += v * (v - 1) // 2 

print(cnt)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 10 00:32:19 2020

@author: liang
"""

N = int(input())
d = dict()
for i in range(N):
    S = input()
    S = ''.join(sorted(list(S)))
    print(S)
    if S in d.keys():
        d[S] += 1
    else:
        d[S] = 1

ans = 0
for n in d.values():
    ans += n*(n-1)//2
print(ans)

# -*- coding: utf-8 -*-
"""
Created on Thu Sep 10 00:32:19 2020

@author: liang
"""

N = int(input())
d = dict()
for i in range(N):
    S = input()
    S = ''.join(sorted(list(S)))
    #print(S)
    if S in d.keys():
        d[S] += 1
    else:
        d[S] = 1

ans = 0
for n in d.values():
    ans += n*(n-1)//2
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

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

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

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

ans = 0
i = 0
while i < N:
    k = 1
    while s[i] == s[i+k]:
        k += 1
    ans += (k-1)*k/2
    i += k
        
print(int(ans))

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n=int(input())
dict={}
count=0
for i in range(0,n):
  temp=str(input())
  temp=sorted(list(temp))
  temp="".join(temp)
  if temp in dict:
    dict[temp]=dict[temp]+1
    count=count+dict[temp]
  else:
    dict[temp]=1
print(count)

n=int(input())
dict={}
count=0
for i in range(0,n):
  temp=str(input())
  temp=sorted(list(temp))
  temp="".join(temp)
  if temp in dict:
    dict[temp]=dict[temp]+1
    count=count+dict[temp]
  else:
    dict[temp]=0
print(count)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
s = []
count=0
for i in range(N):
  a = list(input())
  a.sort()
  s.append(a)

while True:
  if len(s) == 0:
    break
  count += s.count(s[0])
  s=[i for i in s if i != s[0]]
  
print(count)

for i in range(N):
  a = list(input())
  a.sort()
  s.append(a)

duplicate_list = duplicates(s)

for i in range (len(duplicate_list)):
  for j in range (s.count(duplicate_list[i])):
    count += j

print(count)

from collections import defaultdict

N = int(input())
s = defaultdict(lambda:0)
count=0

for i in range(N):
  a = "".join(sorted(input()))
  s[a] +=1
  
  if s[a] >1:
    count += s[a]-1
print(count)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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 range(len(s)):
	for n in range(len(s)):
		if Counter(s[n])==Counter(s[m]) and s[m] != s[n]:
			ans+=1
print(ans/2)

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):
			ans+=1
			s.remove(n)
print(ans)


ans = 0
s = {}
N = int(input())
for i in range(N):
	tmp = []
	string = input()
	for st in string:
		tmp.append(st)
	tmp.sort()
	stmp = ''.join(tmp)
	if stmp in s and s[stmp] > 0:
		ans += s[stmp]
		s[stmp] = s[stmp]+1
	else:
		s[stmp] = 1
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import pandas as pd
import math

N = int(input())
print("No")

import math
from itertools import groupby

N = int(input())
S = ["".join(sorted(input())) for i in range(N)]
sizes = [len(list(v)) for k, v in groupby(sorted(S))]


def combinations_count(n, r):
    if n == 1:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


ans = sum([combinations_count(size, 2) for size in sizes])
print(ans)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import collections

N = int(input())
S = [(sorted(input())) for _ in range(N)]
c = collections.Counter(S)
ans = 0
for i in set(S):
    n = c[i]
    ans += n*(n-1)//2
print(ans)

import collections

N = int(input())
S = [''.join(sorted(input())) for _ in range(N)]
c = collections.Counter(S)
ans = 0
print(S)

for i in set(S):
    n = c[i]
    ans += n*(n-1)//2
print(ans)

import collections

N = int(input())
S = [{sorted(input())}for _ in range(N)]
c = collections.Counter(S)
ans = 0
print(S)

for i in set(S):
    n = c[i]
    ans += n*(n-1)//2
print(ans)

import collections

N = int(input())
S = [(sorted(input()))for _ in range(N)]
c = collections.Counter(S)
ans = 0
print(S)

for i in set(S):
    n = c[i]
    ans += n*(n-1)//2
print(ans)

N = int(input())
S = [set(input())for _ in range(N)]
m = 0
for i in S:
    m += S.count(i)
    
print(m)

import collections

N = int(input())
S = [sorted(input())for _ in range(N)]
c = collections.Counter(S)
ans = 0

for i in set(S):
    n = c[i]
    ans += n*(n-1)//2
print(ans)

import collections

N = int(input())
S = [tuple(sorted(input())) for _ in range(N)]
c = collections.Counter(S)
ans = 0
for i in set(S):
    n = c[i]
    ans += n*(n-1)//2
print(ans)

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
s = []
l_cnt = []
for i in range(N):
  s.append(''.join(sorted(input())))

dic = {}
for x in s:
  if dic.get(x) == None:
    dic[x] = 1
  else:
    dic[x] += 1

print(list(map(lambda n: n*(n-1)//2,list(dic.values()))))

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

dic = {}
for x in s:
  if dic.get(x) == None:
    dic[x] = 1
  else:
    dic[x] += 1

print(sum(map(lambda n: n*(n-1)//2,list(dic.values()))))

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import math
N = int(input())
s = []

for _ in range(N):
  s.append(str(input()))
  
cnt = 0
for i in range(N):
  delete = []
  s1 = s.pop()
  s1list = list(s1)
  same = 0
  
  for j in range(len(s)-1, -1, -1):
    s2 = s[j]
    s2list = list(s2) 
    if sorted(s1list) == sorted(s2list):
      delete.append(s2)
      same += 1
  cnt += math.factorical(same)
  for x in delete:
    s.remove(x)
  if not s:
    break
print(cnt)


from collections import Counter
N = int(input())
s = []
cnt = 0
for _ in range(N):
  a = str(input())
  alist = sorted(list(a))
  s.append(str(''.join(alist)))
  
l = Counter(s)
for i in l.values():
  if i > 1:
    cnt += (i - 1) * i / 2
print(int(cnt))

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import sys
input = sys.stdin.readline

from math import factorial

def ncr(n, r):
    return factorial(n) / factorial(r) / factorial(n - r)

from collections import defaultdict


n = int(input())
d = defaultdict(lambda: 0)

for i in range(n):
    s = list(str(input()).rstrip())
    s.sort()
    s = "".join(s)
    d[s] += 1   

ans = 0
for key in d.keys():
    if d[key] > 1:
        ans += ncr(d[key], 2)
print(d)
print(int(ans))

import sys
from collections import defaultdict
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


input = sys.stdin.readline

n = int(input())
d = defaultdict(lambda: 0)

for i in range(n):
    s = list(str(input()).rstrip())
    s.sort()
    s = "".join(s)
    d[s] += 1   

ans = 0
for key in d.keys():
    if d[key] >= 2:
        ans += cmb(d[key], 2)
print(int(ans))

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
def C(n) :
    if n == 1:
        return 1
    sum = 1
    while (n > 1):
        sum *= n
        n -= 1
    return sum // 2

def main():
    N = int(input())
    dic = {}
    for i in range(N):
        s = ''.join(sorted(input()))

        if s in dic:
            dic[s] += 1
        else:
            dic[s] = 1
    ans = 0
    for v in dic.values():
        ans += C(v)

    print(ans)


if __name__ == '__main__':
    main()


s = [''.join(sorted(input())) for i in range(N)]
 
dic = {}
cnt = 0
for i in range(N):
    if s[i] in dic:
        cnt += dic[s[i]]
        dic[s[i]] += 1
    else:
        dic[s[i]] = 1
print(cnt)
 
 

N = int(input())
dic = {}
for i in range(N):
    s = ''.join(sorted(input()))
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
ans = 0
for v in dic.values():
    ans += v * (v - 1) // 2

print(ans)




Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import sys
import math

input = sys.stdin.readline


def main():
    n = int(input())
    lines = ["".join(sorted(input().strip())) for _ in range(n)]
    count = 0
    for text in set(lines):
        txt_cnt = lines.count(text)
        count += int(math.factorial(txt_cnt) / math.factorial(txt_cnt - 2)) // 2
    print(count)


if __name__ == "__main__":
    main()


import sys
from functools import reduce
from operator import mul
from collections import Counter

input = sys.stdin.readline


def cmb(n, r):
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


def main():
    n = int(input())
    lines = ["".join(sorted(input().strip())) for _ in range(n)]
    count = 0
    for _, v in Counter(lines).most_common():
        if v == 1:
            break
        count += cmb(v, 2)
    print(count)


if __name__ == "__main__":
    main()


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
lis = []
for _ in range(n):
  s = list(str(input()))
  s.sort()
  lis.append(s)
lis.sort()
ans = 0
num = 0
for i in range(n-1):
  if lis[i+1] == lis[i]:
    num += 1
  else:
    ans += (num * (num+1))//2
    num = 0
print(ans)

n = int(input())
lis = []
for _ in range(n):
  s = list(str(input()))
  s.sort()
  lis.append(s)
lis.sort()
ans = 0
num = 0
for i in range(n-1):
  if lis[i+1] == lis[i]:
    num += 1
  else:
    ans += (num * (num+1))//2
    num = 0
ans += (num * (num+1))//2
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

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

N=int(input())
S=["".join(sorted(input())) for _ in range(N)]
dic={}
ans=0
for s in S:
  if s not in dic:
    dic.setdefault(s,1)
  else:
    ans+=dic[s]
    dic[s]+=1
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import math

n = int(input())
s = sorted(["".join(sorted(input())) for i in range(n)])
a = 0
b = []
for i in range(n-1):
  if s[i]==s[i+1]:
    a += 1
    if i==n-2:
      b.append(a)
      a = 0
  else:
    b.append(a)
    a = 0
for i in range(len(b)):
  a += math.factorial(b[i])
print(a)

import math

n = int(input())
s = sorted(["".join(sorted(input())) for i in range(n)])
a = 0
b = []
for i in range(n-1):
  if s[i]==s[i+1]:
    a += 1
  else:
    a = 0
  b.append(a)
print(sum(b))

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
count = 0
dic = {}
for _ in range(n):
    key = ''.join(sorted(input()))
    if key in dic:
        c += dic[key]
        dic[key] += 1
    else:
        dic[key] = 1
print(count)

n = int(input())
count = 0
dic = {}
for _ in range(n):
    key = ''.join(sorted(input()))
    if key in dic:
        count += dic[key]
        dic[key] += 1
    else:
        dic[key] = 1
print(count)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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:
  _sum += line[i]

print(_sum * (_sum-1) / 2)


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] == 2:
    _sum += line[i] - 1
  else:
    _sum += line[i]

print(_sum)

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:
  _sum += int((line[i] * (line[i] - 1)) / 2)

print(_sum)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
# Green Bin
n = int(input())
s = [input() for i in range(n)]
m = 0
list = {}
for i in s:
  i = ' '.join(sorted(i))
  if i in list:
    list[i] = list[i] + 1
  else:
    list[i] = 1
for i in list.values():
  l = i -1
  m = m + int(((l * (l + 1)) / 2))
print(list)

# Green Bin
n = int(input())
s = [input() for i in range(n)]
m = 0
list = {}
for i in s:
  i = ' '.join(sorted(i))
  if i in list:
    list[i] = list[i] + 1
  else:
    list[i] = 1
for i in list.values():
  l = i -1
  m = m + int(((l * (l + 1)) / 2))
print(m)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from scipy.special import comb

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

d = {}
for s in S:
    s = "".join(sorted(s))
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
ans = 0
for v in d.values():
    if v > 1:
        ans += comb(v, 2)
print(ans)        

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

d = {}
ans = 0
for s in S:
    s = "".join(sorted(s))
    if s in d:
        ans += d[s]
        d[s] += 1
    else:
        d[s] = 1
print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import math

N = int(input())
lists = []
result = 0
tempres = 0
for i in range(N):
    lists.append(input())

sortedlist = []
for i in range(0, N):
    sortedlist.append(sorted(lists[i]))

sortedlist.sort()
for i in range(0, N):
    if tempres != 0:
        tempres -= 1
        continue

    for j in range(i + 1, N):
        if sortedlist[i] == sortedlist[j]:
            tempres += 1
        else:
            break

    result += math.factorial(tempres)

print(result)


import math

N = int(input())
lists = []
result = 0
tempres = 0
for i in range(N):
    lists.append(input())

sortedlist = []
for i in range(0, N):
    sortedlist.append(sorted(lists[i]))

sortedlist.sort()
for i in range(0, N):
    if tempres != 0:
        tempres -= 1
        result += tempres
        continue

    for j in range(i + 1, N):
        if sortedlist[i] == sortedlist[j]:
            tempres += 1
        else:
            break
    result += tempres

print(result)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from collections import Counter

n = int(input())
lst = []
lstn = [0] *10**5
j = 0

for i in range(n):
    s = input()
    c = Counter(s)
    if c not in lst:
        lst.append(c)
        lstn[j] = 1
        j += 1
    else:
        k = lst.index(c)
        lstn[k] += 1
        
print(sum(lstn))

from collections import Counter

n = int(input())
lst = []
lstn = [0] *10**5
cnt = 0
j = 0

def nCr(n,r):
    r = min(r,n-r)
    numerator = 1
    for i in range(n,n-r,-1):
        numerator *= i
    denomination = 1
    for i in range(r,1,-1):
        denomination *= i
    return numerator // denomination


for i in range(n):
    s = input()
    c = Counter(s)
    if c not in lst:
        lst.append(c)
        lstn[j] = 1
        j += 1
    else:
        k = lst.index(c)
        lstn[k] += 1

for x in lstn:
    if x != 0:
        cnt += nCr(x,2)
print(cnt)

from collections import Counter

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

sorted_S =  [''.join(sorted(s)) for s in S]
c = Counter(sorted_S)

print(sum([n * (n-1)//2 for n in  list(c.values())]))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
for _ in range(n):
  si = str(input())
  di = {}
  for i in range(10):
    if si[i] in di.keys():
      di[si[i]] += 1
    else:
      di[si[i]] = 1
  frag = True
  for j,st in enumerate(li[0]):
    if di == st:
      li[1][j] += 1
      frag = False
  if frag:
    li[0].append(di)
    li[1].append(1)
sm = 0
for j in li[1]:
  sm += j*(j-1)//2
print(sm)

n = int(input())
dic = {}
for _ in range(n):
  si = str(input())
  li = [si[i] for i in range(10)]
  li.sort()
  moji = "".join(li)
  if moji in dic.keys():
    dic[moji] += 1
  else:
    dic[moji] = 1
sm = 0
for j in dic.values():
  sm += j*(j-1)//2
print(sm)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 25 18:54:16 2020

@author: Kanaru Sato
"""

n = int(input())
Dict = {}
ans = 0

for i in range(n):
    s = list(input())
    s.sort()
    if s in Dict:
        ans += Dict[s]
        Dict[s] += 1
    else:
        Dict[s] = 1

print(ans)

# -*- coding: utf-8 -*-
"""
Created on Wed Mar 25 18:54:16 2020

@author: Kanaru Sato
"""

n = int(input())
Dict = {}
ans = 0

for i in range(n):
    s = list(input())
    s.sort()
    s = "".join(s)
    if s in Dict:
        ans += Dict[s]
        Dict[s] += 1
    else:
        Dict[s] = 1

print(ans)  

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
lens = int(input())
hashes = sorted()[''.join(sorted(input())) for _ in range(lens)])
i = 0
j = 0
r = 0
ans = 0
while i < lens - 1:
    i += 1
    if hashes[i] == hashes[j]:
        r += 1
    else:
        ans += (r * (r + 1)) // 2
        r = 0
        j = i
ans += (r ( r + 1))//2
print(ans)

from collections import Counter
lens = int(input())
hashes = [''.join(sorted(input())) for _ in range(lens)]
ansv = Counter(hashes).values()
ans = sum([x//2 * 2 for x in ansv ])
print(ans)



lens = int(input())
hashes = [''.join(sorted(input())) for _ in range(lens)]
i = 0
j = 0
r = 0
ans = 0
while i < lens - 1:
    i += 1
    if hashes[i] == hashes[j]:
        r += 1
    else:
        ans += (r * (r + 1)) // 2
        r = 0
        j = i
ans += (r ( r + 1))//2
print(ans)

n = int(input())
ws = [list(input()) for _ in range(n)]
 
def sort_l(l):
    l.sort()
    return l
ws = list(map(sort_l, ws))
ws.sort()
 
i = 0
j = 0
r = 0
ans = 0
while(i<n-1):
    i += 1
    if ws[i] == ws[j]:
        r += 1
    else:
        ans += r * (r+1) // 2
        r = 0
        j = i
ans += r * (r+1) // 2
 
print(ans)

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
from collections import Counter

N=int(input())
dic＝{}

ans=0

for i in range(N):
    si=input()
    # ci=Counter(si)
    
    
    sorted_s=''.join(sorted(Counter(si).elements()))
    if sorted_s in dic:
        ans+=dic[sorted_s]
        dic[sorted_s]+=1
    else:
        dic[sorted_s]=1

print(ans)

from collections import Counter

N=int(input())
dic＝{}

ans=0

for i in range(N):
    si=input()
    # ci=Counter(si)
    
    
    sorted_s=''.join(sorted(Counter(si).elements()))
    if sorted_s in dic:
        ans+=dic[sorted_s]
        dic[sorted_s]]+=1
    else:
        dic[sorted_s]=1

print(ans)

from collections import Counter

N=int(input())

dic={}
ans=0

for i in range(N):
    si=input()
    # ci=Counter(si)
    
    
    sorted_s=''.join(sorted(Counter(si).elements()))
    if sorted_s in dic:
        ans+=dic[sorted_s]
        dic[sorted_s]+=1
    else:
        dic[sorted_s]=1

print(ans)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())

l = []
for i in range(n):
    tmp = list(input())
    tmp.sort()
    tmp = ''.join(tmp)
    l.append(tmp)

from collections import Counter
c = Counter(l)
num = c.values()

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

ans = 0
for i in num:
    ans += combinations_count(i, 2)
    if i == 1:
        break

print(ans)


n = int(input())
s = []
for _ in range(n):
    #s.append(list(input())) # !!!
    
    s.append(sorted(input())) # !!!
print(s)
 
x = 0
for i in range(n):
    for j in range(i+1, n):
        if s[i] == s[j]:
            x += 1
 
print(x)

n = int(input())

l = []
for i in range(n):
    tmp = list(input())
    tmp.sort()
    tmp = ''.join(tmp)
    l.append(tmp)

from collections import Counter
c = Counter(l)
num = sorted(list(c.values()), reverse = 1)

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

ans = 0
for i in num:
    if i == 1:
        break
    else:
        ans += combinations_count(i, 2)

print(ans)


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
# -*- coding: utf-8 -*-
N, M = map(int, input().split())
A = [] 
B = [] 
for i in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)

c = 0
for i in range(M):
  if A[i] + i < M:
    c = c + B[i]
  



print(c)



# -*- coding: utf-8 -*-

N = int(input())


ar = []
for i in range(N):
  l = list(input())
  l.sort()
  ar.append("".join(l).__hash__())


list = {}
for i in ar:
  if i in list:
    list[i] = list[i] + 1
  else:
    list[i] = 1
  
count = 0
for i in list.values():
  n = i - 1
  count = count + ((n * (n + 1)) / 2)

print(count)

# -*- coding: utf-8 -*-

n = int(input())

ar = []
for i in range(n):
  ar.append("".join(list(input()).sort()))

count = 0

for i in range(n):
  count = count + ar[i+1:].count(ar[i])

print(count)



# -*- coding: utf-8 -*-

N = int(input())


ar = []
for i in range(N):
  l = list(input())
  l.sort()
  ar.append("".join(l).__hash__())


list = {}
for i in ar:
  if i in list:
    list[i] = list[i] + 1
  else:
    list[i] = 1
  
count = 0
for i in list.values():
  n = i - 1
  count = count + int(((n * (n + 1)) / 2))

print(count)

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import collections
def main4():
    dd = collections.defaultdict(int)
    n = int(input())
    res = 0
    for i in range(n):
        s = input()
        s.sort()
        dd[''.join(s)]+=1
    for i in dd.values():
        res += (i*(i-1))//2
    print(res)

if __name__ == '__main__':
    main4()

import collections
def main4():
    dd = collections.defaultdict(int)
    n = int(input())
    res = 0
    for i in range(n):
        s = input()
        a = sorted(s)
        dd[''.join(a)]+=1
    for i in dd.values():
        res += (i*(i-1))//2
    print(res)


if __name__ == '__main__':
    main4()

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
words = dict()
count = 0
for i in range(n):
  s = sorted(input())
  if s in words:
    count += words[s]
    words[s] += 1
  else:
    words[s] = 0
print(count)

n = int(input())
words = dict()
count = 0
for i in range(n):
  s = ''.join(sorted(input()))
  if s in words:
    count += words[s]
    words[s] += 1
  else:
    words[s] = 1
print(count)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N=int(input())
s=[0]*N
for i in range(N):
    s[i] = input()
i=0
Co=[]
while s != []:
    counter = 1
    a = s.pop(0)
    for word in s:
        if word == a:
            s.remove(word)
            counter+=1
    Co.append(counter)
summary = 0
for i in range(len(Co)):
    summary+=Co[i]*(Co[i]-1)//2
print(summary)

N=int(input())
s=[0]*N
for i in range(N):
    s[i] = input()
    s[i] = sorted(s[i])
s=sorted(s)
counter=1
sum=0
for i in range(N-1):
    if s[i] == s[i+1]:
        counter+=1
    else:
        sum+=counter*(counter-1)//2
        counter=1
sum+=counter*(counter-1)//2
print(sum)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N=int(input())
L=[sorted(input()) for _ in range(N)]
Y=[]
for i in range(len(L)):
    Y.append("".join(L[i]))
print(len(set(Y)))

import collections
N=int(input())
s=[str(sorted(input())) for i in range(N)]
c=collections.Counter(s)
print(sum((v*(v-1))//2 for v in c.values()))

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from collections import Counter
N = int(input())
S = [sorted(input()) for _ in range(N)]
S = sorted(S)
print(sum(map(lambda x: x*(x-1)//2, Counter(S).values())))


import string

def bwords(str):
  str = list(str)
  bword = [0]*len(string.ascii_lowercase)
  for s in str:
  	bword[string.ascii_lowercase.index(s)]+=1
  return bword

def check_bword(a_word,b_word):
  for a,b in zip(a_word,b_word):
    if a != b:
      return False
  return True

N = int(input())
groups = {0: 1}
groups_bword = {0: bwords(input())}

for i in range(1,N):
  s = input()
  b_w = bwords(s)
  
  add_grouped = False
  
  for key,bword in groups_bword.items():
    if check_bword(b_w,bword):
      groups[key]+=1
      add_grouped = True
      break
      
  if not add_grouped:
    groups[len(groups.keys())] = 1
    groups_bword[len(groups_bword.keys())] = b_w

count = 0

for key,nums in groups.items():
  print(key,nums)
  count+=nums*(nums-1)//2
  
print(count)

from collections import Counter
N = int(input())
S = [str(sorted(input())) for _ in range(N)]
print(sum(map(lambda x: x * (x - 1) // 2, Counter(S).values())))


Verdicts: Runtime Error

Wrong Answer

Accepted