Problem p02887 (python)

Fixed submission:
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))

Buggy submission (verdict: Runtime Error):
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))

Buggy submission (verdict: Runtime Error):
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))

Buggy submission (verdict: Runtime Error):
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))

Buggy submission (verdict: Runtime Error):
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))

Buggy submission (verdict: Runtime Error):
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))

Buggy submission (verdict: Runtime Error):
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))

Buggy submission (verdict: Runtime Error):
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))

Buggy submission (verdict: Runtime Error):
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])