ZhenlongDai/ACPR huggingface dataset:
Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
n=int(input())
d=Counter()
for i in range(n):
    t=str("".join(sorted(input())))
    d[t]+=1
print(max(d.values())-1)

Failing test case input:
5
abaaaaaaaa
oweplustno
aaaaaaaaba
twoplusone
aaaabaaaaa

Expected output:
4


Actual output:
2


Fixed submission (verdict: Accepted):
from collections import Counter
n=int(input())
d=Counter()
ans=0
for i in range(n):
    t=str("".join(sorted(input())))
    if t in d:
        ans+=d[t]
    d[t]+=1
print(ans)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
dic={}
for _ in range(n):
    S=''.join(sorted(list(input())))
    if S not in dic.keys():
        dic[S]=0
    else:
        dic[S]+=1
print(sum(dic.values()))

Failing test case input:
5
abaaaaaaaa
oweplustno
aaaaaaaaba
twoplusone
aaaabaaaaa

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
n=int(input())
dic={}
ans=0
for _ in range(n):
    S=''.join(sorted(list(input())))
    if S not in dic.keys():
        dic[S]=1
    else:
        ans+=dic[S]
        dic[S]+=1
print(ans)

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

print(cnt)


Failing test case input:
2
ooeplnsvxt
oisdpiypfn

Expected output:
0


Actual output:
2


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

print(cnt)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import defaultdict
N = int(input())
s = [''.join(sorted(input())) for i in range(N)]
d = defaultdict(lambda: 0)

for _s in s:
    d[_s] += 1

print(sum(map(lambda x: x * (x+1) / 2, d.values())))


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

Expected output:
0


Actual output:
5.0


Fixed submission (verdict: Accepted):
from collections import defaultdict
N = int(input())
s = [''.join(sorted(input())) for i in range(N)]
d = defaultdict(lambda: 0)

for _s in s:
    d[_s] += 1

