Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# あなたは、500円玉をA枚、100円玉をB枚、50円玉をC枚持っています。 これらの硬貨の中から何枚かを選び、合計金額をちょうどX円にする方法は何通りありますか。
A,B,C,X=(int(z) for z in input().split())
# A,B,C,X=map(int,'30 30 30 12000'.split())
N=0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if i*500+j*100+k*50==X:
                N+=1

print(N)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())

N=0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if i*500+j*100+k*50==X:
                N+=1

print(N)

Buggy python submission (verdict: Runtime Error):
# あなたは、500円玉をA枚、100円玉をB枚、50円玉をC枚持っています。 これらの硬貨の中から何枚かを選び、合計金額をちょうどX円にする方法は何通りありますか。
A,B,C,X=(int(z) for z in input().split())
# A,B,C,X=map(int,'30 30 30 12000'.split())
N=0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if i*500+j*100+k*50==X:
                N+=1

print(N)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())

N=0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if i*500+j*100+k*50==X:
                N+=1

print(N)

Buggy python submission (verdict: Runtime Error):
# あなたは、500円玉をA枚、100円玉をB枚、50円玉をC枚持っています。 これらの硬貨の中から何枚かを選び、合計金額をちょうどX円にする方法は何通りありますか。
A,B,C,X=map(int,input().split())
# A,B,C,X=map(int,'30 30 30 12000'.split())
N=0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if i*500+j*100+k*50==X:
                N+=1

print(N)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())

N=0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if i*500+j*100+k*50==X:
                N+=1

print(N)

Buggy python submission (verdict: Runtime Error):
# あなたは、500円玉をA枚、100円玉をB枚、50円玉をC枚持っています。 これらの硬貨の中から何枚かを選び、合計金額をちょうどX円にする方法は何通りありますか。
A,B,C=map(int,input().split())
# A,B,C,X=map(int,'30 30 30 12000'.split())
N=0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if i*500+j*100+k*50==X:
                N+=1

print(N)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())

N=0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if i*500+j*100+k*50==X:
                N+=1

print(N)
Buggy python submission (verdict: Runtime Error):
s1,s2,s3=map(str,input().split())
# c=str(input())
a=s1+s2+s3
b=0

for i in a:
    b=b+int(i)

print(b)

Fixed submission:
# s1,s2,s3=map(str,input().split())
s1s2s3=str(input())
# a=s1+s2+s3
b=0

for i in s1s2s3:
    b=b+int(i)

print(b)
Buggy python submission (verdict: Runtime Error):
from sys import exit

x=int(input())
for i in range(0,201):
	for j in range(-200,i):
		if i**5-j**5==x:
			print(i,j)
			exit()

Fixed submission:
s=input()
if s=="ABC":
	print("ARC")
else:
	print("ABC")
Buggy python submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
B=[0]*(10**10)
res=0

for i in range(n):
	B[A[i]+i]+=1
for i in range(n):
	if i-A[i]>0:
		res+=B[i-A[i]]

print(res)

Fixed submission:
from collections import defaultdict

n=int(input())
A=list(map(int,input().split()))
B=defaultdict(int)
res=0

for i in range(n):
	B[A[i]+i]+=1
	if i-A[i] in B:
		res+=B[i-A[i]]

print(res)

Buggy python submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
B=[0]*(n+max(A)+1)
res=0

for i in range(n):
	if 0<=(i+1)+A[i]:
		B[i+A[i]+1]+=1
		if 0<=i-A[i]+1:
			res+=B[i-A[i]+1]

print(res)

Fixed submission:
from collections import defaultdict

n=int(input())
A=list(map(int,input().split()))
B=defaultdict(int)
res=0

for i in range(n):
	B[A[i]+i]+=1
	if i-A[i] in B:
		res+=B[i-A[i]]

print(res)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def main():
	n=int(input())
	A=list(map(int,input().split()))
	res=0

	for i in range(n):
		for j in range(i+A[i]+1,n):
			if abs(i-j)==A[i]+A[j]:
				res+=1
	print(res)
	
if __name__ == '__main__':
	main()

Fixed submission:
from collections import defaultdict

n=int(input())
A=list(map(int,input().split()))
B=defaultdict(int)
res=0

