Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
mine = []
h, w = map(int, input().split())
for i in range(h):
    mine.append(list(input()[:]))
ans = [[0 for i in range(w)] for j in range(w)]
for i in range(h):
    for j in range(w):
        if mine[i][j] == '#':
            if i != 0:
                ans[i-1][j] += 1
            if j != 0:
                ans[i][j-1] += 1
            if i != h-1:
                ans[i+1][j] += 1
            if j != w-1:
                ans[i][j+1] += 1
            if i != 0 and j != 0:
                ans[i-1][j-1] += 1
            if i != 0 and j != w-1:
                ans[i-1][j+1] += 1
            if i != h-1 and j != 0:
                ans[i+1][j-1] += 1
            if i != h-1 and j != w-1:
                ans[i+1][j+1] += 1

for i in range(h):
    for j in range(w):
        if mine[i][j] == "#":
            print("#", end="")
        else:
            print(ans[i][j], end="")
    print()


Fixed submission:
mine = []
h, w = map(int, input().split())
for i in range(h):
    mine.append(list(input()[:]))
ans = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
    for j in range(w):
        if mine[i][j] == '#':
            if i != 0:
                ans[i-1][j] += 1
            if j != 0:
                ans[i][j-1] += 1
            if i != h-1:
                ans[i+1][j] += 1
            if j != w-1:
                ans[i][j+1] += 1
            if i != 0 and j != 0:
                ans[i-1][j-1] += 1
            if i != 0 and j != w-1:
                ans[i-1][j+1] += 1
            if i != h-1 and j != 0:
                ans[i+1][j-1] += 1
            if i != h-1 and j != w-1:
                ans[i+1][j+1] += 1

for i in range(h):
    for j in range(w):
        if mine[i][j] == "#":
            print("#", end="")
        else:
            print(ans[i][j], end="")
    print()
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
table = []
for i in range(h):
    table.append(list(input()))
poss = True
for i in range(h-1):
    for j in range(w-1):
        if table[i][j] == "#":
            if (table[i+1][j]=="#" and table[i][j+1]=="#") or (table[i+1][j]=="." and table[i][j+1]=="."):
                poss = False
for i in range(1, h):
    if table[i][w-1]=="#" and table[i-1][w]=="#":
        poss = False
for i in range(1, w):
    if table[h][i-1]=="#" and table[h-1][i]=="#":
        poss = False

if poss:
    print("Possible")
else:
    print("Impossible")


Fixed submission:
h, w = map(int, input().split())
table = []
for i in range(h):
    table.append(list(input()))
poss = True
for i in range(h-1):
    for j in range(w-1):
        if table[i][j] == "#":
            if (table[i+1][j]=="#" and table[i][j+1]=="#") or (table[i+1][j]=="." and table[i][j+1]=="."):
                poss = False
for i in range(1, h):
    if table[i][w-2]=="#" and table[i-1][w-1]=="#":
        poss = False
for i in range(1, w):
    if table[h-1][i-1]=="#" and table[h-2][i]=="#":
        poss = False

if poss:
    print("Possible")
else:
    print("Impossible")
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
res=0
while N>0:
    mod=N%10
    N=N//10
    res+=mod
if res%9==0:
    print('Yes')
else:
    print('No')

Fixed submission:
N=input()
nlist=list(map(int,N))
if sum(nlist)%9==0:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
if S=='SSS':
  print(0)
if S=='RSS' or S=='SRS' or S=='SSR' or S=='RSR':
  print(1)
if S=='RRS' or S=='SRR':
  print(2)
if S=='RRR':
  print(3)

Fixed submission:
S=input()
if S=='SSS':
  print(0)
if S=='RSS' or S=='SRS' or S=='SSR' or S=='RSR':
  print(1)
if S=='RRS' or S=='SRR':
  print(2)
if S=='RRR':
  print(3)
Buggy python submission (verdict: Runtime Error):
X,K,D=map(int,input().split(' '))
time=0
if X>=0:
    while X>0:
        X-=D
        time+=1
        if time==K:
            break
    if (K-time)%2==0:
    print(abs(X))
else:
    print(X+D)
