Problem:


Score : 300 points

Problem Statement

There are N slimes lining up from left to right. The colors of these slimes will be given as a string S of length N consisting of lowercase English letters. The i-th slime from the left has the color that corresponds to the i-th character of S.

Adjacent slimes with the same color will fuse into one larger slime without changing the color. If there were a slime adjacent to this group of slimes before fusion, that slime is now adjacent to the new larger slime.

Ultimately, how many slimes will be there?

Constraints

1 \leq N \leq 10^5

|S| = N

S consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

N
S

Output

Print the final number of slimes.

Sample Input 1

10
aabbbbaaca

Sample Output 1

5

Ultimately, these slimes will fuse into abaca.

Sample Input 2

5
aaaaa

Sample Output 2

1

All the slimes will fuse into one.

Sample Input 3

20
xxzaffeeeeddfkkkkllq

Sample Output 3

10



Sample input:
10
aabbbbaaca


Sample output:
5

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
s += "1"
ans = 0
for i in range(n):
  if s[i] != s[i+1]:
    ans += 1

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
R = []

for i in range(N-1):
  if(S[i] != S[i+1]):
    if (i < N-2):
      R.append(S[i])
    else:
      R.append(S[i])
      R.append(S[i+1])
  else:
    continue
if len(R) == 0:
  R.append(S[0])
print(len(R))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
R = []

for i in range(N-1):
  if(S[i] != S[i+1]):
    if (i == N-2):
      R.append(S[i])
      R.append(S[i+1])
    else:
      R.append(S[i])
  else:
    continue
if len(R) == 0:
  R.append(S[0])
print(len(R))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
R = []

for i in range(N-1):
  if(S[i] != S[i+1]):
    if (i == N-2):
      R.append(S[i])
      R.append(S[i+1])
    else:
      R.append(S[i])
  else:
    continue
print(len(R))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
R = []

for i in range(N-1):
  if(S[i] != S[i+1]):
    R.append(S[i])
  else:
    continue
    
if S[N-2] != S[N-1]:
	R.append(S[N-1])
print(R)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
from itertools import groupby
N = int(input())
s = input()
print(len(list(groupby(s))))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
from itertools import groupby
N = int(input())
print(len(list(groupby(input()))))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
from itertools import groupby
def print_ans(input_line):
    """Test Case
    >>> print_ans("aabbbbaaca")
    5
    >>> print_ans("aaaaa")
    1
    >>> print_ans("xxzaffeeeeddfkkkkllq")
    10
    """
    print(len(list(groupby(input_line))))

if __name__ == '__main__':
    N = int(input())
    print_ans(input())

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
List_S = list(S)
Ans = 1

print(List_S)

for i in range(N-1):
    if List_S[i] != List_S[i+1]:
        Ans += 1
    
