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
def list_difference(list1, list2):
    result = list1.copy()
    for value in list2:
        if value in result:
            result.remove(value)

    return len(result)


#n=int(input())

count=0
a=list(itertools.combinations(a,2))
for i in range(len(a)):
    if list_difference(a[i][0],a[i][1])==0:
        count+=1
print(count)

n=int(input())
a=[list(input()) for i in range(n)]
count=0
for i in range(len(a)):
    for j in range(i+1,len(a)):
        p=[col for col  in a[i] if col not in a[j]]
        if len(lst)==0:
            count+=1
print(count)

import itertools
def list_difference(list1, list2):
    result = list1.copy()
    for value in list2:
        if value in result:
            result.remove(value)

    return len(result)


n=int(input())
a=[list(input()) for i in range(n)]
count=0
a=list(itertools.permutations(a))
for i in len(a):
    if list_difference(a[i][0],a[i][1])==0:
        count+=1
print(count)

n=int(input())
a=[list(input()) for i in range(n)]
count=0
for i in range(len(a)):
    for j in range(i+1,len(a)):
        if intersect_list(a[i],a[j])==len(col):
            count+=1
print(count)

n=int(input())
a=[list(input()) for i in range(n)]
count=0
for i in range(len(a)):
    for j in range(i+1,len(a)):
        for element in a[j]:
             try:
                    a[i].remove(element)
                    if len(a[i])==0:
                        count+=1
print(count)

n=int(input())
a=[list(input()) for i in range(n)]
b=[str(sorted(list(i))) for i in a]
count=list(collections.Counter(b).values())
count=[i for i in count if i>1]
print(int(sum([math.factorial(x)/(math.factorial(x-2)*2) for x in count])))

import itertools
def list_difference(list1, list2):
    result = list1.copy()
    for value in list2:
        if value in result:
            result.remove(value)

    return len(result)


#n=int(input())

count=0
a=list(itertools.permutations(a))
for i in range(len(a[1])):
    if list_difference(a[i][0],a[i][1])==0:
        count+=1
print(count)

n=int(input())
string_list=[input() for i in range(n)]
b=[i.sort() for i in strint_list]
g=0
for i  in b:
    g+=(l.count(i)-1)
print(int(g*0.5))

n=int(input())
a=[input() for i in range(n)]
a=list(map(lambda x:list(x),a))
count=0
for i in range(len(a)):
    for j in range(i+1,len(a)):
        if intersect_list(a[i],a[j])==len(col):
            count+=1
print(count)

def intersect_list(lst1, lst2):
    arr = []
    lst = lst1.copy()
    for element in lst2:
        try:
            lst.remove(element)
        except ValueError:
            pass
        else:
            arr.append(element)
    return len(arr)

n=int(input())
a=[input() for i in range(n)]
a=list(map(lambda x:list(x),a))
count=0
for i in range(len(a)):
    for j in range(i+1,len(a)):
        if intersect_list(a[i],a[j])==len(len(a[i])):
            count+=1
print(count)

count=0
for i in range(len(a)):
    for j in range(i+1,len(a)):
        lst = a[i].copy()
        for element in a[j]:
            try:
                lst.remove(element)
            except ValueError:
                pass
        if len(lst)==0:
            count+=1
print(count)

n = int(stdin.readline().rstrip())
a= [stdin.readline().rstrip().split() for _ in range(n)]
count=0
for i in range(len(a)):
    for j in range(i+1,len(a)):
        if intersect_list(a[i],a[j])==len(col):
            count+=1
print(count)

n = int(stdin.readline().rstrip())
a= [stdin.readline().rstrip() for _ in range(n)]
count=0
for i in range(len(a)):
    for j in range(i+1,len(a)):
        if intersect_list(a[i],a[j])==len(col):
            count+=1
print(count)

import math
import collections

n=int(input())
a=[list(input()) for i in range(n)]
b=[str(sorted(list(i))) for i in a]
count=list(collections.Counter(b).values())
count=[i for i in count if i>1]
print(int(sum([math.factorial(x)/(math.factorial(x-2)*2) for x in count])))


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted