Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
p = [int(i) for i in m]
n = input()    
m = n.split()
P = [int(i) for i in m]
n = input()
list = [""]*p[1]
for i, value in enumerate(n):
    list[i%p[1]] =list[i%p[1]] + value
A = 0
for i in list:
    able = [True,True,True]
    for j in i:
        if j == "r":
            if able[2]:
                A = A + P[2]
                able = [True,True,False]
            else:
                able = [True,True,True]
        if j == "s":
            if able[0]:
                A = A + P[0]
                able = [False,True,True]
            else:
                able = [True,True,True]
        if j == "p":
            if able[1]:
                A = A + P[1]
                able = [True,False,True]
            else:
                able = [True,True,True]

print(A)

Fixed submission:
n = input()    
m = n.split()
p = [int(i) for i in m]
n = input()    
m = n.split()
P = [int(i) for i in m]
n = input()
list = [""]*p[1]
for i, value in enumerate(n):
    list[i%p[1]] =list[i%p[1]] + value
A = 0
for i in list:
    able = [True,True,True]
    for j in i:
        if j == "r":
            if able[2]:
                A = A + P[2]
                able = [True,True,False]
            else:
                able = [True,True,True]
        if j == "s":
            if able[0]:
                A = A + P[0]
                able = [False,True,True]
            else:
                able = [True,True,True]
        if j == "p":
            if able[1]:
                A = A + P[1]
                able = [True,False,True]
            else:
                able = [True,True,True]

print(A)
Buggy python submission (verdict: Runtime Error):
import math
n = input()    
m = n.split()
p = [int(i) for i in m]
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(p[0], p[1]))

Fixed submission:
import fractions
n = input()    
m = n.split()
p = [int(i) for i in m]
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

print(lcm(p[0], p[1]))

Buggy python submission (verdict: Runtime Error):
import math
n = input()    
m = n.split()
p = [int(i) for i in m]
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(p[0], p[1]))

Fixed submission:
import fractions
n = input()    
m = n.split()
p = [int(i) for i in m]
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

print(lcm(p[0], p[1]))
Buggy python submission (verdict: Runtime Error):
N = int(input())
n = input()    
m = n.split()
p = [int(i) for i in m]
j = 1
for i in range(N):
    if p[i] == j:
        j = j+1
if j = 1:
    print("-1")
else:
    print(N - j + 1)

Fixed submission:
N = int(input())
n = input()    
m = n.split()
p = [int(i) for i in m]
j = 1
for i in range(N):
    if p[i] == j:
        j = j+1
if j == 1:
    print("-1")
else:
    print(N - j + 1)
Buggy python submission (verdict: Runtime Error):
from collections import deque
n = int(input())
list = []
for i in range(n-1): #因数注意！
    M = input()    
    m = M.split()
    p = [int(i) for i in m] #1列の数列をリスト化
    p = p + [i]
    list.append(p) #list(行列)
color = [0 for i in range(n-1)] #各辺の色
maxcolor = 1
N = deque([[1,0]]) #頂点と使用されている色
delete = deque() #listから探索済みの辺を削除する
while len(list) != 0:
    a = N.popleft()
    b = 0
    for i, value in enumerate(list):
        if value[0] == a[0]:
            b = b + 1
            if b == a[1]:
                b = b + 1
            N.append([value[1],b])
            color[value[2]] = b
            delete.append(i)
            if maxcolor < b:
                maxcolor = b
        elif value[1] == a[0]:
            b = b + 1
            if b == a[1]:
                b = b + 1
            N.append([value[0],b])
            color[value[2]] = b
            delete.append(i)
            if maxcolor < b:
                maxcolor = b
    else:
        c = 0
        while len(delete) != 0:
            c = c + 1
            d = delete.popleft()
            del list[d-c+1]
print(maxcolor)
for i in color:
    print(i)

Fixed submission:
n = input()
if n == "MON":
    print("6")
elif n == "TUE":
    print("5")
elif n == "WED":
    print("4")
elif n == "THU":
    print("3")
elif n == "FRI":
    print("2")
elif n == "SAT":
    print("1")
else:
    print("7")

Buggy python submission (verdict: Runtime Error):
n = input()
if n == "MON":
    print("6")
elif n == "TUE":
    print("5")
elif n == "WEN":
    print("4")
elif n == "THU":
    print("3")
elif n == "FRI":
    print("2")
