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

Fixed submission:
n = int(input())
f = []
for i in range(n):
    f.append(list(map(int, input().split())))
p = []
for i in range(n):
    p.append(list(map(int, input().split())))
count = {}
ans = []
for bits in range(1 << 10):
    count = {}
    for i in range(10):
        if (bits >> i & 1) == 1:
            for j in range(n):
                if j not in count: 
                    count[j] = f[j][i]
                else:
                    count[j] += f[j][i]
    if count != {}:
        flag = 0
        for k in range(n):
            if count[k] != 0:
                flag = 1
        if flag:
            check = 0
            for l in range(n):
                check += p[l][count[l]]
            ans.append(check)
print(max(ans))

Buggy submission (verdict: Runtime Error):
n = int(input())
f = []
for i in range(n):
    f.append(list(map(int, input().split())))
p = []
for i in range(n):
    p.append(list(map(int, input().split())))
count = {}
ans = []
for bits in range(1 << 10):
    count = {}
    for i in range(10):
        if (bits >> i & 1) == 1:
            for j in range(n):
                if j not in count: 
                    count[j] = f[j][i]
                else:
                    count[j] += f[j][i]
    if count != {}:
        if count[0] > 0 or count[1] > 0 or count[2] > 0: 
            check = p[0][count[0]] + p[1][count[1]] + p[2][count[2]]
            ans.append(check)
print(max(ans))

Buggy submission (verdict: Runtime Error):
n = int(input())
f = []
for i in range(n):
    f.append(list(map(int, input().split())))
p = []
for i in range(n):
    p.append(list(map(int, input().split())))
count = {}
ans = []
for bits in range(1 << 10):
    count = {}
    for i in range(10):
        if (bits >> i & 1) == 1:
            for j in range(n):
                if j not in count: 
                    count[j] = f[j][i]
                else:
                    count[j] += f[j][i]
    if count != {}:
        if count[0] > 0 and count[1] > 0 and count[2] > 0: 
            check = p[0][count[0]] + p[1][count[1]] + p[2][count[2]]
            ans.append(check)
print(max(ans))
Problem p03545 (python)

Fixed submission:
n = input()

a = int(n[0])
b = int(n[1])
c = int(n[2])
d = int(n[3])

if (a+b+c+d) == 7:
    print(a, "+" ,b, "+" ,c, "+", d, "=7", sep="")
elif (a+b+c-d) == 7:
    print(a, "+" ,b, "+" ,c, "-", d, "=7", sep="")
elif (a+b-c+d) == 7:
    print(a, "+" ,b, "-" ,c, "+", d, "=7", sep="")
elif (a+b-c-d) == 7:
    print(a, "+" ,b, "-" ,c, "-", d, "=7", sep="")
elif (a-b+c+d) == 7:
    print(a, "-" ,b, "+" ,c, "+", d, "=7", sep="")
elif (a-b+c-d) == 7:
    print(a, "-" ,b, "+" ,c, "-", d, "=7", sep="")
elif (a-b-c+d) == 7:
    print(a, "-" ,b, "-" ,c, "+", d, "=7", sep="")
elif (a-b-c-d) == 7:
    print(a, "-" ,b, "-" ,c, "-", d, "=7", sep="")

Buggy submission (verdict: Runtime Error):
abcd = str(input())
n = 3
x1 = '+'
x2 = '+'
x3 = '+'
for bits in range(1 << n):
    for i in range(n):
        if (bits >> i & 1) == 1:
            if i == 0:
                x1 = '-'
            if i == 1:
                x2 = '-'
            if i == 2:
                x3 = '-'
    check1 = abcd[0] + x1 + abcd[1] + x2 + abcd[2] + x3 + abcd[3]
    check2 = eval(abcd[0] + x1 + abcd[1] + x2 + abcd[2] + x3 + abcd[3])
    if check2 == 7:
        ans = check1
print(ans+'=7')