for i in range(n):
	B[A[i]+i]+=1
	if i-A[i] in B:
		res+=B[i-A[i]]

print(res)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def main():
	n=int(input())
	A=list(map(int,input().split()))
	res=0

	for i in range(n):
		for j in range(i+A[i]+1,n):
			if abs(i-j)==A[i]+A[j]:
				res+=1
	print(res)
	
if __name__ == '__main__':
	main()


Fixed submission:
from collections import defaultdict

n=int(input())
A=list(map(int,input().split()))
B=defaultdict(int)
res=0

for i in range(n):
	B[A[i]+i]+=1
	if i-A[i] in B:
		res+=B[i-A[i]]

print(res)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def main():
	n=int(input())
	A=list(map(int,input().split()))
	res=0

	for i in range(n):
		for j in range(i+1,n):
			if abs(i-j)==A[i]+A[j]:
				res+=1
	print(res)
	
if __name__ == '__main__':
	main()

Fixed submission:
from collections import defaultdict

n=int(input())
A=list(map(int,input().split()))
B=defaultdict(int)
res=0

for i in range(n):
	B[A[i]+i]+=1
	if i-A[i] in B:
		res+=B[i-A[i]]

print(res)
Buggy python submission (verdict: Runtime Error):
s=input()

d=[0]*2019
dp=0
d[0]+=1
l=len(s)

for i in range(l-1,-1,-1):
	dp = (dp+int(s[i])*(10**(l-1-i)))%2019
	d[dp]+=1
res=0

for a in d:
	res+=a*(a-1)//2
	
print(res)