print(Ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(input())
c = 1
for i in range(n):
    print(i)
    if i+1 == n:
        break
    if s[i] != s[i+1]:
        c += 1
print(c)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
a = []
for i in range(N-1):
  if S[i] != S[i+1]:
    a.append(S[i])
if len(a) == 0:
  print(0)
else:
  print(len(a)+1)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(str(input()))

new_s = ""
temp=""

for i in range(n):
  if temp != s[i]:
    new_s += s[i]
    temp=s[i]

print(new_s)

Submission status: Wrong Answer

Solution code:
n = int(input())
S = input()

tmp = ''
cnt = 0
for s in S:
    if s == tmp:
        cnt += 1
    tmp = s
print(cnt)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
ans = 0
for i in range(N-1):
  if S[i] != S[i+1]:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np


def main():
    N = int(input())
    S = input()
    count = 1
    now = S[0]
    for n in range(2, N):
        if(now != S[n]):
            count += 1
            now = S[n]
    print(count)


if(__name__ == "__main__"):
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = input()
    slimes = list(input())

    print(n, slimes)
    one = 0
    count = 0
    for slime in slimes:
        if one != slime:
            count+=1
        one = slime
    print(count)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
le = int(input())
lis = list(input())
alis = []
def delete(n,lis):
    for i in range(n):
        if i==n-1 or lis[i] != lis[i-1]  :
            alis.append(lis[i])
delete(le,lis)
print(len(alis))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
S = []
for i in s:
    S.append(s)
i = 0
while i < n-1:
    if S[i] == S[i+1]:
        S.pop(i)
        n -= 1
    i += 1
print(len(S))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()

counter = 0

for i in range(1,len(s)):
    if s[i-1] != s[i]:
        counter += 1

print(counter)

Submission status: Wrong Answer

Solution code:
def into_lan(s,n):
	ch = s[0]
	res = ''
	ct = 1
	for i in range(1,n):
		if(s[i] == ch):
			ct = ct +  1
		else:
			res = res + ch + str(ct)
			ct = 1
		ch = s[i]
	res = res + ch + str(ct)
	return res

n = int(input())
body = input()
print(len(into_lan(body,n)[0::2]))

Submission status: Wrong Answer

Solution code:
N = int(input())
s = input()
str = ""
i = 0

str = str + s[0]

for i in range(1, N-1):
    if s[i] != s[i+1]:
        str = str + s[i+1]

print(len(str))

Submission status: Wrong Answer

Solution code:
N = int(input())
s = input()
str = ""
i = 0

for i in range(0, N-1):
    if s[i] != s[i+1]:
        str = str + s[i]
        if i == N-2:
            str = str + s[i+1]

print(len(str))

Submission status: Wrong Answer

Solution code:
n=int(input())
S=input()
s=list(S)
 
print(s)
def jokyolist(s):
  jokyo=[]
  #jokyo配列はこれから除去すべき奴の番号のリスト
  for i in range(len(s)-1):
    if s[i]==s[i+1]:
      jokyo.append(i)
    jokyo=sorted(jokyo,reverse=True)
  return jokyo
 
def remov(s,jokyo):
  for i in range(len(jokyo)):
    s.pop(jokyo[i])
    return s
def removtimes(jokyo):
  t=len(jokyo)
  return t
 
i=0
while i<=n:
  jokyo=jokyolist(s)
  if removtimes(jokyo)==0:
    break
  s=remov(s,jokyo)
  i+=1

print(len(s))

Submission status: Wrong Answer

Solution code:
import copy

n = int(input())
str = input()
char_list = list(str)
#del_num = []

#dellist = lambda items, indexes: [item for index, item in enumerate(items) if index not in indexes]
ans =0
for i in range(len(char_list)-1):
    if char_list[i] == char_list[i+1]:
#        del_num.append(i+1)
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()

cnt = 0
for i in range(1, len(S)):
    if S[i-1] == S[i]:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(input())
count = 0

for i in range(n-1):
    if not s[i] == s[i+1]:
        count += 1

if not s[n-2] == s[n-1]:
    count += 1

if count == 0:
    print(1)
else:
    print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(input())
count = 0

for i in range(n-1):
    if not s[i] == s[i+1]:
        count += 1

if not s[n-2] == s[n-1]:
    count += 1

print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(input())
answer = []

for i in range(n-1):
    if not s[i] == s[i+1]:
        answer.append(s[i])

if not s[n-2] == s[n-1]:
    answer.append(s[n-1])

print(len(answer))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()

out = ""
i = 0
while True:
    end = False
    if i == N-1:
        break
    for j in range(i+1, N):
        if S[i] == S[j]:
            end = True
            continue
        else:
            out += S[i]
            i = j
    if end:
        out += S[i]
        break

print(len(out))

Submission status: Wrong Answer

Solution code:
N = input("N")
S = input("S")
result = int(N)
for i in range(len(S) - 1):
  if S[i] == S[i + 1]:
    result -= 1
print(result)

Submission status: Wrong Answer

Solution code:
N = input("スライムの数 : ")
S = input("対応する文字列 : ")
result = int(N)
for i in range(len(S) - 1):
  if S[i] == S[i + 1]:
    result -= 1
print(result)

Submission status: Wrong Answer

Solution code:
N = input("スライムの数 : ")
S = input("対応する文字列 : ")
result = int(N)
for i in range(len(S) - 1):
    if S[i] == S[i + 1]:
        result -= 1
print(result)

Submission status: Wrong Answer

Solution code:
N = input("スライムの数 : ")
S = input("対応する文字列 : ")
result = 1
for i in range(len(S) - 1):
  if S[i] != S[i + 1]:
    result += 1
print(result)

Submission status: Wrong Answer

Solution code:
N = input("スライムの数 : ")
S = input("対応する文字列 : ")
result = 0
for i in range(len(S) - 1):
  if S[i] != S[i + 1]:
    result += 1
print(result)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
count = 0
ans=1
j=''

for i in S:
    count +=1
    if (count>=2) & (i==j): continue
    else:
        j=i
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
count=0
for i in range(N-1):
    if S[i]!=S[i+1]:
        count+=1
if N!=1 and S[N-2]!=S[N-1]:
    count+=1
if count==0:
    count+=1
print(count)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
count=0
for i in range(N-1):
    if S[i]!=S[i+1]:
        count+=1
if S[N-2]!=S[N-1]:
    count+=1
if count==0:
    count+=1
print(count)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
d=[]
for i in range(N):
    if i==1:
        d.append(S[i])
    elif S[i]!=S[i-1]:
        d.append(S[i])
print(len(d))

Submission status: Wrong Answer

Solution code:
import itertools as i
_,S=open(0)
print(len(list(i.groupby(S))))

Submission status: Wrong Answer

Solution code:
N = int(input())
s = input()
cnt = 0
for i in range(1,N):
  if s[i] != s[i-1]:
    cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())

