qyliang/CodeNanoFix huggingface dataset:
Buggy code:
a = "keyence"

b = input()
o = 0
k = len(b)
j = 0
jj = 0
kk = [0 for i in range(8)]
al = 0
if k == 7:
	if a == b:
		print("YES")
	else:
		print("NO")
elif k >= 8:
	for i in range(k):
		if j == 7:
			al = 1
			o = k
			break
		if b[i] == a[j] and jj == 0:
			j += 1
		else:
			jj = 1
			o = j
		if jj == 1:
			if b[:-(o+1)] == a[:o]:
				print("YES")
				break
			else:
				print("NO")
				break
else:
	print("NO")



Fixed code:
a = "keyence"

b = input()
o = 0
k = len(b)
j = 0
jj = 0
kk = [0 for i in range(8)]
al = 0
if k == 7:
	if a == b:
		print("YES")
	else:
		print("NO")
elif k >= 8:
	for i in range(k):
		if j == 7:
			al = 1
			print("YES")
			break
		if b[i] == a[j] and jj == 0:
			j += 1
		else:
			jj = 1
			o = j
		if jj == 1 and o == 0:
			if b[-7:] == a:
				print("YES")
				break
			else:
				print("NO")
				break
		elif jj == 1:
			if b[-(7-o):] == a[o:]:
				print("YES")
				break
			else:
				print("NO")
				break
else:
	print("NO")
Buggy code:
s = list(input())
t = "keyence"
a = i = 0

while True:
    if len(s) == i:
        break
    
    if s[i] == t[i]:
        a += 1
    else:
        break
    i += 1

i = len(s) - 1
o = len(t) - 1

while True:
    if i == -1:
        break
    
    if s[i] == t[o]:
        a += 1
    else:
        break
    i -= 1
    o -= 1

if a == len(t) or 14:
    print("YES")
else:
    print("NO")

Fixed code:
s = list(input())
t = "keyence"
a = i = 0

while True:
    if len(s) == i:
        break
    
    if s[i] == t[i]:
        a += 1
    else:
        break
    i += 1

i = len(s) - 1
o = len(t) - 1

while True:
    if a == len(t):
        break
    
    if s[i] == t[o]:
        a += 1
    else:
        break
    i -= 1
    o -= 1

if a == len(t):
    print("YES")
else:
    print("NO")
Buggy code:
S = input()

ans = "N0"
for i in range(len(S)):
    for j in range(i, len(S)):
        s = S[:i] + S[j:]
        if s == "keyence":
            ans = "YES"

print(ans)


Fixed code:
S = input()

ans = "NO"
for i in range(len(S)):
    for j in range(i, len(S)):
        s = S[:i] + S[j:]
        if s == "keyence":
            ans = "YES"

print(ans)
Buggy code:
s = input()
ans = "NO"
ls = len(s)
if s[:7] == "keyence":
    ans = "YES"
elif s[-7:] == "keyence":
    ans = "YES"
else:
    for i in range(6):
        print(s[:i+1],s[ls-6+i:])
        if s[:i+1]+s[ls-6+i:] == "keyence":
            ans = "YES"
print(ans)

Fixed code:
s = input()
ans = "NO"
ls = len(s)
if s[:7] == "keyence":
    ans = "YES"
elif s[-7:] == "keyence":
    ans = "YES"
else:
    for i in range(6):

        if s[:i+1]+s[ls-6+i:] == "keyence":
            ans = "YES"
print(ans)
Buggy code:
Ss = input()

for i in range(8):
    print(i, Ss[:i] + Ss[-7+i:])
    if Ss[:i] + Ss[-7+i:] == 'keyence':
        print('YES')
        break
else:
    print('NO')


Fixed code:
Ss = input()

for i in range(8):
    if Ss[:i] + Ss[-7+i:] == 'keyence':
        print('YES')
        break
else:
    print('NO')
Buggy code:
def myAnswer(S:list) -> str:
   for i in range(len(S)-1):
      for j in range(i+1,len(S)):
         if("".join(S[:i]+S[j:]) == "keyence"):
            return "YES"
   return "NO"

def modelAnswer():
   return
