Problem p03523 (python)

Fixed submission:
S=input()
Q=[s for s in S if s != 'A']
U=list('KIHBR')
import sys
if S.count('A')>4:
    print('NO')
    sys.exit()
elif len(Q)!=5:
    print('NO')
    sys.exit()
for i in range(len(S)):
    if S[i] not in list('AKIHABARA'):
        print('NO')
        sys.exit()
for i in range(len(S)-1):
    if S[i]==S[i+1]:
        print('NO')
        sys.exit()
    elif S[i]=='K' and S[i+1]!='I':
        print('NO')
        sys.exit()
    elif S[i]=='I' and S[i+1]!='H':
        print('NO')
        sys.exit()
for i in range(len(U)):
    if Q[i]==U[i]:
        pass
    else:
        print('NO')
        break
else:
    print('YES')

Buggy submission (verdict: Runtime Error):
S=input()
Q=[s for s in S if s != 'A']
U=list('KIHBR')
import sys
if S.count('A')>4:
    print('NO')
    sys.exit()
for i in range(len(S)):
    if S[i] not in list('AKIHABARA'):
        print('NO')
        sys.exit()
for i in range(len(S)-1):
    if S[i]==S[i+1]:
        print('NO')
        sys.exit()
    elif S[i]=='K' and S[i+1]!='I':
        print('NO')
        sys.exit()
    elif S[i]=='I' and S[i+1]!='H':
        print('NO')
        sys.exit()
for i in range(len(U)):
    if Q[i]==U[i]:
        pass
    else:
        print('NO')
        break
else:
    print('YES')

Buggy submission (verdict: Runtime Error):
S=input()
Q=[s for s in S if s != 'A']
U=list('KIHBR')
import sys
if S.count('A')>4:
    print('NO')
    sys.exit()
for i in range(len(S)):
    if S[i] not in list('AKIHABARA'):
        print('NO')
        sys.exit()
for i in range(len(S)-1):
    if S[i]==S[i+1]:
        print('NO')
        sys.exit()
    elif S[i]=='K' and S[i+1]!='I':
        print('NO')
        sys.exit()
    elif S[i]=='I' and S[i+1]!='H':
        print('NO')
        sys.exit()
for i in range(len(Q)):
    if Q[i]==U[i]:
        pass
    else:
        print('NO')
        break
else:
    print('YES')

Buggy submission (verdict: Runtime Error):
S=input()
Q=[s for s in S if s != 'A']
U=list('KIHBR')
import sys
if S.count('A')>4:
    print('NO')
    sys.exit()
elif S.count('A')==4:
    if list(S)==list('AKIHABARA'):
        print('YES')
        sys.exit()
    else:
        print('NO')
        sys.exit()
for i in range(len(S)-1):
    if S[i]==S[i+1]:
        print('NO')
        sys.exit()
    elif S[i]=='K' and S[i+1]!='I':
        print('NO')
        sys.exit()
    elif S[i]=='I' and S[i+1]!='H':
        print('NO')
        sys.exit()
for i in range(len(Q)):
    if Q[i]==U[i]:
        pass
    else:
        print('NO')
        break
else:
    print('YES')

Buggy submission (verdict: Runtime Error):
S=input()
Q=[s for s in S if s != 'A']
U=list('KIHBR')

import sys
if S.count('A')>4:
    print('NO')
    sys.exit()
else:
    for i in range(len(S)):
        if S[i] not in list('AKIHABARA'):
            print('NO')
            sys.exit()
for i in range(len(S)-1):
    if S[i]==S[i+1]:
        print('NO')
        sys.exit()
    elif S[i]=='K' and S[i+1]!='I':
        print('NO')
        sys.exit()
    elif S[i]=='I' and S[i+1]!='H':
        print('NO')
        sys.exit()
for i in range(len(Q)):
    if Q[i]==U[i]:
        pass
    else:
        print('NO')
        break
else:
    print('YES')

Buggy submission (verdict: Runtime Error):
S=input()
Q=[s for s in S if s != 'A']
U=list('KIHBR')
import sys
if S.count('A')>4:
    print('NO')
    sys.exit()
for i in range(len(S)-1):
    if S[i]==S[i+1]:
        print('NO')
        sys.exit()
    elif S[i]=='K' and S[i+1]!='I':
        print('NO')
        sys.exit()
    elif S[i]=='I' and S[i+1]!='H':
        print('NO')
        sys.exit()
for i in range(len(Q)):
    if Q[i]==U[i]:
        pass
    else:
        print('NO')
        break
else:
    print('YES')

Buggy submission (verdict: Runtime Error):
S=input()
Q=[s for s in S if s != 'A']
U=list('KIHBR')
import sys
if S.count('A')>4:
    print('NO')
    sys.exit()
for i in range(len(S)-1):
    if S[i]==S[i+1]:
        print('NO')
        sys.exit()
    elif S[i]=='K' and S[i+1]!='I':
        print('NO')
        sys.exit()
for i in range(len(Q)):
    if Q[i]==U[i]:
        pass
    else:
        print('NO')
        break
else:
    print('YES')

Buggy submission (verdict: Runtime Error):
S=input()
Q=[s for s in S if s != 'A']
U=list('KIHBR')
import sys
if S.count('A')>4:
    print('NO')
    sys.exit()
for i in range(len(S)-1):
    if S[i]==S[i+1]:
        print('NO')
        sys.exit()
    elif S[i]=='K' and S[i+1]!='I':
        print('NO')
        sys.exit()
for i in range(len(S)):
    if Q[i]==U[i]:
        pass
    else:
        print('NO')
        break
else:
    print('YES')

Buggy submission (verdict: Runtime Error):
S=input()
Q=[s for s in S if s != 'A']
U=list('KIHBR')
import sys
if S.count('A')>4:
    print('NO')
else:
    for i in range(len(S)-1):
        if S[i]==S[i+1]:
            print('NO')
            sys.exit()
        elif S[i]=='K' and S[i+1]!='I':
            print('NO')
            sys.exit()
    for i in range(len(S)):
        if Q[i]==U[i]:
            pass
        else:
            print('NO')
            break
    else:
        print('YES')

Buggy submission (verdict: Runtime Error):
S=input()
Q=[s for s in S if s != 'A']
U=list('KIHBR')
import sys
if S.count('A')>3:
    print('NO')
else:
    for i in range(len(S)-1):
        if S[i]==S[i+1]:
            print('NO')
            sys.exit()
        elif S[i]=='K' and S[i+1]!='I':
            print('NO')
            sys.exit()
    for i in range(len(S)):
        if Q[i]==U[i]:
            pass
        else:
            print('NO')
            break
    else:
        print('YES')

Buggy submission (verdict: Runtime Error):
S=input()
Q=[s for s in S if s != 'A']
U=list('KIHBR')
if S.count('A')>3:
    print('NO')
else:
    for i in range(len(S)-1):
        if S[i]==S[i+1]:
            print('NO')
        elif S[i]=='K' and S[i+1]!='I':
            print('NO')
    for i in range(len(S)):
        if Q[i]==U[i]:
            pass
        else:
            print('NO')
            break
    else:
        print('YES')