else:
    while X<0:
        X+=D
        time+=1
        if time==K:
            break
    if (K-time)%2==0:
    print(abs(X))
else:
    print(X-D)

Fixed submission:
X,K,D=map(int,input().split(' '))
if X>=0:
    time=X//D
    if time>K:
        print(X-K*D)
    elif (K-time)%2==0:
        print(X%D)
    else:
        print(abs((X%D)-D))
else:
    time=-(X//D)
    if time>K:
        print(abs(X+K*D))
    elif (K-time)%2==0:
        print(X%D)
    else:
        print(abs((X%D)-D))
Buggy python submission (verdict: Runtime Error):
import numpy as np
N,M,X=map(int,input().split())
allList=[]
for _ in range(N):
    allList.append(np.array(list(map(int,input().split()))))
minnum=10**7
for i in range(2**N):
    skill=[0]*(M+1)
    flag=True
    for row in range(N):
        if i&(2**row)>0:
            skill+=allList[row]
    for i in range(M):
        if skill[j+1]<X:
            flag=False
    if flag:
        minnum=min(minnum,skill[0])
if minnum==10**7:
    minnum=-1
print(minnum)

Fixed submission:
import numpy as np
N,M,X=map(int,input().split())
allList=[]
for _ in range(N):
    allList.append(np.array(list(map(int,input().split()))))
minnum=10**7
for i in range(2**N):
    skill=[0]*(M+1)
    flag=True
    for row in range(N):
        if i&(2**row)>0:
            skill+=allList[row]
    for j in range(M):
        if skill[j+1]<X:
            flag=False
    if flag:
        minnum=min(minnum,skill[0])
if minnum==10**7:
    minnum=-1
print(minnum)
Buggy python submission (verdict: Runtime Error):
X=int(input())
flagp=False
flagm=False
for A in range(-10**3,10**3):
    B5=A**5-X
    for B in range(10**3):
        if B5==B**5:
            flagp=True
            break
        elif B5==-B**5:
            flagm=True
            break
        else:
            raise Exception
    else:
        continue
    break
if flagp:
    print(A,B)
else:
    print(A,-B)

Fixed submission:
X=int(input())
flagp=False
flagm=False
flage=True
for A in range(-10**3,10**3):
    B5=A**5-X
    for B in range(10**3):
        if B5==B**5:
            flagp=True
            flage=False
            break
        elif B5==-B**5:
            flagm=True
            flage=False
            break
    else:
        continue
    break
if flagp:
    print(A,B)
elif flage:
    raise Exception
else:
    print(A,-B)

Buggy python submission (verdict: Runtime Error):
X=int(input())
for A in range(int(X**(1/5))+2):
    if X>=A**5:
        if int((X-A**5)**(1/5))==((X-A**5)**(1/5)):
            B=-int((X-A**5)**(1/5))
            break
    else:
        if int((A**5-X)**(1/5))==((A**5-X)**(1/5)):
            B=int((A**5-X)**(1/5))
            break
print(A,B)

Fixed submission:
X=int(input())
flagp=False
flagm=False
flage=True
for A in range(-10**3,10**3):
    B5=A**5-X
    for B in range(10**3):
        if B5==B**5:
            flagp=True
            flage=False
            break
        elif B5==-B**5:
            flagm=True
            flage=False
            break
    else:
        continue
    break
if flagp:
    print(A,B)
elif flage:
    raise Exception
else:
    print(A,-B)

Buggy python submission (verdict: Runtime Error):
X=int(input())
for A in range(int(X**(1/5))+2):
    if int((X-A**5)**(1/5))==((X-A**5)**(1/5)):
        B=-int((X-A**5)**(1/5))
        break
print(A,B)

Fixed submission:
X=int(input())
flagp=False
flagm=False
flage=True
for A in range(-10**3,10**3):
    B5=A**5-X
    for B in range(10**3):
        if B5==B**5:
            flagp=True
            flage=False
            break
        elif B5==-B**5:
            flagm=True
            flage=False
            break
    else:
        continue
    break
if flagp:
    print(A,B)
elif flage:
    raise Exception
else:
    print(A,-B)
Buggy python submission (verdict: Time Limit Exceeded):
import math
K=int(input())
result=0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            result+=math.gcd(math.gcd(a,b),c)
print(result)

Fixed submission:
from math import gcd
K=int(input())
result=0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            result+=gcd(gcd(a,b),c)
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
K=int(input())
result=0
for a in range(1,K+1):
    for b in range(a+1,K+1):
        for c in range(b+1,K+1):
            result+=np.gcd.reduce([a,b,c])*6
    b=a
    for c in range(1,K+1):
        result+=np.gcd.reduce([a,c])*3
    result-=a*2
print(result)

Fixed submission:
from math import gcd
K=int(input())
result=0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            result+=gcd(gcd(a,b),c)
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
K=int(input())
result=0
for a in range(1,K+1):
    for b in range(a+1,K+1):
        for c in range(b+1,K+1):
            result+=np.gcd.reduce([a,b,c])*6
    b=a
    for c in range(1,K+1):
        result+=np.gcd.reduce([a,b,c])*3
    result-=a*2
print(result)

Fixed submission:
from math import gcd
K=int(input())
result=0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            result+=gcd(gcd(a,b),c)
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
Slist=[]
for _ in range(N):
    Slist.append(input())
maxi=0
anslist=[]
for strings in Slist:
    if Slist.count(strings)>maxi:
        maxi=Slist.count(strings)
        if not strings in anslist:
            anslist=[strings]
    elif Slist.count(strings)==maxi:
        if not strings in anslist:
            anslist.append(strings)
for string in sorted(anslist):
    print(string)

Fixed submission:
from collections import defaultdict
charnums=defaultdict(int)
N=int(input())
for _ in range(N):
    charnums[input()]+=1
ans=[]
m=max(charnums.values())
for key,value in charnums.items():
    if value==m:
        ans.append(key)
for an in sorted(ans):
    print(an)
Buggy python submission (verdict: Time Limit Exceeded):
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


def func(a, b, c):
    return a * a + b * b + c * c + a * b + b * c + c * a


n = inp()
limit = int(math.sqrt(n)) + 1
for x in range(1, n + 1):
    ans = 0
    for i in range(1, limit):
        for j in range(i, limit):
            for k in range(j, limit):
                if func(i, j, k) == x:
                    if len(set([i, j, k])) == 1:
                        ans += 1
                    elif len(set([i, j, k])) == 2:
                        ans += 3
                    elif len(set([i, j, k])) == 3:
                        ans += 6
    print(ans)


Fixed submission:
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


def func(a, b, c):
    return a * a + b * b + c * c + a * b + b * c + c * a


n = inp()
limit = int(math.sqrt(n)) + 1
ans = [0] * n
for i in range(1, limit):
    for j in range(i, limit):
        for k in range(j, limit):
            x = func(i, j, k) - 1
            if x < n:
                if len(set([i, j, k])) == 1:
                    ans[x] += 1
                elif len(set([i, j, k])) == 2:
                    ans[x] += 3
                elif len(set([i, j, k])) == 3:
                    ans[x] += 6
for i in ans:
    print(i)
Buggy python submission (verdict: Runtime Error):
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


n, m, k = inpl()
a = inpl()
b = inpl()
tmp = 0
for i in range(len(a)):
    tmp += a[i]
    a[i] = tmp
tmp = 0
for i in range(len(b)):
    tmp += b[i]
    b[i] = tmp
ans = 0
a_start = bisect.bisect_right(a, k)
if a_amount==0:
    print(bisect.bisect_right(b, k))
for a_amount in range(a_start, 0, -1):
    new_k = k - a[a_amount - 1]
    b_amount = bisect.bisect_right(b, new_k)
    ans = max(ans, a_amount + b_amount)
print(ans)


Fixed submission:
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


n, m, k = inpl()
a = inpl()
b = inpl()
tmp = 0
for i in range(len(a)):
    tmp += a[i]
    a[i] = tmp
tmp = 0
for i in range(len(b)):
    tmp += b[i]
    b[i] = tmp
ans = 0
a_start = bisect.bisect_right(a, k)
ans = bisect.bisect_right(b, k)
for a_amount in range(a_start, 0, -1):
    new_k = k - a[a_amount - 1]
    b_amount = bisect.bisect_right(b, new_k)
    ans = max(ans, a_amount + b_amount)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


n = inp()
a = inpl()
ans = 1
for i in a:
    ans *= i
if ans > 10**18:
    print(-1)
    exit()
print(ans)


Fixed submission:
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


n = inp()
a = inpl()
ans = 1
if 0 in a:
    print(0)
    exit()
for i in a:
    ans *= i
    if ans > 10**18:
        print(-1)
        exit()
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))
def inpl_str():
    '''
    一行に複数の文字
    '''
    return list(input().split())