def main():
   S = list(input())
   print(myAnswer(S[:]))
if __name__ == '__main__':
   main()

Fixed code:
def myAnswer(S:str) -> str:
   if(S == "keyence"):return "YES"
   for i in range(len(S)-1):
      for j in range(i+1,len(S)):
         if(S[:i]+S[j:] == "keyence"):
            return "YES"
   return "NO"

def modelAnswer():
   return
def main():
   S = (input())
   print(myAnswer(S))
if __name__ == '__main__':
   main()
Buggy code:
# B - KEYENCE String
def is_keyence_string():
	for i in range(1, len(key)):
		left = key[:i]
		right = key[i-len(key):]
		
		if S.startswith(left) and S.endswith(right):
			return True
	
	return False


S = input().trim()
key = 'keyence'

if S.startswith(key):
	print('YES')
elif S.endswith(key):
	print('YES')
elif is_keyence_string():
	print('YES')
else:
	print('NO')

Fixed code:
# B - KEYENCE String
def is_keyence_string():
	for i in range(1, len(key)):
		left = key[:i]
		right = key[i-len(key):]
		
		if S.startswith(left) and S.endswith(right):
			return True
	
	return False


S = input().strip()
key = 'keyence'

if S.startswith(key):
	print('YES')
elif S.endswith(key):
	print('YES')
elif is_keyence_string():
	print('YES')
else:
	print('NO')
Buggy code:
import itertools
s=str(input())
n='keyence'
k=''
w=list(itertools.combinations(range(len(s)+1), 2))
print(w)
for i,y in w:
    k=s[i:y]
    ss=s.replace(k,'',1)
    print(ss)
    if ss==n or k==n:
        print('YES')
        exit()
print('NO')

Fixed code:

import itertools
s=str(input())
n='keyence'
k=''
w=list(itertools.combinations(range(len(s)+1), 2))
for i,y in w:
    k=s[i:y]
    ss=s.replace(k,'',1)
    #print(ss)
    if ss==n or k==n:
        print('YES')
        exit()
print('NO')
Buggy code:
s=input()
for i in range(len(s)):
    for j in range(i,len(s)+1):
        if s[:i]+s[j]=="keyence":
            print("YES")
            exit()
print("NO")

Fixed code:
s=input()
for i in range(len(s)):
    for j in range(i,len(s)+1):
        if s[:i]+s[j:]=='keyence':
            print('YES')
            exit()
print('NO')
Buggy code:
S = input()
K = "keyence"
for i in range(len(K)):
  print(S[:i], S[(i-(len(K))):])
  if (K[:i] == S[:i]) and (K[(i-(len(K))):] == S[(i-(len(K))):]):
    print("YES")
    exit()
if K == S[:len(K)] or K == S[(-len(K)):]:
  print("YES")
  exit()
print("NO")


Fixed code:
S = input()
K = "keyence"
for i in range(len(K)):
  if (K[:i] == S[:i]) and (K[(i-(len(K))):] == S[(i-(len(K))):]):
    print("YES")
    exit()
if K == S[:len(K)] or K == S[(-len(K)):]:
  print("YES")
  exit()
print("NO")
Buggy code:
S = input().strip()
flag = 0
for i in range(len(S)-1):
    for j in range(i+1,len(S)):
        x = S[:i]+S[j:]
        if x=="keyence":
            flag = 1
            break
    if flag==1:break
if flag==1:
    print("YES")
else:
    print("NO")

Fixed code:
S = input().strip()
flag = 0
if S=="keyence":
    flag = 1
else:
    for i in range(len(S)-1):
        for j in range(i+1,len(S)):
            x = S[:i]+S[j:]
            if x=="keyence":
                flag = 1
                break
        if flag==1:break
if flag==1:
    print("YES")
else:
    print("NO")
Buggy code:
import sys
s=input()
l=len(s)-7
if s=='keyence':
    print('YES')
    sys.exit()
if l<=0:
    print('NO')
    sys.exit()
for i in range(l):
    print(s[:i]+s[i+l:])
    if s[:i]+s[i+l:]=='keyence':
        print('YES')
        sys.exit()
print('NO')

