Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03294 (python)

Fixed submission:
N = int(input())
ANs = list(map(int,input().split()))

m_1 = 0
for a in ANs:
	m_1 += a-1
	
print(m_1)

Buggy submission (verdict: Runtime Error):
N = int(input())
ANs = list(map(int,input().split()))
 
def lcm_base(x, y):
	return (x * y) // gcd(x, y)
	
lcmNum = ANs[0]
for a in ANs[1:]:
	lcmNum = lcm_base(lcmNum,a)
	
#print(lcmNum)
 
f = 0
for a in ANs:
	f += (lcmNum-1)%a
print(f)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
ANs = list(map(int,input().split()))

def lcm_base(x, y):
	return (x * y) // math.gcd(x, y)
	
lcmNum = ANs[0]
for a in ANs[1:]:
	lcmNum = lcm_base(lcmNum,a)
	
#print(lcmNum)

f = 0
for a in ANs:
	f += (lcmNum-1)%a
print(f)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

N = int(input())
ANs = list(map(int,input().split()))

def lcm_base(x, y):
	return (x * y) // math.gcd(x, y)
	
lcmNum = ANs[0]
for a in ANs[1:]:
	lcmNum = lcm_base(lcmNum,a)
	
#print(lcmNum)

f = 0
for a in ANs:
	f += (lcmNum-1)%a
print(f)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

N = int(input())
ANs = list(map(int,input().split()))

def lcm_base(x, y):
	return (x * y) // math.gcd(x, y)
	
def lcm_list(numbers):
	return reduce(lcm_base, numbers, 1)
	
lcmNum = lcm_list(ANs)
#print(lcmNum)
#print(lcmList)

f = 0
for a in ANs:
	f += (lcmNum-1)%a
print(f)

Buggy submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-

import sympy
import math
from functools import reduce

N = int(input())
ANs = list(map(int,input().split()))

def lcm_base(x, y):
	return (x * y) // math.gcd(x, y)
	
def lcm_list(numbers):
	return reduce(lcm_base, numbers, 1)
	
lcmNum = lcm_list(ANs)
lcmList = sympy.factorint(lcmNum)
#print(lcmNum)
#print(lcmList)


anss = []
f = 0
for a in ANs:
	f += (lcmNum-1)%a
print(f)
Problem p03471 (python)

Fixed submission:
n,y = map(int,input().split())
	
for s1 in range(n+1):
	for s2 in range(n-s1+1):
		if y== s1*10000+s2*5000+(n-s1-s2)*1000:
			print("{} {} {}".format(s1,s2,n-s1-s2))
			exit()
else:
	print("{} {} {}".format(-1,-1,-1))

Buggy submission (verdict: Runtime Error):
n,y = map(int,input().split())
	
for s1 in range(n+1):
	for s2 in range(n-s1+1):
		if y== s1*10000+s2*5000+(n-s1-s2)*1000:
			print("{} {} {}".format(s1,s2,s3))
else:
	print("{} {} {}".format(-1,-1,-1))
Problem p02854 (python)

Fixed submission:
from itertools import accumulate
import math

N =int(input())
list_aaa = list(map(int,input().split()))

ans = 10**10

sum_list_aaa =list(accumulate(list_aaa))

for i in range(N):
    zen = sum_list_aaa[i]
    go = sum_list_aaa[-1]-sum_list_aaa[i]
    ans = min(ans,abs(zen-go))

print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import accumulate
import math

N =int(input())
list_aaa = list(map(int,input().split()))

ans = 10**10

sum_list_aaa =list(accumulate(list_aaa))

