ZhenlongDai/ACPR huggingface dataset:
Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math

n = int(input())
s = [0]*n
ans = {}
ans_v = 0

for i in range(n):
    s[i] = "".join(sorted(list(input())))
    
s_set = set(s)

for i in s_set:
    ans[i] = 0
    
for i in s:
    ans[i] += 1

for j in ans.values():
    if j >= 2:
        ans_v += math.factorial(j) /( (math.factorial(j - 2)* math.factorial(2)))
    
print(ans_v)

Failing test case input:
5
abaaaaaaaa
oweplustno
aaaaaaaaba
twoplusone
aaaabaaaaa

Expected output:
4


Actual output:
4.0


Fixed submission (verdict: Accepted):
import math

n = int(input())
s = [0]*n
ans = {}
ans_v = 0

for i in range(n):
    s[i] = "".join(sorted(list(input())))
    
s_set = set(s)

for i in s_set:
    ans[i] = 0
    
for i in s:
    ans[i] += 1

for j in ans.values():
    if j >= 2:
        ans_v += math.factorial(j) /( (math.factorial(j - 2)* math.factorial(2)))
    
print(int(ans_v))

Problem: p02947
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
from math import *
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

n = ni()
li = []
ct = 0
su = 0
alpha2num = lambda c: ord(c) - ord('a') + 1
for i in range(n):
    su = 0
    
    s = input()
    for c in s:
        su += alpha2num(c)
    li.append(su)
for i in range(n):
    for j in range(i+1, n):
        if li[i] == li[j]:
            ct += 1
print(ct)





