Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
a_sorted = []
tmp = 0
tmpp = 0

for i in range(n):
    a.append(int(input()))

for i in range(n):
    
    tmp = a[i]
    a[i] = 0

    print(max(a))

    a[i] = tmp

Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]

sorted_a = sorted(a)

max_a = sorted_a[-1]
max_a_r = sorted_a[-2]

for i in range(n):
    if a[i] == max_a:
        print(max_a_r)
    else:
        print(max_a)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
a_sorted = []
tmp = 0

for i in range(n):
    a.append(int(input()))

for i in range(n):
    
    tmp = a[i]
    a[i] = 0

    a_sorted = sorted(a, reverse=True)

    a[i] = tmp
    
    print(a_sorted[0])


Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]

sorted_a = sorted(a)

max_a = sorted_a[-1]
max_a_r = sorted_a[-2]

for i in range(n):
    if a[i] == max_a:
        print(max_a_r)
    else:
        print(max_a)

Buggy python submission (verdict: Time Limit Exceeded):
import copy

n = int(input())
a = []
a_bak = []
a_sorted = []

for i in range(n):
    a.append(int(input()))

for i in range(n):
    a_bak = copy.copy(a)
    
    a_bak[i] = 0

    a_sorted = sorted(a_bak, reverse=True)

    print(a_sorted[0])

Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]

sorted_a = sorted(a)

max_a = sorted_a[-1]
max_a_r = sorted_a[-2]

for i in range(n):
    if a[i] == max_a:
        print(max_a_r)
    else:
        print(max_a)
Buggy python submission (verdict: Time Limit Exceeded):
#input
a = list(map(int,input().split())) #input from array of integer like "1 2 3"
n = a[3]
a = a[:3]
range_r = n//a[0]+1
range_g = n//a[1]+1
cnt = 0
for r in range(range_r):
  for g in range(range_g):
    rg = r*a[0]+g*a[1]
    if rg > n:
      break
    if (n - rg)%a[2]==0:
      cnt += 1

print(cnt)