forcuss = 0
j = 1
number = 1
print(S)

while j != N:
    if S[forcuss] == S[j]:
        j = j + 1
        continue
    elif S[forcuss] != S[j]:
        number = number + 1
        forcuss = j
        j = forcuss + 1

print(number)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
ans = 0

if N == 1:
    print(1)
else:
    for i in range(1, N):
        if S[i - 1] != S[i]:
            ans += 1

        if i == N-1:
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(input())
ans = 1
start = s[0]
if n == 1:
    print(1)
else:
    for w in s[1:]:
        if w == start:
            continue
        else:
            ans += 1
            start = w
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

n = int(input())

d = input()

s = []
for i in range(n):
    if ((len(s) > 0 and d[i] != s[len(s)-1]) or (len(s) == 0)):
        s.append(d[i])
print(''.join(s))

Submission status: Wrong Answer

Solution code:
X=int(input())
Y = input()
res=""
a=""
for i in Y:
  if res!=i:
    res=i
    a+=i
print(a)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input() + "0"
ans = 0

for i in range(n):
  temp = s[i]
  if s[i+1] != temp:
    ans += 1

print(ans+1)

Submission status: Wrong Answer

Solution code:
print('input >>')
N = input()
S = input()

ans = 1
left = S[0]
for s in S:
    if not s == left:
        ans += 1
        left = s

print('----------output----------')
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
S = input()

ans = 1

S = list(S)
print(S)
for i in range(len(S)-1):
    if S[i]!=S[i+1]:
        ans =ans+1

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
S = input()

ans = 0

S = list(S)
for i in range(len(S)-1):
    if S[i]!=S[i+1]:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
S = input()

ans = 0

S = list(S)
for i in range(len(S)-1):
    if S[i]==S[i+1]:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
 
N = int(input())
s= list(input())
 
s0 = s.pop()
 
cnt = 1
 
while s:
    s1 = s.pop()
    if s1!=s0:
        cnt += 1
        s0 = s1
print(cnt)

Submission status: Wrong Answer

Solution code:
a = input().split()
print(a)

Submission status: Wrong Answer

Solution code:
s=input()
t=''
a=1
for i in range(len(s)-1):
  if s[i]!=s[i+1]:
    a+=1
print(a)

Submission status: Wrong Answer

Solution code:
N = int(input())
Slime = list(input())
check = 'st'
res = 0

for i in range(N-1):
	if Slime[i+1] != check:
		check = Slime[i+1]
		res += 1
res += 1

print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
ans = ""
num = 0

if(N==1):
  print(1)
else:
  for i in range(len(S)-1):
    if(S[i]==S[i+1]):
      num += 1
    else:
      ans += S[i]
  if(S[len(S)-2]!=S[len(S)-1]):
    ans += S[len(S)-1]
  if(num==len(S)-1):
    ans += S[0]