n=inp()
a = inpl()
sorted_a = sorted(a,reverse=True)
place=defaultdict(lambda: [])
for i in range(n):
    place[a[i]].append(i+1)
ans = 0
dp=[[-INF]*(n+1) for i in range(n+1)]
dp[0][0] = 0
for i in range(n):
    if i!=0 and sorted_a[i] == sorted_a[i - 1]:
        index += 1
    else:
        index = 0
    for j in range(n):
        _place = place[sorted_a[i]][index]
        #右
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + sorted_a[i] * abs(n - (i - j) - _place))
        #左
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + sorted_a[i] *  abs(_place - j - 1))

print(max(dp[n]))

Fixed submission:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))
def inpl_str():
    '''
    一行に複数の文字
    '''
    return list(input().split())

r = inp()
print(r*2*math.pi)
Buggy python submission (verdict: Time Limit Exceeded):
n,x,y=map(int,input().split())
ans={i:0 for i in range(n)}
dp=[[0]*n for _ in range(n)]
for i in range(1,n+1):
  for j in range(i+1,n+1):
    if j<=x or y<=i:
      dp[i-1][j-1]=j-i  
    elif j<y:
      if i<=x:
        dp[i-1][j-1]=x-i+min(j-x,1+y-j)
      else:
        dp[i-1][j-1]=min(j-i,i-x+y-j+1)
    elif y<=j:
      if i<=x:
        dp[i-1][j-1]=x-i+1+j-y
      else:
        dp[i-1][j-1]=j-y+min(y-i,1+i-x)
    else:
      print("Error")
      print(i,j)