Fixed submission:
s,w=map(int,input().split())
print("safe") if s>w else print("unsafe")
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=[int(input()) for i in range(n)]
print(len(set(s))

Fixed submission:
n=int(input())
s={input() for i in range(n)}
print(len(s))
Buggy python submission (verdict: Runtime Error):
from collections import Counter

n=int(input())
s=input()

l=list(Counter(s).values())
res=l[0]*l[1]*l[2]

dis=0
chk=0

while chk==0:
	dis+=1
	for i in range(n):
		if dis*2>n-1:
			chk=1
			break
		if i+dis*2>n-1:
			break
		j=i+dis
		k=i+dis*2
		if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
			res-=1
			
print(res)

Fixed submission:
from collections import Counter
from sys import exit

n=int(input())
s=input()

l=list(Counter(s).values())
if len(l)<3:
	print("0")
	exit()
	
res=l[0]*l[1]*l[2]

for i in range(1,n//2+1):
	for j in range(n):
		if j+i*2>n-1:
			break
		a=j
		b=j+i
		c=b+i
		if s[a]!=s[b] and s[b]!=s[c] and s[c]!=s[a]:
			res-=1
			
print(res)
Buggy python submission (verdict: Runtime Error):
s=input()
l=len(s)
q=int(input())
cnt=1

for _ in range(q):
	a=list(input().split())
	if len(a)==1:
		cnt*=(-1)
	else:
		if cnt==1:
			if a[1]=="1":
				s=a[2]+s
			else:
				s=s+a[2]
		else:
			if a[1]=="1":
				s=s+a[2]
			else:
				s=a[2]+s
				
if cnt==-1:
	s=s[::-1]
	
print(s)

Fixed submission:
n,x,y=map(int,input().split())
d=[0]*(n-1)

for i in range(n-1):
	for j in range(i+1,n):
		d[min(j-i-1,abs(x-1-i)+abs(y-1-j))]+=1
		
for i in range(n-1):
	print(d[i])
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
l=len(s)
q=int(input())
cnt=1

for _ in range(q):
	a=list(input().split())
	if len(a)==1:
		cnt*=(-1)
	else:
		if cnt==1:
			if a[1]=="1":
				s=a[2]+s
			else:
				s=s+a[2]
		else:
			if a[1]=="1":
				s=s+a[2]
			else:
				s=a[2]+s
				
if cnt==-1:
	s=s[::-1]
	
print(s)

Fixed submission:
s=input()
l=len(s)
q=int(input())
cnt=1
l=str()
r=str()

for _ in range(q):
	a=list(input().split())
	if a[0]=="1":
		cnt*=(-1)
	else:
		if int(a[1])*cnt==1 or int(a[1])*cnt==-2:
			l+=a[2]
		else:
			r+=a[2]				

s=l[::-1]+s+r
if cnt==-1:
	s=s[::-1] 	

print(s)
Buggy python submission (verdict: Runtime Error):
from sys import exit

n,m = map(int,input().split())
A=[-1]*3

cnt=0
for _ in range(m):
	s,c=map(int,input().split())
	if A[s-1]!=c and A[s-1]!=-1:
		cnt=1
	else:
		A[s-1]=c

if cnt==1 or A[0]==0:
	print("-1")
	exit()
	
if A[0]==-1:
	if n==1:
		A[0]=0
	else:
		A[0]=1

res=0
for i in range(n):
	if A[i]==-1:
		A[i]=0
	res+=A[i]*(10**(n-i-1))

print(res)

Fixed submission:
N=int(input())
if N%2 == 1:
	print(N//2+1)
else:
	print(N//2)
Buggy python submission (verdict: Time Limit Exceeded):
mod=10**9+7

n,a,b=map(int,input().split())
res=pow(2,n,mod)
res=(res-1)%mod

up=1
down=1
for i in range(1,b+1):
	up*=(n-i+1)
	up%mod
	down*=i
	if i==a:
		upa=up
		downa=down

nca=upa%mod
nca*=pow(downa,mod-2,mod)
nca%=mod
ncb=(up%mod)
ncb*=pow(down,mod-2,mod)
ncb%=mod
print((res-nca-ncb)%mod)

Fixed submission:
mod=10**9+7

n,a,b=map(int,input().split())
res=pow(2,n,mod)
res=(res-1)%mod

ncb=1
for i in range(1,b+1):
	ncb*=(n-i+1)*pow(i,mod-2,mod)
	ncb%=mod
	if i==a:
		nca=ncb
		
print((res-nca-ncb)%mod)

Buggy python submission (verdict: Runtime Error):
mod=10**9+7

n,a,b=map(int,input().split())
res=pow(2,n,mod)
res=(res-1)%mod

up=1
down=1
for i in range(1,b+1):
	up*=(n-i+1)
	up%mod
	down*=i
	if i==a:
		upa=up
		downa=down

nca=upa%mod
nca*=pow(downa,mod-2,mod)
nca%=mod
ncb=(up%mod)
ncb=*pow(down,mod-2,mod)
ncb%=mod
print((res-nca-ncb)%mod)

Fixed submission:
mod=10**9+7

n,a,b=map(int,input().split())
res=pow(2,n,mod)
res=(res-1)%mod

ncb=1
for i in range(1,b+1):
	ncb*=(n-i+1)*pow(i,mod-2,mod)
	ncb%=mod
	if i==a:
		nca=ncb
		
print((res-nca-ncb)%mod)

Buggy python submission (verdict: Time Limit Exceeded):
mod=10**9+7

n,a,b=map(int,input().split())
res=pow(2,n,mod)
res=(res-1)%mod

up=1
down=1
for i in range(1,b+1):
	up*=(n-i+1)
	down*=i
	if i==a:
		upa=up
		downa=down

nca=(upa%mod)*pow(downa,mod-2,mod)%mod
ncb=(up%mod)*pow(down,mod-2,mod)%mod
print((res-nca-ncb)%mod)

Fixed submission:
mod=10**9+7

n,a,b=map(int,input().split())
res=pow(2,n,mod)
res=(res-1)%mod

ncb=1
for i in range(1,b+1):
	ncb*=(n-i+1)*pow(i,mod-2,mod)
	ncb%=mod
	if i==a:
		nca=ncb
		
print((res-nca-ncb)%mod)

Buggy python submission (verdict: Runtime Error):
mod=10**9+7

class Combination:
	def __init__(self,size):
		self.size = size + 2
		self.fact = [1, 1] + [0] * size
		self.factInv = [1, 1] + [0] * size
		self.inv = [0, 1] + [0] * size
		
		for i in range(2, self.size):
			self.fact[i] = self.fact[i - 1] * i % mod
			self.inv[i] = -self.inv[mod % i] * (mod//i) % mod
			self.factInv[i] = self.factInv[i - 1] * self.inv[i] % mod
			
	def npk(self,n,k):
		if n < k or n < 0 or k < 0:
			return 0
		return self.fact[n] * self.factInv[n - k] % mod
		
	def nck(self,n,k):
		if n < k or n < 0 or k < 0:
			return 0
		return self.fact[n] * (self.factInv[k] * self.factInv[n - k] % mod) % mod
		
	def nhk(self,n,k):
		return self.nck(n + k - 1, n - 1)
		
n,a,b=map(int,input().split())

ca=Combination(n+a)
cb=Combination(n+b)
nca=ca.nck(n,a)
ncb=cb.nck(n,b)

print(((2**n-1)%mod-nca-ncb)%mod)

Fixed submission:
mod=10**9+7

n,a,b=map(int,input().split())
res=pow(2,n,mod)
res=(res-1)%mod

ncb=1
for i in range(1,b+1):
	ncb*=(n-i+1)*pow(i,mod-2,mod)
	ncb%=mod
	if i==a:
		nca=ncb
		
print((res-nca-ncb)%mod)
Buggy python submission (verdict: Runtime Error):
from sys import exit
n = int(input())
A = list(map(int,input().split()))

for a in A:
	if a%2 == 0:
		if a%3 != 0 and a%5 != 0:
			print("DENIED")
			sys.exit()

print("APPROVED")

Fixed submission:
import sys
n = int(input())
A = list(map(int,input().split()))

for a in A:
	if a%2 == 0:
		if a%3 != 0 and a%5 != 0:
			print("DENIED")
			sys.exit()

print("APPROVED")
Buggy python submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
S = [int(input()) for i in range(N)]

count = Counter(S)
maxnum = max(count.values())
maxlist= [i for i,j in count.items() if j==maxnum]

maxlist.sort()
print("/n".join(maxlist))

Fixed submission:
from collections import Counter
N = int(input())
S = [input() for i in range(N)]

count = Counter(S)
maxnum = max(count.values())
maxlist= [i for i,j in count.items() if j==maxnum]

maxlist.sort()

for m in maxlist:
	print(m)
Buggy python submission (verdict: Runtime Error):
s,t=map(input().split())
a,b=map(int,input().split())
u  =input()
if s==u:
	print(a-1)
else:
	print(b-1)

Fixed submission:
s,t=input().split()
a,b=map(int,input().split())
u  =input()
if s==u:
	print(a-1,b)
else:
	print(a,b-1)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
p=list(map(int,input().split()))

res=0
for i in range(0,n-k+1):
	tmp=sum(p[i:i+k])
	res=max(res,tmp)

print((float(res)+k)/2)

Fixed submission:
from collections import deque

n,k=map(int,input().split())
p=list(map(int,input().split()))

q=deque(p[0:k])
tmp=sum(q)
res=tmp
for i in range(k,n):
	q.append(p[i])
	tmp+=(p[i]-q.popleft())
	res=max(res,tmp)
	
print((float(res)+k)/2)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
print(Yes) if n==m else print(No)

Fixed submission:
n,m=map(int,input().split())
print("Yes") if n==m else print("No")
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[]
for i in range(m):
	p,s=input().split()
	if p in a:
		continue
	if s=="AC":
		a.append(p)
print(len(a))

Fixed submission:
c=input()
print(chr(ord(c)+1))
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[-1]*(10**5)
for i in range(n):
	p,s=input().split()
	p=int(p)
	if s=="AC" and a[p]<0:
		a[p] = a[p]*(-1)
	if s=="WA" and a[p]<0:
		a[p] -= 1
ac=0
wa=0
for i in range(n):
	if a[i] > 0:
		ac += 1
		wa += a[i] - 1

print(ac,wa)		

Fixed submission:
n,m=map(int,input().split())
a=[-1]*n
for i in range(m):
	p,s=input().split()
	p=int(p)-1
	if s=="AC" and a[p]<0:
		a[p] = a[p]*(-1)
	if s=="WA" and a[p]<0:
		a[p] -= 1
ac=0
wa=0
for i in range(n):
	if a[i] > 0:
		ac += 1
		wa += a[i] - 1

print(ac,wa)
Buggy python submission (verdict: Runtime Error):
x=int(input())
ans=x-1
cnt=0
while cnt==0:
	cnt=1
	ans+=1
	for i in range(2,ans):
		if ans%i==0:
			cnt=0
            break
print(ans)

Fixed submission:
x=int(input())
ans=x-1
cnt=0
while cnt==0:
	cnt=1
	ans+=1
	for i in range(2,ans):
		if ans%i==0:
			cnt=0
print(ans)
Buggy python submission (verdict: Runtime Error):
from math import gcd

def lcm(x,y):
	return (x*y)//gcd(x,y)
	
a,b=map(int,input().split())

print(lcm(a,b))

Fixed submission:
from fractions import gcd

def lcm(x,y):
	return (x*y)//gcd(x,y)
	
a,b=map(int,input().split())

print(lcm(a,b))
Buggy python submission (verdict: Time Limit Exceeded):
def prime_factorize(n):
	a=[]

	while n%2 == 0:
		a.append(2)
		n//=2
	f=3


	while f*f<=n:
		if n%f==0:
			a.append(f)
			n//=f
		else:
			f+=2
	if n!=1:
		a.append(n)
	return a
	
n=int(input())
A=prime_factorize(n)
l=len(A)

res=10**13
for i in range(2**l):
	cnt=1
	for j in range(l):
		if (i>>j)&1:
			cnt *= A[j]
	cnt = n//cnt + cnt
	res=min(cnt,res)
print(res-2)

Fixed submission:
from math import sqrt
n=int(input())
ans=n+1
for i in range(1,int(sqrt(n))+1):
	if n%i==0:
		ans = i+n//i
print(ans-2)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split())

res=0

for i in h:
	if i>=k:
       res = res + 1
       
print(res)

Fixed submission:
n, k = map(int,input().split())
h = list(map(int,input().split()))

res = 0
 
for i in h:
	if i >= k:
		res = res + 1
print(res)
Buggy python submission (verdict: Runtime Error):
s = input()
 
for i in range(len(s))
	if i%2==0 and s[i]=='R':
    	print('No')
    	exit()
    elif i%2==1 and s[i]=='L':
    	print('No')
    	exit()
 
print('Yes')

Fixed submission:
s = input()
 
for i in range(len(s)):
	if i%2==1 and s[i]=='R':
		print('No')
		exit()
	elif i%2==0 and s[i]=='L':
		print('No')
		exit()
 
print('Yes')

Buggy python submission (verdict: Runtime Error):
s = input()
 
for i in range(len(s))
	if i%2==0 and s(i)=='R':
    print('No')
    exit()
    elif i%2==1 and s(i)=='L':
    print('No')
    exit()

print('Yes')

Fixed submission:
s = input()
 
for i in range(len(s)):
	if i%2==1 and s[i]=='R':
		print('No')
		exit()
	elif i%2==0 and s[i]=='L':
		print('No')
		exit()
 
print('Yes')

Buggy python submission (verdict: Runtime Error):
s = input()

for i in range(len(s))
	if i%2==0 and s(i)=='R':
    print('No')
    exit
    elif i%2==1 and s(i)=='L':
    print('No')
    exit
print('Yes')

Fixed submission:
s = input()
 
for i in range(len(s)):
	if i%2==1 and s[i]=='R':
		print('No')
		exit()
	elif i%2==0 and s[i]=='L':
		print('No')
		exit()
 
print('Yes')
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

res=0
back=0

for a in A:
	res=res+B[a-1]					#listは０スタート
	if back==a-1 and a!=len(A):		#A内の今考えている変数が前のと同じなら
		res=res+C[back-1]			#listは０スタート
	back=a
    
print(res)

Fixed submission:
n=int(input())
print(n**3)
Buggy python submission (verdict: Runtime Error):
import math

a, b = map(int,input().split())

b = b - a
a = a - 1
print(1+math.ceil(b/a))

Fixed submission:
n=int(input())
H=list(map(int,input().split()))

res=0
cnt=0
for i in range(n-1):
	if H[i]>=H[i+1]:
		cnt += 1
	else:
		cnt = 0
	res=max(res,cnt)
print(res)
Buggy python submission (verdict: Runtime Error):
import collections
n=int(input())
s=collections.Counter(["".join(sorted(input())) for _ in range(n)])
v=list(s.values())
res=0
for u in v:
	if u!=1:
		res += u*(u-1)//2
print(res)

Fixed submission:
a, b = map(int,input().split())
x=a+b
y=a-b
z=a*b
list=[x,y,z]
print(max(list))

Buggy python submission (verdict: Runtime Error):
P=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101]
n=int(input())
A=[1]*n

for i in range(n):
	s=input()
	for j in range(10):
		A[i] *= P[ord(s[j])-97]

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

Fixed submission:
a, b = map(int,input().split())
x=a+b
y=a-b
z=a*b
list=[x,y,z]
print(max(list))

Buggy python submission (verdict: Runtime Error):
a, b = map(int,input().split())
print(max[a+b,a-b,a*b])

Fixed submission:
a, b = map(int,input().split())
x=a+b
y=a-b
z=a*b
list=[x,y,z]
print(max(list))
Buggy python submission (verdict: Time Limit Exceeded):
P=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101]
n=int(input())
A=[1]*n

for i in range(n):
	s=input()
	for j in range(10):
		A[i] *= P[ord(s[j])-97]

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

Fixed submission:
P=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101]
n=int(input())
A=[1]*n

for i in range(n):
	s=input()
	for j in range(10):
		A[i] *= P[ord(s[j])-97]

res=0
A.sort()
cnt=0

for i in range(n-1):
		if A[i]==A[i+1]:
			cnt += 1
		else:
			res += cnt*(cnt+1)//2
			cnt=0
if cnt != 0:
	res += cnt*(cnt+1)//2
print(res)

Buggy python submission (verdict: Runtime Error):
P=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101]
n=int(input())
A=[1]*n