print(len(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
ans = ""
num = 0

if(N==1):
  print(1)
else:
  for i in range(len(S)-1):
    if(S[i]==S[i+1]):
      num += 1
    else:
      ans += S[i]
  if(S[len(S)-2]!=S[len(S)-1]):
    ans += S[len(S)-1]
print(len(ans))

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
s=list(s)
print(s)
T=[]
tmp=0
for i in range(len(s)):
    if s[i]!=tmp:
        T.append(s[i])
        tmp=s[i]
print(len(T))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

# Input
s = [input() for i in range(2)]

N = int(s[0])
S = list(s[1])

print(N)
print(S)

# Process
M = 0

for i in range(1,N):
    if S[i-1] == S[i]:
        M += 1

N = N - M


# Output
print(N)

Submission status: Wrong Answer

Solution code:
import sys
print("hoge")

Submission status: Wrong Answer

Solution code:
print("hoge")

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()

f = 0
for i in range(1, n):
  if (s[i] != s[i-1]):
    f += 1
    
print(f)

Submission status: Wrong Answer

Solution code:
N = int(input())
S=list(input())
cnt=0
for i in range(N-1):
  if S[i]!=S[i+1]:
    cnt+=1
    
print(len(S)-(cnt+1))

Submission status: Wrong Answer

Solution code:

N=int(input())
S=input()
New=[]
for i in range(N-1):
    if not S[i] == S[i+1]:
        New.append(S[i])
if len(New) == 0 or S[N-2] != S[N-1]:
     New.append(S[N-1])
print(len(New))

Submission status: Wrong Answer

Solution code:

N=int(input())
S=input()
j=0
New=[]
for i in range(N-1):
    if not S[i] == S[i+1]:
        New.append(S[i])
        j=j+1
if not S[N-2] == S[N-1]:
     New.append(S[N-1])
print(len(New))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
counter = 0
last_char = None
for char in S:
  if char != last_char:
    counter += 0
    last_char = char

print(counter)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input().split())
 
ans = 1
for i in range(N - 1):
    if i != i + 1:
        ans = ans + 1
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input().split())

ans = 1
for i in range(N):
    if i != i + 1:
        ans = ans + 1
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
List=input()
print(List)
c=1
for i in range(1,N):
    if List[i-1]!=List[i]:
        c=c+1
    else:
        c=c+0
print(c)

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
#import math
#import time
#import random  # randome is not available at Codeforces
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
#eps=10**(-10)
#ts=time.time()
#sys.setrecursionlimit(10**6)
input=lambda: sys.stdin.readline().rstrip()

show_flg=False
show_flg=True

n=I()
s=StoI()
ans=0
groupby(s)
print(len(s))

Submission status: Wrong Answer

Solution code:
def main():
    baselist=[]
    anslist=[]
    baseword = input()
    [baselist.append(i) for i in baseword]
    for index,value in enumerate(baselist):
        if int(index+1)<int(len(baselist)):
            if baselist[index]!=baselist[index+1]:
                anslist.append(baselist[index])
        else:
            anslist.append(baselist[index])
    print(len(anslist))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
count = 0
for i in range(n-1):
  if s[i] == s[i+1]:
    count += 1
print(count)

Submission status: Wrong Answer

Solution code:
N=int(input())
text=input()
x=0
for i in range(N-1):
  if text[i]!=text[i+1]:
    x+=1
print(x)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(input())
now=l[0]
count=0
for i in range(1,n):
  if now!=l[i]:
    count+=1
    now=l[i]
  else:
    pass
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
S = list(input())
ans =0
now_number =0

for i in range(n-1):
    if(S[i] != S[i+1]):
        ans +=1
print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
input = stdin.readline
lmi = lambda: list(map(int, input().split()))
mi = lambda: map(int, input().split())

n = int(input())
s = input().strip('\n')
ans = 0
for i in range(1, n):
    if s[i] != s[i-1]:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
a = 1
for i in range(n-1):
  if s[i] != s[i+1]:
    a += 1

Submission status: Wrong Answer

Solution code:
import sys

n = int(input())
s = input()
i = 0
ck = ''
result = ''
for i in range(len(s) - 1):
	if s[i] == s[i + 1]:
		if s[i] != ck:
			print('ck = ' + ck)
			ck = s[i]
			result += ck
	elif s[i] != ck:
		print('ck = ' + ck)
		ck = s[i]
		result += ck

if s[-1:] != ck:
	result += s[-1:]

print(result)
print(len(result))

Submission status: Wrong Answer

Solution code:
n = int(input())
a=input()
s = set(a)
        
        
print(len(s))

Submission status: Wrong Answer

Solution code:
import sys
N = int(sys.stdin.readline())
S = input()

lis = list(str(S))

count = 0
c = 0

for i in lis:
    c += 1
    if len(lis) == c:
        if count == N -1:
            print(1)
        else:
            print(count)
    elif lis[c - 1] == lis[c]:
        count += 1

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