Fixed submission:
#input
a = list(map(int,input().split())) #input from array of integer like "1 2 3"
n = a[3]
a = a[:3]
range_r = n//a[0]+1
range_g = n//a[1]+1
cnt = 0
for r in range(range_r):
  for g in range((n-r*a[0])//a[1]+1):
    rg = r*a[0]+g*a[1]
    if (n - rg)%a[2]==0:
      cnt += 1

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
#input
a = list(map(int,input().split())) #input from array of integer like "1 2 3"

range_r = a[3]//a[0]+2
range_g = a[3]//a[1]+2
range_b = a[3]//a[2]+2
cnt = 0
r = 0
g = 0
b = 0
for r in range(range_r):
  if r*a[0] > a[3]:
    break
  for g in range(range_g):
    if r*a[0]+g*a[1] > a[3]:
      break
    for b in range(range_b):
      #print("{},{},{}".format(r,g,b))
      nn = r*a[0]+g*a[1]+b*a[2]
      if nn > a[3]:
        break
      if nn == a[3]:
        cnt += 1

print(cnt)

Fixed submission:
#input
a = list(map(int,input().split())) #input from array of integer like "1 2 3"
n = a[3]
a = a[:3]
range_r = n//a[0]+1
range_g = n//a[1]+1
cnt = 0
for r in range(range_r):
  for g in range((n-r*a[0])//a[1]+1):
    rg = r*a[0]+g*a[1]
    if (n - rg)%a[2]==0:
      cnt += 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
a = list(map(str, input().split()))
if a[1] == “+”:
	print(int(a[0]) + int(a[2]))
else:
	print(int(a[0]) - int(a[2]))


Fixed submission:
a = list(map(str, input().split()))
if a[1] == "+":
  print(int(a[0]) + int(a[2]))
else:
  print(int(a[0]) - int(a[2]))

Buggy python submission (verdict: Runtime Error):
a = list(map(str, input().split()))
if a[1] == “+”:
 print(int(a[0]) + int(a[2]))
else:
 print(int(a[0]) - int(a[2]))


Fixed submission:
a = list(map(str, input().split()))
if a[1] == "+":
  print(int(a[0]) + int(a[2]))
else:
  print(int(a[0]) - int(a[2]))

Buggy python submission (verdict: Runtime Error):
a = list(map(str, input().split()))
if a[1] == “+”:
    print(int(a[0]) + int(a[2]))
else:
    print(int(a[0]) - int(a[2]))


Fixed submission:
a = list(map(str, input().split()))
if a[1] == "+":
  print(int(a[0]) + int(a[2]))
else:
  print(int(a[0]) - int(a[2]))

Buggy python submission (verdict: Runtime Error):
a = list(map(str, input().split()))
if a[1] == “+”:
  print(int(a[0]) + int(a[2]))
else:
  print(int(a[0]) - int(a[2]))


Fixed submission:
a = list(map(str, input().split()))
if a[1] == "+":
  print(int(a[0]) + int(a[2]))
else:
  print(int(a[0]) - int(a[2]))
Buggy python submission (verdict: Runtime Error):
a = list(set([int(i) for i in input().split()])).sort()
if a[0]+a[1]==a[2]:
  print("Yes")
else:
  print("No")


Fixed submission:
a = sorted(map(int, input().split()))
if (a[0]+a[1])==a[2]:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
def main():
  a = [int(input()) for i in range(3)]
  print(int((a[0]+a[1])*a[2]/2))

if __name__=='__main__':main()
~                              

Fixed submission:
#!/usr/bin/env python3
def main():
  a = [int(input()) for i in range(3)]
  print(int((a[0]+a[1])*a[2]/2))

if __name__=='__main__':main()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
d = list(map(int,input().split()))
d.sort()
cs = [0]
ans = 0
for i in range(d[-1]):
  cs.append(cs[i]+d.count(i))

ans = cs.count(n/2)
print(ans)

Fixed submission:
n = int(input())
d = list(map(int,input().split()))
d.sort()
cs = [0]
ans = 0
l= 0
for i in range(d[-1]):
  temp = 0
  while(True):
    if i == d[l]:
      temp += 1
      l += 1
    else:
      break

  cs.append(cs[i]+temp)

ans = cs.count(n/2)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
d = list(map(int,input().split()))
d.sort()
cs = [0]
ans = 0
for i in range(d[-1]):
  cs.append(cs[i]+d.count(i))

ans = cs.count(n/2)
print(ans)

Fixed submission:
n = int(input())
d = list(map(int,input().split()))
d.sort()
cs = [0]
ans = 0
l= 0
for i in range(d[-1]):
  temp = 0
  while(True):
    if i == d[l]:
      temp += 1
      l += 1
    else:
      break

  cs.append(cs[i]+temp)

ans = cs.count(n/2)
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))

for i in range(n-1):
    if a[i] <= 0 and a[i+1] <= 0:
        a[i] = -a[i]
        a[i+1] = -a[i+1]
        
for i in range(n-2):
    if a[i] < 0 and a[i+1] >= 0 and a[i+2] <= 0:
        a[i] = -a[i]
        a[i+2] = -a[i+2]
        
for i in range(n-1):
    if a[i] < 0:
        if a[i]+a[i+1] < -(a[i]+a[i+1]):
            a[i] = -a[i]
            a[i+1] = -a[i+1]

if a[n-1]+a[n] < -(a[n-1]+a[n]):
    a[n-1] = -a[n-1]
    a[n] = -a[n]

print(sum(a))

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
dp_table = [0, -10 ** 10]
temp = [0,0]
for i in range(n):
    temp[0] = dp_table[0]
    temp[1] = dp_table[1]
    dp_table[0] = max(temp[0]+a[i],temp[1]-a[i])
    dp_table[1] = max(temp[0]-a[i],temp[1]+a[i])
    
