Problem: 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?

Submission attempts (in order):
N = int(input())
X = input()
S = []
for a in range(N):
    S.append(X[a])
if N == 1:
    print(S)
else:
    
    for i in range(N-1):
        if S[i] != S[i+1] or S[i] == 'X':
            continue
        else:
            j = i+1
            while S[i] == S[j]:
                j += 1
            for l in range(i+1,j):
                S[l] = 'X'
lista = [k for k in S if k != 'X']
print(''.join(lista))

N = int(input())
X = input()
S = []
for a in range(N):
    S.append(X[a])

if N == 1:
    print(X)
else:
    for i in range(N-1):
        if S[i] == 'X':
            continue
        elif S[i] != S[i+1]:
            continue
        else:
            for m in range(i+1,N):
                if S[i] != S[m]:
                    break
            for l in range(i+1,m+1):
                S[l] = 'X'


lista = [k for k in S if k != 'X']
print(''.join(lista))

N = int(input())
X = input()
S = []
for a in range(N):
    S.append(X[a])
if N == 1:
    print(S)
else:
    
    for i in range(N-1):
        if S[i] != S[i+1] or S[i] == 'X':
            continue
        else:
            j = i+1
        while S[i] == S[j]:
            j += 1
            for l in range(i+1,j):
                S[l] = 'X'
lista = [k for k in S if k != 'X']
print(''.join(lista))

N = int(input())
X = input()
S = []
for a in range(N):
    S.append(X[a])
if N == 1:
    print(S)
else:
    
    for i in range(N-1):
        if S[i] != S[i+1] or S[i] == 'X':
            continue
        else:
            j = i+1
        while S[i] == S[j]:
            j += 1
            for l in range(i+1,j):
                S[l] = X
lista = [k for k in S if k != X]
print(''.join(lista))

N = int(input())
X = input()
S = []
for a in range(N):
    S.append(X[a])

if N == 1:
    print(X)
else:
    for i in range(N-1):
        if S[i] == 'X':
            continue
        elif S[i] != S[i+1]:
            continue
        else:
            for m in range(i+1,N):
                if S[i] != S[m]:
                    break
            for l in range(i+1,m):
                S[l] = 'X'


lista = [k for k in S if k != 'X']
print(''.join(lista))

N = int(input())
X = input()
S = []
for a in range(N):
    S.append(X[a])

if N == 1:
    print(X)
else:
    for i in range(1,N):
        if S[i] != S[i-1]:
            continue
        else:
            S[i-1] = 'X'
        
lista = [k for k in S if k != 'X']
print(''.join(lista))

N = int(input())
X = input()
S = []
for a in range(N):
    S.append(X[a])

for i in range(N-1):
  if S[i] != S[i+1] or S[i] == 'X':
    continue
  else:
    j = i+1
    while S[i] == S[j]:
      j += 1
    for l in range(i+1,j):
        S[l] = X
lista = [k for k in S if k != X]
print(''.join(lista))

N = int(input())
X = input()
S = []
for a in range(N):
    S.append(X[a])

for i in range(N-1):
  if S[i] != S[i+1]:
    continue
  else:
    j = i+1
    while S[i] == S[j]:
      j += 1
    for l in range(i+1,j):
        S[l] = X
lista = [k for k in S if k != X]
print(''.join(lista))

N = int(input())
X = input()
S = []
for a in range(N):
    S.append(X[a])
if N == 1:
    print(S)
else:
    
    for i in range(N-1):
        if S[i] == 'X':
            continue
        elif S[i] != S[i+1]:
            continue
        else:
            j = i+1
            while S[i] == S[j]:
                j += 1
            for l in range(i+1,j):
                S[l] = 'X'
print(S)

lista = [k for k in S if k != 'X']
print(''.join(lista))

N = int(input())
X = input()
S = []
for a in range(N):
    S.append(X[a])
print(S)
if N == 1:
    print(X)
else:
    for i in range(N-1):
        if S[i] == 'X':
            continue
        elif S[i] != S[i+1]:
            continue
        else:
            j = i+1
            while S[i] == S[j]:
                j += 1
            for l in range(i+1,j):
                S[l] = 'X'
print(S)

lista = [k for k in S if k != 'X']
print(''.join(lista))

N = int(input())
S = list(input().split())
for i in range(N-1):
  if S[i] != S[i+1]:
    continue
  else:
    j = i+1
    while S[i] == S[j]:
      j += 1
    S[i:j] = 0
print([k for k in S if k != 0])
  

N = int(input())
X = input()
S = []
for a in range(N):
    S.append(X[a])

if N == 1:
    print(1)
else:
    for i in range(1,N):
        if S[i] != S[i-1]:
            continue
        else:
            S[i-1] = 'X'
    lista = [k for k in S if k != 'X']
    print(len(lista))

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted