TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
import math
from collections import Counter as counter
ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(li() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))
##########
def main(n,s):
    res = 0
    for i in counter(s).values():
        if i <= 1 : break
        res += i*(i-1)/2
    print(res)

n = ii()
s = list("".join(sorted(input())) for _ in range(n))
main(n,s)


from collections import Counter as counter
ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(li() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))
##########
def main(n,s):
    res = 0
    for i in counter(s).values():
        if 1 < i :
            res += int(i*(i-1)/2)
    print(res)

n = ii()
s = list("".join(sorted(input())) for _ in range(n))
main(n,s)

Verdicts: Wrong Answer

Accepted
Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
N = int(input())
s = [input() for i in range(N)]
d = {}
for i in s:
    c = ''.join(sorted(i))
    if not c in  d.keys():
        d[c] = 0
    d[c] += d[c]
    e = d.values()
f = 0
for _ in e:
    f += _ - 1
if f>= 0:
    print(f)

n = int(input())

dic = {}
for i in range(n):
  s = input()
  s = sorted(s)
  s = ''.join(s)
  if not s in dic.keys():
    dic[s] = 1
  else:
    dic[s] +=1 
ans = 0

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

n = int(input())

dic = {}
for i in range(n):
  s = input()
  s = sorted(s)
  s = ''.join(s)
  if not s in dic.keys():
    dic[s] = 1
  else:
    dic[s] +=1 
ans = 0

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

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
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)

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))

Verdicts: Wrong Answer

Accepted
Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
n = int(input())
s = [input for _ in range(n)]
c = [i in range(1, n)]

n = int(input())
b = {}
ans = 0
for _ in range(n):
  x = list(input())
  x.sort()
  x = "".join(x)
  if not x in b:
    b[x] = 0
  else:
    b[x] += 1
    ans += b[x]
print(ans)

Verdicts: Runtime Error

Accepted
Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
s_hist = collections.Counter()

N = int(input())
for n in range(N):
    s = input().strip()
    s_hist[" ".join(sorted(s))] += 1

ans = 0
for pair in s_hist.most_common():
    ans += s_hist[pair[0]]*(s_hist[pair[0]]-1)/2
    if(pair[1] == 1):
        break
print(int(ans))

import collections

def make_hist(s):
  hist = collections.Counter()
  for c in s:
    hist[c] += 1
  return hist

ans = 0
s_hist = []
N = int(input())
for n in range(N):
  new_hist = make_hit(input().strip())
  for s in s_hist:
    if(s == new_hist):
      ans += 1
  s_hist.append(new_hist)
print(ans)

import collections
import string

def s_to_hist(s):
    hist = collections.Counter()
    for c in s:
        hist[c] += 1
    hist_list = []
    for al in string.ascii_letters:
        hist_list.append(str(hist[al]))
    return " ".join(hist_list)

s_hist = collections.Counter()

N = int(input())
for n in range(N):
    s = input().strip()
    s_hist[s_to_hist(s)] += 1

ans = 0
#for key in s_hist:
#    ans += s_hist[key]*(s_hist[key]-1)/2
print(int(ans))

import collections

N = int(input())
s_hist = collections.Counter()

for n in range(N):
    s = input().strip()
    s_hist[" ".join(sorted(s))] += 1

ans = 0
for pair in s_hist.most_common():
    ans += s_hist[pair[0]]*(s_hist[pair[0]]-1)/2
    if(pair[1] == 1):
        break
print(int(ans))

Verdicts: Runtime Error

Runtime Error

Wrong Answer

Accepted
Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
n = int(input())
s = {}
total = 0

for i in range(n):
    string = list(input())
    string.sort(reverse = False)
    if tuple(string) in s:
        s[tuple(string)] += 1
    else:
        s[tuple(string)] = 1

for i in s:
    if i != 1:
        total += sum([i for i in range(1,i)])

print(total)

N = int(input())
s_dict = {}
ans = 0
for i in range(N):
  string = list(input())
  string.sort(reverse=False)
  if tuple(string) in s_dict:
    s_dict[tuple(string)] += 1
  else:
    s_dict[tuple(string)] = 1

