Problem:


Score : 300 points

Problem Statement

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.

Constraints

2 \leq N \leq 10^5

s_i is a string of length 10.

Each character in s_i is a lowercase English letter.

s_1, s_2, \ldots, s_N are all distinct.

Input

Input is given from Standard Input in the following format:

N
s_1
s_2
:
s_N

Output

Print the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Sample Input 1

3
acornistnt
peanutbomb
constraint

Sample Output 1

1

s_1 = acornistnt is an anagram of s_3 = constraint. There are no other pairs i, j such that s_i is an anagram of s_j, so the answer is 1.

Sample Input 2

2
oneplustwo
ninemodsix

Sample Output 2

0

If there is no pair i, j such that s_i is an anagram of s_j, print 0.

Sample Input 3

5
abaaaaaaaa
oneplustwo
aaaaaaaaba
twoplusone
aaaabaaaaa

Sample Output 3

4

Note that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.



Sample input:
3
acornistnt
peanutbomb
constraint


Sample output:
1

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

int main (){
  int n;
  cin >> n;
  vector<string> vec;
  for (int i=0;i<n;i++) {
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    int j=0;
    vec.push_back(s);
  }
  sort(vec.begin(),vec.end());
  long long int count=0;
  vector<string>::iterator sx = vec.begin();
  long long int count_=0;
  int count__=0;
  /*
  for (int i=0;i<n;i++){
    if (*sx==*(sx+1)){
      if (count_==0){
        count_=1;
      }
      count_++;
    } else {
      count+=count_*(count_-1)/2;
      count_=0;
    }
    sx++;
  }
  */
  cout << count;
}

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main (){
  int n;
  cin >> n;
  vector<string> vec;
  for (int i=0;i<n;i++) {
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    int j=0;
    vec.push_back(s);
  }
  sort(vec.begin(),vec.end());
  long long int count=0;
  vector<string>::iterator sx = vec.begin();
  long long int count_=0;
  int count__=0;
  /*
  for (int i=0;i<n;i++){
    if (*sx==*(sx+1)){
      if (count_==0){
        count_=1;
      }
      count_++;
    } else {
      count+=count_*(count_-1)/2;
      count_=0;
    }
    sx++;
  }
  */
  cout << count;
}

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main (){
  int n;
  cin >> n;
  vector<string> vec;
  for (int i=0;i<n;i++) {
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    int j=0;
    vec.push_back(s);
  }
  sort(vec.begin(),vec.end());
  long long int count=0;
  vector<string>::iterator sx = vec.begin();
  long long int count_=0;
  int count__=0;
  for (int i=0;i<n;i++){
    if (*sx==*(sx+1)){
      if (count_==0){
        count_=1;
      }
      count_++;
    } else {
      count+=count_*(count_-1)/2;
      count_=0;
    }
    sx++;
  }
  cout << count;
}

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main (){
  int n;
  cin >> n;
  vector<string> vec;
  string s;
  for (int i=0;i<n;i++) {
    vector<char> vechar;
    cin >> s;
    for (int j=0;j<10;j++){
      vechar.push_back(s[j]);
    }
    sort(vechar.begin(),vechar.end());
    int j=0;
    for (vector<char>::iterator vechar_ = vechar.begin();vechar_!=vechar.end();vechar_++){
      s[j]=*vechar_;
      j++;
    }
    vec.push_back(s);
  }
  sort(vec.begin(),vec.end());
  long long int count=0;
  vector<string>::iterator sx = vec.begin();
  long long int count_=0;
  int count__=0;
  for (int i=0;i<n;i++){
    if (*sx==*(sx+1)){
      if (count_==0){
        count_=1;
      }
      count_++;
    } else {
      count+=count_*(count_-1)/2;
      count_=0;
    }
    sx++;
  }
  cout << count;
}

Submission status: Runtime Error

Solution code:
import math

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

S_dict = {}

for S in S_lists:
    S_list = list(S)
    S_list.sort()

    S_str = "".join(S_list)
    if S_str in S_dict.keys():
        S_dict[S_str] = S_dict[S_str] + 1
    else:
        S_dict[S_str] = 1