print(dp_table[0])
Buggy python submission (verdict: Runtime Error):
a,b = int(input())
ans = 0
for i in range(2):
  if a > b:
    ans = a+ans
    a = a-1
  else:
    ans = b+ans
    b = b-1
    
print(ans)

Fixed submission:
a,b = map(int,input().split())
s = 0
for i in range(2):
    if a >= b:
        s += a
        a -= 1
    else:
        s += b
        b -= 1

print(s)

Buggy python submission (verdict: Runtime Error):
a,b = int(input())
ans = 0
for i in range(2):
	if a > b:
	  ans = a+ans
	  a = a-1
	  else:
	    ans = b+ans
   		b = b-1
        
print(ans)

Fixed submission:
a,b = map(int,input().split())
s = 0
for i in range(2):
    if a >= b:
        s += a
        a -= 1
    else:
        s += b
        b -= 1

print(s)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split()) 
t = list(str(input()))
t = [int(s) for s in t]
last = t[0]
temp_c = 0
s = []
con_c = 0
temp_con_c = 0
corrent_p = 0
for i in range(n):
    if last == t[i]:
        temp_c += 1
    else:
        last = t[i]
        s.append(temp_c)
        temp_c = 1
s.append(temp_c)
if t[0] == 0:
    start_n = 0
else:
    start_n = 1
l = len(s)
if k*2 <= l:
    if start_n == 0:
        for i in range(0,k*2):
            temp_con_c += s[i]
        con_c = temp_con_c
        temp_con_c = 0
        corrent_p = 1
    for i in range(corrent_p,l,2):
        for m in range(k*2+1):
            if i+m >= l:
                break
            temp_con_c += s[i+m]
        if temp_con_c > con_c:
            con_c = temp_con_c
        temp_con_c = 0
        
else:
    con_c = n
print(con_c)

Fixed submission:
'''
WA
'''
n,k = map(int,input().split()) 
t = list(str(input()))
t = [int(s) for s in t]
last = t[0]
temp_c = 0
s = []
con_c = 0
temp_con_c = 0
corrent_p = 0
sum_t = []
for i in range(n):
    if last == t[i]:
        temp_c += 1
    else:
        last = t[i]
        s.append(temp_c)
        temp_c = 1
s.append(temp_c)
if t[n-1] == 0:
    s.append(0)
l = len(s)
if k*2 <= l:
    sum_t.append(0)
    for i in range(l):
        sum_t.append(sum_t[i]+s[i])
    l = len(sum_t)
    if t[0] == 0:
        for i in range(l-k*2-1):
            if i%2 == 0:
                temp_con_c = sum_t[i+k*2]-sum_t[i]
            else:
                temp_con_c = sum_t[i+k*2+1]-sum_t[i]
            if temp_con_c > con_c:
                con_c = temp_con_c
    else:
        for i in range(l-k*2-1):
            if i%2 ==0:
                temp_con_c = sum_t[i+k*2+1]-sum_t[i]
            else:
                temp_con_c = sum_t[i+k*2]-sum_t[i]
            if temp_con_c > con_c:
                con_c = temp_con_c
else:
    con_c = n

print(con_c)
Buggy python submission (verdict: Time Limit Exceeded):
#! python


#K, X = [int(x) for x in input().split()]

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

sortedS = [sorted(s) for s in S]

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



Fixed submission:
#! python

from collections import defaultdict

#K, X = [int(x) for x in input().split()]

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

sortedS = ["".join(sorted(s)) for s in S]

cnt = defaultdict(int)
for s in sortedS:
    cnt[s] += 1

ans = 0
for s,c in cnt.items():
    if c >= 2:
        ans += c * (c-1) // 2
print(ans)
Buggy python submission (verdict: Runtime Error):
#!venv/bin/python
#from collections import defaultdict 
from itertools import combinations
import math
import datetime
import numpy
from pprint import pprint
N = int(input())
A = [int(x) for x in input().split()]
import time