Buggy submission (verdict: Runtime Error):
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "8 5\n"
     ]
    }
   ],
   "source": [
    "n,k = map(int,input().split())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "-9 -7 -4 -3 1 2 3 4\n"
     ]
    }
   ],
   "source": [
    "x = list(map(int,input().split()))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n"
     ]
    }
   ],
   "source": [
    "ans = []\n",
    "for i in range(n):\n",
    "    if (i + k -1) >= n:\n",
    "        break\n",
    "    x1 = x[i]\n",
    "    x2 = x[i+k-1]\n",
    "    ans1 = abs(x2) + abs(x2-x1)\n",
    "    ans2 = abs(x1) + abs(x1-x2)\n",
    "    ans.append(ans1)\n",
    "    ans.append(ans2)\n",
    "print(min(ans))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
Problem p03557 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a = sorted(a)
b = sorted(b)
c = sorted(c)

import bisect
count = 0
for i in b:
    a_count = bisect.bisect_left(a, i)
    c_count = n - bisect.bisect_right(c, i)
    count += a_count * c_count
    
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split
     
a.sort()
b.sort()
c.sort()
     
     
from bisect import bisect_left,bisect_right
ans = 0
for i in b:
    count_a = bisect_right(a,i)
    count_c = n - bisect_right(c,i)
    ans += count_a * count_c
print(ans)
Problem p03607 (python)

Fixed submission:
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
    
check = {}
for i in set(a):
    check[i] = 0
for i in a:
    check[i] += 1
    
count = 0
for i in check.items():
    if i[1] % 2 != 0:
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
    
check = [0 for i in range(10**5 + 1)]
for i in a:
    check[i] += 1
count = 0
for i in check:
    if i % 2 != 0:
        count += 1
print(count)
Problem p03612 (python)

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

ans = 0
for i,p in enumerate(P):
    if p == i+1:
        if i + 1 < N:
#             print('i+1,p',i+1,p)
            tmp0 = P[i+1]
            P[i] = tmp0
            P[i+1] = p
            ans += 1
#             print('P',P)
        else:
            ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
P = [int(i) for i in input().split()]

ans = 0
for i,p in enumerate(P):
    if p == i+1:
#         print('i+1,p',i+1,p)
        tmp0 = P[i+1]
        P[i] = tmp0
        P[i+1] = p
        ans += 1
#         print('P',P)
print(ans)
Problem p03681 (python)

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

import math
if abs (N - M) > 1:
    print(0)
else:
    if (N + M) % 2 == 0:
        print(math.factorial(N) * math.factorial(M) * 2 % (10 ** 9 + 7))
    else:
        print(math.factorial(N) * math.factorial(M) % (10 ** 9 + 7))

Buggy submission (verdict: Runtime Error):
X,A,B = map(int, input().split())

if A + X < B:
    print("dengerous")
if A <= B <= A + X:
    print("safe")
if B < A:
    print("delicious")
Problem p03797 (python)

Fixed submission:
N, M = map(int, input().split())
ans1 = 0
import math
if N <= M:
    ans1 = 0
    if 2 * N <= M:
        ans1 = N
        M -= ans1 * 2
        ans2 = math.floor(M / 4)
        print(int(ans1 + ans2))
    else:
        ans1 = math.floor(M / 2)
        print(ans1)
else:
    print(int(math.floor(M / 2)))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
if 2 * N <= M:
    ans1 = N
    M -= ans1 * 2
# print(ans1)
# print(M)

ans2 = M // 4
# print(ans2)

print(ans1 + ans2)
Problem p03828 (python)

Fixed submission:
N = int(input())
import math
def is_prime(num):
    if num < 2:
        return False
    if num == 2 or num == 3 or num == 5:
        return True
    if num % 2 == 0 or num % 3 == 0 or num % 5 == 0:
        return False

    # 疑似素数(2でも3でも5でも割り切れない数字)で次々に割っていく
    prime = 7
    step = 4
    num_sqrt = math.sqrt(num)
    while prime <= num_sqrt:
        if num % prime == 0:
            return False
        prime += step
        step = 6 - step

    return True
  
def make_prime_list(num):
    if num < 2:
        return []

    prime_list = []
    for prime in range(2, num + 1):
        if is_prime(prime):
            prime_list.append(prime)
    return prime_list
  
num = N
prime_list = make_prime_list(num)
pcount={}
for p in prime_list:
    pcount[p]=0
for nn in range(2,num+1):
    for p in prime_list:
        n=nn
        if n<p:
            break
        while n%p==0:
            n//=p
            pcount[p]+=1
            
ans = 1
for i in pcount.values():
    ans *= (i + 1)
print(ans % (10 ** 9 + 7))

Buggy submission (verdict: Runtime Error):
N = int(input())
prime_list = make_prime_list(N)
pcount={}
for p in prime_list:
    pcount[p]=0
for nn in range(2,num+1):
    for p in prime_list:
        n=nn
        if n<p:
            break
        while n%p==0:
            n//=p
            pcount[p]+=1
            
ans = 1
for i in pcount.values():
    ans *= (i + 1)
print(ans % (10 ** 9 + 7))
Problem p03854 (python)

Fixed submission:
S = str(input())
while "eraser" in S:     
    S=S.replace("eraser","")
while "erase" in S: 
    S=S.replace("erase","")
while "dreamer" in S: 
    S=S.replace("dreamer","")
while "dream" in S: 
    S=S.replace("dream","")
if len(S) == 0:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
S = str(input())S = str(input())
while "eraser" in S:     
    S=S.replace("eraser","")
while "erase" in S: 
    S=S.replace("erase","")
while "dreamer" in S: 
    S=S.replace("dreamer","")
while "dream" in S: 
    S=S.replace("dream","")
if len(S) == 0:
    print("YES")
else:
    print("NO")
Problem p03944 (python)

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

L1 = []
L2 = []
L3 = []
L4 = []
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        L1.append(x)
    if a == 2:
        L2.append(x)      
    if a == 3:
        L3.append(y)
    if a == 4:
        L4.append(y)
# print(L1, L2, L3, L4)

if L1 != []:
    x_min = max(L1)
else:
    x_min = 0
    
if L2 != []:
    x_max = min(L2)
else:
    x_max = W
    
if L3 != []:
    y_min = max(L3)
else:
    y_min = 0
    
if L4 != []:
    y_max = min(L4)
else:
    y_max = H
# print(x_min, x_max, y_min, y_max)

x_len = max(0, x_max-x_min)
y_len = max(0, y_max-y_min)
print(x_len * y_len)

Buggy submission (verdict: Runtime Error):
W, H, N = map(int, input().split())
L1 = []
L2 = []
L3 = []
L4 = []
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        L1.append(x)
    if a == 2:
        L2.append(x)      
    if a == 3:
        L3.append(y)
    if a == 4:
        L4.append(y)
        
if L1 != []:
    x_min = min(L1)
else:
    x_min = 0
    
if L2 != []:
    x_max = min(L2)
else:
    x_max = W
    
if L3 != []:
    y_min = min(L3)
else:
    y_min = 0
    
if L4 != []:
    y_min = min(L4)
else:
    y_min = H
    
x_len = min(0, x_max-x_min)
y_len = min(0, y_max-y_min)
print(x_len * y_len)
Problem p03577 (python)

Fixed submission:
s = raw_input()

n = len(s)
print(s[0:n - 8])

Buggy submission (verdict: Runtime Error):
s = raw_input()

n = len(s)
print(s[0:n - 8])
Problem p02903 (python)

Fixed submission:
s = input().split(" ")
h = int(s[0])
w = int(s[1])
a = int(s[2])
b = int(s[3])

for i in range(b):
  for j in range(w):
    if j < a:
      print(1,end="")
    else:
      print(0,end="")
  print("")

for i in range(h - b):
  for j in range(w):
    if j < a:
      print(0,end="")
    else:
      print(1,end="")
  print("")

Buggy submission (verdict: Runtime Error):
s = input().split(" ")
h = int(s[0])
w = int(s[1])
a = int(s[2])
b = int(s[3])

for i in range(b):
  for j in range(w):
  	if i < a:
    	print("1")
  	else:
      print("0")
    print("")

for i in range(h - b):
  for j in range(w):
    if i < a:
      print("0")
    else:
      print("1")
    print("")
Problem p02911 (python)

Fixed submission:
sn,sk,sq = input().split(" ")
n = int(sn)
k = int(sk)
q = int(sq)

l = [k for i in range(n)]

m =[0 for i in range(n)]

for i in range(q):
  sa = input()
  s = int(sa)
  m[s-1] += 1

for i in range(n):
  l[i] = l[i] - (q - m[i])
  
  if l[i] > 0:
    print("Yes")
  
  else:
     print("No")

Buggy submission (verdict: Runtime Error):
sn,sk,sq = input().split(" ")
n = int(sn)
k = int(sk)
q = int(sq)

l = [k for i in range(n)]

m =[0 for i in range(n)]

for i in range(q):
  sa = input()
  s = int(sa)
  m[s-1] += 1

for i in range(n):
  l[i] = l[i] - (q - m[i])
  
  if l[i] > 0:
    print("Yes")
  
  else:
Problem p03231 (python)

Fixed submission:
def main():
    n, m = map(int,input().split())
    s = input()
    t = input()

    l = n * m // gcd(n,m)

    nlist = [0 for i in range(n)]
    mlist = [0 for i in range(m)]
    for i in range(n):
        nlist[i] =  i*l//n

    for i in range(m):
        mlist[i] =  i*l//m

    src_set = set(nlist)
    tag_set = set(mlist)
    matched_list = list(src_set.intersection(tag_set))

    for i in matched_list:
        s_index = nlist.index(i)
        t_index = mlist.index(i)

        if s[s_index] != t[t_index]:
            print("-1")
            exit()

    print(l)

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

if __name__ == "__main__":
        main()

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

def main():
    n, m = map(int,input().split())
    s = input()
    t = input()

    l = n * m // math.gcd(n,m)

    nlist = [0 for i in range(n)]
    mlist = [0 for i in range(m)]
    for i in range(n):
        nlist[i] =  i*l//n

    for i in range(m):
        mlist[i] =  i*l//m

    src_set = set(nlist)
    tag_set = set(mlist)
    matched_list = list(src_set.intersection(tag_set))

    for i in matched_list:
        s_index = nlist.index(i)
        t_index = mlist.index(i)

        if s[s_index] != t[t_index]:
            print("-1")
            exit()

    print(l)


if __name__ == "__main__":
        main()

Buggy submission (verdict: Runtime Error):
import math

def main():
    n, m = map(int,input().split())
    s = input()
    t = input()

    l = n * m // math.gcd(n,m)

    nlist = [0 for i in range(n)]
    mlist = [0 for i in range(m)]
    for i in range(n):
        nlist[i] =  i*l//n

    for i in range(m):
        mlist[i] =  i*l//m

    src_set = set(nlist)
    tag_set = set(mlist)
    matched_list = list(src_set.intersection(tag_set))

    for i in matched_list:
        s_index = nlist.index(i)
        t_index = mlist.index(i)

        if s[s_index] != t[t_index]:
            print("-1")
            exit()

    print(l)




if __name__ == "__main__":
        main()
Problem p03361 (python)

Fixed submission:
def main():
    h, w = input().split()
    h = int(h)
    w = int(w)

    lst =[]
    for i in range(h):
        tmp = input()
        lst.append(list(tmp))

    flag = False

    for i in range(len(lst)):
        if flag:
            break

        for j in range(len(lst[i])):
            if lst[i][j] == "#":
                if j != w - 1:
                    if lst[i][j+1] == "#":
                        continue

                if j != 0:
                    if lst[i][j-1] == '#':
                        continue

                if i != 0:
                    if lst[i-1][j] == '#':
                        continue

                if i != h -1:
                    if lst[i+1][j] == '#':
                        continue

                print("No")
                flag = True
                break

    if flag == False:
        print("Yes")

if __name__ == "__main__":
        main()

Buggy submission (verdict: Runtime Error):
def main():
    h, w = input().split()
    h = int(h)
    w = int(w)

    lst =[]
    for i in range(h):
        tmp = input()
        lst.append(list(tmp))

    flag = False

    for i in range(len(lst)):
        if flag:
            break

        for j in range(i):
            if lst[i][j] == "#":
                if j != w - 1:
                    if lst[i][j+1] == "#":
                        continue

                if j != 0:
                    if lst[i][j-1] == '#':
                        continue

                if i != 0:
                    if lst[i-1][j] == '#':
                        continue

                if i != h -1:
                    if lst[i+1][j] == '#':
                        continue

                print("No")
                flag = True
                break

    if flag == False:
        print("Yes")

if __name__ == "__main__":
        main()

Buggy submission (verdict: Runtime Error):
def main():
    h, w = input().split()
    h = int(h)
    w = int(w)

    lst =[]
    for i in range(h):
        tmp = input()
        lst.append(list(tmp))

    flag = False

    for i in range(len(lst)):
        if flag:
            break

        for j in range(i):
            if lst[i][j] == "#":
                if j != w - 1:
                    if lst[i][j+1] == "#":
                        continue

                if j != 0:
                    if lst[i][j-1] == '#':
                        continue

                if i != 0:
                    if lst[i-1][j] == '#':
                        continue

                if i != h -1:
                    if lst[i+1][j] == '#':
                        continue

                print("No")
                flag = True
                break

    if flag == False:
        print("Yes")

if __name__ == "__main__":
        main()
Problem p03438 (python)

Fixed submission:

def main():
    n = int(input())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))


    Flag = False
    biga = 0
    lessa = 0
    for i in range(n):
        if a[i] > b[i]:
            biga += a[i] - b[i]
        else:
            lessa += (b[i] - a[i]) //2

    tmp = lessa - biga

    if tmp >= 0:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
    def main():
        n = int(input())
        a = list(map(int,input().split()))
        b = list(map(int,input().split()))
     
     
        Flag = False
        biga = 0
        lessa = 0
        for i in range(3):
            if a[i] > b[i]:
                biga += a[i] - b[i]
            else:
     
                lessa += b[i] - a[i]
     
        tmp = lessa -(biga*2)
     
        if tmp >=0:
            print("Yes")
        else:
            print("No")
     
    if __name__ == "__main__":
        main()