Fixed code:
import sys
s=input()
l=len(s)-7
if l<0:
    print('NO')
    sys.exit()
for i in range(7):
#    print(s[:i]+s[i+l:])
    if s[:i]+s[i+l:]=='keyence':
        print('YES')
        sys.exit()
if s[:7]=='keyence':
    print('YES')
else:
    print('NO')
Buggy code:
s = input()
n = len(s)
w = "keyence"

for i in range(7):
    if S[:i] == w[:i] and s[n-7+i:] == w[i:]:
        print("YES")
        exit()

print("NO")

Fixed code:
s = input()
n = len(s)
w = "keyence"
 
for i in range(7):
    if s[:i] == w[:i] and s[n-7+i:] == w[i:]:
        print("YES")
        exit()

print("NO")
Buggy code:
import sys, re
input = sys.stdin.readline().rstrip()

S = input()

if S == 'keyence' or re.fullmatch(r'[a-z]+keyence', S) or re.fullmatch(r'k[a-z]+eyence', S) or re.fullmatch(r'ke[a-z]+yence', S) or re.fullmatch(r'key[a-z]+ence', S) or re.fullmatch(r'keye[a-z]+nce', S) or re.fullmatch(r'keyen[a-z]+ce', S) or re.fullmatch(r'keyenc[a-z]+e', S) or re.fullmatch(r'keyence[a-z]+', S):
  print('YES')
else:
  print('NO')

Fixed code:
import re

S = input()

if S == 'keyence' or re.fullmatch(r'[a-z]+keyence', S) or re.fullmatch(r'k[a-z]+eyence', S) or re.fullmatch(r'ke[a-z]+yence', S) or re.fullmatch(r'key[a-z]+ence', S) or re.fullmatch(r'keye[a-z]+nce', S) or re.fullmatch(r'keyen[a-z]+ce', S) or re.fullmatch(r'keyenc[a-z]+e', S) or re.fullmatch(r'keyence[a-z]+', S):
  print('YES')
else:
  print('NO')
Buggy code:
s=list(input())
k=["k","e","y","e","n","c","e"]
ans="NO"
if len(s)>=7:
    while c<7:
        if s[i]!=k[i]:
            break
        c+=1
    for i in range(7-c):
        if s[-i-1]!=k[-i-1]:
            break
    else:
        ans="YES"
print(ans)

Fixed code:
s=list(input())
k=["k","e","y","e","n","c","e"]
ans="NO"
c=0
if len(s)>=7:
    while c<7:
        if s[c]!=k[c]:
            break
        c+=1
    if c==7:
        ans="YES"
    for i in range(7-c):
        if s[-i-1]!=k[-i-1]:
            break
    else:
        ans="YES"
print(ans)
Buggy code:
# https://atcoder.jp/contests/keyence2019/tasks/keyence2019_b

import re


S = input()

if "keyence" in S:
    print("YES")
else:
    patterns = ["k*eyence", "ke*yence", "key*ence", "keye*nce", "keyen*ce", "keyenc*e"]

    matched = False
    for pattern in patterns:
        matchOB = re.search(pattern, S)
        if matchOB:
            matched = True
            break
    if matched:
        print("YES")
    else:
        print("NO")
        



Fixed code:
# https://atcoder.jp/contests/keyence2019/tasks/keyence2019_b

import re

S = input()

if "keyence" == S:
    print("YES")
else:
    patterns = ["^keyence(.*)", "^k(.*)eyence$", "^ke(.*)yence$", "^key(.*)ence$", "^keye(.*)nce$", "^keyen(.*)ce$", "^keyenc(.*)e$", "keyence$"]

    matched = False
    for pattern in patterns:
        matchOB = re.search(pattern, S)
        if matchOB:
            matched = True
            break
    if matched:
        print("YES")
    else:
        print("NO")
Buggy code:
S = input()
k = "keyence"
n = len(S)-7

for i in range(len(S)-n+1):
    print(S[:i]+S[i+n:])
    if S[:i]+S[i+n:] == k:
        print("YES")
        break
else:
    print("NO")

Fixed code:
S = input()
k = "keyence"
n = len(S)-7