elif n == "SAT":
    print("1")
else n == "SUN":
    print("7")

Fixed submission:
n = input()
if n == "MON":
    print("6")
elif n == "TUE":
    print("5")
elif n == "WED":
    print("4")
elif n == "THU":
    print("3")
elif n == "FRI":
    print("2")
elif n == "SAT":
    print("1")
else:
    print("7")
Buggy python submission (verdict: Runtime Error):
import numpy
n,y= map(int,input().split())

c=list(range(n+1))
lenC=len(c)
v1=numpy.repeat(c, lenC*lenC)
v2=numpy.repeat(lenC*c, lenC)
v3=numpy.repeat(lenC*lenC*c,1)
v = numpy.array([v1,v2,v3]).reshape(3,len(v1))

comb=v[:,sum(v)==n]
m=numpy.matrix([10000, 5000, 1000])
s = m*comb

if y in s:
	ans=comb[:,numpy.array(s).flatten()==y][:,0]
	print("%d %d %d"%(ans[0],ans[1],ans[2]))
else:
	print("%d %d %d"%(-1,-1,-1))




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

ans=(-1,-1,-1)
m=range(n+1)
for a in m:
	for b in m:
		c=n-a-b
		total = 10000*a + 5000*b + 1000*c
		if (c>=0) & (total==y):
			ans=(a,b,c)
			break
		else:
			continue
		break

print("%d %d %d"%ans)

Buggy python submission (verdict: Runtime Error):
import numpy
n,y= map(int,input().split())

c=list(range(n+1))
lenC=len(c)
v1=numpy.repeat(c, lenC*lenC)
v2=numpy.repeat(lenC*c, lenC)
v3=numpy.repeat(lenC*lenC*c,1)
v = numpy.array([v1,v2,v3]).reshape(3,len(v1))

comb=v[:,sum(v)==n]
m=numpy.matrix([10000, 5000, 1000])
s = m*comb

if y in s:
	ans=comb[:,numpy.array(s).flatten()==y][:,0]
	print("%d %d %d"%(ans[0],ans[1],ans[2]))
else:
	print("%d %d %d"%(-1,-1,-1))



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

ans=(-1,-1,-1)
m=range(n+1)
for a in m:
	for b in m:
		c=n-a-b
		total = 10000*a + 5000*b + 1000*c
		if (c>=0) & (total==y):
			ans=(a,b,c)
			break
		else:
			continue
		break