N = int(input())
N = N-1
S = input()
s = ' '
o = ' '
n = 0
for i in range(N):
  if S[n] == S[n+1]:
    if s[-1] != S[n]:
      s = s + S[n]
    n = n + 1
  else:
    if s == o:
      s = s + S[n]
      s = s.lstrip()
    s = s + S[n+1]
    n = n + 1
print(len(s.lstrip()))

Submission status: Wrong Answer

Solution code:
import sys
N = int(sys.stdin.readline())
S = input()

lis = list(str(S))

count = 0
c = 0

for i in lis:
    c += 1
    if len(lis) == c:
        print(count)
    elif lis[c - 1] == lis[c]:
        count += 1

Submission status: Wrong Answer

Solution code:
import sys
N = int(sys.stdin.readline())
S = input()

lis = list(S)

count = 0
c = 0

for i in lis:
    c += 1
    if len(lis) == c :
        print(count)
    elif lis[c - 1] == lis[c]:
        count += 1

Submission status: Wrong Answer

Solution code:
N = int(input())
s_list = list(input())
ans = ""
for i in range(N):
    if i  < N - 2:
        if s_list[i] != s_list[i + 1]:
            ans = ans + s_list[i]
    elif i < N - 1:
        if s_list[i] != s_list[i + 1]:
            ans = ans + s_list[i] + s_list[i + 1]
    if i + 2 == N:
        break
if len(ans) == 0:
    print(len(ans) + 1)
else:
    print(len(ans))

Submission status: Wrong Answer

Solution code:
n =  int(input())
s =  input()

def checker(s):
    new_list = []
    trigger = False
    for i in range(len(s) - 1):
        if i == 0 and s[i] == s[i + 1]:
            trigger = True
            new_list.append(s[i])
        elif i == 0 and s[i] != s[i + 1]:
            new_list.append(s[i])
        elif trigger == False and s[i] == s[i + 1]:
            trigger = True
        elif trigger == False and s[i] != s[i + 1]:
            new_list.append(s[i + 1])
        elif trigger == True and s[i] == s[i + 1]:
            pass
        elif trigger == True and s[i] != s[i + 1]:
            trigger = False
            new_list.append(s[i + 1])
    return ''.join(new_list)


tmp = checker(s)
print(len(tmp))

Submission status: Wrong Answer

Solution code:
n = int(input())
s =  [str(m) for m in list(str(input()))]
nd = list()
for i in range(n-1):
        if s[i] != s[i+1]:
            nd.append(s[i])
if s[n-2] != s[n-1]:
    nd.append(s[n-1])
print(len(nd))

Submission status: Wrong Answer

Solution code:
N = int ( input() )
slimes = str( input() )
list_slimes = list( slimes )
while(True):
  counter = 0
  i = 0
  while(i<len(list_slimes)-1):
    if list_slimes[i] == list_slimes[i+1]:
      del list_slimes[i]
      counter += 1
    i += 1
  if counter == 1:
    break

print( len (list_slimes) )

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()

S=S +"1"
state=0
bonus_sum=0
gokei=0
bonus=0

for i in range(N):
    print("gokei",gokei)
    print("bonus", bonus)
    print("bonus_sum", bonus_sum)
    print(S[i],S[i+1])
    
    if S[i] != S[i +1 ]:
        gokei=gokei+1
        bonus_sum=bonus_sum +bonus
        bonus=0
    else:
        gokei=gokei +1
        bonus = bonus +1

        
print(gokei - bonus_sum)

Submission status: Wrong Answer

Solution code:
import itertools

N = int(input())
L = str(input())

l = [k for k, v in itertools.groupby(L)]
ans = N-len(l)

print(ans)

Submission status: Wrong Answer

Solution code:
import re
n = int(input())
s = input()
memo = ""
isSequenced = False
count = 1
ans = s

for i in s:
  if i != memo and isSequenced == False:
    memo = i
  elif i == memo:
    isSequenced = True
    count += 1
  elif i != memo and isSequenced == True:
    # print("memo is " + memo)
    # print("count is " + str(count))
    # print(memo*count)
    ans = re.sub(memo*count,memo,ans)
    #ans = ans.replace(memo*count,memo)
    memo = i
    isSequenced = False
    count = 1
  # elif i == s[n-1] and isSequenced == True:
  #   print(s[n-1])
  #   ans = re.sub(memo*count,memo,ans)
#print(ans)
if isSequenced == True:
  ans = re.sub(memo*count,memo,ans)