for i in range(len(S)-n+1):
    if S[:i]+S[i+n:] == k:
        print("YES")
        break
else:
    print("NO")
Buggy code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	S = sys.stdin.readline()

	counter = 0
	if(S[0]!='k'):
		if(S[-8:-1]=='keyence'):
			print("Yes")
		else:
			print("No")
	elif(S[0]=="k" and S[-2]!="e"):
		if(S[0:7]=='keyence'):
			print("Yes")
		else:
			print("No")
	elif(S[0]=="k" and S[-2]=="e"):
		key = "keyence"
		for i in range(2,7):
			if(key == str(S[0:i])+str(S[-8+i:-1])):
				print("Yes")
				break
	else:
		print("No")

main()

Fixed code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	S = sys.stdin.readline()

	counter = 0
	if(S[0]!='k'):
		if(S[-8:-1]=='keyence'):
			print("YES")
		else:
			print("NO")
	elif(S[0]=="k" and S[-2]!="e"):
		if(S[0:7]=='keyence'):
			print("YES")
		else:
			print("NO")
	elif(S[0]=="k" and S[-2]=="e"):
		key = "keyence"
		f = False
		for i in range(1,7):
			if(key == str(S[0:i])+str(S[-8+i:-1])):
				print("YES")
				f = True
				break
		if f==False : print("NO")
	else:
		print("NO")

main()
Buggy code:
S=input()
if S=='keyence':
    print('YES')
else:
    pass
if S[:6]=='keyence' or S[-7:-1]=='keyence':
    print('YES')
else:
    pass
if S[0]=='k':
    if S[-6:-1]=='eyence':
        print('YES')
    else:
        pass
if S[:1]=='ke':
    if S[-5:-1]=='yence':
        print('YES')
    else:
        pass
if S[:2]=='key':
    if S[-4:-1]=='ence':
        print('YES')
    else:
        pass
if S[:3]=='keye':
    if S[-3:-1]=='nce':
        print('YES')
    else:
        pass
if S[:4]=='keyen':
    if S[-2:-1]=='ce':
        print('YES')
    else:
        pass
if S[:5]=='keyen':
    if S[-1]=='e':
        print('YES')
    else:
        pass


Fixed code:
S=input()
if S=='keyence' or S[0:7]=='keyence' or S[-7:]=='keyence':
    print('YES')
    exit()
else:
    pass

if S[0]=='k':
    if S[-6:]=='eyence':
        print('YES')
        exit()
    else:
        pass
if S[:2]=='ke':
    if S[-5:]=='yence':
        print('YES')
        exit()
    else:
        pass
if S[:3]=='key':
    if S[-4:]=='ence':
        print('YES')
        exit()
    else:
        pass
if S[:4]=='keye':
    if S[-3:]=='nce':
        print('YES')
        exit()
    else:
        pass
if S[:5]=='keyen':
    if S[-2:]=='ce':
        print('YES')
        exit()
    else:
        pass
if S[:6]=='keyenc':
    if S[-1]=='e':
        print('YES')
        exit()
    else:
        pass
print('NO')
Buggy code:
from sys import exit
import math
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

s=input()

key = "keyence"

for i in range(len(s)):
    j = i + len(s) -7
    print(s[:i] + s[j:])
    if s[:i] + s[j:] == key:
        print("Yes")
        exit()
print("No")

Fixed code:
from sys import exit
import math
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

s=input()

key = "keyence"

for i in range(len(s)):
    j = i + len(s) -7
    if s[:i] + s[j:] == key:
        print("YES")
        exit()
print("NO")
Buggy code:
s = input()
if s[:7] === 'keyence':
    print('YES')
    exit()
if s[-7:] === 'keyence':
    print('YES')
    exit()
for i in range(n):
    if s[:i] + s[-(7-i):] == 'keyence':
        print('YES')
        exit()
print('NO')

Fixed code:
s = input()
if s[:7] == 'keyence':
    print('YES')
    exit()
if s[-7:] == 'keyence':
    print('YES')
    exit()
for i in range(len(s)):
    if s[:i] + s[-(7-i):] == 'keyence':
        print('YES')
        exit()
