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 collections

n=int(input())
a=[''.join(sorted(input())) for _ in range(n)]
 
print(a)

ans = 0
for v in collections.Counter(a).values():
    if v != 1:
        ans += v - 1
print(ans)

import sys

a = []
for l in sys.stdin:
    if l == '\n':
        break
    else :
        a.append(l)

target = a[int(a[0])]

outNum = []
i1 = 0
for item in a:
    if i1 != 0:
        for i in range(0, len(target) - 1):
            flag = False
            if target.count(target[i]) == item.count(target[i]):
                flag = True
            else:
                break
        if flag:
            outNum.append(item)
    i1 = i1 + 1
    flag = False
print(len(outNum))      




import sys

a = []
for l in sys.stdin:
    if l == '\n':
        break
    else :
        a.append(l)

target = a[int(a[0])]
num = 0
for i in range(1, len(a) - 1):
    for j in range(i + 1, len(a)):
        flag = False
        iStrSorted = ''.join(sorted(a[i]))
        jStrSorted = ''.join(sorted(a[j]))]
        if iStrSorted==jStrSorted:
            flag = True
        else:
            flag = False
        if flag:
            num = num + 1
print(num)

import sys
 
a = []
for l in sys.stdin:
    if l == '\n' or l == '\r' or l == '\r\n':
        break
    else :
        a.append(l)
 
target = a[int(a[0])]
num = 0

sortedA = []

for i in a:
    sortedA.append(''.join(sorted(a[i])))
sortedA.pop(0)

for i in range(1, len(a) - 1):
    for j in range(i + 1, len(a)):
        flag = False
        if sortedA[i]==sortedA[j]:
            flag = True
        else:
            flag = False
        if flag:
            num = num + 1
print(num)

import sys

a = []
for l in sys.stdin:
    if l == '\n':
        break
    else :
        a.append(l)

target = a[int(a[0])]
print(target)

outNum = []
i1 = 0
for item in range(0, int(a[0]) - 1):
    if i1 != 0:
        for i in range(0, len(target) - 1):
            flag = False
            if target.count(target[i]) == item.count(target[i]):
                print(item)
                flag = True
            else:
                break
        if flag:
            outNum.append(item)
    i1 = i1 + 1
    flag = False
print(len(outNum))      



import sys

a = []
for l in sys.stdin:
    if l == '\n':
        break
    else :
        a.append(l)

target = a[int(a[0])]

outNum = []
i1 = 0
for item in a:
    if i1 != 0:
        for i in range(0, len(target) - 1):
            flag = False
            if target.count(target[i]) == item.count(item[i]):
                flag = True
            else:
                break
        if flag:
            outNum.append(item)
    i1 = i1 + 1
    flag = False
print(outNum)      



import sys

a = []
for l in sys.stdin:
    if l == '\n':
        break
    else :
        a.append(l)

target = a[int(a[0])]
print(target)

outNum = []
i1 = 0
for item in a:
    if i1 != 0:
        for i in range(0, len(target) - 1):
            flag = False
            if target.count(target[i]) == item.count(target[i]):
                print(item)
                flag = True
            else:
                break
        if flag:
            outNum.append(item)
    i1 = i1 + 1
    flag = False
print(len(outNum))      



import sys

a = []
for l in sys.stdin:
    if l == '\n':
        break
    else :
        a.append(l)

target = a[int(a[0])]
num = 0
for i in range(1, len(a) - 1):
    for j in range(i + 1, len(a)):
        flag = False
        iStrSorted = ''.join(sorted(a[i]))
        print(iStrSorted)
        jStrSorted = ''.join(sorted(a[j]))
        print(jStrSorted)
        if iStrSorted==jStrSorted:
            flag = True
        else:
            flag = False
        if flag:
            num = num + 1
print(num)

import math

import sys
import collections

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

ans = 0
for v in collections.Counter(a).values():
    for i in range(1, v):
        ans += i
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Accepted