answer = 0
for v in S_dict.values():
    if v > 1:
        answer += int(math.factorial(v) / 2)

print(answer)

Submission status: Runtime Error

Solution code:
# B - One Clue
def main():
    count = int(input())
    data = []
    for i in range(count):
        data.append(''.join(sorted(str(input()))))
    unique = list(set(data))
    sameCount = [0 for i in range(len(unique))]
    for j in range(len(unique)):
        for k in range(count):
            if unique[j] == data[k]:
                sameCount[j] = 1 + sameCount[j]

    print(sum(list(range(sameCount[0]))) + sum(list(range(sameCount[1]))))
        

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
n=int(input())
s = [ str(input()) for _ in range(n)]
s = sorted([sorted(x) for x in s])
pairs = 0
from math import factorial
# for i in range(n):
#     for j in range(i+1, n):
#         if s[i] == s[j]:
#             pairs.append(tuple([i,j]))
def comb(n, r):
    return (factorial(n) / factorial(r) / factorial(n - r))

i=0
while i < n-1:
    sames = 0
    for j in range(i+1, n):
        if s[i] == s[j]:
            sames += 1
            continue
        else:
            break
    i += sames + 1
    if sames != 0:
        pairs += comb(sames + 1, 2)

print(int(pairs))

Submission status: Runtime Error

Solution code:
from scipy.misc import comb
 
N = int(input())
s = {}
for _ in range(N):
    b = list(input())
    b.sort()
    c = ''.join(b)
    if not b in s:
        s[b] = 1
    else:
        s[b] += 1
 
a = [comb(v, 2, exact=True) for v in s.values()]
print(sum(a))

Submission status: Runtime Error

Solution code:
from scipy.misc import comb
 
N = int(input())
s = {}
for _ in range(N):
    b = sorted(input())
    #b.sort()
    #c = ''.join(b)
    if not b in s:
        s[b] = 1
    else:
        s[b] += 1
 
a = [comb(v, 2, exact=True) for v in s.values()]
print(sum(a))

Submission status: Runtime Error

Solution code:
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))

Submission status: Runtime Error

Solution code:
from math import factorial

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

li = []
for s in S:
    st = "".join(sorted(list(s)))
    li.append(st)

di = {}
for i in sorted(li):
    if i in di:
        di[i] = di[i] + 1
    else:
        di[i] = 1


ans = 0
for k, v in di.items():
    if v > 1:
        ans += int(factorial(v) / factorial(2) / factorial(v - 2))

print(ans)

Submission status: Runtime Error

Solution code:
from scipy.special import comb

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

li = []
for s in S:
    st = "".join(sorted(list(s)))
    li.append(st)

d = {}
for i in sorted(li):
    if i in d:
        d[i] = d[i] + 1
    else:
        d[i] = 1


ans = 0
for k, v in d.items():
    ans += comb(v, 2, exact=True)

print(ans)

Submission status: Runtime Error

Solution code:
N = input()
s = [''.join(sorted(input())) for i in range(N)]
ans=0
dict={}
for i in s:
  if i in dict:
    ans+=dict[i]
    dict[i]+=1
  else:
    dict[i]=1
print(ans)

Submission status: Runtime Error

Solution code:
N = input()
s = [''.join(sorted(input())) for i in range(N)]
ans=0
dict={}
for i in s:
  if i in dict:
    ans+=dict
    dict[i]+=1
  else:
    dict[i]=1
print(ans)

Submission status: Runtime Error

Solution code:
import collections
from math import factorial

N = int(input())
S = [0]*N
for i in range(N):
    s = list(str(input()))
    s.sort()
    S[i] = "".join(s)

c = collections.Counter(S)
cnt = 0
r = 2

for n in c.values():
    if n >= 2:
        cnt += factorial(n) / factorial(r) / factorial(n - r)
print(int(cnt))

Submission status: Runtime Error

Solution code:
import collections
from math import factorial

N = int(input())
S = [0]*N
for i in range(N):
    s = list(str(input()))
    s.sort()
    S[i] = "".join(s)

c = collections.Counter(S)
V = c.values()
V.sort()
cnt = 0
r = 2