print("%d %d %d"%ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
li= list(map(int,input().split())) 	
Ans=27
ans=0

for i in range(N):
	if li[i]%2==1:
		Ans=0
		break
	else:
		n=li[i]
		ans=0
		while n%2==0:
			n=n/2
			ans= ans+1
		if Ans>ans:
			Ans =ans

print(Ans)

Fixed submission:
s=list(input())

s1=int(s[0])
s2=int(s[1])
s3=int(s[2])
print(s1+s2+s3)

Buggy python submission (verdict: Runtime Error):
N=int(input())
li= list(map(int,input().split())) 	
ans=1
minNum=10**9

for i in range(N):
	if li[i]%2==1:
		ans=0
		break
	elif li[i] < minNum:
		minNum = li[i]
		
if not ans==0:
	n=minNum
	ans=0	
	while n%2==0:
		n=n/2
		ans= ans+1

print(ans)


Fixed submission:
s=list(input())

s1=int(s[0])
s2=int(s[1])
s3=int(s[2])
print(s1+s2+s3)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
a= list(map(int,input().split())) 	

#a=A
#a=list(range(10))+list(range(5))
unq=[0]*len(a)
unqCt=[0]*len(a)
ans=0
ct2=1
ct3=0
while ct2 > 0:
	ct1=0
	ct2=0
	nokori=[0]*len(a)
	for i in range(len(a)):
		if a[0]==a[i]:
			#ctlist[ct1]= i
			ct1 +=1
			#print(ct1)
		else:
			nokori[ct2]=a[i]
			ct2 +=1
			#print(ct2)
	unq[ct3]=a[0]
	unqCt[ct3]=ct1
	ct3+=1
	a=nokori[:-ct1]

kakikae=ct3-K
if kakikae>0:
	ctmin=1
	while kakikae >0:
		for n in range(len(unqCt)):	
			if unqCt[n]==ctmin:
				ans+=ctmin
				kakikae-=1
				if kakikae==0:
					break
		ctmin+=1		
else:
	ans=0	
		
print(ans)

Fixed submission:
import collections
import numpy

N,K = map(int,input().split())
A= list(map(int,input().split())) 	

A = collections.Counter(A)
C=A.most_common()

if len(C)> K:
	dels=len(C) - K
	delsList=numpy.array(C[-dels:])
	ans=sum(delsList)[1]
else :
	ans=0

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N,K = map(int,input().split())
A= list(map(int,input().split())) 	

unq=np.array(list(set(A)))
A=np.array(A)

ct=np.zeros(unq.size,dtype=int)

for i in range(unq.size):
	ct[i]=sum(unq[i]==A)

if unq.size > K:
	x=unq.size-K
	sort_ct=np.sort(ct)
	ans=sum(sort_ct[list(range(x))])
else :
	ans=0

print(ans)


Fixed submission:
import collections
import numpy

N,K = map(int,input().split())
A= list(map(int,input().split())) 	

A = collections.Counter(A)
C=A.most_common()

if len(C)> K:
	dels=len(C) - K
	delsList=numpy.array(C[-dels:])
	ans=sum(delsList)[1]
else :
	ans=0

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
SP = [list(input().split()) for i in range(N)]

hoge = sorted(SP, key = lambda x:x[1], reverse = True)
SPsort = sorted(hoge, key = lambda x:x[0]

for i in range(N):
    print(SP.index(SPsort[i]) + 1)

Fixed submission:
N = int(input())
SP = [list(input().split()) for i in range(N)]

for row in SP:
    row[1] = int(row[1])

hoge = sorted(SP, key = lambda x:x[1], reverse = True)
SPsort = sorted(hoge, key = lambda x:x[0])

for i in range(N):
    print(SP.index(SPsort[i]) + 1)

Buggy python submission (verdict: Runtime Error):
N = int(input())
SP = [list(input().split()) for i in range(N)]

SPsort = sorted(SP, key = lambda x:x[0])

for i in range(N):
    print(SP.index(SPsort[i])) + 1

Fixed submission:
N = int(input())
SP = [list(input().split()) for i in range(N)]

for row in SP:
    row[1] = int(row[1])

hoge = sorted(SP, key = lambda x:x[1], reverse = True)
SPsort = sorted(hoge, key = lambda x:x[0])

for i in range(N):
    print(SP.index(SPsort[i]) + 1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list = list(map(int, input().split(" ")))
c = 0

for x in range(n):
    for y in range(n):
        if x != y and list[x] == list[y]:
            c += 1

if c == 0:
    print("YES")
else:
    print("NO")

Fixed submission:
n = int(input())
a = len(set(map(int, input().split(" "))))
if n == a:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split(" "))
p = list(map(int, input().split(" ")))
e = []
s = [0]
sj = []

for x in p:
    e.append((1 + x) / 2)

for x in range(n):
    s.append(sum(e[:x + 1]))

for x in range(k, n + 1):
    sj.append(s[x] - s[x - k])
    
print(max(sj))


Fixed submission:
n, k = map(int, input().split(" "))
p = list(map(int, input().split(" ")))
e = []
s = [0]
sj = []

for x in p:
    e.append((1 + x) / 2)

for x in range(n):
    s.append(s[x] + e[x])

for x in range(k, n + 1):
    sj.append(s[x] - s[x - k])
    
print(max(sj))

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split(" "))
p = list(map(int, input().split(" ")))
p2 = []

for x in range(n - k + 1):
    c = 0
    for y in range(k):
        c += p[x + y]
    p2.append(c)

a = max(p2)

print((a + k)/2)


Fixed submission:
n, k = map(int, input().split(" "))
p = list(map(int, input().split(" ")))
e = []
s = [0]
sj = []

for x in p:
    e.append((1 + x) / 2)

for x in range(n):
    s.append(s[x] + e[x])

for x in range(k, n + 1):
    sj.append(s[x] - s[x - k])
    
print(max(sj))

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split(" "))
p = list(map(int, input().split(" ")))
max = 0
d = 0
e = 0

for x in range(n - k + 1):
    c = 0
    for y in range(k):
            c += p[x + y]
    if c > max:
        max = c
        d = x

for x in range(k):
    e += (p[d + x] + 1) / 2

print(e)