print(len(ans))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[47]:


N = int(input())
S = list(map(str, input().split()))


# In[81]:


ans = len([S[i] for i in range(len(S)-1) if S[i] != S[i+1]])+ 1
print(ans)


# In[ ]:

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

N = int(input())
N = N-1
S = input()
s = ' '
n = 0
for i in range(N):
  if S[n] == S[n+1]:
    if s[-1] != S[n]:
      s = s + S[n]
    n = n + 1
  else:
    s = s + S[n+1]
    n = n + 1
A = int(len(s.lstrip()))
print(A)

Submission status: Wrong Answer

Solution code:
n = int(input())
s =  [str(m) for m in list(str(input()))]
nd = list()
for i in range(n-1):
        if s[i] != s[i+1]:
            nd.append(s[i])
if s[n-2] != s[n-1]:
    nd.append(s[n-1])
print(",".join(nd).replace(",",""))

Submission status: Wrong Answer

Solution code:
n = int(input())
s =  [str(m) for m in list(str(input()))]
nd = list()
for i in range(n-1):
        if s[i] != s[i+1]:
            nd.append(s[i])
if s[n-2] != s[n-1]:
    nd.append(s[n-1])
print(nd)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

N = int(input())
N = N-1
S = input()
s = ' '
n = 0
for i in range(N):
  if S[n] == S[n+1]:
    if s[-1] != S[n]:
      s = s + S[n]
    n = n + 1
  else:
    s = s + S[n+1]
    n = n + 1
print(len(s.lstrip()))

Submission status: Wrong Answer

Solution code:
n = int(input())

l = str(input())

ans = int(0)

if l[n-2] != l[n-1]:
    ans += 1

for i in range(1,n):
    if l[i-1] != l [i]:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
N = str(input())
S = str(input()).split()
answer = []
 
for s in S:
  if len(answer) == 0:
    answer.append(s)
  elif answer[-1] != s:
    answer.append(s)
print(len(answer))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()

total = []
Y = []

for i in range(10000):
	if len(S)-1 < i + 1:
		Y = Y + [S[i]]
		break
	if S[i] == S[i+1]:
		continue
	else:
		Y = Y + [S[i]]
		
print(len(Y))

Submission status: Wrong Answer

Solution code:
a = int(input().split()[0])
b = list(map(str, input().split()[0]))
k = 0
s = 1
#print(a)
#print(b)
while k<len(b) -1:
 t = b[k]
 u = b[k+1]
 #print("t",t,"u",u)
 if not t == u:
  s = s + 1
  print(s)
 k = k + 1
print(s)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
num = int(input())
colors = list(input())
count = 0

for i in range(num-2):
  if colors[i] != colors[i+1]:
    count += 1
  
print(count+1)

Submission status: Wrong Answer

Solution code:
n = int(input())

l = str(input())

ans = int(0)

if l[n-2] == l[n-1]:
    ans += 1

for i in range(1,n):
    if l[i-1] == l [i]:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
before_slime = S[0]
slime_num = 0
same_flg = False
for i, slime in enumerate(S[1:]):
    # import pdb; pdb.set_trace()
    if before_slime == slime and i == len(S[1:])-1:
        slime_num += 1
    elif before_slime != slime and i == len(S[1:])-1:
        slime_num += 2
    elif before_slime == slime and same_flg:
        before_slime = slime
    elif before_slime != slime and same_flg:
        slime_num += 1
        before_slime = slime
        same_flg = False
    elif before_slime == slime:
        before_slime = slime
        same_flg = True
    else:
        slime_num += 1
        before_slime = slime
print(slime_num)

Submission status: Wrong Answer

Solution code:
def removeDuplicates(S):
    n = len(S)  
    if (n < 2) : 
        return
    j = 0
    for i in range(n):  
        if (S[j] != S[i]): 
            j += 1
            S[j] = S[i]  
    j += 1
    S = S[:j] 
    return len(S) 

n=int(input())
s=input()
s=list(s.rstrip())
print(removeDuplicates(s))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = str(input())
c = "a b c d e f g h i j k l m n o p q r s t u v w x y z"
c = list(c.split())
for i in range(int(n**0.8), 1, -1):
    for j in range(len(c)):
        a = a.replace(c[j] * i, c[j])
print(len(a))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = str(input())
c = "a b c d e f g h i j k l m n o p q r s t u v w x y z"
c = list(c.split())
for i in range(int(n**0.7), 1, -1):
    for j in range(len(c)):
        a = a.replace(c[j] * i, c[j])