Failing test case input:
5
aaab`_aaba
oweplustmo
abaabbaaaa
unoselpows
baab`bb`ba

Expected output:
0


Actual output:
2


Fixed submission (verdict: Accepted):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

n = ni()
li = []
ct = 0
su = 0
alpha2num = lambda c: ord(c) - ord('a') + 1
for i in range(n):
    su = 0
    li.append("".join(sorted(input())))

lll= 1
list.sort(li)
li.append("a")
for i in range(n):

    if li[i] == li[i+1]:
        lll += 1
    else:
        if lll != 1:
            for j in range(1, lll):
                ct += j
        lll = 1
print(ct)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections
n = int(input())
s = [list(input()) for i in range(n)]
l = [''.join(sorted(i)) for i in s]
c = list(collections.Counter(l).values())
x = sum([i for i in c if i != 1])
print(x - 1) if 0 < x else print(x)


Failing test case input:
5
abaaaaaaaa
oweplustmo
aaaaaaaaba
unoselpowt
aaaaaaaaba

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import collections
n = int(input())
s = [list(input()) for i in range(n)]
l = [''.join(sorted(i)) for i in s]
c = list(collections.Counter(l).values())
x = sum([sum([i for i in range(i)]) for i in c if i != 1])
print(x) if 0 < x else print(x)
Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())

string=list()
for i in range(N):
  c=list(input())
  c.sort()
 
  string.append(''.join(c))
  


count=0
M=N
for j in range(N):
  c=string.count(string[j])
  string.remove(string[j])
  M=M-c
  count=count +int(c*(c-1)/2)
  if j+1>M-1:
    break
  
print(count)
  

Failing test case input:
5
abaaaaaaaa
oweplustmo
aaaaaaaaba
unoselpowt
aaaaaaaaba

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
import collections
N=int(input())

string=list()
for i in range(N):
  c=list(input())
  c.sort()
 
  string.append(''.join(c))
  


a=collections.Counter(string)
b=list(a.values())

count=0
for j in range(len(b)):
  count=count +int(b[j]*(b[j]-1)/2)
  
print(count)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
d = {}
ans = 0

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

for k, v in d.items():
    if v != 1:
      print(v)
      ans += v * (v - 1) / 2

print(int(ans))



Failing test case input:
3
acornistnt
bmnbtuoaep
nonstraict

Expected output:
1


Actual output:
2
1


Fixed submission (verdict: Accepted):
n = int(input())
d = {}
ans = 0

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

for k, v in d.items():
  ans += v * (v - 1) / 2

print(int(ans))

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
dict={}

for i in range(n):
  a=input()
  newa="".join(sorted(a))
  dict[newa]=dict.get(newa,0)+1

ans=0

for i in dict:
  ans+=dict[i]*(dict[i]-1)/2

print(ans)

Failing test case input:
5
aaaaaaaaba
oweplustmo
aaaaaaaaba
unoselpowt
aaaaaaaaba

Expected output:
3


Actual output:
3.0


Fixed submission (verdict: Accepted):
n=int(input())
dict={}

for i in range(n):
  a=input()
  newa="".join(sorted(a))
  dict[newa]=dict.get(newa,0)+1

ans=0

for i in dict:
  ans+=dict[i]*(dict[i]-1)/2

print(int(ans))
Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
inlist = []
for i in range(N):
  inputst = input()
  inputstlist = list(inputst)
  inputstlist.sort()
  inlist.append(inputstlist)
inlist.sort()
count=0
for i in range(N):
  skip=0
  for j in range(i+1,N):
    flag1=0
    for k in range(10):
      if inlist[i][k]==inlist[j][k]:
        pass
      else:
        flag1=1
        break
    if flag1==0:
      count+=1
      skip+=1
    else:
      if skip>=1:
        i=i+skip
        count+=((skip-1)+1)*(skip-1)/2
      break
print(count)   

Failing test case input:
5
abaaaaaaaa
oweplustno
aaaaaaaaba
enosulpowt
aaaaaaaaba

Expected output:
4


Actual output:
5.0


Fixed submission (verdict: Accepted):
N = int(input())
inlist = []
for i in range(N):
  inputst = input()
  inputstlist = list(inputst)
  inputstlist.sort()
  inlist.append(inputstlist)
inlist.sort()
count=0
i=0
while i<N:
  skip=0
  for j in range(i+1,N):
    flag1=0
    for k in range(10):
      if inlist[i][k]!=inlist[j][k]:
        flag1=1
        break
    if flag1==0:
      count+=1
      skip+=1
    else:
      break
  if skip>=1:
    i=i+skip
    count+=int(((skip-1)+1)*(skip-1)/2)
  else:
    i+=1
print(count)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = [str(input()) for i in range(n)]

ss = [''.join(sorted(i)) for i in s]
ans = 0
key_dict = {}

for i in ss:
    if i in key_dict:
        key_dict[i] += 1
    else:
        key_dict[i] = 1

a = key_dict.values()
al = [i * (i-1) / 2 if i > 1 else 0 for i in a]

ans = sum(al)
print(ans)

Failing test case input:
3
acornistnt
peaoutbnmb
nonstraict

Expected output:
1


Actual output:
1.0


Fixed submission (verdict: Accepted):
n = int(input())
s = [str(input()) for i in range(n)]

ss = [''.join(sorted(i)) for i in s]
ans = 0
key_dict = {}

for i in ss:
    if i in key_dict:
        key_dict[i] += 1
    else:
        key_dict[i] = 1

a = key_dict.values()
al = [i * (i-1) / 2 if i > 1 else 0 for i in a]

ans = int(sum(al))
print(ans)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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() 

Failing test case input:
3
acornistns
peaoutbnmb
nonsuraict

Expected output:
0


Actual output:
[['a', 'c', 'i', 'n', 'n', 'o', 'r', 's', 's', 't'], ['a', 'b', 'b', 'e', 'm', 'n', 'o', 'p', 't', 'u'], ['a', 'c', 'i', 'n', 'n', 'o', 'r', 's', 't', 'u']]
0


Fixed submission (verdict: Accepted):
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()
Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
s = [''.join(sorted(input())) for _ in range(N)]
k = 0
for i in range(N - 1) :
    for k in range(i + 1, N) :
        if s[i] == s[k] :
            k += 1
print(k)


Failing test case input:
5
abaaaaaaaa
oweplustmo
aaaaaaaaba
unoselpowt
aaaaaaaaba

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
N = int(input())
s = [''.join(sorted(input())) for _ in range(N)]

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

Problem: p02947
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
o = [0]*251
ans = 0
for i in range(n):
    s = input()
    ind = 0
    for j in range(10):
        ind += (ord(s[j])-97)
    if o[ind] != 0:
        ans += o[ind]
    o[ind] += 1

print(ans)

Failing test case input:
5
a_abaaa`ba
umtsolpewo
acaabbaaaa
unoselpows
baab`ababb

Expected output:
0


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
dic = dict()
ans = 0
for i in range(n):
    s = list(input())
    s.sort()
    s = ''.join(s)
    if s in dic:
        ans += dic[s]
        dic[s] += 1
    else:
        dic[s] = 1
print(ans)

Problem: p02947
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
S_counter = Counter(S)
ans = 0
for i in S_counter.values():
    if i > 1:
        ans += (i-1)*i/2
print(int(ans))

Failing test case input:
5
abaaaaaaaa
oweplustno
aaaaaaaaba
twoplusone
aaaabaaaaa

Expected output:
4


Actual output:
0


Fixed submission (verdict: Accepted):
from collections import Counter
N = int(input())
S = ["".join(sorted(input())) for _ in range(N)]
S_counter = Counter(S)
ans = 0
for i in S_counter.values():
    if i > 1:
        ans += (i-1)*i/2
print(int(ans))

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N= int(input())
s = []

for _ in range(N):
    s.append(input())

for i in range(N):
    s[i] = sorted(s[i])

counter = 0
for i in range(N):
    for j in range((i+1), N):
        if s[i] == s[j:N]:
            counter += 1

print(counter) 

Failing test case input:
3
acornistnt
bmnbtuoaep
nonstraict

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
N= int(input())
s = []

for _ in range(N):
    s.append(input())

for i in range(N):
    s[i] = tuple(sorted(s[i]))

import collections
c = collections.Counter(s)
d = [i for i in c.values()]

counter = 0
from math import factorial
for i in d:
    if i > 1:
        counter += i*(i-1)/2

print(int(counter))
Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = [''.join(sorted(list(input()))) for _ in range(N)]

from collections import Counter
a=Counter(S)

ans = 0

for i in a.values():
    if i>1:
        ans += i*(i-1)/2

print(ans)

Failing test case input:
5
aaaaa`aaba
oweplustmo
aaaaabaaba
unoselpowt
aaaa`aaaba

Expected output:
1


Actual output:
1.0


Fixed submission (verdict: Accepted):
N = int(input())
S = [''.join(sorted(list(input()))) for _ in range(N)]

from collections import Counter
a=Counter(S)

ans = 0

for i in a.values():
    if i>1:
        ans += i*(i-1)/2

print(int(ans))

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = [input() for _ in range(n)]
existed = {}
for i in range(n):
  sorted_s = ''.join(sorted(s[i]))
  num = existed.get(sorted_s, 0)
  existed[sorted_s] = num*2 if num != 0 else 1
cnt = 0
for k, v in existed.items():
  cnt += v
print(cnt-2)

Failing test case input:
3
rmusisnoca
odbbutqlmb
sagcttrnon

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
s = [input() for _ in range(n)]
existed = {}
cnt = 0
for i in range(n):
  sorted_s = ''.join(sorted(s[i]))
  if sorted_s in existed:
    cnt += existed[sorted_s]
    existed[sorted_s] += 1
  else:
    existed[sorted_s] = 1
print(cnt)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections
from math import factorial
A = int(input())
listA = []
total = 0
listB = {}
for i in range(A):
    B = list(input())
    B.sort()
    listA.append("".join(B))
for i in listA:
    if i in listB:
        listB[i] += 1
    else:
        listB[i] = 1
listC = listB.values()
listC = [i for i in listC if i > 1]
for i in listC:
    total += factorial(i) 
print(total)

Failing test case input:
5
aaaaa`aaba
oweplustmo
aaaaabaaba
unoselpowt
abaaa`aaaa

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
import collections
from math import factorial
A = int(input())
listA = []
total = 0
listB = {}
for i in range(A):
    B = list(input())
    B.sort()
    listA.append("".join(B))
for i in listA:
    if i in listB:
        listB[i] += 1
        total += listB[i]-1
    else:
        listB[i] = 1
print(total)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
2
onepltsuwo
nxofiodsim

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
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))
Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
s=[''.join(sorted(input())) for i in range(n)]
an=[]
count=0
for i in range(n):
    if s[i] not in an:
        an.append(s[i])
    else:
        count+=1
print(count)

Failing test case input:
5
abaaaaaaaa
oweplustno
aaaaaaaaba
unoselpowt
aaaaaaaaba

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
n=int(input())
s=[''.join(sorted(input())) for i in range(n)]
an={}
count=0
for i in range(n):
    if s[i] not in an:
        an[s[i]]=1
    else:
        an[s[i]]+=1
        count+=an[s[i]]-1
print(count)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
n = int(input())
word_l = list()
for _ in range(n):
  word = ''.join(sorted(list(input())))
  word_l.append(word)
  
word_counter = Counter(word_l)
print('{}'.format(sum(word_counter.values()) - len(word_counter)))

Failing test case input:
5
abaaaaaaaa
oweplustmo
aaaaaaaaba
unoselpowt
aaaaaaaaba

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
from collections import Counter
n = int(input())
word_l = list()
for _ in range(n):
  word = ''.join(sorted(list(input())))
  word_l.append(word)
  
word_counter = Counter(word_l)
print('{}'.format(sum(map(lambda x: sum(range(x)), word_counter.values()))))

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
N = int(input())
S = [input() for i in range(N)]
ctr = Counter()
answer = 0
for s in S:
    a = ''.join(sorted(list(s)))
    print(a)
    if a in ctr:
        answer += ctr[a]
    ctr[a] += 1
print(answer)

Failing test case input:
3
snusinroca
pdboutbnmb
nonsurahct

Expected output:
0


Actual output:
acinnorssu
bbbdmnoptu
achnnorstu
0


Fixed submission (verdict: Accepted):
from collections import Counter
N = int(input())
S = [input() for i in range(N)]
ctr = Counter()
answer = 0
for s in S:
    a = ''.join(sorted(list(s)))
    
    if a in ctr:
        answer += ctr[a]
    ctr[a] += 1
print(answer)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = []
for i in range(n):
    s.append(sorted(list(input())))
cnt_ans = 0
s.sort()

while len(s):
    cnt = 0
    for i in range(1, len(s)):
        if s[0] == s[i]:
            cnt += 1
        else:
            break
    cnt = int((cnt+1) * (cnt) / 2)
    cnt_ans += cnt
    s = s[cnt+1:]
print(cnt_ans)

Failing test case input:
5
abaaaaaaaa
oweplustno
aaaaaaaaba
enosulpowt
aaaaaaaaba

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
s = []
for i in range(n):
    s.append(sorted(list(input())))
cnt_ans = 0
s.sort()
cnt = 0
left = 0
right = 1
while right <= n-1:
    if s[left] == s[right]:
        right += 1
        cnt += 1
    else:
        left, right = right, right+1
        cnt_ans += ((cnt+1)*cnt
        cnt = 0
    if right == n:
        cnt_ans += ((cnt+1)*cnt
print(cnt_ans)
Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = []
for i in range(N):
    S.append(input())
anaglams = {}
count = 0
for s in S:
    chrs = [0]*26
    for c in s:
        if c not in chrs:
            index = ord(c) - ord('a')
            chrs[index] = 1
            continue
        chrs[c] += 1
    if str(chrs) not in anaglams:
        anaglams[str(chrs)] = 0
    else:
        anaglams[str(chrs)] += 1
    count += anaglams[str(chrs)]
print(count)

Failing test case input:
5
aaaaa`aaba
oweplustmo
aaaaabaaba
unoselpowt
aaaaaaaaba

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())
S = []
for i in range(N):
    S.append(input())