Fixed submission:
n, k = map(int, input().split(" "))
p = list(map(int, input().split(" ")))
e = []
s = [0]
sj = []

for x in p:
    e.append((1 + x) / 2)

for x in range(n):
    s.append(s[x] + e[x])

for x in range(k, n + 1):
    sj.append(s[x] - s[x - k])
    
print(max(sj))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
k = int(input())
c = 0

for x in range(n + 1):
    l = list(str(x))
    if len(l) - l.count("0") == k:
        c += 1

print(c)


Fixed submission:
N = input()
K = int(input())
m = len(N)

dp = [[[0] * (K + 1) for _ in range(2)] for _ in range(m + 1)]
dp [0][0][0] = 1

for i in range(1, m + 1):
    l = int(N[i - 1])
    for k in range(K + 1):
        dp[i][1][k] += dp[i - 1][1][k]
        if l != 0:
            dp[i][1][k] += dp[i - 1][0][k]
        else:
            dp[i][0][k] += dp[i - 1][0][k]
        if k - 1 >= 0:
            dp[i][1][k] += 9 * dp[i -1][1][k - 1]
            if l != 0:
                dp[i][0][k] += dp[i - 1][0][k - 1]
                dp[i][1][k] += (l - 1) * dp[i - 1][0][k -1]


print(dp[m][0][K] + dp[m][1][K])
Buggy python submission (verdict: Runtime Error):
n = int(input())
c = set([])
for i in range(1,10):
  for j in range (1,10):
    c.add(i * j)
print("Yes") if n in c else print("No")
    

Fixed submission:
n = [int(i) for i in input().split(" ")]
if max(n) < 10:
  print(n[0] * n[1])
else:
  print(-1)
Buggy python submission (verdict: Runtime Error):
num = input().split(" ")
a = int(num[0])
b = int(num[1])
return max(a+b, a-b, a*b)

Fixed submission:
num = input().split(" ")
a = int(num[0])
b = int(num[1])
print(max(a+b, a-b, a*b))
Buggy python submission (verdict: Time Limit Exceeded):
num = int(input())
words = ["".join(sorted(input())) for i in range(num)]
words_oc = set(words)
res = 0
for i in words_oc:
    c = 0
    for j in words:
        if i == j:
            c += 1
    res += (c**2 - c)//2
print(res)

Fixed submission:
from collections import Counter

num = int(input())
words = ["".join(sorted(input())) for i in range(num)]
x = Counter(words)
res = 0
for c in x.values():
    res += (c**2 - c)//2
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
num = int(input())
words = ["".join(sorted(input())) for i in range(num)]
c = 0
for i in range(len(words)-1):
    for j in range(i+1, len(words)):
        if words[i] == words[j]:
            c += 1
print(c)

Fixed submission:
from collections import Counter

num = int(input())
words = ["".join(sorted(input())) for i in range(num)]
x = Counter(words)
res = 0
for c in x.values():
    res += (c**2 - c)//2
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
num = int(input())
words = ["".join(sorted(input())) for i in range(num)]
c = 0
for i in range(len(words)-1):
    for j in range(i+1, len(words)):
        if words[i] == words[j]:
            c += 1
print(c)

Fixed submission:
from collections import Counter

num = int(input())
words = ["".join(sorted(input())) for i in range(num)]
x = Counter(words)
res = 0
for c in x.values():
    res += (c**2 - c)//2
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

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

N = NLinput[0]
L = NLinput[1]

S_list = []
for i in range(N):
    temp = input()
    S_list.append(temp)

perm = list(itertools.permutations(range(N)))
result = []
for i in perm:
    str_temp = ''
    for j in i:
        str_temp += S_list[j]
    result.append(str_temp)
result = sorted(result)
print(result[0])

Fixed submission:
import itertools

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

N = NLinput[0]
L = NLinput[1]

S_list = []
for i in range(N):
    temp = input()
    S_list.append(temp)

S_list = sorted(S_list)
str_temp = ''
for i in S_list:
    str_temp += i
print(str_temp)
Buggy python submission (verdict: Runtime Error):
from collections import Counter

s=input()
s=Couter(s)

for i in s.values():
    if i%2!=0:
        print("No")
        break
else:
    print("Yes")

Fixed submission:
w= input()
w_set =set(w)

for i in w_set:
    if w.count(i)%2==1:
        print("No")
        exit()