for i in range(N):
    zen = sum_list_aaa[i]
    go = sum_list_aaa[-1]-sum_list_aaa[i]
    ans = min(ans,abs(zen-go)

print(ans)
Problem p02917 (python)

Fixed submission:
N = int(input())
B = list(map(int, input().split()))
res = B[0]
for i in range(1, N-1):
    res += min(B[i - 1], B[i])
res += B[-1]
print(res)

Buggy submission (verdict: Runtime Error):
N = int(input())
B_list = list(map(int,input().split()))
A_list = [0 for i in range(N)]

A_list[0] = B_list[0]

for i in range(1,N-1):
    A_list[i] = min(B_list[i],B_list[i-1])

A_list[-1] = B_list[-1]
print(sum(A_list)
Problem p02953 (python)

Fixed submission:

# N個のマス
N = int(input())

# タイルの高さ（H）のリスト
H_list = list(map(int,input().split()))

Judge = True

# 最初のマスは,単調非現象にするには必ず１低くするのが最適
H_list[0]-=1

for i in range(N-1):
    # 右側i+1のマスが高ければ必ず１低くする
    if H_list[i] < H_list[i+1]:
        H_list[i+1]-=1
    elif H_list[i] > H_list[i+1]:
    # 左側が高くなれば　単調非現象は成立しない
        Judge = False

if Judge == True:
    print('Yes')
elif Judge == False:
    print('No')

Buggy submission (verdict: Runtime Error):

# N個のマス
N = int(input())

# タイルの高さ（H）のリスト
H_list = int(input().split())

Judge = True

# 最初のマスは,単調非現象にするには必ず１低くするのが最適
H_list(0)-=1

for i in range(N-1):
    # 右側i+1のマスが高ければ必ず１低くする
    if H_list(i) < H_list(i+1):
        H_list(i+1)-=1
    elif H_list(i) > H_list(i+1):
    # 左側が高くなれば　単調非現象は成立しない
        Judge = False

if Judge == True:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):

# N個のマス
N = int(input())

# タイルの高さ（H）のリスト
H_list = int(input().split())

Judge = True

for i in H_list:
    if H_list(i) > H_list(i+1):
        H_list(i)-1
    elif:
        pass
    else :
        Judge = False

if Judge == True:
    print('Yes')
else:
    print('No')
Problem p02971 (python)

Fixed submission:
N = int(input())
A_list = []
for i in range(1,N+1):
    A = int(input())
    A_list.append(A)
A_list_sort = sorted(A_list)

max_a = A_list_sort[-1]
max_b = A_list_sort[-2]


for i in range(N):
    if A_list[i] == max_a:
        print(max_b)
    else:
        print(max_a)

Buggy submission (verdict: Runtime Error):
N = int(input())
A_list = []
for i in range(1,N+1):
    A = int(input())
    A_list.append([i,A])

pop_que =[]

for i in range(N):
    pop_que =A_list.pop(0)
    pop_que.append(max(A_list,key=lambda x:x[1]))
    A_list.append(pop_que)

for i in range(N):
    print(f"{A_list[i][2][1]}")

Buggy submission (verdict: Runtime Error):
N = int(input())
A_list = []
for i in range(1,N+1):
    A = int(input())
    A_list.append([i,A])

pop_que =[]
ans_list= []

print(f"A_list:{A_list}")

for i in range(N):
    pop_que =A_list.pop(0)
    pop_que.append(max(A_list,key=lambda x:x[1]))
    A_list.append(pop_que)

#print(f"A_list[0]:{A_list[0]}")
#print(f"A_list[0][0]:{A_list[0][0]}")
#print(f"A_list[0][2][0]:{A_list[0][2][0]}")

for i in range(N):
    print(f"{A_list[i][2][1]}")
Problem p02994 (python)

Fixed submission:
N,L = map(int, input().split())

N_list = [ i for i in range(1,N+1)]

aaa_list = []

for i in range(1,N+1):
    aaa_list.append(L+i-1)

print(sum(aaa_list)-min(aaa_list,key=lambda x: abs(x)))

Buggy submission (verdict: Runtime Error):
N,L = map(int, input().split())

N_list = [ i for i in range(1,N+1)]

aaa_list = []

for i in range(1,N+1):
    aaa_list.append(L+i-1)

print(sum(aaa_list)-min(list_aaa,key=lambda x: abs(x)))
Problem p03239 (python)

Fixed submission:
N,T = map(int,input().split())
list_aaa = [list(map(int,input().split())) for i in range(N)]

min_aaa =1001

for i in range(N):
    if T>= list_aaa[i][1]:
        min_aaa = min(min_aaa,list_aaa[i][0])

if min_aaa ==1001:
    print("TLE")
else:
    print(min_aaa)

Buggy submission (verdict: Runtime Error):
N,T = map(int,input().split())
list_aaa = [list(map(int,input().split())) for i in range(N)]

min_aaa =1001

for i in range(N):
    if T>= list_aaa[i][1]:
        min_aaa = min(min_aaa,list_aaa[i][1])

if min_aaa ==1001:
    print(TLE)
else:
    print(min_aaa)
Problem p03243 (python)

Fixed submission:
N = int(input())

list_aaa = [111,222,333,444,555,666,777,888,999]
cnt =0

for i in range(len(list_aaa)):
    if N > list_aaa[i]:
        cnt +=1

if cnt ==0:
    print(111)
else:
    print(list_aaa[cnt])

Buggy submission (verdict: Runtime Error):
N = int(input())

list_aaa = [111,222,333,444,555,666,777,888,999]
cnt =0

for i in range(len(list_aaa)):
    if N >= list_aaa[i]:
        cnt +=1

if cnt ==0:
    print(111)
else:
    print(list_aaa[cnt])

Buggy submission (verdict: Runtime Error):
N = int(input())

list_aaa = [111,222,333,444,555,666,777,888,999]
cnt =0

for i in range(len(list_aaa)):
    if N >= list_aaa[i]:
        cnt +=1

if cnt ==0:
    print(111)
    exit()
else:
    print(list_aaa[cnt])

Buggy submission (verdict: Runtime Error):
N = int(input())

list_aaa = [111,222,333,444,555,666,777,888,999]
cnt =0

for i in range(len(list_aaa)):
    if N >= list_aaa[i]:
        cnt +=1

if cnt ==0:
    print(111)
    exit()
else:
    print(list_aaa[cnt])
Problem p02910 (python)

Fixed submission:
N=list(input())
a=[]
b=[]
#print(N)
#print(len(N))
for k in range(len(N)):
    if k%2>0:
        b.append(N[k])
    else:
        a.append(N[k])
if   a.count('L')==0 and b.count('R')==0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N=list(input())
a=[]
b=[]
#print(N)
#print(len(N))
for k in range(len(N)+1):
    if k%2>0:
        a.append(N[k])
    else:
        b.append(N[k])
if   a.count('L')==0 and b.count('R')==0:
    print('Yes')
else:
    print('No')
Problem p02842 (python)

Fixed submission:
from math import *
N = int(input())

ans = 0
for i in range(1, N+1):
    if(floor(i*1.08) == N):
        ans = i

if ans == 0:
    print(":(")
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
from math import *
N = int(input())


for i in range(1, N+1):
    if(floor(i*1.08) == N):
        print(i)
	exit()

print(':(')
Problem p02929 (python)

Fixed submission:
import math

N = int(input())
S = input()
mod = 10**9 + 7

left = 0
ret = 1
for i in range(len(S)):
    if S[i] == 'W':
        if left % 2 == 1:
            left += 1
        else:
            if left > 0:
                ret *= left
                ret %= mod
                left -= 1
            else:
                print(0)
                exit()
    else:
        if left % 2 == 1:
            ret *= left
            ret %= mod
            left -= 1
        else:
            left += 1

if left > 0:
    print(0)
    exit()
            
for i in range(1, N+1):
    ret *= i
    ret %= mod
print(ret)

Buggy submission (verdict: Runtime Error):
from functools import lru_cache

N = int(input())
S = input()
mod = 10 ** 9 + 7
x = 0
for i in range(len(S)):
    if S[i] == 'B':
        x += 2**i

@lru_cache(maxsize=10**10)
def func(now, remain=tuple(range(2*N))):
    if len(remain) == 0:
        if now == 0:
            return 1
        else:
            return 0
        
    ret = 0
    for i in range(len(remain)):
        for j in range(i+1, len(remain)):
            temp = list(remain)
            temp.pop(j)
            temp.pop(i)
            ret += func(now ^ ((2**(remain[j]+1)-1)-(2**remain[i]-1)), tuple(temp))
            ret %= mod
    return ret

print(func(x) % mod)
Problem p02949 (python)

Fixed submission:
N, M, P = map(int, input().split())
edge = []

for i in range(M):
    A, B, C = map(int, input().split())
    edge.append((A, B, P-C))

inf = float('inf')
cost = [inf] * (N+1)
cost[1] = 0
for i in range(N-1):
    for e in edge:
        a, b, c = e
        if cost[a] + c < cost[b]:
            cost[b] = cost[a] + c

for i in range(N):
    for e in edge:
        a, b, c = e
        if cost[a] + c < cost[b]:
            if b == N:
                print(-1)
                exit()
            else:
                cost[b] = cost[a] + c
        
print(max(-cost[N], 0))

Buggy submission (verdict: Runtime Error):
N, M, P = map(int, input().split())
edge = []

for i in range(M):
    A, B, C = map(int, input().split())
    edge.append((A, B, P-C))

inf = float('inf')
cost = [inf] * (N+1)
cost[1] = 0
for i in range(N-1):
    for e in edge:
        a, b, c = e
        if cost[a] + c < cost[b]:
            cost[b] = cost[a] + c

for e in edge:
    a, b, c = e
    if cost[a] + c < cost[b]:
        if b == N:
      	    print(-1)
            exit()
        cost[b] = cost[a] + c
        
print(max(-cost[N], 0))

Buggy submission (verdict: Runtime Error):
N, M, P = map(int, input().split())
edge = []

for i in range(M):
    A, B, C = map(int, input().split())
    edge.append((A, B, P-C))

inf = float('inf')
cost = [inf] * (N+1)
cost[1] = 0
for i in range(N-1):
    for e in edge:
        a, b, c = e
        if cost[a] + c < cost[b]:
            cost[b] = cost[a] + c

for e in edge:
    a, b, c = e
    if cost[a] + c < cost[b]:
      if b == N:
      	print(-1)
        exit()
      cost[b] = cost[a] + c
        
print(max(-cost[N], 0))
Problem p02960 (python)

Fixed submission:
S = input()
M = 10**9+7

case = [1] + [0] * 12
temp = [0] * 13
unit = 1
before = 0
for i in reversed(range(len(S))):
    if(S[i] == '?'):
        for k in range(13):
            for j in range(10):
                before = (k - unit * j) % 13
                temp[k] += case[before]
            temp[k] %= M
    else:
        for k in range(13):
            before = (k - unit * int(S[i])) % 13
            temp[k] = case[before]
    case = temp
    unit *= 10
    unit %= 13
    temp = [0] * 13

print(case[5])

Buggy submission (verdict: Runtime Error):
S = input()
N = len(S)
count = [0, 0, 0, 0, 0, 0]
mod = [1, -3, -4, -1, 3, 4]
m = 0
for i in range(N):
    if(S[N-i-1] == '?'):
        count[i % 6] += 1
    else:
        m += mod[i % 6] * int(S[N-i-1])
        m %= 13

M = 10**9 + 7
print(sum(count))

if(sum(count) == 0):
    print(0)
    exit()


def func(power):
    x = 10 ** power % M
    return x // 13
    
    
    
c_min = 13
remain_list = [0, 0, 0, 0, 0, 0]
power = 1
for i in range(6):
    if(count[i] == 0):
        continue
    else:
        remain = count[i] % 13
        power *=  (count[i] - remain)
        remain_list[i] = remain 

c = 0
for i in range(len(remain[0])):
    for j in range(len(remain[1])):
        for k in range(len(remain[2])):
            for l in range(len(remain[3])):
                for m in range(len(remain[4])):
                    for n in range(len(remain[5])):
    if i * mod[0] + j * mod[1] + k * mod[2] + l * mod[3] + m * mod[4] + n * mod[5] % 13 == 0:
        c += 1
                        
    
print(func(power) + c)
Problem p03061 (python)

Fixed submission:
N = int(input())
A = [0] + list(map(int, input().split()))

def gcd(a, b):
    if a < b:
        b, a = a, b
    if b == 0:
        return a
        
    while a % b != 0:
        a %= b
        a, b = b, a

    return b

L = [0] * (N+1)
R = [0] * (N+2)

for i in range(1, N+1):
    ind = N+1-i
    L[i] = gcd(L[i-1], A[i-1])
    R[ind] = gcd(R[ind+1], A[ind])

ret = []
for i in range(1, N+1):
    ret.append(gcd(L[i], R[i+1]))

print(max(ret))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
A.sort()

def divisor(x, m):
    ret = []
    for i in range(1, int(x**0.5)+1):
        if i >= m:
            return ret
            
        if x % i == 0:
            ret.append(i)
            compl = x//i
            if i*i != x and compl < m:
                ret.append(compl)
    return ret

divisor_dict = {}
m = 10 ** 10
for i in range(len(A)):
    if i==3:
        m = 0
        for key, val in divisor_dict:
            if val >= 2 and key > m:
                m = key
    
    div = divisor(A[i], m)
    for j in div:
        if j in divisor_dict:
            divisor_dict[j] += 1
        else:
            divisor_dict[j] = 1
        
max_val = 0
for key, val in divisor_dict.items():
    if val >= N-1 and key > max_val:
        max_val = key

print(max_val)
Problem p03078 (python)

Fixed submission:
from heapq import heappush, heappop

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
cand = []

for i in range(len(A)):
    for j in range(len(B)):
        if(i * j > K):
            break
        for k in range(len(C)):
            if(i *  j * k > K):
                break
            heappush(cand, A[i]+B[j]+C[k])
            if(len(cand) > K):
                heappop(cand)

ret = []
for i in range(K):
    ret.append(heappop(cand))

for i in reversed(range(K)):
    print(ret[i])

Buggy submission (verdict: Runtime Error):
from heapq import heappush, heappop

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
cand = []

for i in range(len(A)):
    for j in range(len(B)):
        if(i + j + 1 >= K):
            break
        for k in range(len(C)):
            if(i + j + k + 1 >= K):
                break
            heappush(cand, A[i]+B[j]+C[k])
            if(len(cand) > K):
                heappop(cand)

ret = []
for i in range(K):
    ret.append(heappop(cand))

for i in reversed(range(K)):
    print(ret[i])

Buggy submission (verdict: Runtime Error):
from heapq import heappush, heappop

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
cand = []

for i in range(len(A)):
    for j in range(len(B)):
        if(i + j + 1 >= K):
            break
        for k in range(len(C)):
            if(i + j + k + 1 >= K):
                break
            heappush(cand, -(A[i]+B[j]+C[k]))

for i in range(K):
    print(-heappop(cand))
Problem p03292 (python)

Fixed submission:
# coding: utf-8
n = input()
list = n.split(" ")
num = [int(x) for x in list ]

print(max(num)-min(num))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
n = input()
list = n.split(" ")
num = [int(x) for x in list ]

print(num.max - num.min)
Problem p03545 (python)

Fixed submission:
n = input()
op_cnt = len(n) - 1  # すき間の個数
for i in range(2 ** op_cnt):
    op = ["-"] * op_cnt  # あらかじめ ["-", "-", "-"] というリストを作っておく
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "+"  # フラグが立っていた箇所を "+" で上書き

    formula = ""
    for p_n, p_o in zip(n, op + [""]):  # 少々モヤッとする
        formula += (p_n + p_o)
    if eval(formula) == 7:
        print(formula + "=7")
        break

Buggy submission (verdict: Runtime Error):
n = [int(x) for x in input()]

op_cnt = len(n) - 1  # すき間の個数
for i in range(2 ** op_cnt):
    op = ["-"] * op_cnt  # あらかじめ ["-", "-", "-"] というリストを作っておく
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "+"  # フラグが立っていた箇所を "+" で上書き
        formula = ""
        for p_n, p_o in zip(n, op + [""]):  # 少々モヤッとする
            formula += (p_n + p_o)
        if eval(formula) == 7:
            print(formula + "=7")
            break
Problem p04044 (python)

Fixed submission:
N, L = map(int, input().split())
S = []
for i in range(N):
    line = input()
    S.append(line)
S.sort()
print("".join(S))

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
c =[]
for i in range(b-1):
    c.append(str(input()))
c = sorted(c)
mojiretu = ''
for x in c:
    mojiretu += x
print(mojiretu)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
c =[]
for i in range(b):
    c.append(str(input()))
c = sorted(c)
mojiretu = ''
for x in c:
    mojiretu += x
print(mojiretu)
Problem p03455 (python)

Fixed submission:
a,b = map(int,input().split())
num = a * b
if num % 2 == 0:
    print('Even')
else:
    print('Odd')

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
num = a * b
if num % 2 = 0:
    print('Even')
else:
    print('Odd')
Problem p03469 (python)

Fixed submission:
print(input().replace('017','018'))

Buggy submission (verdict: Runtime Error):
day = list(map(int,input().split('/')))
day[0] = 2018
print(day[0],day[1],day[2],sep('/'))

Buggy submission (verdict: Runtime Error):
day = list(input().split('/'))
day[0] = '2018'
print(day[0],day[1],day[2],sep(/))

Buggy submission (verdict: Runtime Error):
day = list(input().split('/'))
day[0] = 2018
print(day[0],day[1],day[2],sep(/))
Problem p03493 (python)

Fixed submission:
a = list(input())
b = 0
for i in a:
    b += int(i)
print(b)

Buggy submission (verdict: Runtime Error):
t = input().replace(' ','')
if t % 4 == 0:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
a = list(int(input()))
b = 0
for i in a:
    b += i
print(b)

Buggy submission (verdict: Runtime Error):
a = int(input)
for row in a:
    b += row 
print(b)

Buggy submission (verdict: Runtime Error):
a, b, c = int(input())
print(a+b+c)

Buggy submission (verdict: Runtime Error):
a, b, c = int(input())
print(str(a+b+c))
Problem p03693 (python)

Fixed submission:
a,b,c = map(str,input().split())
t = int(b+c)
if t % 4 == 0:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
t = input().replace(' ','')
if t % 4 == 0:
    print('YES')
else:
    print('NO')
Problem p02924 (python)

Fixed submission:
N = int(input())
print(N * (N - 1) // 2)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
ans = np.sum(np.arange(N))
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
ans = np.sum(range(1,N))
print(ans)

Buggy submission (verdict: Runtime Error):
#import sys
N = int(input())
NL = list(range(1,N+1))
print(sum(NL) - N)
Problem p02947 (python)

Fixed submission:
#import sys
# import math

def modc(a, b, m):
    c = 1
    for i in range(b):
        c = c * (a - i) % m
        c = c * modinv(i + 1, m) % m
    return c


def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)


def modinv(a, m):
    (inv, q, gcd_val) = egcd(a, m)
    return inv % m

N = int(input())
#A, B = list(map(int,input().split()))
S = [''.join(sorted(input())) for _ in range(N)]
D = {}
for s in S :
    if s in D :
        D[s] += 1
    else :
        D[s] = 1
V = list(D.values())

count = 0
for v in V :
    if v == 1 :
        count += 0
    elif v == 2 :
        count += 1
    elif v >= 3 :
        count += modc(v, 2, 2 ** 63 - 1)
print(count)

Buggy submission (verdict: Runtime Error):
#import sys
import math

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

N = int(input())
#A, B = list(map(int,input().split()))
S = [''.join(sorted(input())) for _ in range(N)]
D = {}
for s in S :
    if s in D :
        D[s] += 1
    else :
        D[s] = 1
V = list(D.values())
count = 0
for v in V :
    if v == 1 :
        count += 0
    elif v == 2 :
        count += 1
    elif v >= 3 :
        count += nCr(v,2)
print(count)