for n in c.values():
    if n >= 2:
        cnt += factorial(n) / factorial(r) / factorial(n - r)
print(int(cnt))

Submission status: Runtime Error

Solution code:
import collections
from math import factorial

N = int(input())
S = [0]*N
for i in range(N):
    s = list(str(input()))
    s.sort()
    S[i] = "".join(s)
print(S)

c = collections.Counter(S)
cnt = 0
r = 2
for n in c.values():
    if n >= 2:
        cnt += factorial(n) / factorial(r) / factorial(n - r)
print(int(cnt))

Submission status: Runtime Error

Solution code:
import numpy as np

anum = {}
ans = 0

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

for i in s:
    if i in anum:
        ans += anum[i]
    else:
        anum[i] = 1

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

anum = {}
ans = 0

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

for i in range(N):
    if strings[i] in anum:
        ans += anum[i]
    else:
        anum[strings[i]] = 1

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
s = []
count = 1
ans = 0

def factorial(n):
    if n == 1:
        return 1
    else:
        return n * factorial(n-1)

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

for i in range(1,n):
    if (s[i-1] == s[i]):
        count+=1
    if(s[i-1] != s[i] or (i == n-1 and count>1)):
        ans += factorial(count) / (factorial(count-2) * 2)
        count = 1
print(ans)

Submission status: Runtime Error

Solution code:
from scipy.special import perm, comb
n = int(input())
s = []
count = 1
ans = 0

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

for i in range(1,n):
    if (s[i-1] == s[i]):
        count+=1
    if(s[i-1] != s[i] or (i == n-1 and count>1)):
        ans += comb(count, 2, exact=True)
        count = 1
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
s=[[] for i in range n]
r=0
for i in range(n):
  a=input()
  for j in a:
    s[i].append(j)
    s[i].sort()
s.sort()
k=0
for i in range (n-1):
  if s[i]==s[i+1]:
    k+=1
  else:
    r+=k*(k-1)/2
    k=0
print(r)

Submission status: Runtime Error

Solution code:
import math
from collections import Counter, defaultdict

def ncr(n, r):
	f = math.factorial
	return f(n)//f(r)//f(n-r)

n = int(input())

dct = defaultdict(int)

for i in range(n):
	counter = Counter(input().strip())
	tpl = tuple(sorted(counter.items()))
	dct[tpl] += 1
ans = sum(ncr(val, 2) for val in dct.values())

print(ans)

Submission status: Runtime Error

Solution code:
from collections import Counter
n = int(input())
ss = [sorted(input()) for i in range(n)]
cnt = 0
counter = Counter(ss)
for k, v in counter.items():
  cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
from collections import Counter
n = int(input())
ss = [sorted(input()) for i in range(n)]
cnt = 0
counter = Counter(ss)
for k, v in counter.items():
  cnt += v*(v-1)/2
print(cnt)

Submission status: Runtime Error

Solution code:
n = int(input())
ss = [sorted(input()) for i in range(n)]
cnt = 0
dic = {}
for s in ss:
  if s not in dic.keys():
    dic[s]=1
  else:
    dic[s]+=1
print(cnt)

Submission status: Runtime Error

Solution code:
n = int(input())
ss = [sorted(input()) for i in range(n)]
cnt = 0
dic = {}
for s in ss:
  if s not in dic.keys():
    dic[s]=1
  else :
    dic[s]+=1
for v in dic.values():
  cnt += v*(v-1)/2
print(cnt)

Submission status: Runtime Error

Solution code:
from collections import Counter
n = int(input())
ss = [sorted(input()) for i in range(n)]
dic = Counter(ss)

Submission status: Runtime Error

Solution code:
n = int(input())
ss = [sorted(input()) for i in range(n)]
cnt=0
dic = {}
for s in ss:
  if s not in dic.keys():
    dic[s] = 1
  else :
    dic[s] += 1
for v in dic.values():
  cnt += v
print(cnt)

Submission status: Runtime Error

Solution code:
from collections import Counter
n = int(input())
ss = [sorted(input()) for i in range(n)]
dic = Counter(ss)
cnt=0
for k, v in dic.items():
  cnt += int(v)