anaglams = {}
count = 0
for s in S:
    chrs = [0]*26
    for c in s:
        index = ord(c) - ord('a')
        chrs[index] += 1
    if str(chrs) not in anaglams:
        anaglams[str(chrs)] = 0
    else:
        anaglams[str(chrs)] += 1
    count += anaglams[str(chrs)]
print(count)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)


Failing test case input:
2
oneplustwo
ninemodsix

Expected output:
0

Actual output:
1


Fixed submission (verdict: Accepted):
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)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from operator import itemgetter

n=int(input())
s=[]
li=[]
ans=0
cnt=1

for i in range(n):
  s.append(sorted(input()))
s.sort(key=itemgetter(9,0))
s=s+['']

for i in range(n):
  if s[i]==s[i+1]:
    cnt+=1
  elif cnt>1:
    li.append(int(cnt*(cnt-1)/2))
    cnt=1
  else:
    cnt=1
print(int(sum(li)))

Failing test case input:
5
aaaaaaaaba
oweplustmo
aaaaabaaba
unoselpowt
aaaaaaaaba

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
from operator import itemgetter

n=int(input())
s=[]
li=[]
ans=0
cnt=1

for i in range(n):
  s.append(sorted(input()))
s.sort(key=itemgetter(9,8,7,6,5,4,3,2,1,0))
s=s+['']