Problem p03611 (python)

Fixed submission:

def main():
    n = int(input())
    a = list(map(int,input().split()))

    #lst = [0 for i in range(n*3)]
    ans_lst = [0 for i in range(max(a)+4)]
    """
    for i in range(n):
        lst[3*i] = a[i]
        lst[3*i+1] = a[i]+1
        lst[3*i+2] = a[i]+2
    """

    for i in a:
        ans_lst[i] += 1
        ans_lst[i+1] += 1
        ans_lst[i-1] += 1

    """
    ans = -1
    for i in set(lst):
        ans = max(lst.count(i),ans)
    """

    print(max(ans_lst))


if __name__ == "__main__":
        main()

Buggy submission (verdict: Runtime Error):
    def main():
        n = int(input())
        a = list(map(int,input().split()))
     
        ans_lst = [0 for i in range(max(a)+4)]
     
     
        for i in a:
            ans_lst[i] += 1
            ans_lst[i+1] += 1
            ans_lst[i-1] += 1
     
     
        print(max(ans_lst))
     
     
     
    if __name__ == "__main__":
            main()
Problem p03816 (python)

Fixed submission:
import sys

def main():
    n = input()
    a = input().split()
    n = int(n)
    a = list(map(int, a))


    lst = [0]* 1000000
    dup = 0
    ans =0

    for i in a:
        lst[i]+=1

    for i in lst:
        if i >0:
            ans+= 1
        if i > 1:
            dup = dup + i - 1

    if dup % 2 == 0:
        print(ans)
    else:
        print(ans-1)

