Problem p02953 (python)

Fixed submission:
def main():
    n = int(input())
    h = list(map(int, input().split(' ')))

    ans = True
    MAX = h[0]
    for i in range(n):
        if h[i] > MAX:
            MAX = h[i]
        elif h[i] < MAX - 1:
            ans = False
        else:
            continue
        
    print('Yes' if ans else 'No')


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    h = list(map(int, input().split(' ')))
    l = [h[i] - h[i + 1] for i in range(n-1)]
    print('Yes' if check(l) else 'No')


def check(l):
    for i in range(len(l)):
        if l[i] >= 2:
            return False
        elif l[i] <= 0:
            continue
        else:
            if l[i + 1] >= 1:
                return False
            else:
                continue
    return True


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    h = list(map(int, input().split(' ')))
    l = [h[i] - h[i + 1] for i in range(n-1)]
    print('Yes' if check(l) else 'No')


def check(l):
    if len(l) <= 1:
        return True
    else:
        return check(l[1::]) if l[0] + l[1] <= 1 else False


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    h = list(map(int, input().split(' ')))
    print('Yes' if check(h, 0) else 'No')


def check(l, m):
    if len(l) <= 1:
        return True
    elif m:
        if len(l) == 2:
            return True if l[0] - l[1] <= 0 else False
        else:
            return check(l[1::], 0) if l[0] - l[1] <= 0 else False
    else:
        if l[0] - l[1] >= 2:
            return False
        elif l[0] - l[1] == 1:
            return check(l[1::], 1)
        else:
            return check(l[1::], 0)
            


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    h = list(map(int, input().split(' ')))
    print('Yes' if check(h) else 'No')


def check(l):
    if len(l) <= 1:
        return True
    elif len(l) == 2:
        if l[0] - l[1] < 2:
            return True
        else:
            return False
    else:
        if l[0] - l[1] >= 2:
            return False
        elif l[0] - l[1] == 1 and l[1] - l[2] >= 1:
            return False
        else:
            return check(l[1::])


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    h = list(map(int, input().split(' ')))
    print('Yes' if check(h) else 'No')


def check(l):
    if len(l) <= 1:
        return True
    elif len(l) == 2:
        return False if l[0] - l[1] >= 2 else True
    else:
        return False if l[0] - l[1] == 1 and l[1] - l[2] >= 1 else check(l[1::])


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    h = list(map(int, input().split(' ')))
    print('Yes' if check(h) else 'No')


def check(l):
    if len(l) <= 1:
        ('true')
        return True
    elif len(l) == 2:
        return False if l[0] - l[1] >= 2 else True
    else:
        return False if l[0] - l[1] == 1 and l[1] - l[2] >= 1 else check(l[1::])


if __name__ == '__main__':
    main()