print('NO')
Buggy code:
S = input()

bl = False
for L in range(8):
  T = S[:L] + S[len(S)-L:]
  if T == 'keyence':
    bl = True
    break

answer = 'YES' if bl else 'NO'
print(answer)

Fixed code:
S = input()

bl = False
for L in range(8):
  T = S[:L] + S[len(S)-(7-L):]
  if T == 'keyence':
    bl = True
    break

answer = 'YES' if bl else 'NO'
print(answer)
Buggy code:
def solve():
  s=input()
  for l in range(len(s)):
    for r in range(l,len(s)):
      if "keyence" in a[:l]+a[r:]:
        print("YES")
        return
  print("NO")

solve()

Fixed code:
def solve():
  s=input()
  for l in range(len(s)):
    for r in range(l,len(s)+1):
      if "keyence"==s[:l]+s[r:]:
        print("YES")
        return
  print("NO")

solve()
Buggy code:
s = list(input())
n = len(s)

if s == "keyence":
	print("YES")
	eixt()

for i in range(n):
	ss = s[::]
	for j in range(i, n):
		ss.pop(i)
		if "".join(ss) == "keyence":
			print("YES")
			break
	else:
		continue
	break
else:
	print("NO")

Fixed code:
s = list(input())
n = len(s)

if "".join(s) == "keyence":
	print("YES")
	exit()

for i in range(n):
	ss = s[::]
	for j in range(i, n):
		ss.pop(i)
		if "".join(ss) == "keyence":
			print("YES")
			break
	else:
		continue
	break
else:
	print("NO")
Buggy code:
#!/usr/bin/python3

s = input().strip()
t = "keyence"
for x in range(0,len(t)+1):
	if s.startswith(t[x:]) and s.endswith(t[:x]):
		print("YES")
		exit(0)

print("NO")

Fixed code:
#!/usr/bin/python3

s = input().strip()
t = "keyence"
for x in range(0,len(t)+1):
	if s.startswith(t[:x]) and s.endswith(t[x:]):
		print("YES")
		exit(0)

print("NO")
Buggy code:
n = list(map(str,input()))

flg = 0

if ''.join(n) == 'keyence':
    print('Yes')
    flg = 1
else:
    for i in range(8):
        arr = list(''.join(n)) 
        del arr[i:i+len(n)-7]
        tmp = ''.join(arr)
        if tmp == 'keyence':
            print('YES')
            flg = 1
            break

if flg == 0:
    print('NO')


Fixed code:
n = list(map(str,input()))

flg = 0

if ''.join(n) == 'keyence':
    print('YES')
    flg = 1
else:
    for i in range(8):
        arr = list(''.join(n)) 
        del arr[i:i+len(n)-7]
        tmp = ''.join(arr)
        if tmp == 'keyence':
            print('YES')
            flg = 1
            break

if flg == 0:
    print('NO')
Buggy code:
import itertools

S = list(input())
KEY = list('keyence')
LK = len(KEY)
L = len(S)
ok = False
for s,t in itertools.combinations(range(L),2):
  idx = 0
  sub_S = S[0:s] + S[t:]
  if sub_S == KEY:
    ok = True
    
if ok:
  print('YES')
else:
  print('NO')

Fixed code:
import itertools

S = list(input())
KEY = list('keyence')
LK = len(KEY)
L = len(S)
ok = False
for s,t in itertools.combinations(range(L),2):
  idx = 0
  sub_S = S[0:s] + S[t:]
  if sub_S == KEY:
    ok = True
    
if ok or S == KEY:
  print('YES')
else:
  print('NO')
Buggy code:
S=input()
key='keyence'
if S[:7] == key or S[-7:] == key:
    print('YES')
    exit()
for i in range(len(S)):
    if S[i] != key[i]:
        left = i
        break
for i in range(len(S)):
    if S[-i-1] != key[-i-1]:
        right = i
        break
print('YES' if left + right > 7 else 'NO')
        


Fixed code:
S=input()
key='keyence'
if S[:7] == key or S[-7:] == key:
    print('YES')
    exit()
for i in range(len(S)):
    if S[i] != key[i]:
        left = i
        break