for i in range(n):
  if s[i]==s[i+1]:
    cnt+=1
  elif cnt>1:
    li.append(int(cnt*(cnt-1)/2))
    cnt=1
  else:
    cnt=1
print(int(sum(li)))

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections,functools
n=int(input())
texts=[''.join(sorted(input())) for i in range(n)]

c=collections.Counter(texts)
ans=functools.reduce(lambda x,y:x+y,c.values())
ans-=len(c)
print(ans)

Failing test case input:
5
aaaaaaaaba
oweplustmo
aaaaaaaaba
unoselpowt
aaaaaaaaba

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import collections,functools
n=int(input())
texts=[''.join(sorted(input())) for i in range(n)]

c=collections.Counter(texts)
ans=int(sum([i*(i-1)/2 for i in c.values()]))
print(ans)
Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter

def main():
    n = int(input())
    array_s = []
    array = []
    for i in range(n):
        array_s.append(input())

    for s in array_s:
        array.append(Counter(s))

    ans = 0
    for i in range(n):
        if not array:
            break
        alphabet = array[:][0]
        num = array.count(alphabet)-1
        if num <= 0:
            pass
        elif num <= 1:
            ans += 1
        else:
            ans += (num+1)*num/2
        for j in range(num+1):
            array.remove(alphabet)
    print(ans)


if __name__ == '__main__':
    main()


Failing test case input:
5
abaaaaaaaa
oweplustno
aaaaaaaaba
enosulpowt
aaaaaaaaba

Expected output:
4


Actual output:
4.0


Fixed submission (verdict: Accepted):
def main():
    n = int(input())
    array_s = []
    array = []
    for i in range(n):
        array_s.append(input())

    for s in array_s:
        array.append(''.join(sorted(s)))
    array = sorted(array)
    ans = 0
    count = 1
    for i in range(n-1):
        if array[i] == array[i+1]:
            count += 1
            if i != n-2:
                continue
        ans += int(count*(count-1)/2)
        count = 1
    print(ans)


if __name__ == '__main__':
    main()

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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() 

Failing test case input:
2
oofplnsvwt
oisdpizpfo

Expected output:
0


Actual output:
[['f', 'l', 'n', 'o', 'o', 'p', 's', 't', 'v', 'w'], ['d', 'f', 'i', 'i', 'o', 'o', 'p', 'p', 's', 'z']]
0


Fixed submission (verdict: Accepted):
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()
Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input()) 
inlist = [input() for i in range(N)] 
result = []


for component in inlist :
    dic = []
    for n in component:
        dic.append(n)
    dic.sort()
    dic2 = "".join(dic)
    result.append(dic2)
print(result)

counter = 0
for k1, v1 in enumerate(result):
    for k2, v2 in enumerate (result):
        if v1 == v2 and k1 > k2:
            counter += 1

print (counter)

Failing test case input:
5
aaaaa`aaba
oweplustmo
aaaaabaaba
unoselpowt
abaaa`aaaa

Expected output:
1


Actual output:
['`aaaaaaaab', 'elmoopstuw', 'aaaaaaaabb', 'elnoopstuw', '`aaaaaaaab']
1


Fixed submission (verdict: Accepted):
N = int(input()) 
inlist = [input() for i in range(N)] 
result = {}

def combination(a):
    x = 1
    x = a * (a-1) / 2
    return x


for component in inlist :
    dic = []
    for n in component:
        dic.append(n)
    dic.sort()
    dic2 = "".join(dic)
    if dic2 in result.keys():
        result[dic2] += 1
    else :
        result[dic2] = 1


counter = 0
for v in result.values():
    counter += combination(v)

print (int(counter))

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
n = int(input())
t = []
count = 0
for _ in range(n):
    s = input()
    c = Counter(s)
    if c in t:
        count += 1
    else:
        t.append(c)

print(count)

Failing test case input:
5
abaaaaaaaa
oweplustno
aaaaaaaaba
twoplusone
aaaabaaaaa

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
counter = 0
tmp = {}
for _ in range(n):
    s = str(sorted(input()))
    if s in tmp:
        counter += tmp[s]
        tmp[s] += 1
    else:
        tmp[s] = 1
print(counter)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

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

sm = sorted(ss)
c = 0
for i in range(n-1):
	if sm[i] == sm[i+1]:
		c += 1
print(c)

Failing test case input:
5
abaaaaaaaa
oneplustwo
aaaaaaaaba
twoplusone
aaaabaaaaa

Expected output:
4

Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())

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

sm = sorted(ss)
c = 0
ans = 0
for i in range(n-1):
	if sm[i] == sm[i+1]:
		c += 1
		ans += c
	else:
		c = 0
print(ans)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
cnt = 0
d = {}
for i in range(n):
  sortsi = ''.join(sorted(s[i]))
  
  if sortsi in d: cnt+=1
  else: d[sortsi]=1
print(cnt)

Failing test case input:
5
abaaaaaaaa
oweplustmo
aaaaaaaaba
unoselpowt
aaaaaaaaba

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
cnt = 0
d = {}
for i in range(n):
  sortsi = ''.join(sorted(s[i]))
  if sortsi in d:
    cnt+=d[sortsi]
    d[sortsi]+=1
  else: 
    d[sortsi]=1
print(cnt)
Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter

n = int(input())
s = []
for i in range(n):
    s.append(''.join(sorted(input())))
    
v = list(Counter(s).values())
ans = []
for i in range(len(v)):
    if v[i] >= 2:
        ans.append((v[i] * (v[i]-1))/2)