print(cnt)

Submission status: Runtime Error

Solution code:
from collections import Counter
n = int(input())
ss = [sorted(input()) for i in range(n)]
dic = Counter(ss)
cnt=0
for k, v in dic.items():
  cnt += v
print(cnt)

Submission status: Runtime Error

Solution code:
from collections import Counter
n = int(input())
ss = [sorted(input()) for i in range(n)]
dic = Counter(ss)
cnt=0
for k, v in dic:
  cnt += v
print(cnt)

Submission status: Runtime Error

Solution code:
from math import factorial
import collections
N, *s = open(0).read().split()
s_sorted = [''.join(sorted(c)) for c in s]
c = collections.Counter(s_sorted)
res = list(set(s_sorted))
count = 0
for s in res:
  if c[s] > 2:
    count += factorial(c[s]) / factorial(2) / factorial(c[s] - 2)
  elif c[s] == 2:
    count += 1
print(count)

Submission status: Runtime Error

Solution code:
from math import factorial
import collections
N, *s = open(0).read().split()
s_sorted = [''.join(sorted(c)) for c in s]
c = collections.Counter(s_sorted)
res = list(set(s_sorted))
count = 0
for s in res:
  if c[s] > 2:
    count += factorial(c[s]) / factorial(2) / factorial(c[s] - 2)
  elif c[s] == 2:
    count += 1
print(int(count))

Submission status: Runtime Error

Solution code:
from math import factorial
import collections
import itertools
N, *s = open(0).read().split()
s_sorted = [''.join(sorted(c)) for c in s]
c = collections.Counter(s_sorted)
res = list(set(s_sorted))
count = 0
for s in res:
  if c[s] > 2:
    #count += len(list(itertools.combinations(range(c[s]), 2)))
    count += factorial(c[s]) / factorial(2) / factorial(c[s] - 2)
  elif c[s] == 2:
    count += 1
print(int(count))

Submission status: Runtime Error

Solution code:
N, *s = open(0).read().split()
s_sorted = []
s_sorted = ''.join(sorted(c)) for c in s:
count = 0
for s in s_sorted:
  count += s_sorted.count(s)-1
  s_sorted.pop(0)
print(count)

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
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))

Submission status: Runtime Error

Solution code:
N = int(input())
s = list(map(int,input().split()))

import collections as coll
import sys

x = coll.Counter(s[N])

for i in range(len(s)):
  ti = coll.Counter(s[i])
  if x = ti:
    print(i)
    sys.exit()
  else:
    pass
  
print(0)

Submission status: Runtime Error

Solution code:
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))

Submission status: Runtime Error

Solution code:
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 += factorial(i)/factorial(2)/factorial(i-2)

print(int(counter))

Submission status: Runtime Error

Solution code:
import collections
from scipy.special import comb

N = int(input())
s = []
for _ in range(N):
    s.append(list(input()))

for i in range(len(s)):
    s[i] = tuple(sorted(s[i]))
    
c = collections.Counter(s)

cnt = 0
for c_ in c.values():
    cnt += comb(c_, 2)
    
print(int(cnt))

Submission status: Runtime Error

Solution code:
from math import factorial

def ncr(n, r):
    if n < r:
        return 0
    return factorial(n) / factorial(r) / factorial(n - r)

N = int(input())

from collections import defaultdict

s = defaultdict(int)

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

print(int(sum([ncr(v, 2) for v in s.values()])))

Submission status: Runtime Error

Solution code:
from math import factorial

def ncr(n, r):
    return factorial(n) / factorial(r) / factorial(n - r)

N = int(input())

from collections import defaultdict

s = defaultdict(int)

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

print(int(sum([ncr(v, 2) for v in s.values()])))

Submission status: Runtime Error

Solution code:
N= int(input())
s = []

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

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

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

print(counter)

Submission status: Runtime Error

Solution code:
N= int(input())
s = []

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

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

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

print(counter)

Submission status: Runtime Error

Solution code:
N= int(input())
s = []

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

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

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

print(counter)

Submission status: Runtime Error

Solution code:
k, x = tuple([int(i) for i in input().split(' ')])