for i in range(0,n):
  for j in range(i,n):
    ans[dp[i][j]]+=1
for i in range(1,n):
  print(ans[i])

Fixed submission:
n,x,y=map(int,input().split())
ans={i:0 for i in range(n)}
dp=[[0]*n for _ in range(n)]
for i in range(1,n+1):
  for j in range(i+1,n+1):
    if j<=x or y<=i:
      dp[i-1][j-1]=j-i  
    elif j<y:
      if i<=x:
        dp[i-1][j-1]=x-i+min(j-x,1+y-j)
      else:
        dp[i-1][j-1]=min(j-i,i-x+y-j+1)
    elif y<=j:
      if i<=x:
        dp[i-1][j-1]=x-i+1+j-y
      else:
        dp[i-1][j-1]=j-y+min(y-i,1+i-x)
    else:
      print("Error")
      print(i,j)
for i in range(0,n):
  for j in range(i,n):
    ans[dp[i][j]]+=1
for i in range(1,n):
  print(ans[i])
Buggy python submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
f={i:set([]) for i in range(n)}
for _ in range(m):
  a,b=map(int,input().split())
  a-=1
  b-=1
  f[a].add(b)
  f[b].add(a)
b={i:set([]) for i in range(n)}
for _ in range(k):
  c,d=map(int,input().split())
  c-=1
  d-=1
  b[c].add(d)
  b[d].add(c)
joined=set([])
def append_friends(j):
  if j in friends:
    return
  friends.add(j)
  s=f[j]
  for a in s:
    append_friends(a)
  return 
dp=[]
result=[]
for i in range(n):
  if i in joined:
    for j in dp:
      if i in j:
        result.append(j)
        break
    continue
  friends=set([])
  append_friends(i)
  dp.append(friends)
  result.append(friends)
  joined=joined|friends