for i in range(n):
	s=input()
	for j in range(10):
		A[i] *= P[ord(s[j])]

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

Fixed submission:
P=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101]
n=int(input())
A=[1]*n

for i in range(n):
	s=input()
	for j in range(10):
		A[i] *= P[ord(s[j])-97]

res=0
A.sort()
cnt=0

for i in range(n-1):
		if A[i]==A[i+1]:
			cnt += 1
		else:
			res += cnt*(cnt+1)//2
			cnt=0
if cnt != 0:
	res += cnt*(cnt+1)//2
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n=int(input())
s=[]
res=0
for i in range(n):
	t=input()
	s.append(Counter(t))
for i in range(n):
	for j in range(i+1,n):
		if s[i]==s[j]:
			res += 1
print(res)

Fixed submission:
P=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101]
n=int(input())
A=[1]*n

for i in range(n):
	s=input()
	for j in range(10):
		A[i] *= P[ord(s[j])-97]

res=0
A.sort()
cnt=0

for i in range(n-1):
		if A[i]==A[i+1]:
			cnt += 1
		else:
			res += cnt*(cnt+1)//2
			cnt=0
if cnt != 0:
	res += cnt*(cnt+1)//2
print(res)
Buggy python submission (verdict: Runtime Error):
N = int(input())
n = len(str(N))