print(" ".join([str(i) for i in range(x - k + 1, x + k)]))

Submission status: Runtime Error

Solution code:
n = int(input())
ss = []
cnt = 0

# for _ in range(n):
#     ss.append(input())

# for i, s1 in enumerate(ss[0:n-2+1]):
#     for s2 in ss[i + 1:n-1+1]:
#         # print(s1, s2)
#         if sorted(s1) == sorted(s2):
#             cnt += 1

for _ in range(n):
    ss.append(input())

map = {}
for s in ss:
    sorted_s = ''.join(sorted(s))
    if sorted_s in map.keys():
        map[sorted_s] += 1
    else:
        map[sorted_s] = 1


# map = {'a': 1, 'b': 2, 'c': 3, 'd': 4}

# print(map)


def factorial(n):
    if n > 0:
        return n * factorial(n-1)
    else:
        return 1

# あとはxC2の組み合わせの総数を求めれば良い


for n in map.values():
    if n > 1:
        cnt += factorial(n) // (2 * factorial(n-2))
    # print(n)
    # print(cnt)

print(cnt)

Submission status: Runtime Error

Solution code:
n = int(input())
ss = []
cnt = 0

# for _ in range(n):
#     ss.append(input())

# for i, s1 in enumerate(ss[0:n-2+1]):
#     for s2 in ss[i + 1:n-1+1]:
#         # print(s1, s2)
#         if sorted(s1) == sorted(s2):
#             cnt += 1

for _ in range(n):
    ss.append(input())

map = {}
for s in ss:
    sorted_s = ''.join(sorted(s))
    if sorted_s in map.keys():
        map[sorted_s] += 1
    else:
        map[sorted_s] = 1

# print(map)

def factorial(n):
    x = 1
    if n > 0:
        x = n * factorial(n-1)
    return x

# あとはxC2の組み合わせの総数を求めれば良い

for n in map.values():
    if n == 1:
        continue
    cnt += factorial(n) // 2 * factorial(n-2)

print(cnt)

Submission status: Runtime Error

Solution code:
N = int(input())
S = [input() for i in range(N)]
 
d = {}
for s in S:
  s = "".join(sorted(s))
  if s in d:
    d[s] += 1
  else:
    d[s] = 1

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

Submission status: Runtime Error

Solution code:
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  # このとき s と uniqued_s_list[j] は同じはずなので

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

Submission status: Runtime Error

Solution code:
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())
arr = {}
ans = 0
for _ in range(N):
    S = input()
    tmp_arr = []
    for i in range(10):
        tmp_arr.append(S[i])
    tmp_arr.sort()
    moji_sorted = ''
    for i in tmp_arr:
        moji_sorted += i
    if moji_sorted in arr:
        arr[moji_sorted] += 1
    else:
        arr[moji_sorted] = 1
# print(arr)

for i in arr.values():
    ans += C(i,2)

print(ans)

Submission status: Runtime Error

Solution code:
word_dict={}
for word in S:
  word=''.join(sorted(word))
  if word in word_dict.keys() and word_dict[word]==0:#2nd
    word_dict[word] = word_dict[word]+1
  elif word in word_dict.keys() and word_dict[word]==1:#3rd
    word_dict[word]= word_dict[word]+2
  elif word in word_dict.keys() and word_dict[word]==3:#4th
    word_dict[word]= word_dict[word]+3
  elif word in word_dict.keys() and word_dict[word]==6:#5th
    word_dict[word]= word_dict[word]+4
  elif word in word_dict.keys() and word_dict[word]==10:#6th
    word_dict[word]= word_dict[word]+5
  elif word in word_dict.keys() and word_dict[word]==15:#7th
    word_dict[word]= word_dict[word]+6
  else:
    word_dict[word] = 0
print(word_dict)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
N, M = map(int, input().split())
A = [] # 日後
B = [] # 報酬
for i in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)

c = 0
for i in range(M):
  if A[i] + i < M:
    c = c + B[i]
  
# 文字列の入力
# s = input()
# 出力
print(c)

Submission status: Runtime Error

Solution code:
N_number = int(input())
strings = []
count = 0
for i in range(N_number):
  string = input().sort()
  if string in strings:
    count += 1
  strings.append(string)
  