print(sum(map(lambda x: x * (x-1)

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

Failing test case input:
3
sntsinroca
peaoutbnmb
nonsuraict

Expected output:
0


Actual output:
{'acinnorsst': 0, 'abbemnoptu': 0, 'acinnorstu': 0}
0


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

N = int(input())
S = [input() for _ in range(N)]

ctr = Counter()
ans = 0
for Si in S:
    x = "".join(sorted(list(Si)))
    if x in ctr:
        ans += ctr[Si]
    ctr[Si] += 1

print(ans)

Failing test case input:
3
acornistnt
peaoutbnmb
nonstraict

Expected output:
1


Actual output:
0


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

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
d = {}
ans = 0
for st in range(n):
    s = ''.join(sorted(input()))
    if d.get(s) == None:
        d[s] = 1
    else:
        ans += d[s]
        d[s] += 1

Failing test case input:
3
nnusisroca
pdboutbnmb
scharttnon

Expected output:
0


Actual output:

Fixed submission (verdict: Accepted):
n = int(input())
d = {}
ans = 0
for st in range(n):
    s = ''.join(sorted(input()))
    if d.get(s) == None:
        d[s] = 1
    else:
        ans += d[s]
        d[s] += 1

print(ans)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
r = dict()
find = False
for i in range(n):
    l = str(sorted([c for c in input()]))
    if l not in  r:
        r[l] = 1
    else:
        r[l] = r[l] + 1
        find=True

if not find:
    print('0')

sum = 0    
def comb(n, k):
    bo = 1
    for kk in range(1, k+1):
        bo = bo * kk
    si = 1
    for kk in range(n-k+1 ,n+1):
        si = si * kk
    return int(si / bo)

for k, v in r.items():
    sum = sum + comb(v, 2)
print(sum)

Failing test case input:
2
ooeplnsvxt
nisdpiypfn

Expected output:
0


Actual output:
0
0


Fixed submission (verdict: Accepted):
n = int(input())
r = dict()
find = False
for i in range(n):
    l = str(sorted([c for c in input()]))
    if l not in  r:
        r[l] = 1
    else:
        r[l] = r[l] + 1
        find=True

sum = 0    
def comb(n, k):
    bo = 1
    for kk in range(1, k+1):
        bo = bo * kk
    si = 1
    for kk in range(n-k+1 ,n+1):
        si = si * kk
    return int(si / bo)

for k, v in r.items():
    sum = sum + comb(v, 2)
print(sum)
Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from operator import itemgetter
N = int(input())
S = [list(input()) for i in range(N)]

for l in range(N):
  S[l].sort()
S.sort(key = itemgetter(0))

for k in range(N):
  S[k] = ''.join(S[k])
ans = 0

for j in range(N-1):
  for m in range(j+1,N):
    if S[j] == S[m]:
      ans += 1
    else:
      break

print(ans)

Failing test case input:
3
acornistnt
peaoutbnmb
constraint

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
from operator import itemgetter
N = int(input())
S = [list(input()) for i in range(N)]

for l in range(N):
  S[l].sort()
  S[l] = ''.join(S[l]) 

S.sort()

X = []
p = 1

for j in range(N-1):
  if S[j] == S[j+1]:
    p +=1
  else:
    X.append(p)
    p = 1
X.append(p)


def comb(n):
  if n == 2: return 1
  else:
    return int(n*(n-1)/2)

ans = 0

for k in range(len(X)):
  ans += comb(X[k])

print(ans)

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

n = int(input())


sort_list = list()
for i in range(n):
  i_sort = "".join(sorted(input()))
  
  sort_list.append(i_sort)
  
  
  
counts = 0
cc = collections.Counter(sort_list)

v, c = zip(*cc.most_common())

for c_ in c:
  if c_ > 2:
    c_ -= 1
  if c_ != 1:
    counts += c_
print(counts)

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

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
import collections

n = int(input())


sort_list = list()
for i in range(n):
  i_sort = "".join(sorted(input()))
  
  sort_list.append(i_sort)
  
  
  
counts = 0
cc = collections.Counter(sort_list)
v, c = zip(*cc.most_common())

for c_ in c:
  counts += (c_ * (c_ - 1)) / 2
print(int(counts))

Problem: p02947
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
s_list = [input() for _ in range(int(N))]
import math
ok = {}
count = 0
for s in s_list:
    s = ''.join(sorted(s))
    if s in ok:
        ok[s] += 1 
    else:
        ok[s] = 1

for val in ok:
    prev = (ok[val] - 1)
    if prev != 0:
        count += math.floor(ok[val] * prev / prev)

Failing test case input:
5
abaaaaaaaa
oweplustno
aaaaaaaaba
twoplusone
aaaaaaaaba

Expected output:
4


Actual output:

Fixed submission (verdict: Accepted):
N = int(input())
s_list = [input() for _ in range(int(N))]
import math
ok = {}
count = 0
for s in s_list:
    s = ''.join(sorted(s))
    if s in ok:
        ok[s] += 1 
    else:
        ok[s] = 1

for val in ok:
    prev = (ok[val] - 1)
    if prev != 0:
        count += math.floor(ok[val] * prev / 2)
print(count)
Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections
N = int(input())
array = []
for i in range(N):
    s = input()
    dict = {}
    for j in range(len(s)):
        if s[j] not in dict:
            dict[s[j]] = 1
        else:
            dict[s[j]] += 1
    dict = sorted(dict)
    array.append(str(dict))
sum = 0
c = collections.Counter(array)
for v in c.values():
    sum += int(v*(v-1)/2)
print(sum)

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

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
import collections
N = int(input())
array = []
for i in range(N):
    s = input()
    dict = {}
    for j in range(len(s)):
        if s[j] not in dict:
            dict[s[j]] = 1
        else:
            dict[s[j]] += 1
    dict = sorted(dict.items())

    array.append(str(dict))
sum = 0
c = collections.Counter(array)
for v in c.values():
    sum += int(v*(v-1)/2)
print(sum)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections
n = int(input())
s = [0]*n
c = {}
T = [0]*n
for i in range(n):
	s[i] = input()
	c[i] = collections.Counter(list(s[i]))
	T[i] = str(c[i])
D = collections.Counter(T)
ans = 0
for i in D.values():
	ans += i*(i-1)
print(ans)

Failing test case input:
5
aaaaaaaaba
oweplustmo
aaaaaaaaba
unoselpowt
aaaaaaaaba

Expected output:
3


Actual output:
6


Fixed submission (verdict: Accepted):
import collections
import math
n = int(input())
s = [0]*n
T = [0]*n
L = [0]*n
ans = 0
for i in range(n):
	s[i] = input()
	T[i] = sorted(list(s[i]))
	L[i] = ''.join(T[i])
D = collections.Counter(L)
for i in D.values():
	ans += i*(i-1)/2
print(int(ans))

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

for i in range(N-1):
    num=0
    if(s[i]==s[i+1]):     
        num += 1
    elif(num>0):
        count += num*(num-1)/2
        count = 0
    
        
print(count)

Failing test case input:
5
abaaaaaaaa
oneplustwo
aaaaaaaaba
twoplusone
aaaabaaaaa

Expected output:
4

Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
s = sorted(["".join(sorted((input()))) for i in range(N)])
count = 0

num=1
for i in range(N-1):
    if(s[i]==s[i+1]):
        num += 1
    elif(num>1):
        count += num*(num-1)/2
        num = 1
    
if(num>1):
    count += num*(num-1)/2
print(int(count))
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] = 0
    continue
  else:
      if d[i] == 0:
        d[i] = d[i] + 2
        count = count + 2
      else:
        d[i] = d[i] + 1
        count = count + 1
print(count)


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

Expected output:
0


Actual output:
['_aaaaaaaab', 'elmoopstuw', 'aaaaaaaabb', 'elnoopstuw', '`aaaaaabbb']
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):
from collections import *
 
n = int(input())
dic = defaultdict(int)
for i in range(n):
  dic["".join(sorted(input()))] += 1

 
ans = 0
for k,v in dic.items(): 
  
  ans += (v-1)
  
print(ans)

Failing test case input:
5
abaaaaaaaa
oweplustno
aaaaaaaaba
enosulpowt
aaaaaaaaba

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
from collections import *
 
n = int(input())
dic = defaultdict(int)
for i in range(n):
  dic["".join(sorted(input()))] += 1
 
ans = 0
for k,v in dic.items(): 
  ans += int(v*(v-1)/2)
  
print(ans)

Problem: p02947
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
s = [input() for _ in range(n)]
for i in range(n):
  s[i] = ''.join(sorted(s[i]))
t = {}
for i in range(n):
  if s[i] in t:
    t[s[i]] += 1
  else:
    t[s[i]] = 1
print(sum(t[k] * (t[k] -1) / 2 for k in t))


Failing test case input:
3
rmusisnoca
odbbutpmmb
sagcrttnon

Expected output:
0


Actual output:
0.0


Fixed submission (verdict: Accepted):
n = int(input())
s = [input() for _ in range(n)]
for i in range(n):
  s[i] = ''.join(sorted(s[i]))
t = {}
for i in range(n):
  if s[i] in t:
    t[s[i]] += 1
  else:
    t[s[i]] = 1
print(sum(t[k] * (t[k] -1)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
Dictionary = {}
for i in range(N):
        string = "".join(sorted(input()))
        if string in Dictionary:
                Dictionary[string] += 1
        else:
                Dictionary[string] = 1

ans = 0
for i in Dictionary.values():
        count_tmp = i*(i-1)/2
        ans += count_tmp

print(ans)

Failing test case input:
3
rmusisnoca
bmlqtubbdo
sagcttrnnn

Expected output:
0


Actual output:
0.0


Fixed submission (verdict: Accepted):
N = int(input())
Dictionary = {}
for i in range(N):
        string = "".join(sorted(input()))
        if string in Dictionary:
                Dictionary[string] += 1
        else:
                Dictionary[string] = 1

ans = 0
for i in Dictionary.values():
        count_tmp = i*(i-1)/2
        ans += count_tmp

print(int(ans))
Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
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(0)

print(sum(cnt))

Failing test case input:
5
abaaaaaaaa
oweplustno
aaaaaaaaba
enosulpowt
aaaaaaaaba

Expected output:
4


Actual output:
3


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

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,*sl, = map(lambda x:''.join(sorted(x)),open(0).read().split())
count = 0
dict = {}
for s in sl:
  if s in dict:
    count += dict[s]
    dict[s] += 1
  else:
    dict[s] = 1

Failing test case input:
2
vwtsnlqfoo
oepyipdsio

Expected output:
0


Actual output:

Fixed submission (verdict: Accepted):
n,*sl, = map(lambda x:''.join(sorted(x)),open(0).read().split())
count = 0
dict = {}
for s in sl:
  if s in dict:
    count += dict[s]
    dict[s] += 1
  else:
    dict[s] = 1
print(count)

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

amount = int(input())
strings = list(map(str, [input() for i in range(amount)]))
sum = 0

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

strings.sort()

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

print(sum)


Failing test case input:
5
abaaaaaaaa
oweplustno
aaaaaaaaba
twoplusone
aaaaaaaaba

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):

amount = int(input())
strings = list(map(str, [input() for i in range(amount)]))
sum = 0
sum2 = 0

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

strings.sort()

for j in range(len(strings)-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))

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

for i in range(N-1):
    num=1
    if(s[i]==s[i+1]):     
        num += 1
    elif(num>0):
        count += num*(num-1)/2
        num = 1
    
        
print(count)

Failing test case input:
2
onepltsuwo
nfoyiodsim

Expected output:
0


Actual output:
0.0


Fixed submission (verdict: Accepted):
N = int(input())
s = sorted(["".join(sorted((input()))) for i in range(N)])
count = 0

num=1
for i in range(N-1):
    if(s[i]==s[i+1]):
        num += 1
    elif(num>1):
        count += num*(num-1)/2
        num = 1
    
if(num>1):
    count += num*(num-1)/2
print(int(count))
Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import *
 
n = int(input())
dic = defaultdict(int)
for i in range(n):
  dic["".join(sorted(input()))] += 1
print(dic.items())
 
ans = 0
for k,v in dic.items(): 
  print(v)
  ans += int(v*(v-1)/2)
  
print(ans)

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

Expected output:
0


Actual output:
dict_items([('_`aaaaaabb', 1), ('elmnopstuw', 1), ('aaaaaaabbc', 1), ('elnoopssuw', 1), ('`aaaabbbbb', 1)])
1
1
1
1
1
0


Fixed submission (verdict: Accepted):
from collections import *
 
n = int(input())
dic = defaultdict(int)
for i in range(n):
  dic["".join(sorted(input()))] += 1
 
ans = 0
for k,v in dic.items(): 
  ans += int(v*(v-1)/2)
  
print(ans)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
d = dict()
res = 0
for i in range(n):
  ss = input()
  ss = list(ss)
  ss.sort()
  ss = ''.join(ss)
  if d.__contains__(ss):
    res += d[ss]
  else:
    d[ss] = 1
print(res)
    

Failing test case input:
5
abaaaaaaaa
oweplustmo
aaaaaaaaba
unoselpowt
aaaaaaaaba

Expected output:
3


Actual output:
2


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

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections
n = int(input())
s = [0]*n
c = {}
T = [0]*n
ans = 0
for i in range(n):
	s[i] = input()
	c[i] = collections.Counter(list(s[i]))
	T[i] = str(c[i])
D = collections.Counter(T)
for i in D.values():
	ans += i*(i-1)/2
print(ans)

Failing test case input:
3
acornistnt
peaoutbnmb
nonsuraict

Expected output:
0


Actual output:
0.0


Fixed submission (verdict: Accepted):
import collections
import math
n = int(input())
s = [0]*n
T = [0]*n
L = [0]*n
ans = 0
for i in range(n):
	s[i] = input()
	T[i] = sorted(list(s[i]))
	L[i] = ''.join(T[i])
D = collections.Counter(L)
for i in D.values():
	ans += i*(i-1)/2
print(int(ans))

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

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

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

    print(count)


if __name__ == "__main__":
    main()


Failing test case input:
5
aaaaa_aaba
oweplustmo
abaabaaaaa
unoselpowt
abaaa`aaaa

Expected output:
0


Actual output:
0 1
0 2
0 3
0 4
1 2
1 3
1 4
2 3
2 4
3 4
0


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

    count = 0
    found = {}
    for _ in range(n):
        str = ''.join(sorted(input()))
        if str in found:
            count += found[str]
            found[str] += 1
        else:
            found[str] = 1

    print(count)


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)]
ans=0
cnt={}
for x in s:
  if x in cnt:
    cnt[x]+=1
  else:
    cnt[x]=1
  ans+=cnt[x]*(cnt[x]-1)/2
print(int(ans))


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)]
ans=0
cnt={}
for i in range(n):
  if s[i] in cnt:
    cnt[s[i]]+=1
  else:
    cnt[s[i]]=1
print(sum(cnt[key]*(cnt[key]-1)

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

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 


N = int(input())
s = [" ".join(sorted(list(input()))) for _ in range(N)]
c = collections.Counter(s)
ans = 0
print(c.values())
for i in c.values():
    if i > 1:
        ans += cmb(i, 2)
print(ans)


Failing test case input:
2
oofplnsvwt
oisdpiypfo

Expected output:
0


Actual output:
dict_values([1, 1])
0


Fixed submission (verdict: Accepted):
import collections

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 


N = int(input())
s = [" ".join(sorted(list(input()))) for _ in range(N)]
c = collections.Counter(s)
ans = 0
for i in c.values():
    if i > 1:
        ans += cmb(i, 2)
print(ans)

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




def main():
    
    n = int(input())
    s = []
    for _ in range(n):
        s.append(input())
    print(process(n, s))


def process(n, s):
    s = list(map(lambda s: ''.join(sorted(s)), s))
    hash = {}

    count = 0
    print(s[0])
    for i in range(0, n):
        if s[i] in hash:
            hash[s[i]] += 1
        else:
            hash[s[i]] = 1
        count += hash[s[i]] - 1
    return count


if __name__ == "__main__":
    main()


Failing test case input:
3
sntsinroca
pdaoutbnmb
nonsuraict

Expected output:
0


Actual output:
acinnorsst
0


Fixed submission (verdict: Accepted):




def main():
    
    n = int(input())
    s = []
    for _ in range(n):
        s.append(input())
    print(process(n, s))


def process(n, s):
    s = list(map(lambda s: ''.join(sorted(s)), s))
    hash = {}

    count = 0
    for i in range(0, n):
        if s[i] in hash:
            hash[s[i]] += 1
        else:
            hash[s[i]] = 1
        count += hash[s[i]] - 1
    return count


if __name__ == "__main__":
    main()
Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = []
for i in range(N):
    S.append(input())
d = {}
for s in S:
    new_s = "".join((sorted(s)))
    if new_s in d:
        d[new_s] += d[new_s]
    else:
        d[new_s] = 1
print(max(d.values()))


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

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())
S = [input() for _ in range(N)]
d = {}
ans = 0
for s in S:
    ss = "".join(sorted(s))
    if ss in d:
        d[ss] += 1
        ans += d[ss]
    else:
        d[ss] = 0
print(ans)

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

ans = N
for i in range(N):
    for j in range(i+1, N):
        if S[i]==S[j]:
            ans -= 1
print(ans)

Failing test case input:
3
rnusisnoca
odbbutmmpb
sahcrttnon

Expected output:
0


Actual output:
3


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

D = {}
ans = 0
for s in S:
    if s in D:
        D[s] += 1
        ans += D[s]
    else:
        D[s] = 0

print(ans)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
s = list(list(input())for i in range(N))
count = 1
ans = 0
s.sort()
for i in range(0,N-1):
    if s[i] == s[i+1]:
        ans += count
        count += 1
    else:
        count = 1
print(ans)

Failing test case input:
3
acornistnt
peaoutbnmb
constraint

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
s = list(list(input())for i in range(N))
count = 1
ans = 0
for i in range(N):
    s[i].sort()
s.sort()
for i in range(0,N-1):
    if s[i] == s[i+1]:
        ans += count
        count += 1
    else:
        count = 1
print(ans)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import defaultdict

N = int(input())

s = [input() for i in range(N)]

line = defaultdict(int)

for anagram in s:
  a = sorted(anagram)
  line[''.join(a)] += 1

_sum = 0

for i in line:
  _sum += line[i]

print(_sum * (_sum-1) / 2)


Failing test case input:
3
snusinroca
pdboutbnmb
nonsuraict

Expected output:
0


Actual output:
3.0


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

N = int(input())

s = [input() for i in range(N)]

line = defaultdict(int)

for anagram in s:
  a = sorted(anagram)
  line[''.join(a)] += 1

_sum = 0

for i in line:
  _sum += int((line[i] * (line[i] - 1)) / 2)

print(_sum)
Problem: p02947
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
s_list = [input() for _ in range(int(N))]
import math
ok = {}
count = 0
for s in s_list:
    s = ''.join(sorted(s))
    if s in ok:
        ok[s] += 1 
    else:
        ok[s] = 1

for val in ok:
    count += math.floor(ok[val] * 2 / ok[val])
print(count)

Failing test case input:
2
ooeplnsuwt
nfpyiodsim

Expected output:
0


Actual output:
4


Fixed submission (verdict: Accepted):
N = int(input())
s_list = [input() for _ in range(int(N))]
import math
ok = {}
count = 0
for s in s_list:
    s = ''.join(sorted(s))
    if s in ok:
        ok[s] += 1 
    else:
        ok[s] = 1

for val in ok:
    prev = (ok[val] - 1)
    if prev != 0:
        count += math.floor(ok[val] * prev / 2)
print(count)

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


Failing test case input:
5
abaaaaaaaa
oweplustno
aaaaaaaaba
enosulpowt
aaaaaaaaba

Expected output:
4


Actual output:
5


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

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections
n = int(input())
s = [0]*n
c = {}
T = [0]*n
ans = 0
for i in range(n):
	s[i] = input()
	c[i] = collections.Counter(list(s[i]))
	T[i] = str(c[i])
D = collections.Counter(T)
for i in D.values():
	ans += i*(i-1)/2
print(int(ans))

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

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
import collections
import math
n = int(input())
s = [0]*n
T = [0]*n
L = [0]*n
ans = 0
for i in range(n):
	s[i] = input()
	T[i] = sorted(list(s[i]))
	L[i] = ''.join(T[i])
D = collections.Counter(L)
for i in D.values():
	ans += i*(i-1)/2
print(int(ans))
Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections

n = int(input())
s = [input() for i in range(n)]
s = map(list,s)
lst = []
for i in s:
  i.sort()
  lst.append(''.join(i))
ans = collections.Counter(lst)
ctr = 0
for v in ans.values():
  if v != 1:
    ctr += (v-1)
print(ctr)

Failing test case input:
5
abaaaaaaaa
oweplustno
aaaaaaaaba
twoplusone
aaaaaaaaba

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
import collections

n = int(input())
s = [input() for i in range(n)]
s = map(list,s)
lst = []
for i in s:
  i.sort()
  lst.append(''.join(i))
ans = collections.Counter(lst)
ctr = 0
for v in ans.values():
  if v != 1:
    for n in range(1,v):
      ctr+=n
      
print(ctr)

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

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

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

for i in range(n):
  if s[i]==s[i+1]:
    cnt+=1
  elif cnt>1:
    li.append(cnt*(cnt-1)/2)
    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

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

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

Failing test case input:
2
owustlpeno
nxofmodsii

Expected output:
0


Actual output:

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.8.2), verdict: Wrong Answer):
dict={}
for _ in range(int(input())):
  s=''.join(sorted(input()))
  if s not in dict: dict[s]=1
  else:
    dict[s]+=dict[s]
print(sum(dict.values())-2)

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

Expected output:
0


Actual output:
3


Fixed submission (verdict: Accepted):
dict={}
for _ in range(int(input())):
  s=''.join(sorted(input()))
  if s not in dict: dict[s]=1
  else: dict[s]+=1
print(sum([i*(i-1)
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=0
for i in range(n):
  for j in range(i,n):
    if data[i]==data[j]:
      count=count+1
print(count)

Failing test case input:
3
nnusisroca
odbbutpnmb
sahcrttnon

Expected output:
0


Actual output:
3


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):
H = int(input())
S = []
for _ in range(H):
	S.append(input()) 

L = []

for i in range(0,len(S)):
	L.append(sorted(S[i]))

for i in range(0,len(L)):
	L[i] = ",".join(L[i])

print(L)

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

print(counter)

Failing test case input:
2
onepltsuwo
nxofiodsim

Expected output:
0


Actual output:
['e,l,n,o,o,p,s,t,u,w', 'd,f,i,i,m,n,o,o,s,x']
0


Fixed submission (verdict: Accepted):
H = int(input())
S = []
for _ in range(H):
	S.append(input()) 

L = []

for i in range(0,len(S)):
	L.append(sorted(S[i]))

for i in range(0,len(L)):
	L[i] = ",".join(L[i])

dicL = dict()
answer = 0

for l in L:
	if l in dicL:
		dicL[l] += 1
		answer += dicL[l]
	else:
		dicL[l] = 0
		
print(answer)

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

print(count)

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 = []

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

    for d in dic.values():
        ans += d
    print(ans)


if __name__ == "__main__":
    main()


Failing test case input:
5
abaaaaaaaa
oweplustno
aaaaaaaaba
unoselpowt
aaaaaaaaba

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
def main():
    n = int(input())
    s = ["".join(sorted(input())) for _ in range(n)]
    ans = 0
    dic = {}
    for i in s:
        if i not in dic:
            dic[i] = 0
        else:
            dic[i] += 1
            ans += dic[i]
        
    print(ans)


if __name__ == "__main__":
    main()

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

n = int(input())

dd = {'a1':0}
cnt = 0

for i in range(n):
  s = ''.join(sorted(input()))
  if s in dd.keys():
    dd[s] += 1
    cnt += 1
  else:
    dd[s] = 0
  
  
print(cnt)  

Failing test case input:
5
abaaaaaaaa
oweplustno
aaaaaaaaba
enosulpowt
aaaaaaaaba

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
import sys

n = int(input())

d = {}
cnt = 0

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

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

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

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] in s[j:N]:
            counter += 1

print(counter)  

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

Expected output:
1


Actual output:
4


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 = sorted([sorted((input())) for i in range(N)])
count = 0

for i in range(N-1):
    num=1
    if(s[i]==s[i+1]):     
        num += 1
    elif(num>1):
        count += num*(num-1)/2
        num = 1
    
        
print(count)

Failing test case input:
5
abaaaaaaaa
oweplustno
aaaaaaaaba
unoselpowt
aaaaaaaaba

Expected output:
4


Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
s = sorted(["".join(sorted((input()))) for i in range(N)])
count = 0

num=1
for i in range(N-1):
    if(s[i]==s[i+1]):
        num += 1
    elif(num>1):
        count += num*(num-1)/2
        num = 1
    
if(num>1):
    count += num*(num-1)/2
print(int(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:
        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:
['_', '`', 'a', 'a', 'a', 'a', 'a', 'a', 'b', 'b']
['e', 'l', 'm', 'n', 'o', 'p', 's', 't', 'u', 'w']
['a', 'a', 'a', 'a', 'a', 'a', 'a', 'b', 'b', 'c']
['e', 'l', 'n', 'o', 'o', 'p', 's', 's', 'u', 'w']
['`', 'a', 'a', 'a', 'a', 'b', 'b', 'b', 'b', 'b']
0


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):
import sys
input=sys.stdin.readline

