Problem p02953 (python)

Fixed submission:
n = int(input())
l = list(map(int, input().split()))
if n == 1:
    print("Yes")
else:
    l1 = l[1:]+[0]
    d = [i-j for (i,j) in zip(l1, l)][:-1]
    t = [i for i in d if i <= -2]
    if len(t) >= 1:
        print("No")
    else:
        if -1 not in d or d.count(-1)==1:
            print("Yes")
        else:
            p = d.index(-1)
            d = d[p+1:]
            s = ''.join(map(str, d))
            spl = s.split("-1") 
            if "" in spl[:-1]:
                print("No")
            else:
                if spl[-1] == "":
                    spl = [s for s in spl if s != '']
                    y = [int(i) for i in spl]
                    if 0 not in y:
                        print("Yes")
                    else:
                        print("No")
                else:
                    y = [int(i) for i in spl]
                    if 0 in y[:-1]:
                        print("No")
                    else:
                        print("Yes")

Buggy submission (verdict: Runtime Error):
n = input()
l = list(map(int, input().split()))
l1 = l[1:]+[0]
d = [i-j for (i,j) in zip(l1, l)][:-1] ##dは差分のリスト
t = [i for i in d if i <= -2]
if len(t) >= 1:
    print("No")
else:
    s = ''.join(map(str, d)) ## dを文字列にする
    spl = s.split("-1") ##-1でdを区切る
    if "" not in spl:
        print("Yes")
    else:
        if spl[-1] == "" and spl[-2] != "" and spl[-2] != "0" and "" not in spl[:-1]:
            print("Yes")
        else:
            if "" in spl:
                print("No")
            else:
                y = [int(i) for i in spl]
                if 0 in y:
                    print("No")
                else:
                    print("Yes")

Buggy submission (verdict: Runtime Error):
n = input()
l = list(map(int, input().split()))

if l.count(0)+ l.count(1) == len(l):
    print("Yes")
else:
    l1 = l[1:]+[0]
    print(l1)
    d = [i-j for (i,j) in zip(l1, l)][:-1] ##dは差分のリスト
    print(d)
    t = [i for i in d if i <= -2]
    if len(t) >= 1:
        print("No")
    else:
        s = ''.join(map(str, d)) ## dを文字列にする
        spl = s.split("-1") ##-1でdを区切る
        print(spl)
        if "" not in spl:
            print("Yes")
        else:
            if spl[-1] == "" and spl[-2] != "" and spl[-2] != "0" and "" not in spl[:-1]:
                print("Yes")
            else:
                if "" in spl:
                    print("No")
                else:
                    y = [int(i) for i in spl]
                    print(y)
                    if 0 in y:
                        print("No")
                    else:
                        print("Yes")

Buggy submission (verdict: Runtime Error):
n = input()
l = list(map(int, input().split()))
 
if l.count(0)+ l.count(1) == len(l):
    print("Yes")
else:
    l1 = l[1:]+[0]
    print(l1)
    d = [i-j for (i,j) in zip(l1, l)][:-1] ##dは差分のリスト
    print(d)
    if -2 in d:
        print("No")
    else:
        s = ''.join(map(str, d)) ## dを文字列にする
        spl = s.split("-1") ##-1でdを区切る
        print(spl)
        if "" not in spl:
            print("Yes")
        else:
            if spl[-1] == "" and spl[-2] != "" and spl[-2] != "0" and "" not in spl[:-1]:
                print("Yes")
            else:
                if "" in spl:
                    print("No")
                else:
                    y = [int(i) for i in spl]
                    print(y)
                    if 0 in y:
                        print("No")
                    else:
                        print("Yes")

Buggy submission (verdict: Runtime Error):
n = input()
l = list(map(int, input().split()))

if l.count(0)+ l.count(1) == len(l):
    print("Yes")
else:
    l1 = l[1:]+[0]
    print(l1)
    d = [i-j for (i,j) in zip(l1, l)][:-1] ##dは差分のリスト
    print(d)
    if -2 in d:
        print("1No")
    else:
        s = ''.join(map(str, d)) ## dを文字列にする
        spl = s.split("-1") ##-1でdを区切る
        print(spl)
        if "" not in spl:
            print("2Yes")
        else:
            if spl[-1] == "" and spl[-2] != "" and spl[-2] != "0" and "" not in spl[:-1]:
                print("3Yes")
            else:
                if "" in spl:
                    print("4No")
                else:
                    y = [int(i) for i in spl]
                    print(y)
                    if 0 in y:
                        print("5No")
                    else:
                        print("6Yes")