mat = numpy.zeros((N,N))
a2 = numpy.array(A).reshape(-1,1)

#pprint(a2)

for i in range(N):
    mat[i,i] = 0.5
    j = i + 1 if i != N -1 else 0
    mat[i,j] = 0.5
#print("mat")
#pprint(mat)
rev_mat = numpy.linalg.inv(mat)
#print("rev")
#print(rev_mat)

ans = numpy.dot(rev_mat,a2)
da = []
for a in ans:
    for b in a:
        da.append(str(int(b)))
print(" ".join(da))


Fixed submission:
#!venv/bin/python
#from collections import defaultdict 
from itertools import combinations
import math
import datetime
import numpy
from pprint import pprint
N = int(input())
A = [int(x) for x in input().split()]

ans = []

ans1 = 0
plus = 1
for i in range(N):
    ans1 += plus * A[i]
    plus *= -1

ans.append(ans1)
plus = -1
for i in range(1,N):
    t = i - 1
    a = ans[t] + plus * 2 * A[t]
    plus *= -1
    ans.append(a)

print(" ".join([str(abs(s)) for s in ans]))
Buggy python submission (verdict: Runtime Error):
#!venv/bin/python
#from collections import defaultdict 
from itertools import combinations
import math

N, K = [int(x) for x in input().split()]
ELEMENT = 10 ** 9 + 7
L = N - K # 赤の数


def homo(n,r):
    #print("homo")
    #print(n,r)
    return combi(n+r-1,r)

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

for i in range(K):
    con = combi(K-1,i)
    ho = homo(i+2,L-i)
    print(con*ho % ELEMENT)

Fixed submission:
#!venv/bin/python
#from collections import defaultdict 
from itertools import combinations
import math

N, K = [int(x) for x in input().split()]
ELEMENT = 10 ** 9 + 7
L = N - K # 赤の数


def homo(n,r):
    #print("homo")
    #print(n,r)
    return combi(n+r-1,r)

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

for i in range(K):
    #print ("i: {}".format(i))
    con = combi(K-1,i)
    if L-i < 0:
        print(0)
    else:
        ho = homo(i+2,L-i)
        print(con*ho % ELEMENT)
Buggy python submission (verdict: Runtime Error):
#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 
import time
import sys
from pprint import pprint


N, K = [ int(x) for x in input().split() ]

if K==0:
    print(0)
else:
    print(N-K)


Fixed submission:
#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 
import time
import sys
from pprint import pprint


N, K = [ int(x) for x in input().split() ]

if K==1:
    print(0)
else:
    print(N-K)
Buggy python submission (verdict: Runtime Error):
#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 
import time
import sys
from pprint import pprint

N = int(input())
P = []
for _i in range(N):
    P.append([ int(x) for x in input().split() ])

diff = defaultdict(int)
for i in range(N):
    for j in range(i+1,N):
        key = "{} - {}".format(abs(P[i][0]-P[j][0]), abs(P[i][1]-P[j][1]))
        diff[key] += 1

key = max (diff.keys(), key=lambda x: diff[x])
print(N-diff[key])

Fixed submission:
#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 
import time
import sys
from pprint import pprint

N = int(input())
P = []
for _i in range(N):
    P.append([ int(x) for x in input().split() ])

diff = defaultdict(int)
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        key = "{} - {}".format(P[i][0]-P[j][0], P[i][1]-P[j][1])
        diff[key] += 1

if N == 1:
    print(1)
else:
    key = max(diff.keys(), key=lambda x: diff[x])
    print(N-diff[key])
Buggy python submission (verdict: Time Limit Exceeded):
#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 

N, M = [ int(x) for x in input().split() ]

nm = []
for _i in range(M):
    nm.append([ int(x) for x in input().split() ])

ans = { x: 1 for x in range(1, N+1) }