for i in s_dict.values():
  if i != 1:
    ans += sum([i for i in range(1,i)])

print(ans)


Verdicts: Runtime Error

Accepted
Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
import math

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

d = dict()
for x in a:
  s = ''.join(sorted(x))
  if s not in d.keys():
    d[s] = 1
  else:
    d[s] += 1

print(sum([comb(i, 2) for i in d.values()]))

import math

def comb(n, r):
  if n < r:
    return 0
  else:
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

d = dict()
for x in a:
  s = ''.join(sorted(x))
  if s not in d.keys():
    d[s] = 1
  else:
    d[s] += 1

print(sum([comb(i, 2) for i in d.values()]))

Verdicts: Runtime Error

Accepted
Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
#n = int(input())
#L = list(map(int, input().split()))
import math
import sys
import heapq
import fractions


def cmb(n, r):
    if n - r < r:
        r = n - r
    if r == 0:
        return 1
    if r == 1:
        return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

N = int(input())
s = []
n = 0
for i in range(N):
    s.append(list(input()))
ans = 0


for i in range(N):
    s[i]=set(s[i])
    s[i].sort()
s.sort()

for i in range(1,N):

    if s[i]==s[i-1]:
        n += 1
        if i == N-1:
            ans += cmb(n+1, 2)
    else:
        if n > 0:
            ans += cmb(n+1,2)
            n = 0
print(ans)



N = int(input())
S = []
for i in range(N):
    S.append(input())

kintama = 0
for i in range(len(S)):
    A = list(S[i])
    for j in range(i+1,len(S)+1):
        B = list(S[j])
        if set(A)==set(B):
            kintama += 1

print(kintama)



#n = int(input())
#L = list(map(int, input().split()))
import math
import sys
import heapq
import fractions


def cmb(n, r):
    if n - r < r:
        r = n - r
    if r == 0:
        return 1
    if r == 1:
        return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

N = int(input())
s = []
n = 0
for i in range(N):
    s.append(list(input()))
ans = 0


for i in range(N):
    s[i].sort()
s.sort()

for i in range(1,N):

    if s[i]==s[i-1]:
        n += 1
        if i == N-1:
            ans += cmb(n+1, 2)
    else:
        if n > 0:
            ans += cmb(n+1,2)
            n = 0
print(ans)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
n=int(input())
print(len(set([''.join(sorted(i)) for i in [input() for i in range(n)]])))

n=int(input())
print(len(set([sorted(i) for i in [input() for i in range(n)]])))

def ra(a): 
    ll,l=[],1
    for i in range(len(a)-1):
        if a[i]==a[i+1]:
            l+=1
        else:
            ll.append(l)
            l=1
    ll.append(l)
    return ll