import collections


N = int(input())







l = {}
for i in range(N):
    if i == N-1:
      S = list(input())
    else:
      S = list(input()[:-1])
    S.sort()
    S = tuple(S)
    if S in l.keys():
      l[S] += 1
    else:
      l[S] = 1
ans = 0
for j in l.values():
  ans += j*(j-1)/2
print(int(ans))

Failing test case input:
5
aaaaaaaaba
oweplustmo
aaaaaaaaba
unoselpowt
aaaaaaaaba

Expected output:
3


Actual output:
1


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

import collections


N = int(input())







l = {}
for i in range(N):
    S = list(input())
    S.remove("\n")
    S.sort()
    S = tuple(S)
    if S in l.keys():
      l[S] += 1
    else:
      l[S] = 1
ans = 0
for j in l.values():
  ans += j*(j-1)/2
print(int(ans))

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections
N = int(input())
li = [input() for x in range(N)]
ans = 0
wli = list()
for k in li:
    word = ''.join(sorted(list(k)))
    if word in wli:
        ans += 1
    else:
        wli.append(word)
print(ans)

Failing test case input:
5
aaaaaaaaba
oweplustmo
aaaaaaaaba
unoselpowt
aaaaaaaaba

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import collections
N = int(input())
li = [input() for x in range(N)]
ans = 0
di = dict()
for k in li:
    word = ''.join(sorted(list(k)))
    if word in di.keys():
        ans += di[word]
        di[word] += 1
    else:
        di[word] = 1
