Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

K, S = map(int, readline().split())

ans = 0
for X in range(0, K + 1):
    for Y in range(0, K + 1):
        for Z  in range(0, K + 1):
            if X + Y + Z == S:
                ans += 1
print(ans)

Fixed submission:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

K, S = map(int, readline().split())

ans = 0
for X in range(0, K + 1):
    for Y in range(0, K + 1):
        Z = S - X - Y
        if 0 <= Z and Z <= K:
            ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

S_int = int(readline())
S_str = str(S_int)

pattern = []
fmt = '0' + str(len(S_str)-1) + 'b'
for i in range(2**(len(S_str)-1)):
    pattern.append(format(i, fmt))

answer = 0
for plus_flags in pattern:
    tmp = []
    tmp_str = S_str[0]
    for i, is_plus in enumerate(plus_flags, start=1):
        if is_plus == "1":
            tmp.append(int(tmp_str))
            tmp_str = ""
        tmp_str += S_str[i]
    if tmp_str:
        tmp.append(int(tmp_str))
    answer += sum(tmp)
print(answer)

Fixed submission:
# arc 061 Many Formulas
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

S = read().rstrip().decode('utf-8')

def F(S):
    total = 0
    for i in range(2 ** (len(S) - 1)):
        operator_list = format(i, 'b').zfill(len(S)) # 最大桁は必ず0
        sum_ = 0
        num = 0
        for j, operator in zip(S, operator_list):
            if operator == "0":
                num = num * 10 + int(j)
            else:
                sum_ += num
                num = int(j)
        sum_ += num

        total += sum_
    return total

ans = F(S)
print(ans)
Buggy python submission (verdict: Runtime Error):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

from collections import Counter

n = ii()
A = iil()

di = Counter(A)
A.sort()

ans = 0
l = []
for item in A:
    if di[item] > 1:
        if l[-1] != item:
            l.append(item)
        continue
    flag = True
    for i in l:
        if item%i == 0:
            flag = False
            break
    if flag:
        l.append(item)
        ans += 1
print(ans)


Fixed submission:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

from collections import Counter

n = ii()
A = iil()
di = Counter(A)
A.sort()