n=int(input())
print(sum([i*(i-1)//2 for i in ra(sorted([''.join(sorted(i)) for i in [input() for i in range(n)]]))]))

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
def main():
    n = int(input())
    count = 0
    lists =[]
    count_dict = {}

    for i in range(n):
        input_data = ''.join(sorted(input()))
        if input_data in lists:
            if input_data not in count_dict.keys():
                count_dict[input_data] = 1
        
            count_dict[input_data] += 1
        else:
            lists.append(input_data)

    count = sum(
        v for v in d.values()
    )

    print(count)


if __name__ == '__main__' :
    main()

import collections

def main():
    n = int(input())
    c = [[] for i in range(n)]
    count = 0
    lists =[]

    for num in range(n):
        c[num] = input()

    for i in c:
        if i in lists:
            count = count + lists.count(i)
            lists.append(i)
        else:
            lists.append(i)

    print(count)


if __name__ == '__main__' :
    main()

import collections

def main():
    n = int(input())
    s = [[] for i in range(n)]
    c = [[] for i in range(n)]
    count = 0
    for num,i in enumerate(s):
        s[num] = input()
        c[num] = collections.Counter(i)


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

    print(count)


if __name__ == '__main__' :
    main()

def main():
    n = int(input())
    count = 0
    count_dict = {}

    for i in range(n):
        input_data = ''.join(sorted(input()))
        if input_data in count_dict:
            count += count_dict[input_data]
            count_dict[input_data] += 1
        else:
            count_dict[input_data] = 1

    print(count)


if __name__ == '__main__' :
    main()

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
n = int(input())

s = []
ss = []
for i in range(n)
	s.append(str(input()))
  	ss.append(sorted(str(input())))
  
c = 0
for i in range(n)
	for l in range(i+1,n)
  		if ss[i] == ss[l]:
      		c += 1
print(c)
  

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)

Verdicts: Runtime Error

Accepted
Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
a = map(str, input().split())
slist = []
for w in a:
    _w = ''.join(sorted(list(w)))
    slist.append(_w)
n_dup = len(slist) - len(list(set(slist)))
print(n_dup)

n = int(input())
a = map(str, input().split())
slist = []
for w in a:
    _w = ''.join(sorted(list(w)))
    slist.append(_w)
    print(_w)
n_dup = len(slist) - len(list(set(slist)))
print(n_dup)

n = int(input())
sdict = {}
for i in range(n):
    w = input()
    _w = ''.join(sorted(w))
    if _w not in sdict.keys():
        sdict[_w] = 1
    else:
        sdict[_w] += 1

def nc2(n):
    return int(n * (n-1) / 2)

n_dup = sum([nc2(val) for val in sdict.values() if val > 1])
print(int(n_dup))


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
N = int(input())
cnt = 0

sList = []

for n in range(0, N):
    string = list(input())
    sList.append(string)
    sList[n].sort()
    print(sList[n])

for i in range(0, N - 1):
    for j in range(i + 1, N):
        if sList[i] == sList[j]:
            cnt += 1
print(cnt)


import collections


def main():
    n = int(input())
    print(sum(cVal * (cVal - 1) // 2 for cVal in collections.Counter(
        [''.join(sorted(list(input()))) for _ in range(n)]).values()))


if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted
Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
Ncount = int(input())
strings = []
count_flag = 0
letters = {}
letters_count = []
for i in range(Ncount):
  strings.append(''.join(sorted(input())))
print(strings)
for i in strings:
  if i not in letters:
    letters[i] = 0
  else :
    letters[i] += 1
    letters[i] += letters[i] - 1

for i in letters:
  count_flag += letters[i] 

print(count_flag)

Ncount = input()
strings = []
count_flag = 0
letters = {}
for i in range(int(Ncount)):
  strings.append(''.join(sorted(input())))

for i in strings:
  if i not in letters:
    letters[i] = 0
  else :
    letters[i] += 1
    count_flag += letters[i]

print(count_flag)

Verdicts: Wrong Answer

Accepted
Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
import collections
n=int(input())
Words = [input() for t in range(n)]

Words2=[]
for i in Words:
        i=''.join(sorted(i))
        Words2.append(i)

c = collections.Counter(Words2)

values, counts = zip(*c.most_common())

print(counts)

ans=0
for j in counts:
        ans+=j*(j-1)//2
print(ans)


import collections
n=int(input())
Words = [input() for t in range(n)]

Words2=[]
for i in Words:
        i=''.join(sorted(i))
        Words2.append(i)

c = collections.Counter(Words2)

values, counts = zip(*c.most_common())

ans=0
for j in counts:
        ans+=j*(j-1)//2
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
di ={}
n = int(input())
di = {}
for i in range(n):
    sl = tuple(sorted(list(input()))
    if sl in di:
      di[sl] += 1
    else:
      di[sl] = 1
def nc2(n):
    a = 1
    for i in range(1,n):
        a *= i
    return int(a / 2)
ls = di.items()
cnt = 0
for i in ls:
    cnt += nc2(i[1])
print(cnt)


n = int(input())
di = {}
for i in range(n):
    sl = "".join(sorted(list(input())))
    if sl in di:
      di[sl] += 1
    else:
      di[sl] = 1
def nc2(n):
    a = n * (n-1) /2
    return int(a) #1c2 =0
ls = di.items()
cnt = 0
for i in ls:
    cnt += nc2(i[1])
print(cnt)


Verdicts: Runtime Error

Accepted
Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
N = int(input())
s = [sorted(input()) for i in range(N)]

s_int = []
a_ord = ord('a')
for _s in s:
    v = list(map(lambda x: ord(x)-a_ord, _s))
    v = sum([v[i]*26**i for i in range(len(v))])
    s_int.append(v)

s_int = sorted(s_int)

cnt = 0
old = -1
for i in s_int:
    _cnt = 1
    if old == i:
        _cnt += 1
    else:
        cnt += _cnt * (_cnt+1)
        _cnt = 1
        old = i

print(cnt)


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(d.values()))


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())))


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())))


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
n = int(input())
s = [input() for i in range(n)]
ss = [sorted(s[i]) for i in range(n)]
dic = [''.join(ss[i]) for i in range(n)]
cnt = 0
for i in range(len(dic)-1):
    for j in range(len(dic)-2):
        if dic[i] == dic[j]:
            cnt += 1
