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: Time Limit Exceeded

Solution code:
import sys

input = sys.stdin.readline
n = int(input())
strs = [input() for i in range(n)]

ret = []
for str in strs:
  l = list(str.strip())
  l.sort()
  ret.append("".join(l))

count = 0
length = len(ret)
for index, content in enumerate(ret):
  if index < length - 1:
    for i in range(index+1, length):
      if ret[index] == ret[i]:
        count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
s=[str(sorted(input())) for i in range(N)]
ans=0
for i in set(s):
    c=0
    for j in s:
        if i ==j:c+=1
    ans+=c*(c-1)//2
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys

input = sys.stdin.readline
n = int(input())
strs = [input() for i in range(n)]


ret = []
for str in strs:
  l = list(str)
  l.sort()
  ret.append("".join(l))

set = set(ret)

count = 0
for index, content in enumerate(ret):
  if index < len(ret) - 1:
    list = ret[index+1:]
    count += list.count(content)
print(count)

Submission status: Time Limit Exceeded

Solution code:
import sys

input = sys.stdin.readline
n = int(input())
strs = [input() for i in range(n)]


ret = []
for str in strs:
  l = list(str)
  s = sorted(l)
  ret.append("".join(s))

set = set(ret)

count = 0
for index, content in enumerate(ret):
  if index < len(ret) - 1:
    list = ret[index+1:]
    count += list.count(content)
print(count)

Submission status: Time Limit Exceeded

Solution code:
import sys

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

ret = []
for str in strs:
  l = list(str)
  s = sorted(l)
  ret.append("".join(s))

set = set(ret)

count = 0
for index, content in enumerate(ret):
  if index < len(ret) - 1:
    list = ret[index+1:]
    count += list.count(content)
print(count)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
lists = []
count = 0
while count < n:
    lists.append(input())
    count += 1

new_lists = []
for i in lists:
    new_lists.append(''.join(sorted(i)))

answer = 0
x = 1
for i in new_lists:
    if i in new_lists[x:]:
        answer += new_lists[x:].count(i)
    x += 1

print(answer)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
list = [input() for i in range(n)]
for c in range(n):
  list[c] = sorted(list[c])

ans=0

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

print(ans)

Submission status: Time Limit Exceeded

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


dic={}
counter=0
for i in range(N):
  if (s[i] in dic.keys())==True:
    counter+=dic[s[i]]
    dic[s[i]]=dic[s[i]]+1
  else:
    dic[s[i]]=1

print(counter)

Submission status: Time Limit Exceeded

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


dic={}
counter=0
for i in range(N):
  if (s[i] in dic.keys())==True:
    counter+=dic[s[i]]
    dic[s[i]]=dic[s[i]]+1
  else:
    dic[s[i]]=1

print(counter)

Submission status: Time Limit Exceeded

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

counter=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: Time Limit Exceeded

Solution code:
import math
import sys
import collections

# imgur.com/Pkt7iIf.png

def getdict(n):
    d = {}
    if type(n) is list:
        for i in n:
            if i in d:
                d[i] += 1
            else:
                d[i] = 1
    else:
        for i in range(n):
            t = ii()
            if t in d:
                d[t] += 1
            else:
                d[t] = 1
    return d
def cdiv(n, k): return n // k + (n % k != 0)
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(map(int, input().split()))
def lcm(a, b): return abs(a*b) // math.gcd(a, b)

n = ii()
d = {}
for i in range(n):
    t = str(sorted(list(input())))
    d[t] = 1 if t not in d else d[t] + 1

r = 0
for i in d.values():
    r += i*(i-1)//2
print(r)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
strings = []
for i in range(N):
    string = list(input())
    string.sort()
    strings.append(string)
strings.sort()
anagramNum = 0
for i in range(N-1):
    for j in range(i+1, N):
        if strings[j] == strings[i]: anagramNum += 1
print(anagramNum)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
s=[input() for _ in range(n)]
ans=0
for i in range(n-1):
    for j in range(i+1,n):
        if sorted(s[i])==sorted(s[j]):
            ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import copy
s = []
N = int(input())
for i in range(N):
    s.append([i for i in input()])
for i in range(N):
	s[i].sort()
count = 0
for i, s1 in enumerate(s):
    for j, s2 in enumerate(s):
        if j <= i:
            continue
        if s1 == s2:
            count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
import copy
s = []
N = int(input())
for i in range(N):
    s.append([i for i in input()])
