Buggy code:
S=list(input())
if "k" and "e" and "y" and "e" and "n" and "c" and "e" in S:
    if S[-1]=="e" and S[-2]=="c" and S[-3]=="n" and S[-4]=="e" and S[-5]=="y" and S[-6]=="e" and S[-7]=="k":
        print("Yes")
    else:
        if S[0]=="k":
            if S[1]=="e":
                if S[2]=="y":
                    if S[3]=="e":
                        if S[4]=="n":
                            if S[5]=="c":
                                if S[6]=="e":
                                    print("YES")
                                else:
                                    if S[-1]=="e":
                                        print("YES")
                                    else:
                                        print("No")
                            else:
                                if S[-1]=="e" and S[-2]=="c":
                                    print("YES")
                                else:
                                    print("No")
                        else:
                            if S[-1]=="e" and S[-2]=="c" and S[-3]=="n":
                                print("YES")
                            else:
                                print("NO")
                    else:
                        if S[-1]=="e" and S[-2]=="c" and S[-3]=="n" and S[-4]=="e":
                            print("YES")
                        else:
                            print("NO")
                else:
                    if S[-1]=="e" and S[-2]=="c" and S[-3]=="n" and S[-4]=="e" and S[-5]=="y":
                        print("YES")
                    else:
                        print("NO")
            else:
                if S[-1]=="e" and S[-2]=="c" and S[-3]=="n" and S[-4]=="e" and S[-5]=="y" and S[-6]=="e":
                    print("YES")
                else:
                    print("NO")
        else:
            print("NO")
else:
    print("NO")

Fixed code:
S=list(input())
if "k" and "e" and "y" and "e" and "n" and "c" and "e" in S:
    if S[-1]=="e" and S[-2]=="c" and S[-3]=="n" and S[-4]=="e" and S[-5]=="y" and S[-6]=="e" and S[-7]=="k":
        print("YES")
    else:
        if S[0]=="k":
            if S[1]=="e":
                if S[2]=="y":
                    if S[3]=="e":
                        if S[4]=="n":
                            if S[5]=="c":
                                if S[6]=="e":
                                    print("YES")
                                else:
                                    if S[-1]=="e":
                                        print("YES")
                                    else:
                                        print("NO")
                            else:
                                if S[-1]=="e" and S[-2]=="c":
                                    print("YES")
                                else:
                                    print("NO")
                        else:
                            if S[-1]=="e" and S[-2]=="c" and S[-3]=="n":
                                print("YES")
                            else:
                                print("NO")
                    else:
                        if S[-1]=="e" and S[-2]=="c" and S[-3]=="n" and S[-4]=="e":
                            print("YES")
                        else:
                            print("NO")
                else:
                    if S[-1]=="e" and S[-2]=="c" and S[-3]=="n" and S[-4]=="e" and S[-5]=="y":
                        print("YES")
                    else:
                        print("NO")
            else:
                if S[-1]=="e" and S[-2]=="c" and S[-3]=="n" and S[-4]=="e" and S[-5]=="y" and S[-6]=="e":
                    print("YES")
                else:
                    print("NO")
        else:
            print("NO")
else:
    print("NO")