ans=[0]*n
for i in range(n):
  ans[i]=str(len(result[i]-b[i]-f[i]-{i}))
print(" ".join(ans))

Fixed submission:
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))

class UnionFind():
    def __init__(self, n):
        """
        Parameters
        ----------
        n:int
            the number of node
        """
        self.par = [-1] * n # -self.par[i] means the tree size

    def find(self, x):
        """
        Parameters
        ----------
        x:int
            target node

        Return
        ----------
        res:int
            root node
        """
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.par[x] > self.par[y]: # lesser has many nodes
                x, y = y, x
            self.par[x] += self.par[y]
            self.par[y] = x

    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    
    def size(self, x):
        '''
        Parameters
        ----------
        x:int
            target node
        
        Return
        ----------
        x:int
            size of  group  to which belongs
        '''
        return - self.par[self.find(x)]
        

n, m, k = inpl()
dame = collections.defaultdict(set)
uf = UnionFind(n)
ans=[0]*n
for i in range(m):
    a, b = inpl()
    a, b = a - 1, b - 1
    dame[a].add(b)
    dame[b].add(a)
    uf.union(a,b)
for i in range(k):
    c, d = inpl()
    c, d = c - 1, d - 1
    if uf.is_same(c,d):
        dame[c].add(d)
        dame[d].add(c)
for i in range(n):
    ans[i] = uf.size(i) - len(dame[i]) - 1
    # 同じグループに所属 - (友達+ブロック) - 自分
print(*ans)

'''

'''
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n=int(input())
s=[Counter(input()) for i in range(n)]
s = [sorted(i.items(), key=lambda x:x[0]) for i in s]
s = ["".join(str(i)) for i in s]
dp={}
for i in range(n):
  dp.setdefault(s[i],0)
  dp[s[i]]+=1
ans=0
for i in dp.keys():
  ans+=dp[i]*(dp[i]-1)//2
print(ans)

Fixed submission:
n=int(input())
s=["".join(sorted(list(input()))) for i in range(n)]
s.sort()
dp=[1]
for i in range(n-1):
  if s[i]==s[i+1]:
    dp[len(dp)-1]+=1
  else:
    dp.append(1)
ans=0
for i in dp:
  ans+=i*(i-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n=int(input())
s=[Counter(input()) for i in range(n)]
s = [sorted(i.items(), key=lambda x:x[0]) for i in s]
s = ["".join(str(i)) for i in s]
dp={}
for i in range(n):
  dp.setdefault(s[i],0)
  dp[s[i]]+=1
ans=0
for i in dp.keys():
  ans+=dp[i]*(dp[i]-1)//2
print(ans)

Fixed submission:
n=int(input())
s=["".join(sorted(list(input()))) for i in range(n)]
s.sort()
dp=[1]
for i in range(n-1):
  if s[i]==s[i+1]:
    dp[len(dp)-1]+=1
  else:
    dp.append(1)
ans=0
for i in dp:
  ans+=i*(i-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n=int(input())
#s=[input() for i in range(n)]
s=[Counter(input()) for i in range(n)]
ans=0
for i in range(n):
  for j in range(i+1,n):
    if s[i]==s[j]:
      ans+=1
print(ans)
#def verify_anagrams(first_word, second_word):
#    return Counter(first_word) == Counter(second_word)

Fixed submission:
n=int(input())
s=["".join(sorted(list(input()))) for i in range(n)]
s.sort()
dp=[1]
for i in range(n-1):
  if s[i]==s[i+1]:
    dp[len(dp)-1]+=1
  else:
    dp.append(1)
ans=0
for i in dp:
  ans+=i*(i-1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
for i in range(n-1,-1,-1):
  if sum(ans[i::i+1])%2!=a[i]:
    ans[i]=1
ans=[i+1 for i in range(n) if ans[i]==1]
print(len(ans))
ans=" ".join(ans)
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
for i in range(n-1,-1,-1):
  if sum(ans[i::i+1])%2!=a[i]:
    ans[i]=1
ans=[i+1 for i in range(n) if ans[i]==1]
print(len(ans))
ans=list(map(str,ans))
ans=" ".join(ans)
print(ans)