count = 0
already = []
for i in s:
    for j in s:
        if i == j or j in already:
            continue
        origin = copy.copy(j)
        for c in i:
            try:
                index = origin.index(c)
            except ValueError:
                break
            origin.pop(index)
        if len(origin) == 0:
            count += 1
            already.append(i)
print(count)

Submission status: Time Limit Exceeded

Solution code:
import copy
s = []
N = int(input())
for i in range(N):
    s.append([i for i in input()])
count = 0
already = []
for i in s:
    for j in s:
        if i == j or j in already:
            continue
        origin = copy.copy(j)
        for c in i:
            try:
                index = origin.index(c)
            except ValueError:
                continue
            origin.pop(index)
        if len(origin) == 0:
            count += 1
            already.append(i)
print(count)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
li = [''.join(sorted(input())) for _ in range(n)]

ans = 0
le = len(li)
while le > 1:
  t = li[0]
  cnt = 0
  for n, w in reversed(list(enumerate(li[1:]))):
    if t == w:
      cnt += 1
      li.pop(n + 1)
  ans += cnt * (cnt + 1) / 2
  li.pop(0)
  le = len(li)

print(int(ans))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
li = [sorted(list(input())) for a in range(n)]

ans = 0
for n, wx in enumerate(li):
  for wy in li[n+1:]:
    if wx == wy:
      ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
li = [input() for a in range(n)]
li2 = []
for w in li:
  di = {}
  for x in w:
    if x in di:
      di[x] += 1
    else:
      di[x] = 1
  li2.append(di)
  
li3 = []
for l in li2:
  wl = ''
  for k in sorted(l):
    wl += k + str(l[k])
  li3.append(wl)

ans = 0
for n, wx in enumerate(li3):
  for wy in li3[n+1:]:
    if wx == wy:
      ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
data = []
for i in range(n):
    s = list(input())
    s.sort()
    data.append(s)
i=0
j=0
count=0
for i in range(n):
  for j in range(i+1,n):
    if data[i]==data[j]:
      count=count+1
print(count)

Submission status: Time Limit Exceeded

Solution code:
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+1,n):
    if data[i]==data[j]:
      count=count+1
print(count)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
check = []

for _ in range(n):
  s = list(input())
  s.sort()
  s = "".join(s)
  #print(s)
  check.append(s)
  
cnt=0
check_set = set(check)
for c in check_set:
  temp_cnt = check.count(c)
  if c==1:
    pass
  else:
    cnt +=  temp_cnt*(temp_cnt-1)/2
print(int(cnt))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
s = []
for i in range(N):
    word = sorted(input())
    s.append(word)
moji = ""
temp = []
cnt = 0
for i in range(N):
    moji = ""
    for x in s[i]:
        moji += x
    temp.append(moji)
for i in range(len(temp)):
    for j in range(i+1,len(temp)):
        if temp[i] == temp[j]:
            cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
li = []
count = 0
for i in range(N):
  s = list(input())
  s.sort()
  s =''.join(s)
  li.append(s)
#print(li)
for i in range(N):
  x = li.count(li[i]) 
  count += x * (x - 1 ) / 2 / x
print(int(count))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import itertools

n = int(input())
s = []
for i in range(n):
    a = input()
    s.append(''.join(sorted(a)))
list_1 = list(itertools.combinations(s, 2))
ans = 0
for i,j in enumerate(list_1):
    if j[0] == j[1]:
        ans += 1
    else:
        ans += 0
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
s=[sorted(list(input())) for _ in range(n)]
ans=0

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = []
b = []
count = 0
for i in range(n):
  s.append(input())
  a = (list(s[0]))
  a.sort()
    
  
  s.pop(0)
  b.append("".join(a))
  a.clear()

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

print(count)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = []
a = []
b = []
count = 0
for i in range(n):
  s.append(input())
  for j in s[0]:
    a.append(j)
  a.sort()
    
  #print(a)
  s.pop(0)
  b.append("".join(a))
  a.clear()

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

print(count)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
l = list()
c = 0
for i in range(0,n):
  l.append(sorted(input()))
  for j in range(0,i):
    if l[i] == l[j]:
      c = c+1

print(c)

Submission status: Time Limit Exceeded