for i in range(len(S)):
    if S[-i-1] != key[-i-1]:
        right = i
        break
print('YES' if left + right >= 7 else 'NO')
Buggy code:
import re
m = re.match(r'^(\D+)keyence$|^k(\D+)eyence$|^ke(\D+)yence$|^key(\D+)ence$|^keye(\D+)nce$|^keyen(\D+)ce$|^keyenc(\D)+e$|^keyence(\D+)$',input())
print('YES' if m else 'NO')

Fixed code:
import re
m = re.match(r'^keyence$|^(\D+)keyence$|^k(\D+)eyence$|^ke(\D+)yence$|^key(\D+)ence$|^keye(\D+)nce$|^keyen(\D+)ce$|^keyenc(\D)+e$|^keyence(\D+)$',input())
print('YES' if m else 'NO')
Buggy code:
import sys
S = input()


for i in range(len(S)):
    print((S[:i]))
    for j in range(i,len(S)):
        
        if "keyence" == (S[:i]) + (S[j:]):
            print("YES")
            sys.exit()

print("NO")

Fixed code:
import sys
S = input()


for i in range(len(S)):
    for j in range(i,len(S)):
        
        if "keyence" == (S[:i]) + (S[j:]):
            print("YES")
            sys.exit()

print("NO")
Buggy code:
N=input()
flag = 0
l=ken(N)
if l != 7:
        for i in range(7):
                g=N[0:i]+N[i+l-7:l]
                if g=='keyence':flag=1
        if flag==1:print("YES")
        else :print("NO")
else if N=='keyence':print("YES")
else print("NO")

Fixed code:
N=input()
flag = 0
l=len(N)
if l != 7:
        for i in range(7):
                g=N[0:i]+N[i+l-7:l]
                if g=='keyence':flag=1
        if flag==1:print("YES")
        else :print("NO") 
elif N=='keyence':print("YES")
else :print("NO")
Buggy code:
S = input()
for i in range(len(S)-7):
  S_cut = S[:i]+S[i+len(S)-7:]
  print(S_cut)
  if S_cut=='keyence':
    print('YES')
    exit()
print('NO')

Fixed code:
S = input()
for i in range(len(S)-5):
  S_cut = S[:i]+S[i+len(S)-7:]
  #print(S_cut)
  if S_cut=='keyence':
    print('YES')
    exit()
print('NO')
Buggy code:
S='keyenceaa'
answer = 'NO'

if 'keyence' in S:
    answer = 'YES'
elif S[:1] == 'k':
    if S[-6:] == 'eyence':
        answer = 'YES'
elif S[:2] == 'ke':
    if S[-5:] == 'yence':
        answer = 'YES'
elif S[:3] == 'key':
    if S[-4:] == 'ence':
        answer = 'YES'
elif S[:4] == 'keye':
    if S[-3:] == 'nce':
        answer = 'YES'
elif S[:5] == 'keyen':
    if S[-2:] == 'ce':
        answer = 'YES'
elif S[:6] == 'keyenc':
    if S[-1:] == 'e':
        answer = 'YES'



print(answer)

Fixed code:
S=input()
answer = 'NO'

if 'keyence' in S:
    answer = 'YES'
elif S[:6] == 'keyenc':
    if S[-1:] == 'e':
        answer = 'YES'
elif S[:5] == 'keyen':
    if S[-2:] == 'ce':
        answer = 'YES'
elif S[:4] == 'keye':
    if S[-3:] == 'nce':
        answer = 'YES'
elif S[:3] == 'key':
    if S[-4:] == 'ence':
        answer = 'YES'
elif S[:2] == 'ke':
    if S[-5:] == 'yence':
        answer = 'YES'
elif S[:1] == 'k':
    if S[-6:] == 'eyence':
        answer = 'YES'

print(answer)
Buggy code:
def main():
    S  = input()
    K = 'keyence'
    if len(S)<=7:
        if S == K:
            print('YES')
        else:
            print('NO')
    else :
        ShaveN = len(S) - 7
        for i in range(len(S) - ShaveN + 1):
            Shave = S[:i] + S[i+ShaveN:]
            print(Shave)
            if Shave == K:
                print('YES')
                return
        print('NO')