print(len(a))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = str(input())
c = "a b c d e f g h i j k l m n o p q r s t u v w x y z"
c = list(c.split())
for i in range(int(n**0.5), 1, -1):
    for j in range(len(c)):
        a = a.replace(c[j] * i, c[j])
print(len(a))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(map(str,input().split()))
loc = 0
i = 1
ans = []
for _ in range(N):
    i += 1
    target = S[0][loc:i]
    #print(target)
    if len(set(target)) > 1 or loc == N-1:
        ans.append(S[0][loc])
        loc = i - 1
if len(ans) == 0:
    print(S[0][0])
else:
    print(len(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = str(input())
c = "a b c d e f g h i j k l m n o p q r s t u v w x y z"
c = list(c.split())
for i in range(int(n/2), 1, -1):
    for j in range(len(c)):
        a = a.replace(c[j] * i, c[j])
print(len(a))

Submission status: Wrong Answer

Solution code:
import sys
N=int(input())
s=list(str(input()))
i=0
ans=0
while i!=N-1:
  count=1
  ans+=1
  while i+count<=N-1 and s[i]==s[i+count]:
    count+=1
  i+=count
  if i==N:
    print(ans)
    sys.exit()
  elif i==N-1:
    if s[N-2]!=s[N-1]:
      ans+=1
    print(ans)
    sys.exit()
print(ans)

Submission status: Wrong Answer

Solution code:
slime_number = int(input())
slime_colors = list(input())

last_slime = 'ほげ'
result = 0

for i in range(slime_number - 1):
  if last_slime != slime_colors[i + 1]:
    last_slime = slime_colors[i + 1]
    result += 1

print(max(result, 1))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()

total = []

def yugo(st,x):
	if len(st) <= x + 1 or x > 202:
		return st[x:]
		
	if st[x] == st[x + 1]:
		return yugo(st,x+1)
	else:
		return st[x] +  yugo(st,x+1)
	

for i in range(int(N/200)+1):
	ans = yugo(S,i * 200)

print(len(ans))

Submission status: Wrong Answer

Solution code:
import itertools
n = input()
s = input()

ans = [[k, len(list(g))] for k, g in itertools.groupby(s)]
len(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
ans=[]
if len(set(s))==1:
    print(1)
else:
    for i in range(n-1):
        if s[i]!=s[i+1]:
            ans+=s[1]
    if s[-2]!=s[-1]:
        ans+=s[-1]
    print(len(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = str(input())
b = "aa bb cc dd ee ff gg hh jj ii kk ll mm nn oo pp qq rr ss tt uu vv ww xx yy zz"
b = list(b.split())
c = "a b c d e f g h i j k l m n o p q r s t u v w x y z"
c = list(c.split())
for i in range(int(n/2)):
    for j in range(len(b)):
        a = a.replace(b[j],c[j])
print(len(a))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())

r = 0
for i in range(N):

    if i + 1 != N:
        if S[i] == S[i+1]:
            pass
        else:
            r = r + 1
    else:
        if S[i] != S[i-1]:
            r = r + 1
        else:
            pass
if r == 0:
    r = 1     
else:
    pass

print(r)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())

iii = []
iii.append(len(S))

def SSS():
    for i in range(0, N):
        if S[i] == S[i + 1]:
            del S[i]
    iii.append(len(S))
    if iii[0] == [1]:
        print(S)
    else:
        SSS()

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
idx = 0
idx = 1
ans = 1
if n == 1:
    print(1)
else:
    tmp = s[1]
    while(idx<n):
        if s[idx]==tmp:
            idx += 1
        else:
            tmp = s[idx]
            idx += 1
            ans +=1
    print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
sl = list(s)
anssl = list(s)

for i, e in enumerate(sl):
    if i < len(sl) - 2:
        if e == sl[i+1]:
            anssl[i+1] = False
if sl[len(sl)-1] == sl[(len(sl)-2)]:
    anssl[len(sl)-1] = False
ans = [i for i in anssl if i != False]
print(len(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())

r = 0
for i in range(N):

    if i + 1 != N:
        if S[i] == S[i+1]:
            pass
        else:
            r = r + 1
    else:
        if S[i] != S[i-1]:
            r = r + 1
        else:
            if r == 0:
                r = 1
            else:
                pass

print(r)