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):
from math import factorial
def cmb(n,r):
  return factorial(n)//(factorial(r)*factorial(n-r))
n=int(input())
s=[input() for i in range(n)]
s.sort()
cnt=0
ans=0
for i in range(1,n):
  if s[i]==s[i-1]:
    cnt+=1
  else:
    ans+=cmb(cnt+1,2)
    cnt=0
print(ans)

from math import factorial
from collections import Counter
def comb(n,k):
  if n<0 or k<0 or n<k:return 0
  if n==0 and k==0:return 1
  a=factorial(n)
  b=factorial(k)
  c=factorial(n-k)
  return a//(b*c)
n=int(input())
s=[list(Counter(input())) for i in range(n)]
s.sort()
cnt=1
ans=0
for i in range(1,n):
  if s[i]==s[i-1]:
    cnt+=1
  else:
    ans+=comb(cnt,2)
    cnt=1
if cnt>=2:
  ans+=comb(cnt,2)
print(ans)

from math import factorial
def cmb(m,r):
  return factorial(m)//(factorial(r)*factorial(m-r))
n=int(input())
s=[input() for i in range(n)]
s.sort()
cnt=0
ans=0
for i in range(1,n):
  if s[i]==s[i-1]:
    cnt+=1
  else:
    ans+=cmb(cnt+1,2)
    cnt=0
print(ans)


from math import factorial
def comb(n,k):
  if n<0 or k<0 or n<k:return 0
  if n==0 and k==0:return 1
  a=factorial(n)
  b=factorial(k)
  c=factorial(n-k)
  return a//(b*c)
n=int(input())
s=[sorted(list(input())) for i in range(n)]
s.sort()
cnt=1
ans=0
for i in range(1,n):
  if s[i]==s[i-1]:
    cnt+=1
  else:
    ans+=comb(cnt,2)
    cnt=1
if cnt>=2:
  ans+=comb(cnt,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):
n = int(input())
s = ["".join(sorted(list(input()))) for _ in range(n)]

cnt=0
for i in range(n):
    if s.count(s[i])!=1
        cnt += s.count(s[i])/s.count(s[i])
print(cnt-n)


n = int(input())
s = ["".join(sorted(list(input()))) for _ in range(n)]

cnt=0
for i in range(n):
    if s.count(s[i])!=1:
        cnt += s.count(s[i])/s.count(s[i])
print(cnt-n)


n = int(input())
s = ["".join(sorted(list(input()))) for _ in range(n)]
s.sort()
print(s)
cnt=0
for i in range(n-1):
    if s[i]==s[i+1]
    cnt +=1
print(cnt-n)


n = int(input())
s = ["".join(sorted(list(input()))) for _ in range(n)]
s.sort()
cnt=0
for i in range(n-1):
    if s[i]==s[i+1]:
    cnt +=1
print(cnt)

n = int(input())
s = ["".join(sorted(list(input()))) for _ in range(n)]
s.sort()
ans=0
pairs=1
for i in range(n-1):

    if s[i]==s[i+1]:
        pairs += 1
    else:      
        ans += pairs*(pairs-1)/2
        pairs =1
if pairs != 1:
    ans += pairs*(pairs-1)/2
    pairs =1
print(int(ans))

Verdicts: Runtime Error

Wrong Answer

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

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

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