print(sum(ans))

Failing test case input:
3
acornistnt
bmnbtuoaep
nonstraict

Expected output:
1


Actual output:
1.0


Fixed submission (verdict: Accepted):
from collections import Counter

n = int(input())
s = []
for i in range(n):
    s.append(''.join(sorted(input())))
    
v = list(Counter(s).values())
ans = []
for i in range(len(v)):
    if v[i] >= 2:
        ans.append((v[i] * (v[i]-1))/2)

print(int(sum(ans)))

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import time

ans = 0
s = []
N = int(input())
for i in range(N):
	tmp = []
	string = input()
	for st in string:
		tmp.append(st)
	tmp.sort()
	if tmp in s:
		ans += 1
	else:
		s.append(tmp)
print(ans)

Failing test case input:
5
abaaaaaaaa
oweplustno
aaaaaaaaba
twoplusone
aaaaaaaaba

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
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)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
import collections
A = int(input())
listA = []
total = 0
listB = {}
for i in range(A):
    B = list(input())
    B.sort()
    listA.append("".join(B))
for i in listA:
    if i in listB:
        listB[i] += 1
    else:
        listB[i] = 1
for i in listB.values():
    if i > 1:
        total += math.factorial(i) 
print(total)

Failing test case input:
5
abaaaaaaaa
oweplustmo
aaaaaaaaba
unoselpowt
aaaaaaaaba

Expected output:
3


Actual output:
6


Fixed submission (verdict: Accepted):
import collections
from math import factorial
A = int(input())
listA = []
total = 0
listB = {}
for i in range(A):
    B = list(input())
    B.sort()
    listA.append("".join(B))
for i in listA:
    if i in listB:
        listB[i] += 1
        total += listB[i]-1
    else:
        listB[i] = 1
print(total)
Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = []

for i in range(N):
    s = input()
    S.append(''.join(sorted(s)))

S.sort()
count = 0
sw = 0
for i in range(1, len(S)):
    if S[i-1]==S[i]:
        sw = 1
        count += 1
    else:
        if sw==1:
            count += 1
            sw = 0

if sw==1:
    count += 1

print(count)

Failing test case input:
5
abaaaaaaaa
oneplustwo
aaaaaaaaba
twoplusone
aaaabaaaaa

Expected output:
4

Actual output:
5


Fixed submission (verdict: Accepted):
N = int(input())
S = []

for i in range(N):
    s = input()
    S.append(''.join(sorted(s)))

S.sort()
count = 0
sw = 0
series = []
for i in range(1, len(S)):
    if S[i-1]==S[i]:
        sw = 1
        count += 1
    else:
        if sw==1:
            count += 1
            series.append(count)
            count = 0
            sw = 0
if sw==1:
    count += 1
series.append(count)

count = int(sum([c * (c-1)/2 for c in series]))

print(count)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
s = [0]*N
p = [0]*N
for i in range(N):
    s[i] = "".join(sorted(input()))
    print(s)
    for j in range(i-1,-1,-1):
        if s[i] == s[j]:
            p[i] = p[j] + 1
            break

print(sum(p))

Failing test case input:
3
rlusisnoca
bmlqtubbdo
sagcttrnnn

Expected output:
0


Actual output:
['acilnorssu', 0, 0]
['acilnorssu', 'bbbdlmoqtu', 0]
['acilnorssu', 'bbbdlmoqtu', 'acgnnnrstt']
0


Fixed submission (verdict: Accepted):
N = int(input())
s = [0]*N
p = {}
ans = 0
for i in range(N):
    s[i] = "".join(sorted(input()))
    if s[i] in p:
        ans += p[s[i]]
        p[s[i]] += 1
    else:
        p[s[i]] = 1

print(ans)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
n = int(input())
l = [input() for _ in range(n)]
l = [sorted([j for j in i]) for i in l]
l = ["".join(i) for i in l]
al = list(set(l))
ans_dict = {}
ans = 0
for i in l:
    if i in ans_dict:
        ans += ans_dict[i]
        ans_dict[i]+=1
    else:
        ans_dict[i] = 1
    ans = 0

print(ans)

Failing test case input:
5
abaaaaaaaa
oweplustno
aaaaaaaaba
twoplusone
aaaaaaaaba

Expected output:
4


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
l = [input() for _ in range(n)]
l = [sorted([j for j in i]) for i in l]
l = ["".join(i) for i in l]
al = list(set(l))
ans_dict = {}
ans = 0
for i in l:
    if i in ans_dict:
        
        ans += ans_dict[i]
        ans_dict[i]+=1
    else:
        ans_dict[i] = 1

print(ans)
Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = [input() for i in range(N)]
d = {}
S_trans = [''.join(sorted(list(s))) for s in S]
print(S_trans)
count = 0
for s in S_trans:
  if s in d:
    count += d[s]
    d[s] += 1
  else:
    d[s] = 1
  
print(count)

Failing test case input:
5
aaaaa_aaba
oweplustmo
abaabaaaaa
unoselpows
ababa`baaa

Expected output:
0


Actual output:
['_aaaaaaaab', 'elmoopstuw', 'aaaaaaaabb', 'elnoopssuw', '`aaaaaabbb']
0


Fixed submission (verdict: Accepted):
N = int(input())
S = [input() for i in range(N)]
d = {}
S_trans = [''.join(sorted(list(s))) for s in S]
count = 0
for s in S_trans:
  if s in d:
    count += d[s]
    d[s] += 1
  else:
    d[s] = 1
print(count)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
n = int(input())
s = [input() for i in range(n)]