Solution code:
def main():
     AlfaToNum={'a':2,'b':3,'c':5,'d':7,'e':11,'f':13,'g':17,'h':19,'i':23,'j':29,'k':31,'l':37,'m':41,'n':43,'o':47,'p':53,'q':59,'r':61,'s':67,'t':71,'u':73,'v':79,'w':83,'x':89,'y':97,'z':101}
     n=int(input())
     s=[]
     ans=0
     for i in range(n):
          si=input()
          cnt=1
          for j in si:
               cnt*=AlfaToNum[j]
          s.append(cnt)
     #print(s)
     for i in range(n):
          for j in range(i+1,n):
               if s[i]==s[j]:
                    ans+=1
     print(ans)
if __name__ == '__main__':
     main()

Submission status: Time Limit Exceeded

Solution code:
#ABC137-C
N = int(input())
s = [input() for i in range(N)]  #N回の入力の仕方(Str)
for i in range(N):
    s[i] = sorted(s[i])
cnt = 0
for i in range(N):
    for j in range(i+1, N):
        if s[i] == s[j]:
            cnt += 1
        else:
            pass
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
l = []
for _ in range(int(input())):
  s=input()
  s=list(s)
  s.sort()
  t=''.join(s)
  l.append(t)
c=0
for i in range(len(l)-1):
  for j in range(i+1,len(l)):
    if l[i]==l[j]:
      c+=1
print(c)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

count = 0
count_list = []
ss = []

for i in range(n):
    s = sorted(input())
    
    for num, match in enumerate(ss):
        if match == s:
            count += count_list[num]
            count_list[num] += 1
            break

    else:
        ss.append(s)
        count_list.append(1)

print(count)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = [input() for _ in range(N)]
A = []
cnt = 0
for k in S:
   A.append(''.join(sorted(k)))
for i in A[:]:
    cnt += A.count(i) - 1
    A.remove(i)
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = []
count = 0
SCount = [0]*N
new = True

for i in range(N):
  new = True
  sj = input()
  sj = list(sj)
  sj.sort()
  for i in range(len(S)):
    if S[i] == sj:
      SCount[i]+=1
      count+=SCount[i]
      new = False
  if new == True:
      S.append(sj)
print(count)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [list(str(input())) for k in range(n)]
s_sorted = list(map(lambda x: sorted(x), s))
ans = 0
for i in range(n):
    counter = s_sorted[:i+1].count(s_sorted[i])
    ans += counter - 1
print(ans)

Submission status: Time Limit Exceeded

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

count = 0
for i in range(len(S)-1):
  for j in range(len(S)-i-1):
    k=j+i+1
    if S[i] == S[k]:
      count += 1
print(count)

Submission status: Time Limit Exceeded

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

count = 0
for si in S:
  for sj in S:
    if si == sj:
      count += 1
ans = int((count - N)/2)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [list(map(str, input())) for _ in range(n)]
ans = 0

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = []
for i in range(n):
  s.append(sorted(list(input().strip())))
ans = 0
for i in range(0,n-1):
  for j in range(i+1, n):
    if s[i] == s[j]:
      ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = input()
N = int(N)
list_anagram = []
list_modified = []
for n in range(1, N + 1):
    s = input()
    #list_anagram.append(s)
    list_s = []
    for i in range(0, 10):
        list_s.append(s[i])
    list_s.sort()
    s_modified = ''
    for i in range(0, 10):
        s_modified = s_modified + list_s[i]
    list_modified.append(s_modified)
    
m = 0
    
for k in range(0, N):
    for l in range (k + 1, N):
        if list_modified[k] == list_modified[l]:
            m += 1
        else:
            continue
print(m)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = [input() for _ in range(N)]
A = []
cnt = 0
for k in S:
   B = sorted(k)
   C = ''.join(B)
   A.append(C)
for i in range(N):
    for j in range(i + 1, N):
        if A[i] == A[j]:
            cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [list(str(input())) for k in range(n)]
s_sorted = list(map(lambda x: sorted(x), s))
ans = 0
for i in range(n):
    for j in range(n):
        if i < j:
            if s_sorted[i] == s_sorted[j]:
                ans += 1
            else:
                pass
        else:
            pass
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = [input() for _ in range(N)]
A = []
cnt = 0
for k in S:
   B = sorted(k)
   C = ''.join(B)
   A.append(C)
for i in range(N):
    for j in range(N):
        if i >= j:
            continue
        elif A[i] == A[j]:
            cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
li = list(sorted(input()) for _ in range(N))
ans = 0
for i in range(N):
  tmp = li[i]
  li[i] = 0
  if tmp in li:
    ans += li.count(tmp)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

data = []
result = 0