@author: avina
"""

n = int(input())
d = {}
for i in range(n):
  a = list(input())
  a.sort()
  a = ''.join(a)
  if a not in d:
    d[a] = 1
  else:
    d[a]+=1
ans = 0
for i in d:
    ans += ((d[i])*(d[i]-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):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from collections import defaultdict
import math

N = int(input())
H = defaultdict(int)

for i in range(N):
    s = "".join(sorted(input()))
    H[s] += 1

ret = 0
for v in H.values():
    ret += math.factorial(v) // (math.factorial(v - 2) * math.factorial(2))
print(ret)

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from collections import defaultdict
import math

N = int(input())
H = defaultdict(int)

for i in range(N):
    s = "".join(sorted(input()))
    H[s] += 1

ret = 0
for v in H.values():
    if v >= 2:
        ret += math.factorial(v) // (math.factorial(v - 2) * math.factorial(2))
print(ret)

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())
#c = 0

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




import collections

n = int(input())
#c = 0

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

import collections

n = int(input())
#c = 0

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




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):
N = int(input())
s = []
a = 0
b = 0
for i in range(N):
    s.append(''.join(sorted(list(input()))))
    
a = len(s)
b = len(set(s))

print(int((a - b)*2))

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

ans = 0
for i in range(N):
    for j in range(N):
        if not i == j:
            if (si == sj):
                ans += 1
print(int(ans/2))

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

print(s)
ans = 0
for i in range(N):
    for j in range(N):
        if not i == j:
            if (s[i] == s[j]):
                ans += 1
print(int(ans/2))

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

Verdicts: Wrong Answer

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())
S=[]
for i in range(n):
    S.append(sorted(input()))
ans=0
for i in range(n):
    for j in range(n):
        if S[i]==S[j]:
            ans+=1
            
print((ans-n)/2)

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


memo={}
ans=0
for i in range(n):
  if S[i] not in memo:
    memo[S[i]]=1
  else:
    memo[S[i]]+=1
    ans+=memo[S[i]]-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):
d={}
ans=0
for i in range(N):
    s=''.join(sorted(input()))
    if s in d:
        ans+=d[s]
        d[s]+=1
    else:
        d[s]=1
print(ans)

import sys
read_=sys.stdin.buffer.readline

N=int(read_())
ans_d={}
ans=0
for i in range(N):
    s=''.join(sorted(input()))
    if s in ans_d:
        ans+=ans_d[s]
        ans_d[s]+=1
    else:
        ans_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):
#coding: utf-8
amount = int(input())
strings = list(map(str, [input() for i in range(amount)]))
sum = 0
sum2 = 0

for i in range(len(strings)):
	# print(strings[i])
	abc = list(strings[i])
	abc.sort()
	strings[i] = ''.join(abc)
	# print(strings[i])

strings.sort()

for j in range(len(strings)-1):
	# print(j+1)
	# print(strings[j]+strings[j+1])
	if strings[j] == strings[j+1]:
		sum2 = sum2+1
	else:
		sum = sum + sum2 * (sum2+1) / 2
		sum2 = 0

sum = sum + sum2 * (sum2+1) / 2
print(sum)


#coding: utf-8
amount = int(input())
strings = list(map(str, [input() for i in range(amount)]))
sum = 0

for i in range(len(strings)):
	# print(strings[i])
	abc = list(strings[i])
	abc.sort()
	strings[i] = ''.join(abc)
	# print(strings[i])

strings.sort()

for j in range(len(strings-1)):
	# print(j)
	if strings[j] == strings[j+1]:
		sum = sum+1

print(sum)


#coding: utf-8
amount = int(input())
strings = list(map(str, [input() for i in range(amount)]))
sum = 0
sum2 = 0

for i in range(len(strings)):
	# print(strings[i])
	abc = list(strings[i])
	abc.sort()
	strings[i] = ''.join(abc)
	# print(strings[i])

strings.sort()

for j in range(len(strings)-1):
	# print(j+1)
	# print(strings[j]+strings[j+1])
	if strings[j] == strings[j+1]:
		sum2 = sum2+1
	else:
		sum = sum + sum2 * (sum2+1) / 2
		sum2 = 0

sum = sum + sum2 * (sum2+1) / 2
print(int(sum))


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):
n=int(input())
s=[]
for i in range(n):
    s.append("".join(sorted(input())))

S=set(s)

import math

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


ans=0
for x in S:
    a=s.count(x)
    ans+=cmb(a,2)
print(ans)


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

S=set(s)

from operator import mul
from functools import reduce

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

from collections import Counter

ans=0
l=Counter(s)
for x in S:
    a=l[x]
    if a<2:
        continue
    else:
        ans+=cmb(a,2)
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
input = sys.stdin.readline

N = int(input())
lis_all = []
lis_pat = []
lis_num = []

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

count = 0
for i in range(N):
    lis_S = list(str(input()))
    lis_S.sort()
    if lis_S not in lis_all:
        lis_pat.append(lis_S)
    lis_all.append(lis_S)

for i in lis_pat:
    lis_num.append(lis_all.count(i))

ans = 0
for i in lis_num:
    if i != 1:
        ans += comb(i,2)
   
print(ans)
    


import math

N = int(input())
lis_all = []
lis_pat = []
lis_num = []

count = 0
for i in range(N):
    lis_S = list(str(input()))
    lis_S.sort()
    if lis_S not in lis_all:
        lis_pat.append(lis_S)
    lis_all.append(lis_S)

ans = 0
for i in lis_pat:
    if lis_all.count(i) != 1:
        ans += math.factorial(lis_all.count(i))/2
   
print(ans)
    

import math

N = int(input())
lis_all = []
lis_pat = []
lis_num = []

count = 0
for i in range(N):
    lis_S = list(str(input()))
    lis_S.sort()
    if lis_S not in lis_all:
        lis_pat.append(lis_S)
    lis_all.append(lis_S)

ans = 0
for i in lis_pat:
    if lis_all.count(i) != 1:
        ans += math.factorial(i)/2
   
print(ans)
    


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

Verdicts: Runtime Error

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

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

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):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
from operator import mul
from functools import reduce

input = sys.stdin.readline

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

def comb(a, b):
    n = a
    for _ in range(b):
        n -= 1
        a *= n

    for i in range(1, b):
        b *= i
    return int(a / b)


def main():
    n = int(input())
    m = {}
    for l in sys.stdin:
        s = ''.join(sorted(l.strip()))
        if s in m:
            m[s] += 1
        else:
            m[s] = 1
    cnt = 0
    for k, v in m.items():
        if v == 1:
            cnt += 1
        else:
            cnt += cmb(v, 2)
    print(cnt)

main()


#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
from operator import mul
from functools import reduce

input = sys.stdin.readline

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

def comb(a, b):
    n = a
    for _ in range(b):
        n -= 1
        a *= n

    for i in range(1, b):
        b *= i
    return int(a / b)


def main():
    n = int(input())
    m = {}
    for l in sys.stdin:
        s = ''.join(sorted(l.strip()))
        if s in m:
            m[s] += 1
        else:
            m[s] = 1
    cnt = 0
    for k, v in m.items():
        if v == 1:
            continue
        if v == 2:
            cnt += 1
        else:
            cnt += cmb(v, 2)
    print(cnt)

main()


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
def combinations(n, r):
  if n == r:
    return 1
  else:
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N = int(input())
s = [sorted(input())]
ans = 0
for i in range(N-1):
  s_i = sorted(input())
  s.append(s_i)
s = sorted(s)
count=1
for j in range(N-1):
  if s[j] == s[j+1]:
    count+=1
  else:
    ans += combinations(count,2)
    count=1
if count != 1:
  ans += combinations(count,2)
print(ans)

import math
def combinations(n, r):
  if n == r:
    return 1
  else:
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N = int(input())
s = [sorted(input())]
ans = 0
for i in range(N-1):
  s_i = sorted(input())
  s.append(s_i)
s = sorted(s)
count=1
for j in range(N-1):
  if s[j] == s[j+1]:
    count+=1
  else:
    if count != 1:
      ans += combinations(count,2)
    count=1
if count != 1:
  ans += combinations(count,2)
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):
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(long, S_dict.values())))

ans = 0
N = int(input())
s_list = [''.join(sorted(input())) for _ in range(N)]
s_list.sort()

count = 1
for i in range(1, N):
    if s_list[i] == s_list[i-1]:
        count += 1
    else:
        ans += (count*(count-1))/2
        count = 1

    if i == N-1:
        ans += (count*(count-1))/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):
n=int(input())
l=[list(str(input())) for i in range(n)]
cnt=0
nums=[x for x in range(n)]
for m in l:
  m.sort()
print(l)
for i in nums[:n-1]:
  for j in l[i+1:]:
    if(l[i]==j):
      cnt+=1
print(cnt)

n=int(input())
l=[list(str(input())) for i in range(n)]
cnt=0
nums=[x for x in range(n)]
for m in l:
  m.sort()
print(l)
for i in nums[:n-2]:
  for j in l[i+1:]:
    if(l[i]==j):
      cnt+=1
print(cnt)

        

from collections import Counter
n=int(input())
l=["".join(sorted(list(str(input())))) for i in range(n)]
cnt=Counter(l)
ans=0
for i in set(l):
  n=cnt[i]
  ans+=n*(n-1)//2
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):
from collections import Counter


n=int(input())
S = []
for i in range(n):
    S.append(''.join(sorted(input())))

cnt = Counter(S)
 
ans = 0
for num in cnt.values():
    ans += num*(num-1)/2
print(ans)


from collections import Counter


n=int(input())
S = []
for i in range(n):
    S.append(''.join(sorted(input())))

cnt = Counter(S)
 
ans = 0
for num in cnt.values():
    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):
def isAnagram(s, ss):
	i = 0
	while ss != "" and i < len(s):
		ss.replace(s[i], '')
		i += 1
	if ss == "":
		return 1
	else:
		return 0


c = int(input())

strings = []
for i in range(c):
	strings.append(input())

count = 0
for i in range(c):
	for j in range(i, c):
		count += isAnagram(strings[i], strings[j])

print(count)




import collections
 
N = int(input())
#read strings and sort each one alpha!
s = ["".join(sorted(input())) for i in range(N)]

# count every word occurences
c = collections.Counter(s)

cnt = 0
for i in set(s):
    n = c[i]
    
    cnt += n*(n-1)//2
print(cnt) 

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):
def countPairs(str_arr):
	count = 0
	for i in range(N):
		for j in range(i+1,N):
			if str_arr[i] == str_arr[j]:
				count += 1
	return count


N = int(input())
str_arr = []

for i in range(N):
	str = input()
	str_arr.append(str)

print(countPairs(str_arr))

import operator as op
from functools import reduce
import math
	

def ncr(n, r):
	if n < r:
		return 0
	else :
		return (math.factorial(n)) / (math.factorial(n-r)*math.factorial(r))

def countPairs(str_arr, N):
	str_cnt = [0]
	str = str_arr[0]
	j = 0
	for i in range(N):
		if(str_arr[i]==str):
			str_cnt[j] += 1
		else:
			str = str_arr[i]
			j += 1
			str_cnt.append(0)
			str_cnt[j] += 1
	count = 0
	for i in range(len(str_cnt)):
		count += ncr(str_cnt[i],2)
	print(int(count))

def main():
	N = int(input())
	str_arr = []
	for i in range(N):
		str = input()
		str_arr.append(sorted(str))
	str_arr = sorted(str_arr)
	countPairs(str_arr, N)


main()

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):
for i in range(n):
    s.append("".join(sorted(input())))
s.sort()

a = 0
r = 0
i = 1
l = len(s)
while i < l:
    if s[i] == s[i-1]:
        r = r+1
    else:
        a = a + sum(range(r+1))
        r = 0
    i = i+1

if r > 0: a = a + sum(range(r+1))
print(a)

n = int(input())

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

a = 0
r = 0
i = 1
l = len(s)
while i < l:
    if s[i] == s[i-1]:
        r = r+1
    else:
        a = a + sum(range(r+1))
        r = 0
    i = i+1

if r > 0: a = a + sum(range(r+1))
print(a)


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 resolve():
    '''
    code here
    '''
    import collections
    N = int(input())
    Ss = [sorted([item for item in input()]) for _ in range(N)]
    
    sss = []
    for line in Ss:
        sss.append(''.join(line))
    line_cnt = collections.Counter(sss)

    cnt = 0
    for letter, num in line_cnt.most_common():
        if num >=2:
            cnt += num

    print(cnt)
if __name__ == "__main__":
    resolve()


def resolve():
    '''
    code here
    '''
    import collections
    import math
    N = int(input())
    Ss = [sorted([item for item in input()]) for _ in range(N)]
    
    sss = []
    for line in Ss:
        sss.append(''.join(line))
    line_cnt = collections.Counter(sss)

    cnt = -1
    for letter, num in line_cnt.most_common():
        if num >=2:
            cnt += math.comb(num, 2)

    print(cnt) if cnt != -1 else print(0)
if __name__ == "__main__":
    resolve()


def resolve():
    '''
    code here
    '''
    import collections
    import math
    N = int(input())
    Ss = [sorted([item for item in input()]) for _ in range(N)]
    
    sss = []
    for line in Ss:
        sss.append(''.join(line))
    line_cnt = collections.Counter(sss)

    cnt = 0
    for letter, num in line_cnt.most_common():
        if num >=2:
            cnt += math.comb(num, 2)

    print(cnt)
if __name__ == "__main__":
    resolve()


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):
a = int(input())
b = []
for _ in range(a):
  b.append(sorted(list(input())))

for i in range(a):
  for j in range(i+1, a):
    check = True
    for k in range(10):
      if b[i] != b[j]:
        check = False
    if check = True:
      ans += 1
print(ans)

a = int(input())
b = {}
strings = ''
ans = 0

for i in range(a):
    check = False
    strings = ''.join(sorted(list(input())))
    if strings in b.keys():
      check = True
    if check == True:
      ans += b[strings]
      b[strings] += 1
    else:
      b[strings] = 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):
N = int(input())

SS = []
for i in range(N):
  s = list(input())
  s.sort()
  SS.append(s)
  
SS.sort()

ans = 0
prev = None
cnt = 0
for i in range(N):
  s = SS[i]
  if s == prev:
    if not cnt:
      cnt = 2
    else:
      cnt += 1
  else:
    ans += cnt
    cnt = 0
  prev = s
  
ans += cnt
print(ans)
  


from collections import Counter
N = int(input())

SS = []
for i in range(N):
  s = list(input())
  s.sort()
  SS.append(s)
  
SS.sort()

ans = 0
prev = None
for i in range(N):
  s = S[i]
  if s == prev:
    ans += 1
  prev = s
  
print(ans)
  

from collections import Counter
N = int(input())
SS = [input() for _ in range(N)]

STR_IN_S = [[[] for _ in range(11)] for _ in range(26)]

for i in range(N):
  S = SS[i]
  c = Counter(S)
  for j in range(26):
    s = chr(97+j)
    STR_IN_S[j][c[s]].append(i)
    
SAME = [set(range(N)) for _ in range(N)]

for i in range(26):
  for j in range(11):
    l = STR_IN_S[i][j]
    for x in l:
      SAME[x] &= l
  
ans = 0
for i in range(N):
  ans += len(SAME[i]) - 1
  
print(ans)

from collections import Counter
N = int(input())
SS = [input() for _ in range(N)]

STR_IN_S = [[[] for _ in range(11)] for _ in range(26)]

for i in range(N):
  S = SS[i]
  c = Counter(S)
  for j in range(26):
    s = chr(97+j)
    STR_IN_S[j][c[s]].append(i)
    
SAME = [set(range(N)) for _ in range(N)]

for i in range(26):
  for j in range(11):
    l = STR_IN_S[i][j]
	nl = set(l)
    for x in l:
      SAME[x] &= nl
  
ans = 0
for i in range(N):
  ans += len(SAME[i]) - 1
  
print(ans)


from collections import Counter
N = int(input())
SS = [input() for _ in range(N)]

STR_IN_S = [[[] for _ in range(11)] for _ in range(26)]

for i in range(N):
  S = SS[i]
  c = Counter(S)
  for j in range(26):
    s = chr(97+j)
    STR_IN_S[j][c[s]].append(i)
    
SAME = [set(range(N)) for _ in range(N)]

for i in range(26):
  for j in range(11):
    l = STR_IN_S[i][j]
    nl = set(l)
    for x in l:
      SAME[x] &= nl
  
ans = 0
for i in range(N):
  ans += len(SAME[i]) - 1
  
print(ans)


from collections import defaultdict
N = int(input())

SS = []
for i in range(N):
  s = list(input())
  s.sort()
  SS.append(s)
  
SS.sort()


ans = 0
cnt = defaultdict(int)
for i in range(N):
  s = SS[i]
  s = ''.join(s)
  cnt[s] += 1
  
for _,v in cnt.items():
  ans += v * (v - 1) // 2
  
print(ans)
  


Verdicts: Wrong Answer

Runtime Error

Runtime Error

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

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

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

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
  else:
    count += A_unique_count * (A_unique_count -1) /2
#    print('i' + str(i))
#    print(count)
    A_unique_count = 1

count += A_unique_count * (A_unique_count -1) /2
print(int(count))
  

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):
counter={}
ans=0
for i in range(n):
	ss = sorted(s[i])
	ss=("").join(ss)
	if ss not in counter:
		counter[ss]=0
	else:
		counter[ss]+=1
		ans+=counter[ss]

print(ans)

n=int(input())
s=[]
for _ in range(n):
	s.append(str(input()))

counter={}
ans=0
for i in range(n):
	ss = sorted(s[i])
	ss=("").join(ss)
	if ss not in counter:
		counter[ss]=0
	else:
		counter[ss]+=counter[ss]+1
print(counter)
for k,v in counter.items():
	if v>0:
		ans+=v
print(ans)

n=int(input())
s=[]
for _ in range(n):
	s.append(str(input()))

counter={}
ans=0
for i in range(n):
	ss = sorted(s[i])
	ss=("").join(ss)
	if ss not in counter:
		counter[ss]=0
	else:
		counter[ss]+=1
		ans+=counter[ss]

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):
import itertools
import collections
 
n = int(input())
lists = [str(input()) for i in range(n)]
 
lists2 = ["".join(sorted(i)) for i in lists]
l = collections.Counter(lists2)
c = l.values()
 
print(sum([i * (i - 1)/ 2 for i in c]))

import collections

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

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

import collections

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

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

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):
n = int(input())
ans = 0
s = []
cnt = []
for i in range(n):
  s_ = list(str(input()))
  s_.sort()
  if s_ in s:
    cnt[s.index(s_)] += 1
  else:
    s.append(s_)
    cnt.append(1)

print(sum(cnt))

n = int(input())
s = list(ranege(n))
for i in range(n):
  s[i] = list(str(input()))
  s[i].sort()

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

n = int(input())
ans = 0
s = []
cnt = []
for i in range(n):
  s_ = list(str(input()))
  s_.sort()
  if s_ in s:
    cnt[s.index(s_)] += 1
  else:
    s.append(s_)
    cnt.appned(1)

print(sum(cnt))

n = int(input())
s = []
cnt = {}
ans = 0
for i in range(n):
  s_ = list(str(input()))
  s_.sort()
  if s_ in s:
    ans += cnt[s_]
    cnt[s_] += 1
  else:
    s.append(s_)
    cnt[s_] = 1

print(ans)


n = int(input())
s = []
cnt = {}
ans = 0
for i in range(n):
  s_ = list(str(input()))
  s_.sort()
  s_ = "".join(s_)
  if s_ in cnt:
    ans += cnt[s_]
    cnt[s_] += 1
  else:
    cnt[s_] = 1

print(ans)

Verdicts: Wrong Answer

Runtime Error

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):
from collections import Counter,defaultdict
import math

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

N = int(input())
A = defaultdict(int)
for _ in range(N):
    c = Counter(list(input()))
    d = sorted(c.items(),key= lambda x:x[0])
    A[tuple(d)] += 1

SUM = 0
for v in A.values():
    SUM += combinations_count(v,2)

print(SUM)

from collections import Counter,defaultdict
import math

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

N = int(input())
A = defaultdict(int)
for _ in range(N):
    c = Counter(list(input()))
    d = sorted(c.items(),key= lambda x:x[0])
    A[tuple(d)] += 1

SUM = 0
for v in A.values():
    if v > 1:
        SUM += combinations_count(v,2)

print(SUM)

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())
d = dict()
for i in range(n):
  S = ''.join(sorted(list(input())))
  if S in d.keys():
    d[S] +=1
  else:
    d[S] = 1

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

n = input()
s = [''.join(sorted(input())) for i in range(n)]
count = 0
for i in range(n):
  for j in range(i+1,n):
    if s[j][0]==s[i][0]:
      count+=1
print(count)

from collections import Counter
n = input()
s = [''.join(list(input()).sort()) for i in range(n)]
d = Counter(s)
count = 0
for i in d.values():
  if i !=1:
    count+=i
print(count)

n = int(input())
d = dict()
for i in range(n):
  s = input()
  S = ''.join(sorted(list(s)))
  if S in d.keys():
    d[S] +=1
  else:
    d[S] = 1
 
ans = 0
for i in d.values():
  ans += n*(n-1)//2
print(ans)

from collections import Counter
n = input()
s = [list(input()).sort() for i in range(n)]
d = Counter(s)
count = 0
for i in d.values():
  if i !=1:
    count+=i
print(count)

n = input()
s = [''.join(sorted(input())) for i in range(n)]
count = 0
for i in range(n):
  for j in range(i+1,n):
    if s[j]==s[i]:
      count+=1
print(count)

from collections import Counter
n = input()
s = [''.join(sorted(input())) for i in range(n)]
d = Counter(s)
count = 0
for i in d.values():
  if i !=1:
    count+=i
print(count)

from collections import Counter
n = input()
s = [list(input()).sort() for i in range(n)]
d = {a: len(a) for a in s}
count = 0
for i in d.values():
  if i !=1:
    count+=i
print(count)

n = int(input())
d = dict()
for i in range(n):
  S = ''.join(sorted(list(input())))
  if S in d.keys():
    d[S] +=1
  else:
    d[S] = 1
 
ans = 0
for i in d.values():
  ans += i*(i-1)//2
print(ans)

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

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

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

def main(): 
    n = int(input())
    s = [''.join(sorted(input())) for _ in range(n)]
    ans = 0
    dic = {}
    for si in s:
        if si in dic:
            ans += dic[si]
            dic[si] += 1
        else:
            dic[si] = 1
    print(ans)


if __name__ == "__main__":
    main() 

Verdicts: Wrong Answer

Wrong Answer

Accepted