ans = 0
d = {}
for i in s:
    a = [c for c in i]
    a.sort()
    print(a)
    a = "".join(a)
    if a in d:
        print(d[a])
        ans+= d[a]
        d[a] +=1
    else:
        d[a] = 1
print(ans)


Failing test case input:
3
acornistnt
bmnbtuoaep
nonstraict

Expected output:
1


Actual output:
['a', 'c', 'i', 'n', 'n', 'o', 'r', 's', 't', 't']
['a', 'b', 'b', 'e', 'm', 'n', 'o', 'p', 't', 'u']
['a', 'c', 'i', 'n', 'n', 'o', 'r', 's', 't', 't']
1
1


Fixed submission (verdict: Accepted):
import sys
n = int(input())
s = [input() for i in range(n)]

ans = 0
d = {}
for i in s:
    a = [c for c in i]
    a.sort()
    a = "".join(a)
    if a in d:
        ans+= d[a]
        d[a] +=1
    else:
        d[a] = 1
print(ans)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

a = [input() for i in range(n)]

for i in range(n):
    a[i] = ''.join(sorted(a[i]))

a = sorted(a)

ans = 0
sum = 1
for i in range(n-1):
    if a[i] == a[i+1]:
        sum += 1
    else :
        ans += (sum*(sum-1))/2
        sum = 1

ans += (sum*(sum-1))/2
print(ans)

Failing test case input:
2
ooeplnsvxt
nfpyipdsim

Expected output:
0


Actual output:
0.0


Fixed submission (verdict: Accepted):
n = int(input())

a = [input() for i in range(n)]

for i in range(n):
    a[i] = ''.join(sorted(a[i]))

a = sorted(a)

ans = 0
sum = 1
for i in range(n-1):
    if a[i] == a[i+1]:
        sum += 1
    else :
        ans += (sum*(sum-1))/2
        sum = 1

ans += (sum*(sum-1))/2
print(int(ans))

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = list([input() for i in range(n)])
q = [''.join(sorted(x)) for x in s]

c = 0
c1 =  0
p = sorted(q)
for i in range(n-1):
	if p[i] == p[i+1]:
		c+=1
	else:
		if i != 0 or i == n-2:
			if p[i] == p[i-1] or i == n-2:			
				for j in range(c+1):
					c1+=j
		c=0



print(c1+1)

Failing test case input:
2
oteplnsuwo
nfpyiodsim

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
s = list([input() for i in range(n)])
q = [''.join(sorted(x)) for x in s]

c = 0
c1 =  0
p = sorted(q)
p.append("a")

for i in range(n):
	if p[i] == p[i+1]:
		c+=1
	else:
		
		if c>0:
			for j in range(c+1):
				c1+=j
				
		c=0
print(c1)
Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections

N = int(input())
list = [''.join(sorted(input())) for i in range(N)]

c = collections.Counter(list)
ans_list = c.most_common()
ans = [ans[1] for ans in ans_list if not ans[1]==1]
print(sum(ans))

Failing test case input:
5
abaaaaaaaa
oweplustno
aaaaaaaaba
twoplusone
aaaabaaaaa

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
import collections

N = int(input())
list = [''.join(sorted(input())) for i in range(N)]