for _nm in nm:
    nums = range(_nm[0], _nm[1] + 1)
    new_ans = {}
    for n in nums:
        if n in ans:
            new_ans[n] = 1
    ans = new_ans

print(len(ans.keys()))

Fixed submission:
#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 

N, M = [ int(x) for x in input().split() ]

nm = []
for _i in range(M):
    nm.append([ int(x) for x in input().split() ])

ans = [1,N]

for _nm in nm:
    if ans[0] < _nm[0]:
        ans[0] = _nm[0]
    if ans[1] > _nm[1]:
        ans[1] = _nm[1]

print(max(ans[1] - ans[0] + 1,0))
Buggy python submission (verdict: Runtime Error):
#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 

N, M = [ int(x) for x in input().split() ]
A = [ int(x) for x in input().split() ]
BC = []
for _i in range(M):
    BC.append([ int(x) for x in input().split() ])
A = sorted(A)
BC = sorted(BC, key = lambda x: x[1], reverse = True)

p = 0

def solve():
    global A, BC, p
    for bc in BC:
        for _i in range(bc[0]):
            if A[p] < bc[1]:
                A[p] = bc[1]
                p += 1
            else:
                return

solve()
print(sum(A))



Fixed submission:
#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 

N, M = [ int(x) for x in input().split() ]
A = [ int(x) for x in input().split() ]
BC = []
for _i in range(M):
    BC.append([ int(x) for x in input().split() ])
A = sorted(A)
BC = sorted(BC, key = lambda x: x[1], reverse = True)

p = 0

def solve():
    global A, BC, p
    for bc in BC:
        for _i in range(bc[0]):
            if p >= len(A):
                return
            if A[p] < bc[1]:
                A[p] = bc[1]
                p += 1
            else:
                return

solve()
print(sum(A))
Buggy python submission (verdict: Time Limit Exceeded):
#!venv/bin/python

#N = [ int(x) for x in input().split() ]
#S = input()

N = int(input())
K = []
for n in range(N-1):
    K.append([ int(x) for x in input().split() ])

color = [ None for i in range(N)]
color[0] = 1
solved = 1

next_k = K
while solved < N:
    K = next_k
    next_k = []
    for k in K:
        f = k[0] - 1
        t = k[1] - 1
        l = k[2]
        if color[f]:
            if l % 2 == 0:
                color[t] = color[f]
            else:
                color[t] = color[f] * -1
        elif color[t]:
            if l % 2 == 0:
                color[f] = color[t]
            else:
                color[f] = color[t] * -1
        else:
            next_k.append(k)
            continue
        solved += 1

ans = []
for c in color:
    if c == 1:
        ans.append("1")
    else:
        ans.append("0")
print("\n".join(ans))

Fixed submission:
#!venv/bin/python

#N = [ int(x) for x in input().split() ]
#S = input()

from collections import defaultdict 

N = int(input())
K = []
bridge = defaultdict(list)
for n in range(N-1):
    k = [ int(x) for x in input().split() ]
    K.append(k)
    bridge[k[0]].append([k[1], k[2]])
    bridge[k[1]].append([k[0], k[2]])

color = [ None for i in range(N + 1)]

queue = []
queue.append(1)
color[1] = 1


while queue:
    point = queue.pop()
    for b in bridge[point]:
        if not color[b[0]]:
            queue.append(b[0])
            if b[1] % 2 == 0:
                color[b[0]] = color[point]
            else:
                color[b[0]] = color[point] * -1

ans = []
for c in color[1:]:
    if c == 1:
        ans.append("1")
    else:
        ans.append("0")
print("\n".join(ans))
Buggy python submission (verdict: Time Limit Exceeded):
#!venv/bin/python

import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 

#A,B,K = [int(x) for x in input().split()]
S = input()

def hoge(input):
    new = []
    i = 0
    remove = False
    while i < len(input) - 1:
        if input[i] != input[i+1]:
            i = i + 2
            remove = True
        else:
            i = i + 1
            new.append(input[i])
    if i == len(input) - 1:
        new.append(input[-1])
    return new,remove