print(ans)
Problem: p02947
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n = int(input())
s = []
for i in range(n):
    s.append(input())
    
S = set()
ans = 0
for i in s:
    if "".join(sorted(i)) in S:
        ans +=1
    else:
        S.add("".join(sorted(i)))
print(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(input())
    
dic = dict()
ans = 0
for i in s:
    if "".join(sorted(i)) in dic:
        ans += dic["".join(sorted(i))]
        dic["".join(sorted(i))] +=1
    else:
        dic["".join(sorted(i))] = 1
print(ans)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    n = int(input())
    a = [input() for i in range(n)]
    num = 0
    for i in range(len(a)):
        a[i] = "".join(sorted(a[i]))
    a.sort()
    for i in range(len(a)):
        e = a[i]
        j = 1
        while i+j < len(a) and e == a[i+j]:
            j = j + 1
        num = num + conb(j)
        i = i+j
    print(num)


def conb(x):
    return x*(x-1)/2


main()


Failing test case input:
2
vwtsnlqfoo
nepyipdsio

Expected output:
0


Actual output:
0.0


Fixed submission (verdict: Accepted):
def main(text=""):
    n = int(input())
    a = [input() for i in range(n)]
    
    num = 0
    for i in range(len(a)):
        a[i] = "".join(sorted(a[i]))
    a.sort()
    i = 0
    while i < len(a):
        e = a[i]
        j = 1
        while i+j < len(a) and e == a[i+j]:
            j = j + 1
        if j != 1:
            num = num + combination(j)
            i = i+j
        else:
            i = i+1
    print(num)


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


main()

Problem: p02947
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
s = []
l = 1
z = 0
for i in range(0,N):
    s.append(str(input()))
for i in range(0,N):
    s[i] = ''.join(sorted(s[i]))
s.sort()
for i in range(0,N-1):
    if s[i] == s[i+1]:
        l += 1
    else:
        z += l*(l-1)/2
        l = 1
print(z)


Failing test case input:
3
rmusisnoca
bmlqtubbdo
sagcttrnnn

Expected output:
0


Actual output:
0.0


Fixed submission (verdict: Accepted):
N = int(input())
s = []
l = 1
z = 0
for i in range(0,N):
    s.append(str(input()))
for i in range(0,N):
    s[i] = ''.join(sorted(s[i]))
s.sort()
for i in range(0,N-1):
    if s[i] == s[i+1]:
        l += 1
    else:
        z += l*(l-1)/2
        l = 1
z += l*(l-1)/2
print(int(z))
Problem: p02947
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def resolve():
    
    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 = -1
    for letter, num in line_cnt.most_common():
        if num >=2:
            cnt += num

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


Failing test case input:
5
aaaaaaaaba
oweplustmo
aaaaaaaaba
unoselpowt
aaaaaaaaba

Expected output:
3


Actual output:
2


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

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def sig(s):
  ls = list(s)
  work = 0
  for c in ls:
    work += ord(c)
  return work

def norm_str(s):
  ls = list(s)
  return "".join(sorted(ls))
  
ans = 0
pool = set()
n = int(input())
for i in range(n):
  s = input()
  
  norm = norm_str(s)
  
  if norm in pool:
    ans += 1
  else:
    pool.add(norm)
  
print(ans)

Failing test case input:
5
abaaaaaaaa
oweplustmo
aaaaaaaaba
unoselpowt
aaaaaaaaba

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
def norm_str(s):
  ls = list(s)
  return "".join(sorted(ls))
  
ans = 0
pool = {}
n = int(input())
for i in range(n):
  s = input()
  norm = norm_str(s)
  
  if norm in pool:
    pool[norm] += 1
    ans += pool[norm]
    
  else:
    pool[norm] = 0
  
print(ans)

Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = int(input())
b = []
strings = ''
ans = 0

for i in range(a):
    check = True
    strings = sorted(list(input()))
    if strings not in b:
      check = False
      b.append(strings)
    if check == True:
      ans += 1
print(ans)

Failing test case input:
5
abaaaaaaaa
oweplustno
aaaaaaaaba
twoplusone
aaaaaaaaba

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
a = int(input())
b = {}
strings = ''
ans = 0

for i in range(a):
    check = True
    strings = ''.join(sorted(list(input())))
    if strings not in b.keys():
      check = False
      b[strings] = 1
    if check == True:
      ans += b[strings]
      b[strings] += 1

print(ans)
Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from itertools import groupby
n=int(input())
l=[]
for _ in range(n):
  s=input()
  s=''.join(sorted(s))
  l.append(s)
l.sort()
c=0
for i,j in groupby(l):
  z=len(list(j))
  c=c+(z*(z-1)/2)
print(c)

Failing test case input:
3
rmusisnoca
odbbutplmb
sagcttrnon

Expected output:
0


Actual output:
0.0


Fixed submission (verdict: Accepted):
from itertools import groupby
n=int(input())
l=[]
for _ in range(n):
  s=input()
  s=''.join(sorted(s))
  l.append(s)
l.sort()
c=0
for i,j in groupby(l):
  z=len(list(j))
  c=c+(z*(z-1)
print(c)

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



A = int(input())
S = []
for i in range (0, A):
    S.append(input())

ans = 0
groupList = []
groupDict = {}

ans = 0
for i in range(0, len(S)):
    a = list(S[i])
    a.sort()
    b = ''.join(a)
    if b in groupDict:
        groupDict[b] += 1
    else :
        groupDict[b] = 1

for v in groupDict.values():
    ans += (v * (v - 1)) / 2
        
print(ans)
    

Failing test case input:
3
rmusisnoca
bmlqtubbdo
sagcttrnon

Expected output:
0


Actual output:
0.0


Fixed submission (verdict: Accepted):



A = int(input())
S = []
for i in range (0, A):
    S.append(input())

ans = 0
groupList = []
groupDict = {}

ans = 0
for i in range(0, len(S)):
    a = list(S[i])
    a.sort()
    b = ''.join(a)
    if b in groupDict:
        groupDict[b] += 1
    else :
        groupDict[b] = 1

for v in groupDict.values():
    ans += (v * (v - 1)) / 2
        
print(int(ans))

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

cnt = 0
for n in range(N):
    s = ''.join(sorted(input()))

    if s in S.keys():
        cnt += S[s]
        S[s] += 1
        print(s)
    else:
        S[s] = 1

print(cnt)


Failing test case input:
3
acornistnt
peaoutbnmb
nonstraict

Expected output:
1


Actual output:
acinnorstt
1


Fixed submission (verdict: Accepted):
N = int(input())
S = {}

cnt = 0
for n in range(N):
    s = ''.join(sorted(input()))

    if s in S.keys():
        cnt += S[s]
        S[s] += 1
    else:
        S[s] = 1

print(cnt)

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

N = int(input())
s = [0] * N


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


c = collections.Counter(s)

count = 0
for v in c.values():
    count += v-1
    

print(count)

Failing test case input:
5
abaaaaaaaa
oneplustwo
aaaaaaaaba
twoplusone
aaaabaaaaa

Expected output:
4

Actual output:
3


Fixed submission (verdict: Accepted):
import collections

N = int(input())
s = [0] * N


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


c = collections.Counter(s)

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

print(int(count))
Problem: p02947
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
  N = int(input())
  S = [input() for _ in range(N)]

  d = {}
  for i, s in enumerate(S):
    x = "".join(sorted(s))
    if x in d:
      d[x] += 1
    else:
      d[x] = 1
  print(d)
  cnt = 0
  for v in d.values():
    if v == 1:
      continue
    if v == 2:
      cnt += 1
    elif v == 3:
      cnt += v
    else:
      cnt += sum(list(range(1,v)))

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

Failing test case input:
5
aaaba_aaba
oweplustmo
abaabbaaaa
unoselpows
ab`bb`baaa

Expected output:
0


Actual output:
{'_aaaaaaabb': 1, 'elmoopstuw': 1, 'aaaaaaabbb': 1, 'elnoopssuw': 1, '``aaaabbbb': 1}
0


Fixed submission (verdict: Accepted):
def main():
  N = int(input())
  S = [input() for _ in range(N)]

  d = {}
  for i, s in enumerate(S):
    x = "".join(sorted(s))
    if x in d:
      d[x] += 1
    else:
      d[x] = 1
  
  cnt = 0
  for v in d.values():
    if v == 1:
      continue
    if v == 2:
      cnt += 1
    elif v == 3:
      cnt += v
    else:
      cnt += sum(list(range(1,v)))

  print(cnt)
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)]

Sdic = {}
ans = 0

for i in range(N):
    if S[i] not in Sdic:
        Sdic[S[i]] = 1
    else:
        Sdic[S[i]] += 1
        ans += Sdic[S[i]]
print(ans)

Failing test case input:
5
abaaaaaaaa
oweplustno
aaaaaaaaba
twoplusone
aaaabaaaaa

Expected output:
4


Actual output:
7


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

Sdic = {}
ans = 0

for i in range(N):
    if S[i] not in Sdic.keys():
        Sdic[S[i]] = 1
    else:
        ans += Sdic[S[i]]
        Sdic[S[i]] += 1
print(ans)

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


print(sum(s.values()))


Failing test case input:
5
abaaaaaaaa
oweplustno
aaaaaaaaba
enosulpowt
aaaaaaaaba

Expected output:
4


Actual output:
3


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


print(sum(sv.values()))