if __name__ == "__main__":
        main()

Buggy submission (verdict: Runtime Error):
import sys

def main():
    n = input()
    a = input().split()
    n = int(n)
    a = list(map(int, a))


    lst = [0]* 20
    dup = 0
    ans =0

    for i in a:
        lst[i]+=1

    for i in lst:
        if i >0:
            ans+= 1
        if i > 1:
            dup = dup + i - 1

    if dup % 2 == 0:
        print(ans)
    else:
        print(ans-1)

if __name__ == "__main__":
        main()
Problem p03605 (python)

Fixed submission:
a =input()
if "9" in a:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a =int(input())
if "9" in a:
  print("Yes")
else:
  print("No")
Problem p03693 (python)

Fixed submission:
i = list(map(int, input().split()))
s=i[1]*10+i[2]
if s%4==0:
  print("YES")
else :
  print("NO")

Buggy submission (verdict: Runtime Error):
r,g,b=input().split()
sum=100*r+10*g+b
if sum%4==0:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
r,g,b=input().split()
sum=100*r+10*g+b
if sum%4==0:
  print("YES")
else:
  print("NO")
Problem p03694 (python)

Fixed submission:
a=int(input())
i =  input().split()
max=int(max(i))
min=int(min(i))
answer=int(max)-int(min)
print(answer)