ans = 0
l = set()
for item in A:
    if di[item] > 1:
        if item not in l:
            for i in range(1,1000000//item+1):
                l.add(item*i)
        continue
    if item not in l:
        for i in range(1,1000000//item+1):
            l.add(item*i)
        ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

from collections import Counter

n = ii()
A = iil()

di = Counter(A)
A.sort()

ans = 0
l = []
for item in A:
    flag = True
    for i in l:
        if item%i == 0:
            flag = False
            break
    if flag:
        l.append(item)
        if di[item] == 1:
            ans += 1
print(ans)


Fixed submission:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

from collections import Counter

n = ii()
A = iil()
di = Counter(A)
A.sort()

ans = 0
l = set()
for item in A:
    if di[item] > 1:
        if item not in l:
            for i in range(1,1000000//item+1):
                l.add(item*i)
        continue
    if item not in l:
        for i in range(1,1000000//item+1):
            l.add(item*i)
        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

n,k = iim()
A = iil()
'''
A = [0]*200000
上記でtryしても41回で全て明るさ200000になる
'''

def imos(l):
    n = len(l)
    tmp = [0]*n
    for i,item in enumerate(l):
        l = max(0,i-item)
        r = min(n-1,i+item)
        tmp[l] += 1
        if r+1 < n:
            tmp[r+1] -= 1
    for i in range(1,n):
        tmp[i] += tmp[i-1]
    return tmp

for _ in range(min(k,50)):
    A = imos(A)
#    print(_,min(A))

print(*A)

Fixed submission:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

n,k = iim()
A = iil()
'''
A = [0]*200000
上記でtryしても41回で全て明るさ200000になる
'''

def imos(l):
    n = len(l)
    tmp = [0]*n
    for i,item in enumerate(l):
        l = max(0,i-item)
        r = min(n-1,i+item)
        tmp[l] += 1
        if r+1 < n:
            tmp[r+1] -= 1
    for i in range(1,n):
        tmp[i] += tmp[i-1]
    return tmp

for _ in range(min(k,100)):
    A = imos(A)
#    print(_,min(A))

print(*A)

Buggy python submission (verdict: Time Limit Exceeded):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

n,k = iim()
A = iil()
'''
A = [0]*200000
上記でtryしても41回で全て明るさ200000になる
'''

def imos(l):
    n = len(l)
    tmp = [0]*n
    for i,item in enumerate(l):
        l = max(0,i-item)
        r = min(n-1,i+item)
        tmp[l] += 1
        if r+1 < n:
            tmp[r+1] -= 1
    for i in range(1,n):
        tmp[i] += tmp[i-1]
    return tmp

for _ in range(min(k,100)):
    A = imos(A)
#    print(_,min(A))

print(*A)

Fixed submission:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

n,k = iim()
A = iil()
'''
A = [0]*200000
上記でtryしても41回で全て明るさ200000になる
'''

def imos(l):
    n = len(l)
    tmp = [0]*n
    for i,item in enumerate(l):
        l = max(0,i-item)
        r = min(n-1,i+item)
        tmp[l] += 1
        if r+1 < n:
            tmp[r+1] -= 1
    for i in range(1,n):
        tmp[i] += tmp[i-1]
    return tmp

for _ in range(min(k,100)):
    A = imos(A)
#    print(_,min(A))

print(*A)
Buggy python submission (verdict: Runtime Error):
a,b,c,k=map(int,input().split())
l=[1]*a+[0]*b+[-1]*c
print(sum(l[:k]))

Fixed submission:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

a,b,c,k = iim()
if k < a:
    print(k)
elif k <= a+b:
    print(a)
else:
    print(a+(k-a-b)*(-1))
Buggy python submission (verdict: Runtime Error):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

x = ii()
l = [0]
i = 0
num = 0
while num < 10**10:
    i += 1
    num = i**5
    l.append(num)
l = set(l)
for item in l:
    if x - item in l or item - x in l:
        print(int(item**0.2),int((x-item)**0.2))
        exit()

Fixed submission:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

x = ii()
l = [0]
i = 0
num = 0
while num < 10**15:
    i += 1
    num = i**5
    l.append(num)
#print(l[-1]-l[-2])
l = set(l)
for item in l:
    if item > x:
        if item - x in l:
            print(int(item**0.2),int((item-x)**0.2))
            exit()
    else:
        if x - item in l:
            print(int(item**0.2),int((x-item)**0.2)*(-1))
            exit()

'''
    if x - item in l:#Aがitemでx-itemは-B**5
        print(int(item**0.2),int(abs(item-x)**0.2)*(-1))
        exit()
    elif item - x in l:#Aがitemでx-itemはB**5
#        print(item,item-x)
        print(int(item**0.2),int(abs(item-x)**0.2)*(-1))
        exit()
'''
Buggy python submission (verdict: Runtime Error):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
import itertools
n,m,q = iim()

A = list(itertools.combinations_with_replacement([1,2,3,4,5,6,7,8,9,10],m))
ans = 0
l = []
for i in range(q):
    l.append(iil())

for i in A:
    sc = 0
    for j in l:
        if i[j[1]-1] - i[j[0]-1] == j[2]:
            sc += j[3]
    ans = max(ans,sc)
print(ans)

Fixed submission:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
import itertools
n,m,q = iim()

ans = 0
l = []
for i in range(q):
    l.append(iil())

for i in itertools.combinations_with_replacement(list(range(1,m+1)),n):
    sc = 0
    for j in l:
        if i[j[1]-1] - i[j[0]-1] == j[2]:
            sc += j[3]
    ans = max(ans,sc)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
s = list(input())
baf = [i for i, x in enumerate(s) if x == 'B']
raf = [i for i, x in enumerate(s) if x == 'R']
gaf = [i for i, x in enumerate(s) if x == 'G']
bbf = []
rbf = []
gbf = []
ans = 0
for i,item in enumerate(s):
    if item == 'B':
        baf.remove(i)
        bbf.append(i)
        for j in rbf:
            if 2*i-j in gaf:
                ans += len(gaf)-1
            else:
                ans += len(gaf)
        for j in gbf:
            if 2*i-j in raf:
                ans += len(raf)-1
            else:
                ans += len(raf)
    elif item == 'R':
        raf.remove(i)
        rbf.append(i)
        for j in gbf:
            if 2*i-j in baf:
                ans += len(baf)-1
            else:
                ans += len(baf)
        for j in bbf:
            if 2*i-j in gaf:
                ans += len(gaf)-1
            else:
                ans += len(gaf)
    else:
        gaf.remove(i)
        gbf.append(i)
        for j in rbf:
            if 2*i-j in baf:
                ans += len(baf)-1
            else:
                ans += len(baf)
        for j in bbf:
            if 2*i-j in raf:
                ans += len(raf)-1
            else:
                ans += len(raf)

print(ans)


Fixed submission:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
s = list(input())
baf = s.count('B')
raf = s.count('R')
gaf = s.count('G')
bbf = 0
rbf = 0
gbf = 0
ans = 0
for i,item in enumerate(s):
    if item == 'B':
        baf -= 1
        bbf += 1
        ans += rbf*gaf
        ans += raf*gbf
    elif item == 'R':
        raf -= 1
        rbf += 1
        ans += bbf*gaf
        ans += baf*gbf
    else:
        gaf -= 1
        gbf += 1
        ans += rbf*baf
        ans += raf*bbf
cnt = 0
for i in range(n):
    num = min(i,n-1-i)
    for j in range(1,num+1):
        if s[i-j] != s[i+j] and s[i-j] != s[i] and s[i+j] != s[i]:
            cnt += 1
print(ans-cnt)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = int(input())
query = [0]*n
for i in range(n):
    query[i] = list(map(str, input().split()))
#    print(query[i])

for i in range(n):
    if int(query[i][0]) == 1:
        s = s[::-1]
    else:
        if int(query[i][1]) == 1:
            s = query[i][2] + s
        else:
            s = s + query[i][2]
#    print(s)
print(s)

Fixed submission:
s = input()
n = int(input())
query = [0]*n
rev = 0
for i in range(n):
    query[i] = list(map(str, input().split()))
    if query[i][0] == '1':
        rev = rev + 1

begin = ''
end = ''
pal = 0

for i in range(n):
    if int(query[i][0]) == 1:
        pal = (pal+1)%2
    else:
        if pal == 0:
            if int(query[i][1]) == 1:
                begin = query[i][2] + begin 
            else:
                end = end + query[i][2]
        else:
            if int(query[i][1]) == 1:
                end = end + query[i][2] 
            else:
                begin = query[i][2] + begin
#    print('--------'+str(i+1)+'th try-----')
#    print('begin:'+begin)
#    print('end:'+end)
#    print('pal:'+str(pal))
if rev%2 == 1:
    print(end[::-1]+s[::-1]+begin[::-1])
else:
    print(begin+s+end)
Buggy python submission (verdict: Runtime Error):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,m = iim()
l = [-1]*n
flag = True
for i in range(m):
    s,c = iim()
    if l[s-1] != -1 and l[s-1] != c:
        flag = False
    else:
        l[s-1] = c

if n > 1 and l[0] == 0:
    flag = False

ans = ''
for i,item in enumerate(l):
    if item == -1:
        if i == 0 and n > 1:
            ans += '1'
        else:
            ans += '0'
    else:
        ans += str(item)
print(ans if flag else -1)


Fixed submission:
n = int(input())
print(n//2+n%2)
Buggy python submission (verdict: Time Limit Exceeded):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
count = {}
c = 0
for i in range(n):
    s = input()
    count[s] = count.get(s,0)+1
ans = sorted([kv[0] for kv in count.items() if kv[1] == max(count.values())])
for item in ans:
    print(item)

Fixed submission:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
count = {}
cmax = 0
for i in range(n):
    s = input()
    c = count.get(s,0)+1
    cmax = max(c,cmax)
    count[s] = c
ans = sorted([kv[0] for kv in count.items() if kv[1] == cmax])
for item in ans:
    print(item)
Buggy python submission (verdict: Runtime Error):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
s,t=iim()
a,b=iim()
u=ii()

if u == s:
    print(a-1,b)
else:
    print(a,b-1)

Fixed submission:
def ii():return int(input())
def iim():return map(int,input().split())
def ism():return map(str,input().split())
def iil():return list(map(int,input().split()))
s,t=ism()
a,b=iim()
u=input()

if u == s:
    print(a-1,b)
else:
    print(a,b-1)
Buggy python submission (verdict: Runtime Error):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
n = ii()
music = []
length = []
for i in range(n):
    ti,leng = map(str,input().split())
    music.append(ti)
    length.append(leng)
x = input()

num = music.index(x)
print(sum(length[x::]))

Fixed submission:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
n = ii()
music = []
length = []
for i in range(n):
    ti,leng = map(str,input().split())
    music.append(ti)
    length.append(int(leng))
x = input()

num = music.index(x)
print(sum(length[num+1::]))
Buggy python submission (verdict: Time Limit Exceeded):
import re
s = input()
l = []
for i in range(len(s)+1):
    left = s[:i]
    right = s[i:]
    ml = re.match('<+',left[::-1])
    num = 0
    if ml:
        num = ml.end()
    mr = re.match('>+',right)
    if mr:
        num = max(num,mr.end())
    l.append(num)
#print(l)
print(sum(l))

Fixed submission:
s = input().replace('><','> <').split()
ans = 0
#print(list(s))
for st in s:
    lt = st.count('<')
    gt = len(st) - lt
    if lt > gt:
        gt -= 1
    else:
        lt -= 1
    ans += (lt*lt+lt)//2 + (gt*gt+gt)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b = map(int,input())

if a < 10 and b < 10:
    print(a*b)
else:
    print(-1)

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

if a < 10 and b < 10:
    print(a*b)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,m = iim()
broke = []
for j in range(m):
    broke.append(ii())

num = [1]
if broke[0] == 1:
    num.append(0)
    broke.pop(0)
else:
    num.append(1)

for i in range(2,n+1):
    if len(broke) and broke[0] == i:
        num.append(0)
        broke.pop(0)
    else:
        num.append((num[-1]+num[-2])%1000000007)

print(num[-1])

Fixed submission:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,m = iim()
broke = []
for j in range(m):
    broke.append(ii())
if n > 1:
    num = [1]
    if len(broke) and broke[0] == 1:
        num.append(0)
        broke.pop(0)
    else:
        num.append(1)

    for i in range(2,n+1):
        if len(broke) and broke[0] == i:
            num.append(0)
            broke.pop(0)
        else:
            num.append((num[-1]+num[-2])%1000000007)
    print(num[-1])
else:
    print(1)
Buggy python submission (verdict: Runtime Error):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

#pythonだとTLE/pypyだとAC
'''
r,g,b,n = iim()
ans = 0
for i in range(n//r+1):
    for j in range(n//g+1):
        num = n-i*r-j*g
        if num%b == 0 and num//b >= 0:
#            print(i,j,num//b)
            ans += 1
print(ans)
'''

#上を受けてpythonでも通るように改良
*num,n = iim()
a,b,c = map(int,sorted(num))
ans = 0
for i in range(n//c+1):
    if a!= 1:
        for j in range(n//b+1):
            num = n-i*r-j*g
            if num%a == 0 and num//a >= 0:
                ans += 1
    else:
        n -= i*c
        if n == 0:
            ans += 1
        elif n > 0:
            if n%b == 0:
                ans += n//b+1
            else:
                ans += n//b
print(ans)

Fixed submission:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

r,g,b,n = iim()
ans = 0
for i in range(n//r+1):
    for j in range(n//g+1):
        num = n-i*r-j*g
        if num%b == 0 and num//b >= 0:
#            print(i,j,num//b)
            ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

r,g,b,n = iim()
ans = 0
for i in range(n//r+1):
    for j in range(n//g+1):
        num = n-i*r-j*g
        if num%b == 0 and num//b >= 0:
#            print(i,j,num//b)
            ans += 1
print(ans)

Fixed submission:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

r,g,b,n = iim()
ans = 0
for i in range(n//r+1):
    for j in range(n//g+1):
        num = n-i*r-j*g
        if num%b == 0 and num//b >= 0:
#            print(i,j,num//b)
            ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

a,b,k = iim()
ans = []
for i in range(min(a,b)):
    if a%i == 0 and b%i == 0:
        ans.append(i)

print(ans[k-1])

Fixed submission:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

a,b,k = iim()
ans = []
for i in range(1,min(a,b)+1):
    if a%i == 0 and b%i == 0:
        ans.append(i)

print(ans[-k])
Buggy python submission (verdict: Runtime Error):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
from math import gcd

n,m = iim()
s = input()
t = input()
num = gcd(n,m)
lcm = n*m//num
print(lcm if s[::n//num] == t[::m//num] else -1)


Fixed submission:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
#from math import gcd
from fractions import gcd
n,m = iim()
s = input()
t = input()
num = gcd(n,m)
lcm = n*m//num
print(lcm if s[::n//num] == t[::m//num] else -1)
Buggy python submission (verdict: Runtime Error):
#import math
import fractions
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,x = iim()
xmod = list(map(lambda y:int(y)-x,input().split()))
#print(xmod)
num = xmod[0]
for i in xmod:
    gcd = fractions.gcd(num,i)

print(gcd)

Fixed submission:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
A = iil()

if 2 in A:
    print('No')
else:
    print('Yes')
Buggy python submission (verdict: Runtime Error):
import math
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,x = iim()
xmod = list(map(lambda y:int(y)-x,input().split()))
#print(xmod)
num = xmod[0]
for i in xmod:
    gcd = math.gcd(num,i)

print(gcd)

Fixed submission:
#import math
import fractions
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,x = iim()
xmod = list(map(lambda y:abs(int(y)-x),input().split()))
#print(xmod)
gcd = xmod[0]
for i in xmod:
    gcd = fractions.gcd(gcd,i)

print(gcd)
Buggy python submission (verdict: Runtime Error):
import re
s = input()
k = int(input())

if s[0] != '1':
    print(s[0])
    exit()
else:
    pos = re.search(r'1+',s).end()
    if k < pos:
        print(1)
    else:
        print(s[pos])

Fixed submission:
import re
s = input()
k = int(input())

if s[0] != '1':
    print(s[0])
    exit()
else:
    pos = re.search(r'1+',s).end()
    if k <= pos:
        print(1)
    else:
        print(s[pos])
Buggy python submission (verdict: Runtime Error):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
A = iil()
ans = 0
for i in range(1,n)
    if A[i-1] == A[i]:
        ans += 1
        A[i] = -1
print(ans)

Fixed submission:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
A = iil()
ans = 0
for i in range(1,n):
    if A[i-1] == A[i]:
        ans += 1
        A[i] = -1
print(ans)