print(count)

Submission status: Runtime Error

Solution code:
N_number = int(input())
strings = []
count = 0
for i in N_number:
  string = input().sort()
  if string in strings:
    count += 1
  strings.append(string)
  
print(count)

Submission status: Runtime Error

Solution code:
import statistics as stat
import collections as cl

N = int(input())

s_li = []
s_dic:dict = {}
c = 0
for i in range(N) :
    s = ''.join(sorted(list(input())))
    # con = s_li.count(s)
    # if (con >= 1) :
    #     c += con
    # s_li.append(s)
    if (s in s_dic) :
        c += s_dic[s]
        s_dic[s] += 1
    else :
        s_dic[s] = 1
print(c)

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(){
    int N;
    map<string, ll> m;
    cin >> N;
    string S;
    for(int i=0;i<N;i++){
        cin >> S;
        vector<char> v;
        //範囲ベースforループ
        for(auto x:S)v.push_back(x);
        sort(v.begin(), v.end());
        string T = "";
        for(auto x:v)T += x;
        m[T]++;
    }
    ll ans = 0;
    for(auto x:m) ans += (x.second-1)*x.second/2;
    cout << ans << endl;
}

Submission status: Runtime Error

Solution code:
n=int(input())
string_list=[sorted(input()) for i in range(n)]
string_set=set(string_list)
cnt=0
for s in string_set:
  n=string_list.count(s)
  cnt+=int(n*(n-1)/2)
print(cnt)

Submission status: Runtime Error

Solution code:
from collections import Counter
n=int(input())
string_list=[Counter(input()) for i in range(n)]
string_set=set(string_list)
cnt=0
for s in string_set:
  n=string_list.count(s)
  cnt+=int(n*(n-1)/2)
print(cnt)

Submission status: Runtime Error

Solution code:
from collections import Counter
n=int(input())
string_list=[sorted(Counter(input()), key=lambda x:x[0]) for i in range(n)]
cnt=0
for i in range(n):
  si = string_list[i]
  for j in range(i, n):
    sj = string_list[j]
    if si.items() == sj.items():
      cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
from collections import defaultdict as dd
N = int(input())
S = []
for i in range(N):
    s = input()
    s = sorted(s)
    s = ''.join(s)
    S.append(s)

SS = sorted(list(set(S)))
SN = []
for i in range(len(SS)):
    SN.append(S.count(SS[i]))
    if i < len(SS) - 1:
        j = S.index(SS[i+1])
        S = S[j:]


res = 0
for sn in SN:
    res += sn * (sn - 1) // 2

print(res)

Submission status: Runtime Error

Solution code:
import numpy as np

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

S = np.array(S)

s = list('abcdefghijklmnopqrstuvwxyz')

T = np.zeros([N, 26])

for i, a in enumerate(s):
  T[:, i] = np.sum(S == a, axis=1)

T3 = np.atleast_3d(T)

print(int((np.sum(np.prod(T3 == T3.T, axis=1)) - N) / 2))

Submission status: Runtime Error

Solution code:
import numpy as np

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

S = np.array(S)

s = list('abcdefghijklmnopqrstuvwxyz')

T = np.zeros([N, 26])

for i, a in enumerate(s):
  T[:, i] = np.sum(S == a, axis=1)

T3 = np.atleast_3d(T)
r = np.prod(T3 == T3.T, axis=1)