print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
arr=list(map(int,input().split()))
for i in arr:
	if arr.count(i)>1:
		print("NO")
		break
else:
	print("YES")

Fixed submission:
n=int(input())
arr=set(map(int,input().split()))
print("YES" if n==len(arr) else "NO")

Buggy python submission (verdict: Runtime Error):
n=int(input())
arr=set(map(int,input().split())
print("YES" if n==len(arr) else "NO")

Fixed submission:
n=int(input())
arr=set(map(int,input().split()))
print("YES" if n==len(arr) else "NO")
Buggy python submission (verdict: Runtime Error):
N = int(input())
A_list = list(map(int, input().split()))

ans_list = []
for i in range(1, N + 1):
    ans_list.append(A_list.index(i) + 1)
    
print(' '.join([str(n) for n in ans_list]))


Fixed submission:
N, K = map(int, input().split())
h_list = [int(i) for i in input().split()]

count = 0
for i in h_list:
    if i >= K:
        count += 1
    else:
        pass

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A_list = list(map(int, input().split()))

ans_list = []
for i in range(1, N + 1):
    ans_list.append(A_list.index(i) + 1)
    
print(' '.join([str(n) for n in ans_list]))


Fixed submission:
N = int(input())
index_list = [int(i) - 1 for i in input().split()]
ans_list = [0] * N

num_list = [i + 1 for i in range(N)]
for i in range(N):
    ans_list[index_list[i]] = num_list[i]

print(*ans_list)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A_list = list(map(int, input().split()))

ans_list = []
for i in range(1, N + 1):
    ans_list.append(str(A_list.index(i) + 1))

ans = ' '.join(ans_list)
print(ans)


Fixed submission:
N = int(input())
index_list = [int(i) - 1 for i in input().split()]
ans_list = [0] * N

num_list = [i + 1 for i in range(N)]
for i in range(N):
    ans_list[index_list[i]] = num_list[i]

print(*ans_list)
Buggy python submission (verdict: Runtime Error):
S = input()

length = len(S)
for i in range(length):
    if (i + 1) % 2 == 0:
        global evenN
        if S[i] == 'R':
            evenN = False
        else:
            evenN = True
    if (i + 1) % 2 == 1:
        global oddN
        if S[i] == 'L':
            oddN = False
        else:
            oddN = True


if oddN is True and evenN is True:
    print('Yes')
else:
    print('No')


Fixed submission:
S = input()

length = len(S)
evenN = []
oddN = []
for i in range(length):
    if (i + 1) % 2 == 0:
        if S[i] == 'R':
            evenN.append(False)
        else:
            evenN.append(True)
    if (i + 1) % 2 == 1:
        if S[i] == 'L':
            oddN.append(False)
        else:
            oddN.append(True)


if all(oddN) is True and all(evenN) is True:
    print('Yes')
else:
    print('No')

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

l = len(S)
for i in range(l):
    if (i + 1) % 2 == 0:
        if S[i] == 'R':
            even = False
        else:
            even = True
    if (i + 1) % 2 == 1:
        if S[i] == 'L':
            odd = False
        else:
            odd = True


if odd == True and even == True:
    print('Yes')
else:
    print('No')


Fixed submission:
S = input()

length = len(S)
evenN = []
oddN = []
for i in range(length):
    if (i + 1) % 2 == 0:
        if S[i] == 'R':
            evenN.append(False)
        else:
            evenN.append(True)
    if (i + 1) % 2 == 1:
        if S[i] == 'L':
            oddN.append(False)
        else:
            oddN.append(True)


if all(oddN) is True and all(evenN) is True:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
h_list = list(map(int, input().split()))

count_list = []
count = 0
for i in range(N-1):
    if h_list[i] >= h_list[i+1]:
        count += 1
        count_list.append(count)
    else:
        count = 0
        count_list.append(0)
    
print(max(count_list))


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

count_list = []
if len(h_list) == 1:
    count_list.append(0)
else:
    count = 0
    for i in range(N-1):
        if h_list[i] >= h_list[i+1]:
            count += 1
            count_list.append(count)
        else:
            count = 0
            count_list.append(0)
    
print(max(count_list))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s_list=[input() for i in range(n)]

#出現するアルファベットをカウントしていく
al_list=[chr(ord('a') + i) for i in range(26)]

num_list = []
for _s in s_list:
    num = ''
    for _al in al_list:
        num += str(_s.count(_al))
    num_list.append(num)

count_list = []
for _num in num_list:
    count = num_list.count(_num)
    if count != 1: #1はカウントしても無駄
        count_list.append(count)

ans = 0
for i in range(1,n+1):
    ans += count_list.count(i) * (i - 1) / 2

print(int(ans))


Fixed submission:
from collections import Counter #ハッシュ法
N = int(input())
s_list = [input() for i in range(N)]

#出現するアルファベットをカウントしていく
al_list = [chr(ord('a') + i) for i in range(26)]

num_list = []
count_by_kw = Counter()
for _s in s_list:
    num = ''
    for _al in al_list:
        num += str(_s.count(_al))
    
    num_list.append(num)

count_list = list(Counter(num_list).values()) 

ans = 0
for i in range(len(count_list)):
    k = count_list[i]
    ans += k * (k - 1) / 2

print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s_list=[input() for i in range(n)]

#出現するアルファベットをカウントしていく
al_list=[chr(ord('a') + i) for i in range(26)]

num_list = []
for _s in s_list:
    num = ''
    for _al in al_list:
        num += str(_s.count(_al))
    num_list.append(num)

count_list = []
for _num in num_list:
    count = num_list.count(_num)
    count_list.append(count)

ans = 0
for i in range(1,n+1):
    ans += count_list.count(i) * (i - 1) / 2

print(int(ans))





Fixed submission:
from collections import Counter #ハッシュ法
N = int(input())
s_list = [input() for i in range(N)]

#出現するアルファベットをカウントしていく
al_list = [chr(ord('a') + i) for i in range(26)]

num_list = []
count_by_kw = Counter()
for _s in s_list:
    num = ''
    for _al in al_list:
        num += str(_s.count(_al))
    
    num_list.append(num)

count_list = list(Counter(num_list).values()) 

ans = 0
for i in range(len(count_list)):
    k = count_list[i]
    ans += k * (k - 1) / 2

print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A_list = [int(input()) for i in range(N)]

for i in range(N):
    compare_list = A_list[0:i] + A_list[i+1:]
    print(max(compare_list))


Fixed submission:
N = int(input())
A_list = [int(input()) for i in range(N)]

sorted_A_list = sorted(A_list)
n1 = sorted_A_list[-1]
n2 = sorted_A_list[-2]

for i in range(N):
    if A_list[i] == n1:
        print(n2)
    else:
        print(n1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
d_list = list(map(int, input().split()))

count = 0
for k in range(min(d_list), max(d_list) + 1):
    ABC = 0
    ARC = 0
    for i in range(N):
        if k > d_list[i]:
            ABC += 1
        else:
            ARC += 1
    if ABC > ARC:
        break
    elif ABC == ARC:
        count += 1
    else:
        pass

print(count)
        

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

k = d_list[int(N/2)]
count = 0
for i in range(N):
    if count == int(N/2):
        print(d_list[int(N/2)] - d_list[int(N/2)-1])
        break
    elif k > d_list[i]:
        count += 1
    else:
        pass
else: # kの候補の右端は必ずd_listの中
    print(0)
Buggy python submission (verdict: Runtime Error):
import math
A, B, C, D = map(int, input().split())

def multiple(X, Y, Z):
    min_z = math.ceil(X / Z)
    max_z = math.floor(Y / Z) 
    z_num = max_z - min_z + 1
    return z_num

num_c = multiple(A, B, C)
num_d = multiple(A, B, D)

lem = int((C * D) / math.gcd(C, D)) 
num_lem = multiple(A, B, lem)

print(B - A + 1 - num_c - num_d + num_lem)


Fixed submission:
A, B, C, D = map(int, input().split())

def multiple(X, Y, Z):
    # 天井関数math.ceilが誤差でおかしくなってるから組み込み関数を使う
    if X % Z != 0:
        min_z = X // Z + 1
    else:
        min_z = X / Z
    max_z = Y // Z
    num_z = max_z - min_z + 1
    return int(num_z)

def gcd(X, Y):
    while Y!= 0:
        X, Y = Y, X % Y
    return X

if C == 1 or D == 1:
    print(0)
else:
    num_c = multiple(A, B, C)
    num_d = multiple(A, B, D)
    lcm = int((C * D) / gcd(C, D)) 
    num_lcm = multiple(A, B, lcm)
    print(B - A + 1 - num_c - num_d + num_lcm)