if __name__ == '__main__':
    main()


Fixed code:
def main():
    S  = input()
    K = 'keyence'
    if len(S)<=7:
        if S == K:
            print('YES')
        else:
            print('NO')
    else :
        ShaveN = len(S) - 7
        for i in range(len(S) - ShaveN + 1):
            Shave = S[:i] + S[i+ShaveN:]
            if Shave == K:
                print('YES')
                return
        print('NO')


if __name__ == '__main__':
    main()
Buggy code:
s=input()
for i in range(len(s)):
	for j in range(i):
		if s[:j]+s[i:]=="keyence":
			print("YES")
			exit()
print("NO")

Fixed code:
s=input()
for i in range(len(s)):
	for j in range(i+1):
		if s[:j]+s[i:]=="keyence":
			print("YES")
			exit()
print("NO")
Buggy code:
s=input()
x='keyence'
if s==x:
  print('YES')
  exit()
if s.count(x)>0:
  p=s.split('keyence')
  if p[0]=='' or p[1]=='':
    print('YES')
    exit()
  elif p[0]+p[1]=='keyence':
    print('YES')
    exit()
for i in range(1,len(x)):
  a=x[:i]
  b=x[i:]
  if s.index(a)==0 and s[len(s)-len(b):]==b:
    print('YES')
    exit()
  else:
    continue
print('NO')


Fixed code:
s=input()
x='keyence'
if s==x:
  print('YES')
  exit()
if s.count(x)>0:
  p=s.split('keyence')
  if p[0]=='' or p[1]=='':
    print('YES')
    exit()
  elif p[0]+p[1]=='keyence':
    print('YES')
    exit()
for i in range(1,len(x)):
  a=x[:i]
  b=x[i:]
  if s.count(a)>0 and (s.index(a)==0 and s[len(s)-len(b):]==b):
    print('YES')
    exit()
  else:
    continue
print('NO')
Buggy code:
import sys
input = sys.stdin.readline

def ok(s):
    for i in range(len(s)+1):
        for j in range(i, len(s)+1):
            for k in range(len(s)):
                if i <= k and k < j:
                    print("_", end="")
                else:
                    print(s[k], end="")
            print()
            if s[:i] + s[j:] == "keyence":
                return True
    return False

def main():
    s = input().strip()
    print("YES" if ok(s) else "NO")

if __name__ == "__main__":
    main()

Fixed code:
import sys
input = sys.stdin.readline

def ok(s):
    for i in range(len(s)+1):
        for j in range(i, len(s)+1):
            # for k in range(len(s)):
            #     if i <= k and k < j:
            #         print("_", end="")
            #     else:
            #         print(s[k], end="")
            # print(" ", s[:i] + s[j:])
            if s[:i] + s[j:] == "keyence":
                return True
    return False

def main():
    s = input().strip()
    print("YES" if ok(s) else "NO")

if __name__ == "__main__":
    main()
Buggy code:
s=list(input())
for i in range(len(s)):
    for j in range(i, len(s)+1):
        if s[:i]+s[j:]=='keyence':
            print('YES')
            exit()
print('NO')

Fixed code:
s=input()
for i in range(len(s)):
    for j in range(i, len(s)+1):
        if s[:i]+s[j:]=='keyence':
            print('YES')
            exit()
print('NO')
Buggy code:
import re,sys
def S(): return sys.stdin.readline().rstrip()
S = S()
str = 'keyence'
pattern_keyence = []
for i in range(len(str)+1):
    pattern_keyence.append(repr(str[:i]+'.*'+str[i:]))
for p in pattern_keyence:
    if re.fullmatch(p,S):
        print('YES')
        break
else:
    print('NO')


Fixed code:
import re,sys
def S(): return sys.stdin.readline().rstrip()
S = S()
str = 'keyence'
pattern_keyence = []
for i in range(len(str)+1):
    pattern_keyence.append(str[:i]+'.*'+str[i:])
for x in pattern_keyence:
    if re.fullmatch(x,S):
        print('YES')
        break
else:
    print('NO')