print((np.sum(r) - len(r)) // 2)

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
import itertools
from math import factorial
from scipy.special import comb

N = int(input())
s = {}
for _ in range(N):
    b = list(input())
    b.sort()
    c = ''.join(b)
    if not c in s:
        s[c] = 1
    else:
        s[c] += 1

a = [comb(v, 2, exact=True) for v in s.values()]
print(sum(a))

Submission status: Runtime Error

Solution code:
import itertools
from math import factorial

N = int(input())
s = {}
for _ in range(N):
    b = list(input())
    b.sort()
    c = ''.join(b)
    if not c in s:
        s[c] = 1
    else:
        s[c] += 1

a = [factorial(v) / factorial(2) / factorial(v - 2) for v in s.values()]
print(sum(a))

Submission status: Runtime Error

Solution code:
import itertools
from math import factorial

N = int(input())
s = {}
for _ in range(N):
    b = list(input())
    b.sort()
    c = ''.join(b)
    if not c in s:
        s[c] = 1
    else:
        s[c] += 1

a = [int(factorial(v) / factorial(2) / factorial(v - 2)) for v in s.values()]
print(sum(a))

Submission status: Runtime Error

Solution code:
import itertools
from math import factorial

N = int(input())
s = {}
for _ in range(N):
    b = list(input())
    b.sort()
    c = ''.join(b)
    if not c in s:
        s[c] = 1
    else:
        s[c] += 1

a = [int(factorial(v) / factorial(2) / factorial(v - 2)) for v in s.values()]
sum(a)

Submission status: Runtime Error

Solution code:
N = int(input())
s = []
for i in range (N):
    word = input()
    word_lst = []
    for j in range (len(word)):
        word_lst.append(word[j])
    word_lst = np.sort(word_lst)
    words = ""
    for j in range (len(word_lst)):
        words += word_lst[j]
    s.append(words)
#print (s)

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

Submission status: Runtime Error

Solution code:
N = int(input())
s = []
for i in range (N):
    word = input()
    word_lst = []
    for j in range (len(word)):
        word_lst.append(word[j])
    word_lst = np.sort(word_lst)
    words = ""
    for j in range (len(word_lst)):
        words += word_lst[j]
    s.append(words)
#print (s)

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

Submission status: Runtime Error

Solution code:
from math import factorial

N = int(input())
d = {}
for _ in range(N):
    s = input()
    s_sorted = "".join(sorted(s))
    if not d.get(s_sorted):
        d[s_sorted] = 1
    else:
        d[s_sorted] += 1

ans = 0
for _, v in d.items():
    if v == 1:
        continue
    x = factorial(v) / factorial(2) / factorial(v - 2)
    ans += x

print(round(ans))

Submission status: Runtime Error

Solution code:
from collections import defaultdict
from math import factorial

N = int(input())
st = set()
d = defaultdict(int)
for _ in range(N):
    s = input()
    s_sorted = "".join(sorted(s))
    if s_sorted in st:
        d[s_sorted] += 1
    else:
        st.add(s_sorted)

ans = 0
for _, v in d.items():
    tmp = v + 1
    x = factorial(tmp) / factorial(2) / factorial(tmp - 2)
    ans += x

print(round(ans))

Submission status: Runtime Error

Solution code:
from collections import defaultdict
from math import factorial

N = int(input())
st = set()
d = defaultdict(int)
for _ in range(N):
    s = input()
    s_sorted = "".join(sorted(s))
    if s_sorted in st:
        d[s_sorted] += 1
    else:
        st.add(s_sorted)

ans = 0
for _, v in d.items():
    x = factorial(v + 1) / factorial(2)
    ans += x

print(round(ans))

Submission status: Runtime Error

Solution code:
from collections import defaultdict
from math import factorial

N = int(input())
# S = []
st = set()
d = defaultdict(int)
for _ in range(N):
    s = input()
    s_sorted = "".join(sorted(s))
    if s_sorted in st:
        d[s_sorted] += 1
    else:
        st.add(s_sorted)

ans = 0
for _, v in d.items():
    x = factorial(v + 1) / factorial(2)
    ans += x

print(round(ans))

Submission status: Runtime Error

Solution code:
n=int(input())
s=[]
r=[]
c=0
for i in range(n):
    a=input()
    a.sorted()
    s.append(a)
for i in range(n):
    if a[i]==a[i+1]:
        c+=1
        r.append(c)
    else:
        c=0
        r.append(c)
print(sum(r))

Submission status: Runtime Error

Solution code:
N=int(input())
s=[sorted(list(input())) for i in range(N)]
s.sort()

counter=long(0)

i=0
while i<N-1:
  j=i+1
  while j<N:
    if s[i]==s[j]:
	    counter+=1
	    j+=1
    else:
      break
    
  i+=1
  
print(counter)

Submission status: Runtime Error

Solution code:

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)