Problem p02947 (python)

Fixed submission:
n = int(input())
strdict = {}
count = 0
for i in range(n):
    sortedstr = "".join(sorted(str(input())))
    strdict.setdefault(sortedstr, 0)
    count += strdict[sortedstr]
    strdict[sortedstr] += 1
print(count)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from math import factorial
 
n = int(input())
strlist = []
for i in range(n):
    strlist.append(sorted(str(input())))
strlist.sort()

allcount = 0
while (len(strlist) > 1):
    count = 1
    while True:
        if(len(strlist) > 1):
            if(strlist[-1] == strlist[-2]):
                count += 1
                strlist.pop()
            else:
                strlist.pop()
                if(count > 1):
                    allcount += int(factorial(count) / factorial(2) / factorial(count-2))
                break
        else:
            strlist.pop()
            if(count > 1):
                allcount += int(factorial(count) / factorial(2) / factorial(count-2))
            break
print(allcount)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from math import factorial
 
n = int(input())
strlist = []
for i in range(n):
    strlist.append(sorted(str(input())))
strlist.sort()

allcount = 0
while (len(strlist) > 0):
    count = 1
    while (len(strlist) > 0):
        if(len(strlist) > 1):
            if(strlist[-1] == strlist[-2]):
                count += 1
                strlist.pop()
            else:
                strlist.pop()
                if(count > 1):
                    allcount += int(factorial(count) / factorial(2) / factorial(count-2))
                break
        else:
            strlist.pop()
            if(count > 1):
                allcount += int(factorial(count) / factorial(2) / factorial(count-2))
            break
print(allcount)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from math import factorial
 
n = int(input())
strlist = []
for i in range(n):
    strlist.append(sorted(str(input())))
strlist.sort()

allcount = 0
while (len(strlist) > 0):
    count = 1
    while (len(strlist) > 0):
        if(len(strlist) > 1 and strlist[-1] == strlist[-2]):
            count += 1
            strlist.pop()
        else:
            strlist.pop()
            if(count > 1):
                allcount += int(factorial(count) / factorial(2) / factorial(count-2))
            break
print(allcount)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from math import factorial
 
n = int(input())
strlist = []
for i in range(n):
    strlist.append(sorted(str(input())))
strlist.sort()

allcount = 0
while (len(strlist) > 1):
    count = 1
    while (len(strlist) > 0):
        if(len(strlist) > 1 and strlist[-1] == strlist[-2]):
            count += 1
            strlist.pop()
        else:
            strlist.pop()
            if(count > 1):
                allcount += int(factorial(count) / factorial(2) / factorial(count-2))
            break
print(allcount)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from math import factorial

n = int(input())
strlist = []
for i in range(n):
    strlist.append(sorted(list(str(input()))))

allcount = 0
while (len(strlist) > 1):
    i = 1
    count = 1
    while True:
        if(strlist[0] == strlist[i]):
            count += 1
            strlist.pop(i)
        else:
            i += 1
        if(i==len(strlist)):
            if(count > 1):
                allcount += int(factorial(count) / factorial(2) / factorial(count-2))
            break
    strlist.pop(0)
print(allcount)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from math import factorial

n = int(input())
strlist = []
for i in range(n):
    strlist.append(set(str(input())))

allcount = 0
while (len(strlist) > 1):
    i = 1
    count = 1
    while True:
        if(strlist[0] == strlist[i]):
            count += 1
            strlist.pop(i)
        else:
            i += 1
        if(i==len(strlist)):
            if(count > 1):
                allcount += int(factorial(count) / factorial(2) / factorial(count-2))
            break
    strlist.pop(0)
print(allcount)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from math import factorial

n = int(input())
strlist = []
for i in range(n):
    strlist.append(list(str(input())))

allcount = 0
while (len(strlist) > 1):
    i = 1
    count = 1
    while True:
        if(set(strlist[0]) == set(strlist[i])):
            count += 1
            strlist.pop(i)
        else:
            i += 1
        if(i==len(strlist)):
            if(count > 1):
                allcount += int(factorial(count) / factorial(2) / factorial(count-2))
            break
    strlist.pop(0)
print(allcount)