for i in range(N):
    counter = 0
    new = input()
    list_1 = list(new)
    list_1.sort()
    for j in data:
        if j == list_1:
            counter += 1
    
    result += counter
    data.append(list_1)

print(result)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [input() for i in range(n)]
# print(n)
# print(s)
s = list(map(list, s))
# print(s)
for i in range(n):
    s[i].sort()
    s[i] = "".join(s[i])
# print(s)
# c = set(s)
# print(c)


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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [input() for i in range(n)]
# print(n)
# print(s)
s = list(map(list, s))
# print(s)
for i in range(n):
    s[i].sort()
# print(s)
count = 0
for i in range(n):
    a = s[i]
    for j in range(i+1,n):
        b = s[j]
        if a == b:
            count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

counter = 0

for i in range(n):
  for j in range(n):
    if list[i]==list[j]:
      counter += 1
      
answer = int((counter-n)/2)

print(answer)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

N = int(input())

s = [Counter(input()) for _ in range(N)]
  
cnt = 0
for i in range(N):
    for j in range(i + 1, N):
      if s[i] == s[j]:
        cnt += 1
        
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

input_patterns = []

patterns = {}

a_max = ord('z')
a_min = ord('a')


def init_key():
    ini_key = []
    for i in range(26):
        ini_key.append(0)
    return ini_key

for i in range(n):
    val = input()
    input_patterns.append(val)

#input_patterns = ['acornistnt', 'peanutbomb', 'constraint']
count = 0
for inp in input_patterns:
    key = init_key()
    for j in range(len(inp)):
        # make [0, 0, 1, 0, 2, 3, ...]
        #       a  b  c  d  e  f  
        for k in range(26):
            if inp[j] == chr(ord('a') + k):
                key[k] = key[k] + 1

    skey = ''
    for k in range(26):
        skey = skey + str(key[k])

    if skey in patterns:
        patterns[skey] = patterns[skey] + 1
    else:
        patterns[skey] = 1

    if patterns[skey] > 1:
        count = count + patterns[skey] - 1

        
result = 0

#for skey in patterns:
#    if patterns[skey] > 1:
#        for i in range(1, int(patterns[skey])):
#            result = result + i

print('{}'.format(count))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

input_patterns = []

patterns = {}

a_max = ord('z')
a_min = ord('a')


def init_key():
    ini_key = []
    for i in range(26):
        ini_key.append(0)
    return ini_key

for i in range(n):
    val = input()
    input_patterns.append(val)

#input_patterns = ['acornistnt', 'peanutbomb', 'constraint']
    
for inp in input_patterns:
    key = init_key()
    for j in range(len(inp)):
        # make [0, 0, 1, 0, 2, 3, ...]
        #       a  b  c  d  e  f  
        for k in range(26):
            if inp[j] == chr(ord('a') + k):
                key[k] = key[k] + 1

    skey = ''
    for k in range(26):
        skey = skey + str(key[k])

    if skey in patterns:
        patterns[skey] = patterns[skey] + 1
    else:
        patterns[skey] = 1

result = 0

for skey in patterns:
    if patterns[skey] > 1:
        for i in range(1, int(patterns[skey])):
            result = result + i

print('{}'.format(result))

Submission status: Time Limit Exceeded

Solution code:
import sys
 
n=int(input())
a=[input() for i in range(n)]
 
num = 0
sortedA = []
 
end = len(a) - 1
 
for i in range(0, end):
    if i == 0:
        sortedA.append(''.join(sorted(a[0])))
    for j in range(i + 1, end + 1):
        if i == 0:
            sortedA.append(''.join(sorted(a[j])))
        if sortedA[i] == sortedA[j]:
            num = num + 1
print(num)

Submission status: Time Limit Exceeded

Solution code:
#print([chr(ord('a') + i) for i in range(26)]) #aを数字に変えて文字列に変える
count = 0
N = int(input())
S = []
for i in range(N):
    L = ''.join(sorted(input()))
    S.append(L)

for k in range(N - 1):
    for l in range(k, N - 1):
        if k == N - 1:
            exit()
        if S[k] == S[l + 1]:
            count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

input_patterns = []

patterns = []

a_max = ord('z')
a_min = ord('a')


def init_key():
    ini_key = []
    for i in range(26):
        ini_key.append(0)
    return ini_key

for i in range(n):
    val = input()
    input_patterns.append(val)

#input_patterns = ['acornistnt', 'peanutbomb', 'constraint']
    
