Problem p03017 (python)

Fixed submission:
def main():
    inp = input()
    st = inp.split()
    n = int(st[0])
    a = int(st[1])
    b = int(st[2])
    c = int(st[3])
    d = int(st[4])
    inp = input()
    # 2 rocks
    rock_count = 0
    for i in range(a, b):
        if inp[i] == '#':
            rock_count += 1
        elif inp[i] == '.':
            rock_count = 0
        if rock_count == 2:
            print("No")
            return
    if inp[b] == "#" and (inp[b-1] == "#" or inp[b+1] == "#"):
        print("No")
        return

    max_cd = c if c > d else d
    continuous_count = 0
    nothing_count = 0
    nothing_3 = False
    if inp[b-1] == '.':
        nothing_count += 1
    if inp[b-2] == '.':
        nothing_count += 1
    for i in range(b, max_cd):
        if inp[i] == '#':
            continuous_count += 1
            nothing_count = 0
        elif inp[i] == '.':
            continuous_count = 0
            nothing_count += 1
        if continuous_count == 2:
            print("No")
            return
        if nothing_count == 3 and i < d + 1:
            nothing_3 = True

    # c < d
    if c < d or nothing_3:
        print("Yes")
    else:
        if (inp[d-1] == '.' and inp[d-2] == '.') and (inp[d] == '.' or inp[d-3] == '.'):
            print("Yes")
        else:
            print("No")
    return


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    inp = input()
    st = inp.split()
    n = int(st[0])
    a = int(st[1])
    b = int(st[2])
    c = int(st[3])
    d = int(st[4])
    inp = input()
    # 2 rocks
    rock_count = 0
    for i in range(a, b):
        if inp[i] == '#':
            rock_count += 1
        elif inp[i] == '.':
            rock_count = 0
        if rock_count == 2:
            print("No")
            return
    if inp[b] == "#" and (inp[b-1] == "#" or inp[b+1] == "#"):
        print("No")
        return

    max_cd = c if c > d else d
    continuous_count = 0
    nothing_count = 0
    nothing_3 = False
    if inp[b-1] == '.':
        nothing_count += 1
    for i in range(b, max_cd+1):
        if inp[i] == '#':
            continuous_count += 1
            nothing_count = 0
        elif inp[i] == '.':
            continuous_count = 0
            nothing_count += 1
        if continuous_count == 2:
            print("No")
            return
        if nothing_count == 3 and i < d + 1:
            nothing_3 = True

    # c < d
    if c < d or nothing_3:
        print("Yes")
    else:
        if (inp[d-1] == '.' and inp[d-2] == '.') and (inp[d] == '.' or inp[d-3] == '.'):
            print("Yes")
        else:
            print("No")
    return


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    inp = input()
    st = inp.split()
    n = int(st[0])
    a = int(st[1])
    b = int(st[2])
    c = int(st[3])
    d = int(st[4])
    inp = input()
    # 2 rocks
    rock_count = 0
    for i in range(a, b):
        if inp[i] == '#':
            rock_count += 1
        elif inp[i] == '.':
            rock_count = 0
        if rock_count == 2:
            print("No")
            return
    if inp[b] == "#" and (inp[b-1] == "#" or inp[d+1] == "#"):
        print("No")
        return

    max_cd = c if c > d else d
    continuous_count = 0
    nothing_count = 0
    nothing_3 = False
    if inp[b-1] == '.':
        nothing_count += 1
    for i in range(b, max_cd+1):
        if inp[i] == '#':
            continuous_count += 1
            nothing_count = 0
        elif inp[i] == '.':
            continuous_count = 0
            nothing_count += 1
        if continuous_count == 2:
            print("No")
            return
        if nothing_count == 3 and i < d + 1:
            nothing_3 = True

    # c < d
    if c < d or nothing_3:
        print("Yes")
    else:
        if (inp[d-1] == '.' and inp[d-2] == '.') and (inp[d] == '.' or inp[d-3] == '.'):
            print("Yes")
        else:
            print("No")
    return


if __name__ == '__main__':
    main()