if n==1:
	print(N)
else:
	M = [9,0]*(n//2)			#list[9,0]がn//2個繋がっている
    M.pop()						#pop()でlistの最後尾を削除
    M = map(str,M)				#joinの際には文字列しか使えないのでstrを使用
    M = int(''.join(M))			#join(M)=90909みたいな。それを数字化
    if n%2==0:
		print(M)
	else:
		M = M + N - 10**n + 1
        print(M)

Fixed submission:
N = int(input())
n = len(str(N))
 
if n==1:
	print(N)
else:
	M = [9,0]*(n//2)			#list[9,0]がn//2個繋がっている
	M.pop()						#pop()でlistの最後尾を削除
	M = map(str,M)				#joinの際には文字列しか使えないのでstrを使用
	M = int(''.join(M))			#join(M)=90909みたいな。それを数字化
	if n%2==0:
		print(M)
	else:
		M = M + N - 10**(n-1) + 1
		print(M)
Buggy python submission (verdict: Runtime Error):
s=input()
s=sorted(s)

if s[1]==s[2] and s[3]==s[4] and s[1]!=s[3]:
	print('Yes')
else:
  	print('No')

Fixed submission:
s=input()
s=sorted(s)
 
if s[0]==s[1] and s[2]==s[3] and s[0]!=s[2]:
	print('Yes')
else:
  	print('No')
Buggy python submission (verdict: Runtime Error):
a,p=map(int,input().split())
print((a*3+p)//2

Fixed submission:
a,p=map(int,input().split())
print((a*3+p)//2)
Buggy python submission (verdict: Runtime Error):
A=[int(input()) for _ in range(5)]
k=int(input())

if max(A)-min(A)>k:
	print(":(")
else:
	print("Yay!

Fixed submission:
A=[int(input()) for _ in range(5)]
k=int(input())

if (max(A)-min(A))>k:
	print(":(")
else:
	print("Yay!")

Buggy python submission (verdict: Runtime Error):
from sys import exit

A=[int(input()) for _ in range(5)]
k=int(input())

if max(A)-min(A)>k:
	print(":(")
else:
	print("Yay!

Fixed submission:
A=[int(input()) for _ in range(5)]
k=int(input())

if (max(A)-min(A))>k:
	print(":(")
else:
	print("Yay!")
Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
for i in range(q):
	l,r=map(int,input().split())
	print(s[l-1:r].count("AC"))

Fixed submission:
n,q=map(int,input().split())
s=input()

len=len(s)
L=[0]*len
R=[0]*len
res=s.count("AC")

cnt=0
for i in range(len-1):
	if s[i]=="A" and s[i+1]=="C":
		cnt+=1
	L[i+1]=cnt

cnt=0
for i in range(len-1):
	if s[len-i-1]=="C" and s[len-i-2]=="A":
		cnt+=1
	R[len-i-2]=cnt

for _ in range(q):
	l,r=map(int,input().split())
	print(res-L[l-1]-R[r-1])
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())	!map(int　でinputの中身をint性質にしている
print(b*a//2)					!//はint表示、/はreal表示。多分

Fixed submission:
a,b,c=map(int,input().split())	#map(int　でinputの中身をint性質にしている
print(b*a//2)					#//はint表示、/はreal表示。多分
Buggy python submission (verdict: Runtime Error):
n=int(input()
if n==1:
	print("Hello World")
else:
	a=int(input())
	b=int(input())
	print(a+b)

Fixed submission:
n=int(input())
if n==1:
	print("Hello World")
else:
	a=int(input())
	b=int(input())
	print(a+b)
Buggy python submission (verdict: Runtime Error):
N,T=map(int,input().split())
res=1001

for _ in range(N):
	c,t=map(int,input().split())
	if t<=T:
		res=min(res,c)

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

Fixed submission:
N,T=map(int,input().split())
res=1001

for _ in range(N):
	c,t=map(int,input().split())
	if t<=T:
		res=min(res,c)

if res==1001:
	print("TLE")
else:
	print(res)
Buggy python submission (verdict: Runtime Error):
from sys import exit

n=int(input())
x=[0]*n
y=[0]*n
h=[0]*n

for i in range(n):
	xx,yy,hh=map(int,input().split())
	x[i]=xx
	y[i]=yy
	h[i]=hh
	
hres=0

if n==1:
	print(xx,yy,hh)
	exit()
else:
	for cx in range(101):
		for cy in range(101):
			cnt=0
			h2=h[0]+abs(x[0]-cx)+abs(y[0]-cy)
			for i in range(1,n):
				h1=h[i]+abs(x[i]-cx)+abs(y[i]-cy)
				if h2!=h1:
					cnt=1
			if cnt==0 and h1>hres:
				hres=h1
				xres=cx
				yres=cy
				
print(xres,yres,hres)

Fixed submission:
from sys import exit

def ht(cx,cy,x,y,h):
	return h+abs(x-cx)+abs(y-cy)

n=int(input())			#高々100なのでほとんどが高さ0っていう状況はない
xyh=[0]*n

for i in range(n):
	x,y,h=map(int,input().split())
	xyh[i]=[x,y,h]
xyh.sort(key=lambda x:x[2],reverse=True)			#h=0を選択してしまうことを避ける

for cx in range(101):
	for cy in range(101):
		H=ht(cx,cy,xyh[0][0],xyh[0][1],xyh[0][2])
		for i in range(1,n):
			if max(H-abs(xyh[i][0]-cx)-abs(xyh[i][1]-cy),0)!=xyh[i][2]:			#H=ht(このfor文で選択した座標)にすると、高さ0の場合に合わなくなる
				break
			
		else:			#直前のifが行われなければ、という意味。forの外における
			print(cx,cy,H)
			exit()