for inp in input_patterns:
    key = init_key()
    for j in range(len(inp)):
        # make [0, 0, 1, 0, 2, 3, ...]
        #       a  b  c  d  e  f  
        for k in range(26):
            if inp[j] == chr(ord('a') + k):
                key[k] = key[k] + 1

    patterns.append(key)

result = 0

for i in range(len(patterns) - 1):
    for j in range(i+1, len(patterns)):
#        print('comparing s{} s{}'.format(i, j))
        if patterns[i] == patterns[j]:
            result = result + 1

print('{}'.format(result))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
 
n=int(input())
a=[input() for i in range(n)]

num = 0
sortedA = []

end = len(a) - 1

for i in range(0, end):
    if i == 0:
        sortedA.append(''.join(sorted(a[0])))
    for j in range(i + 1, end + 1):
        if i == 0:
            sortedA.append(''.join(sorted(a[j])))
        if sortedA[i] == sortedA[j]:
            num = num + 1
print(num)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
inlist = []
for i in range(N):
  inputst = input()
  inputstlist = list(inputst)
  inputstlist.sort()
  inlist.append(inputstlist)
inlist.sort()
count=0
for i in range(N):
  for j in range(i+1,N):
    flag1=0
    for k in range(10):
      if inlist[i][k]==inlist[j][k]:
        pass
      else:
        flag1=1
        break
    if flag1==0:
      count+=1
    else:
      break
print(count)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
inlist = []
for i in range(N):
  inputst = input()
  inputstlist = list(inputst)
  inputstlist.sort()
  inlist.append(inputstlist)
count=0
for i in range(N):
  for j in range(i+1,N):
    if inlist[i]==inlist[j]:
      count+=1
print(count)

Submission status: Time Limit Exceeded

Solution code:
import sys
 
a = []
for l in sys.stdin:
    if l == '\n':
        break
    else :
        a.append(l)

num = 0
sortedA = []

end = len(a) - 1

for i in range(0, end):
    if i == 0:
        sortedA.append(''.join(sorted(a[1])))
    for j in range(i + 1, end):
        if i == 0:
            sortedA.append(''.join(sorted(a[j + 1])))
        if sortedA[i] == sortedA[j]:
            num = num + 1
print(num)

Submission status: Time Limit Exceeded

Solution code:
import sys
 
a = []
for l in sys.stdin:
    if l == '\n' or l == '\r':
        break
    else :
        a.append(l)

target = a[int(a[0])]
num = 0
sortedA = []

end = len(a) - 1

for i in range(0, end):
    if i == 0:
        sortedA.append(''.join(sorted(a[1])))
    for j in range(i + 1, end):
        if i == 0:
            sortedA.append(''.join(sorted(a[j + 1])))
        if sortedA[i] == sortedA[j]:
            num = num + 1
print(num)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
# スペース区切りの整数の入力
ar = []
for i in range(n):
  l = list(input())
  l.sort()
  ar.append("".join(l).__hash__())


count = 0
for i in range(n):
  count = count + ar[i+1:].count(ar[i])

print(count)

Submission status: Time Limit Exceeded

Solution code:
import sys
 
a = []
for l in sys.stdin:
    a.append(l)
 
target = a[int(a[0])]
num = 0

sortedA = []

for i in a:
    sortedA.append(''.join(sorted(i)))
sortedA.pop(0)

end = len(a) - 1

for i in range(0, end):
    for j in range(i + 1, end):
        if sortedA[i] == sortedA[j]:
            num = num + 1
print(num)

Submission status: Time Limit Exceeded

Solution code:
import sys
 
a = []
for l in sys.stdin:
    a.append(l)
 
target = a[int(a[0])]
num = 0

sortedA = []

for i in a:
    sortedA.append(''.join(sorted(i)))
sortedA.pop(0)

for i in range(0, len(a) - 1):
    for j in range(i + 1, len(a) - 1):
        if sortedA[i] == sortedA[j]:
            num = num + 1
print(num)

Submission status: Time Limit Exceeded

Solution code:
import sys
 
a = []
for l in sys.stdin:
    if l == '\n' or l == '\r':
        break
    else :
        a.append(l)
 
target = a[int(a[0])]
num = 0

sortedA = []

for i in a:
    sortedA.append(''.join(sorted(i)))
sortedA.pop(0)

for i in range(0, len(a) - 1):
    for j in range(i + 1, len(a) - 1):
        flag = False
        if sortedA[i] == sortedA[j]:
            flag = True
            num = num + 1