print(int(cnt)-len(dic))


n = int(input())
s = [input() for i in range(n)]
ss = [sorted(s[i]) for i in range(n)]
dic = [''.join(ss[i]) for i in range(n)]
key = [i for i in set(dic)]
cnt = 0
for i in range(len(dic)-1):
    if dic[i] == dic[i+1]:
        cnt += 1
print(int(cnt))


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


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
import math
n = int(input())
lst = list()
num = 0
flag = 1
for i in range(n):

    s = input()
    s = list(s)
    s.sort()
    lst.append(s)

lst.sort()

for i in range(n-1):
    if (lst[i] == lst[i+1]):
        flag = flag + 1
    else:
        num = num + math.factorial(flag) // (math.factorial(flag - 2) * 2)
        flag = 1
if (flag > 1):
    num = num + math.factorial(flag) // (math.factorial(flag - 2) * 2)
print(num)


n = int(input())
lst = list()
num = 0
for i in range(n):

    s = input()
    s = list(s)
    s.sort()
    lst.append(s)
print(lst)

for i in range(n):
    for j in range(i+1, n):
        if (lst[i] == lst[j]):
            num = num + 1
print(num)


import math
n = int(input())
lst = list()
num = 0
flag = 1
for i in range(n):

    s = input()
    s = list(s)
    s.sort()
    lst.append(s)

lst.sort()

for i in range(n-1):
    if (lst[i] == lst[i+1]):
        flag = flag + 1
    else:
        if (flag > 1):
            num = num + math.factorial(flag) // (math.factorial(flag - 2) * 2)
        flag = 1
if (flag > 1):
    num = num + math.factorial(flag) // (math.factorial(flag - 2) * 2)
print(num)


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
import fractions


def P(n, r):
    return fractions.factorial(n)//fractions.factorial(n-r)

def C(n, r):
    return P(n, r)//fractions.factorial(r)

n = int(input())
str_list = []
for i in range(n):
    str_list.append(list(sorted(input())))
str_list=sorted(str_list)
str_list.append("a")

ans=0
cnt=0
for i in range(n):
    if str_list[i]==str_list[i+1]:
        cnt+=1
    else:
        if cnt==1:
            ans+=1
            cnt = 0
        else:
            ans+=C(cnt+1,2)
            cnt=0

print(ans)


import math


def P(n, r):
    return math.factorial(n)//math.factorial(n-r)

def C(n, r):
    return P(n, r)//math.factorial(r)

n = int(input())
str_list = []
for i in range(n):
    str_list.append(list(sorted(input())))
str_list=sorted(str_list)
str_list.append("a")

ans=0
cnt=0
for i in range(n):
    if str_list[i]==str_list[i+1]:
        cnt+=1
    else:
        if cnt==1:
            ans+=1
            cnt = 0
        else:
            ans+=C(cnt+1,2)
            cnt=0