Buggy submission (verdict: Runtime Error):
a=int(input())
  max=h[0]
  min=h[0]
for i in a:
  h[i]=int(input())
  
  if max<h[i] :
    max=h[i]
  if min>h[i] :
    min=h[i]
answer=max-min
print(answer)
Problem p02947 (python)

Fixed submission:
import copy
import math
import sys

sys.setrecursionlimit(10 ** 7)

N = int(input())
s_list = [input() for i in range(N)]


def split(word):
    return [char for char in word]


normalized_s_list = sorted([''.join(sorted(split(s))) for s in s_list])

uniqued_s_list = sorted(list(set(normalized_s_list)))

j = 0
counter = 0
result = 0
for s in normalized_s_list:
    if s == uniqued_s_list[j]:
        counter += 1
    else:
        result += (1 / 2) * counter * (counter - 1)
        j += 1
        counter = 1  # このとき s と uniqued_s_list[j] は同じはずなので

result += (1 / 2) * counter * (counter - 1)
print(int(result))

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

sys.setrecursionlimit(10 ** 7)

N = int(input())
s_list = [input() for i in range(N)]


def split(word):
    return [char for char in word]


normalized_s_list = sorted([''.join(sorted(split(s))) for s in s_list])

uniqued_s_list = list(set(normalized_s_list))

j = 0
counter = 0
result = 0
for s in normalized_s_list:
    if s == uniqued_s_list[j]:
        counter += 1
    else:
        result += (1 / 2) * counter * (counter - 1)
        j += 1
        counter = 1  # このとき s と uniqued_s_list[j] は同じはずなので

result += (1 / 2) * counter * (counter - 1)
print(int(result))