c = collections.Counter(list)
ans_list = c.most_common()
ans = [ans[1]*(ans[1]-1)
ans_len = len(ans)
if ans_len==0:
    print(0)
else:
    print(sum(ans))

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
input=sys.stdin.readline

N=int(input())

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

print(ans)

Failing test case input:
5
aaaaa`aaba
oweplustmo
aaaaabaaba
unoselpowt
aaaa`aaaba

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
import sys
input=sys.stdin.readline

N=int(input())

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

print(ans)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections
n = int(input())
s = collections.Counter(["".join(sorted(input())) for _ in range(n)]).most_common()
print(s)
cnt = 0
for i in s:
    for j in range(1, i[1]):
        cnt += j
print(cnt)

Failing test case input:
3
rmusisnoca
odbbutpmmb
sagcrttnon

Expected output:
0


Actual output:
[('acimnorssu', 1), ('bbbdmmoptu', 1), ('acgnnorstt', 1)]
0


Fixed submission (verdict: Accepted):
import collections
n = int(input())
s = collections.Counter(["".join(sorted(input())) for _ in range(n)]).most_common()

cnt = 0
for i in s:
    for j in range(1, i[1]):
        cnt += j
print(cnt)

Problem: p02947
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n=int(input())
ss=[input() for i in range(n)]
d={}
ans=0
for i in ss:
    a=[c for c in ss]
    a.sort()
    a="".join(a)

    if a in d:
        ans+=d[a]
        d[a]+=1
    
    else:
        d[a]=1

print(ans)

Failing test case input:
5
a_abaaa`ba
umtsnlpewo
acaabbaaaa
unoselpows
bbaba`baab

Expected output:
0


Actual output:
10


Fixed submission (verdict: Accepted):
n=int(input())
ss=[input() for i in range(n)]
d={}
ans=0
for i in ss:
    a=[c for c in i]
    a.sort()
    a="".join(a)

    if a in d:
        ans+=d[a]
        d[a]+=1
    
    else:
        d[a]=1

print(ans)
Problem: p02947
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from collections import deque

n = int(input())
words = deque()
for i in range(n):
    words.append(input())

unique = {}
count = 0

for word in words:
    sorted_word = sorted(word)
    if ''.join(sorted_word) in unique:
        count += 1
    else:
        unique[''.join(sorted_word)] = 1

print(count)

Failing test case input:
5
abaaaaaaaa
oweplustmo
aaaaaaaaba
unoselpowt
aaaaaaaaba

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
from collections import deque

n = int(input())
words = deque()
for i in range(n):
    words.append(input())

unique = {}
count = 0

for word in words:
    sorted_word = sorted(word)
    if ''.join(sorted_word) in unique:
        count += unique[''.join(sorted_word)]
        unique[''.join(sorted_word)] += 1
    else:
        unique[''.join(sorted_word)] = 1

print(count)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a=int(input())
lis=sorted([sorted([f for f in input()]) for i in range(a)])
lis+=["w"]
kari=""
ans=0
cou=1
for i in lis:
  if kari!=i:
    ans+=cou*(cou-1)/2
    cou=1
    kari=i
  else:
    cou+=1
print(ans)

Failing test case input:
5
abaaaaaaaa
oweplustmo
aaaaaaaaba
unoselpowt
aaaaaaaaba

Expected output:
3


Actual output:
3.0


Fixed submission (verdict: Accepted):
a=int(input())
lis=sorted([sorted([f for f in input()]) for i in range(a)])
lis+=["w"]
kari=""
ans=0
cou=1
for i in lis:
  if kari!=i:
    ans+=cou*(cou-1)/2
    cou=1
    kari=i
  else:
    cou+=1
print(int(ans))

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
data = []
for i in range(n):
    s = list(input())
    s.sort()
    data.append(s)
data.sort()
i=0
j=0
count=1
decount=0
for i in range(n-1):
  print(i)
  if data[i]==data[i+1]:
    count=count+1
  else:
    decount=decount+(count-1)*count/2
    count=1
decount=decount+(count-1)*count/2
print(int(decount))


Failing test case input:
2
oofqlnsvwt
oisdpiypfn

Expected output:
0


Actual output:
0
0


Fixed submission (verdict: Accepted):
n = int(input())
data = []
for i in range(n):
    s = list(input())
    s.sort()
    data.append(s)
data.sort()
i=0
j=0
count=1
decount=0
for i in range(n-1):
  if data[i]==data[i+1]:
    count=count+1
  else:
    decount=decount+(count-1)*count/2
    count=1
decount=decount+(count-1)*count/2
print(int(decount))

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = []
for i in range(n):
  text = input()
  text = ''.join(sorted(text))
  s.append(text)

count = {}
for i in s:
  if i in count:
    count[i] += 1
  else:
    count[i] = 1

sum = 0
for v in count.values():
  int(v)
  sum += (v*(v-1)/2)

print(sum)

Failing test case input:
3
nnusisroca
odbbutpnmb
scharttnon

Expected output:
0


Actual output:
0.0


Fixed submission (verdict: Accepted):
n = int(input())
s = []
for i in range(n):
  text = ''.join(sorted(input()))
  s.append(text)

count = {}
for i in s:
  if i in count:
    count[i] += 1
  else:
    count[i] = 1

sum = 0
for v in count.values():
  int(v)
  sum += (v*(v-1)

print(sum)
Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())

lst = []

for i in range(N):
    lst.append("".join(sorted(list(input()))))


d={}
count = 0

print(lst)

for i in lst:
  if not i in d:
    d[i] = 1
    continue
  else:
    d[i] = d[i] + 1
    count = count + d[i]-1


print(count)


Failing test case input:
3
nnusisroca
odbbutpnmb
scharttnon

Expected output:
0


Actual output:
['acinnorssu', 'bbbdmnoptu', 'achnnorstt']
0


Fixed submission (verdict: Accepted):
N = int(input())

lst = []

for i in range(N):
    lst.append("".join(sorted(list(input()))))


d={}
count = 0

for i in lst:
  if not i in d:
    d[i] = 1
    continue
  else:
    d[i] = d[i] + 1
    count = count + d[i]-1


print(count)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def clc(num):
  return 1+num*(num-1)/2 +num-1

n =int(input())
cnt=0
pr=0
s=[None]*n
ans=[0]*n
for i in range(n):
  s[i]=sorted(input())
s.sort()
for j in range(0, n-1, 1):
  if s[j] == s[j+1]:
    ans[cnt] += 1
  else:
    cnt +=1
clcnums = [clc(n) for n in ans if n!= 0]
print(sum(clcnums))

Failing test case input:
3
acornistnt
bmnbtuoaep
nonstraict

Expected output:
1


Actual output:
1.0


Fixed submission (verdict: Accepted):
def clc(num):
  return int(1+num*(num-1)/2 +num-1)

n =int(input())
cnt=0
pr=0
s=[None]*n
ans=[0]*n
for i in range(n):
  s[i]=sorted(input())
s.sort()
for j in range(0, n-1, 1):
  if s[j] == s[j+1]:
    ans[cnt] += 1
  else:
    cnt +=1
clcnums = [clc(n) for n in ans if n!= 0]
print(sum(clcnums))

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s_list = []
anagrams = []
ans = 0

for i in range(n):
    s = list(input())
    s = sorted(s)
    s_list.append(s)

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

print(ans)


Failing test case input:
3
snusinroca
pdboutbnmb
nonsurahcs

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
dict = {}
ans = 0

for i in range(n):
    s = ''
    list = sorted(input())
    for j in list:
        s += j
    if i != 0 and s in dict.keys():
        ans += dict[s]
        dict[s] += 1
    else:
        dict[s] = 1

print(ans)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = []
for i in range(n):
  text = ''.join(sorted(input()))
  s.append(text)

count = {}
for i in s:
  if i in count:
    count[i] += 1
  else:
    count[i] = 1

sum = 0
for v in count.values():
  int(v)
  sum += (v*(v-1)/2)

print(sum)

Failing test case input:
2
oneplustwo
ninemodsix

Expected output:
0

Actual output:
0.0


Fixed submission (verdict: Accepted):
n = int(input())
s = []
for i in range(n):
  text = ''.join(sorted(input()))
  s.append(text)

count = {}
for i in s:
  if i in count:
    count[i] += 1
  else:
    count[i] = 1

sum = 0
for v in count.values():
  int(v)
  sum += (v*(v-1)

print(sum)
Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
lst = []
for i in range(N):
  
  
  lst.append(list(input()))
count = 0
index = 0
s = list(map(set, lst))

for i in range(len(lst)):
  i_set = set(lst[i])
  if i_set in s[0:i]+s[i+1:len(s)]:
    count = count + 1
    
print(count)

Failing test case input:
5
aaaaaaaaba
oweplustmo
aaaaabaaba
unoselpowt
aaaaaaaaba

Expected output:
1


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())

lst = []

for i in range(N):
    lst.append("".join(sorted(list(input()))))


d={}
count = 0

for i in lst:
  if not i in d:
    d[i] = 1
    continue
  else:
    d[i] = d[i] + 1
    count = count + d[i]-1


print(count)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
s = [input() for i in range(N)]
ans ={}
num = 0

for i in range(N):
    s[i] = ''.join(sorted(s[i]))
    if s[i] in ans.keys():
        num += 1
    else:
        ans[s[i]] = i

print(num)

Failing test case input:
5
abaaaaaaaa
oweplustmo
aaaaaaaaba
unoselpowt
aaaaaaaaba

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
N = int(input())
s = [input() for i in range(N)]
ans ={}
num = 0

for i in range(N):
    s[i] = ''.join(sorted(s[i]))
    if s[i] in ans.keys():
        ans[s[i]] += 1
        num += ans[s[i]]
    else:
        ans[s[i]] = 0

print(num)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
s = [input().split() for i in range(N)]
count = 0

s = [sorted(str(i)) for i in s]
print(s)
for i in range(N):
    for j in range(i+1, N):
        if s[i] == s[j]:
            count += 1
print(count)


Failing test case input:
5
aaab`_aaba
oweplustmo
abaabbaaaa
unoselpows
baab`bb`ba

Expected output:
0


Actual output:
[["'", "'", '[', ']', '_', '`', 'a', 'a', 'a', 'a', 'a', 'a', 'b', 'b'], ["'", "'", '[', ']', 'e', 'l', 'm', 'o', 'o', 'p', 's', 't', 'u', 'w'], ["'", "'", '[', ']', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'b', 'b', 'b'], ["'", "'", '[', ']', 'e', 'l', 'n', 'o', 'o', 'p', 's', 's', 'u', 'w'], ["'", "'", '[', ']', '`', '`', 'a', 'a', 'a', 'b', 'b', 'b', 'b', 'b']]
0


Fixed submission (verdict: Accepted):
N = int(input())
s = [''.join(sorted(input())) for i in range(N)]
s.sort()
count = 0
num = 1
for i in range(N-1):
    if s[i] == s[i+1]:
        num += 1
    else:
        count += num * (num - 1) 
        num = 1
print(count + num * (num - 1)
Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from sys import stdin


def main():
    N = int(stdin.readline())
    s = [stdin.readline().rstrip().split() for _ in range(N)]

    s_flat = [flatten for inner in s for flatten in inner]

    s_dict = {}
    sum = 0

    for S in s_flat:
        new_S = ''.join(sorted(S))
        print(new_S)
        if not s_dict.get(new_S):
            s_dict[new_S] = 1
        else:
            sum += s_dict[new_S]
            s_dict[new_S] = s_dict[new_S] + 1

    print(sum)


if __name__ == "__main__":
    main()


Failing test case input:
5
aaaba_aaba
oweplustmo
abaabbaaaa
unoselpows
baab`bb`ba

Expected output:
0


Actual output:
_aaaaaaabb
elmoopstuw
aaaaaaabbb
elnoopssuw
``aaabbbbb
0


Fixed submission (verdict: Accepted):
from sys import stdin


def main():
    N = int(stdin.readline())
    s = [stdin.readline().rstrip().split() for _ in range(N)]

    s_flat = [flatten for inner in s for flatten in inner]

    s_dict = {}
    sum = 0

    for S in s_flat:
        new_S = ''.join(sorted(S))
        if not s_dict.get(new_S):
            s_dict[new_S] = 1
        else:
            sum += s_dict[new_S]
            s_dict[new_S] = s_dict[new_S] + 1

    print(sum)


if __name__ == "__main__":
    main()

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
amap = {}
cnt = 0
n = int(input())
for i in range(n):
  s = "".join(sorted(input()))
  if s in amap:
    cnt += 1
  else:
    amap[s] = True

print(cnt)

Failing test case input:
5
abaaaaaaaa
oweplustno
aaaaaaaaba
enosulpowt
aaaaaaaaba

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
amap = {}
cnt = 0
n = int(input())
for i in range(n):
  s = "".join(sorted(input()))
  if s in amap:
    cnt += amap[s]
    amap[s] += 1
  else:
    amap[s] = 1

print(cnt)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

n = int(input())
s = list([input() for i in range(n)])
q = [''.join(sorted(x)) for x in s]

c = 0

p = sorted(q)
for i in range(n-1):
	if p[i] != p[i+1]:
		if i!=0:
			if p[i] == p[i-1]:
				c+=1

c1 = len(s)
c2 = len(set(q))

print(c1-c2+c)

Failing test case input:
5
aaaaa`aaba
oweplustmo
aaaaabaaba
unoselpowt
abaaa`aaaa

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
s = list([input() for i in range(n)])
q = [''.join(sorted(x)) for x in s]

c = 0
c1 =  0
p = sorted(q)
p.append("a")

for i in range(n):
	if p[i] == p[i+1]:
		c+=1
	else:
		
		if c>0:
			for j in range(c+1):
				c1+=j
				
		c=0
print(c1)