print(num)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
# スペース区切りの整数の入力
ar = []
for i in range(n):
  l = list(input())
  l.sort()
  ar.append("".join(l))


count = 0
for i in range(n):
  count = count + ar[i+1:].count(ar[i])

print(count)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
# スペース区切りの整数の入力
ar = []
for i in range(n):
  ar.append("".join(sorted(input())))

#for t in ar:
#  print(t)
#for i in range(n):
#  for j in range(i+1, n):
#    if ar[i] == ar[j]:
#      ar[j] = ar[i]

count = 0
#for i in range(n):
#  for j in range(i+1, n):
#    if ar[i] is ar[j]:
#      count = count + 1

for i in range(n):
  count = count + ar[i+1:].count(ar[i])

print(count)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
# スペース区切りの整数の入力
ar = []
for i in range(n):
  ar.append("".join(sorted(input())))

#for t in ar:
#  print(t)
for i in range(n):
  for j in range(i+1, n):
    if ar[i] == ar[j]:
      ar[j] = ar[i]

count = 0
#for i in range(n):
#  for j in range(i+1, n):
#    if ar[i] is ar[j]:
#      count = count + 1

for i in range(n):
  count = count + ar[i+1:].count(ar[i])

print(count)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
# スペース区切りの整数の入力
ar = []
for i in range(n):
  ar.append("".join(sorted(input())))

#for t in ar:
#  print(t)
for i in range(n):
  for j in range(i+1, n):
    if ar[i] == ar[j]:
      ar[j] = ar[i]

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

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations

N = int(input())

SC = []
for _ in range(N):
    SC.append(''.join(sorted(input())))

r = 0
for si, sj in combinations(SC, 2):
    if si == sj:
        r += 1

print(r)

Submission status: Time Limit Exceeded

Solution code:
import sys
 
a = []
for l in sys.stdin:
    if l == '\n' or l == '\r' or l == '\r\n':
        break
    else :
        a.append(l)
 
target = a[int(a[0])]
num = 0
for i in range(1, len(a) - 1):
    for j in range(i + 1, len(a)):
        flag = False
        iStrSorted = ''.join(sorted(a[i]))
        jStrSorted = ''.join(sorted(a[j]))
        if iStrSorted==jStrSorted:
            flag = True
        else:
            flag = False
        if flag:
            num = num + 1
print(num)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
# スペース区切りの整数の入力
ar = []
for i in range(n):
  ar.append("".join(sorted(input())))

#for t in ar:
#  print(t)

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
li=[input() for i in range(n)]
result=[]
li_=[]
re=0

for i in range(n):
  li[i]=sorted(li[i])
  if li[i] not in result:
    result.append(li[i])
    li_.append(1)
  else:
    re+=li_[result.index(li[i])]
    li_[result.index(li[i])]+=1

print(re)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
li=[input() for i in range(n)]
result=0
li=[sorted(li[i]) for i in range(n)]

for i in range(n-1):
  for j in range(i+1,n):
    if li[i]==li[j]:
      result+=1
print(result)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
li=[input() for i in range(n)]
result=0

for i in range(n-1):
  for j in range(i+1,n):
    flg=True
    for k in range(10):
      if li[i].count(li[i][k])!=li[j].count(li[i][k]):
        flg=False
        break
    if flg==True:
      result+=1
print(result)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
str_list = []
ans = 0

for i in range(N):
  tmp_str = input()
  tmp_list = list(tmp_str)
  tmp_list.sort()
  tmp_str = ''.join(tmp_list)
  str_list.append(tmp_str)

set_list = set(str_list)
set_list = list(set_list)

for i in range(len(set_list)):
  tmp_ans = str_list.count(set_list[i])
  tmp_ans = tmp_ans * (tmp_ans -1) /2
  ans += tmp_ans

print(int(ans))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [''] * n
s = [input() for _ in range(n)]
  
def is_anagram(a, b):
    if len(a) != len(b): 
        return False
    else:
        return sorted(a) == sorted(b)

import itertools
a = map(lambda x: is_anagram(x[0], x[1]), list(itertools.combinations(s, 2)))
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
d={}
for i in range(n):
  a=str(sorted(input()))
  if a in list(d.keys()):
    d[a]+=1
  else:
    d[a]=1
l=list(d.values())
c=0
for i in l:
  c+=(i*(i-1))//2
print(c)