print(ans)


def fact(n):
    if n == 0 or n == 1:
        return 1
    else:
        return n * fact(n-1)

def P(n, r):
    return fact(n)//fact(n-r)

def C(n, r):
    return P(n, r)//fact(r)

n = int(input())
str_list = []
for i in range(n):
    str_list.append(list(sorted(input())))
str_list=sorted(str_list)
str_list.append("a")

ans=0
cnt=0
for i in range(n):
    if str_list[i]==str_list[i+1]:
        cnt+=1
    else:
        if cnt==1:
            ans+=1
            cnt = 0
        else:
            ans+=C(cnt+1,2)
            cnt=0

print(ans)


from collections import Counter
import sys
input = sys.stdin.readline

n = int(input())
s = [''.join(sorted(input())).strip() for _ in range(n)]
c = Counter(s)
ans=sum(map(lambda x: x*(x-1)//2, c.values()))
print(ans)


Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
def resolve():
    n = int(input())
    words = []
    for _ in range(n):
        words.append(str(sorted(list(input()))))
    a = collections.Counter(words)
    ans = 0
    for i in a.values():
        ans += i*(i-1)//2
    print(ans)
resolve()

import collections
def resolve():
    n = int(input())
    words = []
    for _ in range(n):
        words.append(str(sorted(list(input()))))
    a = collections.Counter(words)
    ans = 0
    for i in a.values():
        ans += i*(i-1)//2
    print(ans)
resolve()

Verdicts: Runtime Error

Accepted
Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
n = int(input())
s=[]
for i in range(n):
    
    b=list(input())
    b.sort
    mojiretu = ''.join(b)
    if mojiretu not in s:
        s.append(mojiretu)
print(len(s))

#c
n = int(input())
count=0
dic={}
for i in range(n):
    
    b=list(input())
    b.sort()
    mojiretu = ''.join(b)
    if mojiretu not in dic:
        dic[mojiretu] =1
    else:
        dic[mojiretu] +=1
for v in dic.values():
    count += v*(v-1)//2
print(count)

Verdicts: Wrong Answer

Accepted
Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
N=int(input())
sn=[list(input()).sort() for _ in range(N)]
print(sn)

N=int(input())
dict={}
for _ in range(N):
  s=''.join(sorted(input()))
  dict[s]=dict.setdefault(s,0)+1
  
cnt=0
for c in dict.values():
  cnt+=(1+c-1)*(c-1)//2
  
print(cnt)

Verdicts: Wrong Answer

Accepted
Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
def main():
    n = int(input())
    s = [["" for j in range(10)] for i in range(n)]

    for i in range(n):
        s[i] = list(input()).sort()

    print(int(count_anagram(s[0], s[1:], 0)))


def count_anagram(s, str_list, total):
    cnt = 0
    tmp = []
    for i, t in enumerate(str_list):
        if s == t:
            cnt += 1
            tmp.append(i)
    if cnt > 0:
        total += (cnt+1) * cnt / 2
        for i in tmp:
            str_list.pop(i)

    if str_list:
        return count_anagram(str_list[0], str_list[1:], total)
    else:
        return total


if __name__ == '__main__':
    main()


import collections

n = int(input())
s = ["".join(sorted(input())) for i in range(n)]

counter = collections.Counter(s)

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

print(ans)


Verdicts: Runtime Error

Accepted
Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
from collections import defaultdict
n = int(input())
s = [''.join(sorted(input())) for i in range(n)]
dd = defaultdict(int)
for i in range(n):
  dd[s[i]] += 1
c = 0
print(dd)
for i in dd.values():
  c += i * (i-1) // 2
print(c)

from collections import defaultdict
n = int(input())
s = [''.join(sorted(input())) for i in range(n)]
dd = defaultdict(int)
for i in range(n):
  dd[s[i]] += 1
c = 0
for i in dd.values():
  c += i * (i-1) // 2
print(c)

Verdicts: Wrong Answer

Accepted
Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
import sys
inputs = sys.stdin.readlines()

n = int(inputs[0])
S = inputs[1:]

d = defaultdict(lambda: -1)
for i in range(n):
    s = ''.join(sorted(list(S[i])))
    d[s] += 1

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

import sys
from collections import defaultdict
inputs = sys.stdin.readlines()

n = int(inputs[0])
S = inputs[1:]

d = defaultdict(lambda: -1)
for i in range(n):
    s = ''.join(sorted(list(S[i].rstrip())))
    d[s] += 1

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

Verdicts: Runtime Error

Accepted
Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
N = int(input())
D = {}
for _ in range(N):
    S = "".join(sorted(input()))
    print("S",S)
    print("D",D)
    if S in D:
        D[S] += 1
    else:
        D[S] = 1

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

print(ans)

N = int(input())
D = {}
for _ in range(N):
    S = "".join(sorted(input()))
    print("S",S)
    print("D",D)
    if S in D:
        D[S] += 1
    else:
        D[S] = 1

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

print(ans)

n = int(input())
s = [sorted(input()) for i in range(n)]

S = []
ans = 0
for i in range(n):
    if s[i] in S:
        ans += 1
    else:
        S.append(s[i])

ans = ans + (len(S) - 1)
print(ans)

N = int(input())
D = {}
for _ in range(N):
    S = "".join(sorted(input()))
    if S in D:
        D[S] += 1
    else:
        D[S] = 1

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

print(ans)

Verdicts: Runtime Error

Runtime Error

Wrong Answer

Accepted
Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
import copy
import math
import sys

sys.setrecursionlimit(10 ** 7)

N = int(input())
s_list = [input() for i in range(N)]


def split(word):
    return [char for char in word]


normalized_s_list = sorted([''.join(sorted(split(s))) for s in s_list])

uniqued_s_list = sorted(list(set(normalized_s_list)))

j = 0
counter = 0
result = 0
for s in normalized_s_list:
    print(j)
    if s == uniqued_s_list[j]:
        counter += 1
    else:
        result += (1 / 2) * counter * (counter - 1)
        j += 1
        counter = 1  

result += (1 / 2) * counter * (counter - 1)
print(int(result))


import copy
import math
import sys

sys.setrecursionlimit(10 ** 7)

N = int(input())
s_list = [input() for i in range(N)]


def split(word):
    return [char for char in word]


normalized_s_list = sorted([''.join(sorted(split(s))) for s in s_list])

uniqued_s_list = list(set(normalized_s_list))

j = 0
counter = 0
result = 0
for s in normalized_s_list:
    if s == uniqued_s_list[j]:
        counter += 1
    else:
        result += (1 / 2) * counter * (counter - 1)
        j += 1
        counter = 1  

result += (1 / 2) * counter * (counter - 1)
print(int(result))


import copy
import math
import sys

sys.setrecursionlimit(10 ** 7)

N = int(input())
s_list = [input() for i in range(N)]


def split(word):
    return [char for char in word]


normalized_s_list = sorted([''.join(sorted(split(s))) for s in s_list])

uniqued_s_list = sorted(list(set(normalized_s_list)))

j = 0
counter = 0
result = 0
for s in normalized_s_list:
    if s == uniqued_s_list[j]:
        counter += 1
    else:
        result += (1 / 2) * counter * (counter - 1)
        j += 1
        counter = 1  

result += (1 / 2) * counter * (counter - 1)
print(int(result))


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
from math import factorial
N = int(input())
P = {}
ans = 0
def counter(s):
    ret = [0]*26
    for ss in s:
        ret[ord(ss)-ord('a')] += 1
    return tuple(ret)
for _ in range(N):
    s = input()
    c = counter(s)
    if not c in P.keys():
        P[c] = 1
    else:
        P[c] += 1
for v in P.values():
    ans += factorial(v) // factorial(2) // factorial(v-2)
print(ans)


from math import factorial
N = int(input())
P = {}
ans = 0
def counter(s):
    ret = [0]*26
    for ss in s:
        ret[ord(ss)-ord('a')] += 1
    return tuple(ret)
for _ in range(N):
    s = input()
    c = counter(s)
    if not c in P.keys():
        P[c] = 1
    else:
        P[c] += 1
for v in P.values():
    ans += factorial(v) / factorial(2) / factorial(v-2)
print(int(ans))


from math import factorial
N = int(input())
P = {}
ans = 0
def counter(s):
    ret = [0]*26
    for ss in s:
        ret[ord(ss)-ord('a')] += 1
    return tuple(ret)
for _ in range(N):
    s = input()
    c = counter(s)
    if not c in P.keys():
        P[c] = 1
    else:
        P[c] += 1
for v in P.values():
    if v > 1:
        ans += factorial(v) // factorial(2) // factorial(v-2)
print(ans)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
from collections import Counter

n = int(input())
s = [input() for i in range(n)]
st = []
ans = 0
for i in range(n):
    sti = str(sorted(s[i]))
    st.append(sti)
count = Counter(st)
for i in count.values():
    if i != 1:
        for j in range(1, i):
            ans += j * (j - 1) // 2
print(ans)


n = int(input())
s = [input() for i in range(n)]
st = []
ans = 0
for i in range(len(s)):
    st.append(list(tuple(s[i])))
    st[i].sort()
    st.sort()
    if st[i - 1] == st[i]:
        ans += 1
print(ans)


from collections import Counter

n = int(input())
s = [input() for i in range(n)]
st = []
ans = 0
for i in range(n):
    st.append(list(tuple(s[i])))
    st[i].sort()
    st[i] = str(st[i])
st.sort()
count = Counter(st)
for v in count.values():
    if v != 1:
        for n in range(1, v):
            ans += n
print(ans)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
# -*- coding: utf-8 -*-
from collections import Counter
from itertools import combinations

N = int(input())
c = ["".join(sorted(str(input()))) for x in range(N)]
cs = Counter(c)

print(cs)
ans=0
for i in cs.values():
    if i!=1:
        ans += (i * (i-1))/2

print(int(ans))

# -*- coding: utf-8 -*-
from collections import Counter
from itertools import combinations

N = int(input())
c = ["".join(sorted(str(input()))) for x in range(N)]
cs = Counter(c)

ans=0
for i in cs.values():
    if i!=1:
        ans += (i * (i-1))/2

print(int(ans))

Verdicts: Wrong Answer

Accepted
Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
n = int(input())
s = [input() for i in range(n)]
def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

# [[1, 1], [0, 1], [0, 0], [1, 0]]
for i in range(n):
    s[i] = sorted(s[i])
print(len(get_unique_list(s)))

n = int(input())
s = [input() for i in range(n)]
def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

# [[1, 1], [0, 1], [0, 0], [1, 0]]
dic = {}

for i in range(n):
    sen = '・'.join(sorted(s[i]))
    #print(sen)
    if sen not in dic:
        dic[sen]=1
    else:
        dic[sen]+=1    
#print(dic)
ans = 0
for i in dic.values():
    ans += i*(i-1)//2
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
S=[]
cho=[0]
p=0
n = int(input())
for i in range(n):
    s=sorted(input())
    if s in S:
        cho[p]+=1
        p+=1
    S.append(s)
import collections
from scipy.special import comb
a=0
Sd=list(set(S))
c = collections.Counter(S)
for p in  range(len(Sd)):
    if c[Sd[p]] >=2:
        a  += comb(c[Sd[p]], 2, exact=True)
print(a)

S=[]
n = int(input())
for i in range(n):
    s=''.join(sorted(input()))
    S.append(s)
import collections
from scipy.special import comb
a=0
Sd=list(set(S))
c = collections.Counter(S)
for p in  range(len(Sd)):
    if c[Sd[p]] >=2:
        a  += comb(c[Sd[p]], 2, exact=True)
print(a)

Verdicts: Runtime Error

Accepted