input = S
while True:
    input, remove = hoge(input)
    if not remove:
        break
print(len(S) - len(input))


Fixed submission:
#!venv/bin/python

import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 

#A,B,K = [int(x) for x in input().split()]
S = input()

cnt_1 = 0
cnt_0 = 0

for s in S:
    if s == "0":
        cnt_0 += 1
    else:
        cnt_1 += 1

print(min(cnt_1,cnt_0) * 2)
Buggy python submission (verdict: Time Limit Exceeded):
#!venv/bin/python

import math
import numpy as np
import random
import copy
import statistics 
import bisect

#N,M = [int(x) for x in input().split()]

N = int(input())
A = [int(x) for x in input().split()]

alives = N
A = sorted(A)

while alives > 1:
    biggest = A.pop(-1)
    second = A[-1]
    times = int(math.floor(biggest / second))
    new_hp = biggest - second * times
    if new_hp <= 0:
        alives -= 1
    bisect.insort_left(A, new_hp)

for a in A:
    if a > 0:
        print (a)
        break


Fixed submission:
#!venv/bin/python

import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq

#N,M = [int(x) for x in input().split()]

N = int(input())
A = [-1 * int(x) for x in input().split()]

alives = N
A = sorted(A)

heap = heapq.heapify(A)
heap = A
num = 0
while alives > 1:
    biggest = -1 * heapq.heappop(heap)
    second = -1 * heapq.heappop(heap)
    times = int(math.floor(biggest / second))
    new_hp = biggest - second * times
    if new_hp <= 0:
        alives -= 1
    heapq.heappush(heap, second * -1)
    heapq.heappush(heap,new_hp * -1)
    num += 1

for a in A:
    if a < 0:
        print (a * -1)
        break
Buggy python submission (verdict: Runtime Error):
#!venv/bin/python

N,K = [int(x) for x in input().split()]
A = [format(int(x), 'b') for x in input().split()]

count_1 = [0 for i in range(40)]
count_0 = [0 for i in range(40)]

print(A)

for a in A:
    for i in range(40):
        if i >= len(a):
            count_0[i] += 1
            continue
        if a[-(i+1)] == "1":
            count_1[i] += 1
        else:
            count_0[i] += 1
        
k = 0
for i in range(39,0,-1):
    if 2 ** i + k > K:
        continue
    if count_0[i] > count_1[i]:
        k += 2 ** i

ans = 0
for a in A:
    ans += k ^ int(a,2)
print(ans)


Fixed submission:
#!venv/bin/python

T, X = [int(x) for x in input().split()]

print(T / X)
Buggy python submission (verdict: Runtime Error):
a,b = input().split(" ")
a_plus_b = a+b
a_minus_b = a-b
a_mul_b = a*b

max_three = max(a_plus_b, max(a_minus_b, a_mul_b))
print(max_three)

Fixed submission:
a,b = [int(s) for s in input().split(" ")]
a_plus_b = a+b
a_minus_b = a-b
a_mul_b = a*b

max_three = max(a_plus_b, max(a_minus_b, a_mul_b))
print(max_three)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
strList = []
for i in range(N):
    inStr = input()
    inList = []
    for j in range(len(inStr)):
        inList.append(inStr[j])
    inList.sort()
    strList.append(''.join(inList))

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

Fixed submission:
N = int(input())
strDict = {} 
for i in range(N):
    inStr = input()
    inList = []
    for j in range(len(inStr)):
        inList.append(inStr[j])
        inList.sort()
    sortStr = ''.join(inList)
    if sortStr in strDict:
        strDict[sortStr] = strDict[sortStr] + 1
    else:
        strDict[sortStr] = 1

anaglam = 0

for i in strDict.keys():
    anaglam = anaglam + strDict[i]*(strDict[i]-1)//2
    
print(anaglam)