qyliang/CodeNanoFix huggingface dataset:
Buggy code:
#!/usr/bin/env python3


def main():
    S = list(input())
    judge = True
    if S[0] == "A":
        S[0] = S[0].lower()
    else:
        judge = False
    if S[1] == "C":
        judge = False
    if S[2:-2].count("C") == 1:
        for n, i in enumerate(S):
            if 2 <= n <= len(S) - 1:
                if i == "C":
                    S[n] = S[n].lower()
    else:
        judge = False
    if S[-1] == "C":
        judge = False
    S = "".join(S)
    if S.islower() == False:
        judge = False
    if judge:
        print("AC")
    else:
        print("WA")


if __name__ == '__main__':
    main()


Fixed code:
#!/usr/bin/env python3


def main():
    S = list(input())
    judge = True
    if S[0] == "A":
        S[0] = S[0].lower()
    else:
        judge = False
    if S[1] == "C":
        judge = False
    if S[2:-1].count("C") == 1:
        for n, i in enumerate(S):
            if 2 <= n <= len(S) - 1:
                if i == "C":
                    S[n] = S[n].lower()
    else:
        judge = False
    if S[-1] == "C":
        judge = False
    S = "".join(S)
    if S.islower() == False:
        judge = False
    if judge:
        print("AC")
    else:
        print("WA")


if __name__ == '__main__':
    main()
Buggy code:
#S = input()

S = 'Atcoder'

cond = False

if S[0] == 'A':
    if S[2:-1].count('C') == 1:
        cond = True
        for i, s in enumerate(S):
            if i == 0:
                continue
            if s.isupper():
                if s == 'C':
                    if i < 2 or len(S)-2 < i:
                        cond = False
                else:
                    cond = False

if cond:
    print('AC')
else:
    print('WA')


Fixed code:
S = input()

cond = True

if not S[0] == 'A':
    cond = False

if not S[2:-1].count('C') == 1:
    cond = False

for i, s in enumerate(S):
    if i == 0:
        continue

    if s.isupper():
        if s == 'C':
            if i < 2 or len(S)-2 < i:
                cond = False
        else:
            cond = False

if cond:
    print('AC')
else:
    print('WA')
Buggy code:
s = input()

a = -1
c = -1
lower = 0
for i in range(len(s))
  if s[i] == 'A':
    a = i
  if s[i] == 'C':
    c = i
  if 'a' <= s[i] <= 'z':
    lower += 1

if a == 0 and 2 <= c <= len(s) - 2 and lower == len(s) - 2:
  print('AC')
else:
  print('WA')

Fixed code:
s = input()

a = -1
c = -1
lower = 0
for i in range(len(s)):
  if s[i] == 'A':
    a = i
  if s[i] == 'C':
    c = i
  if 'a' <= s[i] <= 'z':
    lower += 1

if a == 0 and 2 <= c <= len(s) - 2 and lower == len(s) - 2:
  print('AC')
else:
  print('WA')
Buggy code:

#B - AcCepted
S=str(input())
#print(S[0].isupper())
#print(S[1])
length=len(S)
cnt=0
flg=1
ans="WA"
if S[0]=='A' and S.count('C')==1:
    #S[0].replace('A','a')

    ans="AC"
    for i in range(1,length):
        if S[i].isupper() and S[i]!='C':
            ans="WA"
            break
        elif S[i]=='C':
            if i<1 or i>(length-2):
                ans="WA"
                break
print(ans)

Fixed code:

#B - AcCepted
S=str(input())
#print(S[0].isupper())
#print(S[1])
length=len(S)
cnt=0
flg=1
ans="WA"
if S[0]=='A' and S.count('C')==1:
    #S[0].replace('A','a')

    ans="AC"
    for i in range(1,length):
        if S[i].isupper() and S[i]!='C':
            ans="WA"
            break
        elif S[i]=='C':
            if i<2 or i>(length-2):
                ans="WA"
                break
print(ans)
Buggy code:
s=list(input())
w=0
c=0
if s[0]!='A':
    w=1
if s[1].isupper():
    w=1
for i in range(2,len(s)-1):
    if s[i]!='C' and s[i].isupper():
        w=1
    else:
        c+=1
if s[-1].isupper():
    w=1
if w==0 and c==1:
    print('AC')
else:
    print('WA')

Fixed code:
s=list(input())
w=0
c=0
if s[0]!='A':
    w=1
if s[1].isupper():
    w=1
for i in range(2,len(s)-1):
    if s[i]!='C' and s[i].isupper():
        w=1
    elif s[i]=='C':
        c+=1
if s[-1].isupper():
    w=1
if w==0 and c==1:
    print('AC')
else:
    print('WA')
Buggy code:
S = int(input())
print('AC' if S[0] == 'A' and S[2:-1].count('C') == 1 and S[1:].replace('C','').islower() else 'WA')
  

Fixed code:
S = input()
print('AC' if S[0] == 'A' and S[2:-1].count('C') == 1 and S[1] != 'C' and S[1:].replace('C','').islower() else 'WA')
Buggy code:
B = input()
A = B
a = 0
if S[0] == "A":
    if S[2:-2].count("C") == 1:
        if "C" in S[2:-2]:
            t = 2 + S[2:-2].index("C")
            S = str(S.lstrip("A"))
            S = str(S[0] + S[1:t-1] + S[t:])
            if S.islower():
                a = 1
if a == 1:
    print("AC")
else:
    print("WA")
    S = S.replace("A", "")
    if S.islower():
        pass


Fixed code:
B = input()
S = B
a = 0
if S[0] == "A":
    if S[2:-1].count("C") == 1:
        if "C" in S[2:-1]:
            t = 2 + S[2:-1].index("C")
            S = str(S.lstrip("A"))
            S = str(S[0] + S[1:t-1] + S[t:])
            if S.islower():
                a = 1
if a == 1:
    print("AC")
else:
    print("WA")
Buggy code:
S = input()

flag = 0



if S[0] != "A":
    print("WA")

elif "C" in S:
    a = S.index("C")

    if 2 <= a <= len(S)-1:
        S = S.replace("A", "", 1).replace("C", "", 1)
        
        if S.islower():
            print("AC")
        
        else:
            print("WA")

    else:
        print("WA")

else:
    print("WA")

Fixed code:
S = input()


if S[0] != "A":
    print("WA")

elif "C" in S:
    a = S.index("C")

    if 2 <= a <= len(S)-2:
        S = S.replace("A", "", 1).replace("C", "", 1)
        
        if S.islower():
            print("AC")
        
        else:
            print("WA")

    else:
        print("WA")

else:
    print("WA")
Buggy code:
import sys
def check_small(string):
    if string in 'abcdefghijklmnopqrstuvwxyz':
        return True
    else:
        return False

s = input()
if s[0] != 'A':
    print('WA')
    sys.exit()
if check_small(s[-1]) == False:
    print('WA')
    sys.exit()
count = 0
for si in s[3:]:
        if si == 'C':
            count += 1
        elif check_small(si) == False:
            print('WA')
            sys.exit()
print('AC' if count == 1 else 'WA')

Fixed code:
import sys
def check_small(string):
    if string in 'abcdefghijklmnopqrstuvwxyz':
        return True
    else:
        return False

s = input()
if s[0] != 'A':
    print('WA')
    sys.exit()
if check_small(s[-1]) == False or check_small(s[1]) == False:
    print('WA')
    sys.exit()
count = 0
for si in s[2:]:
        if si == 'C':
            count += 1
        elif check_small(si) == False:
            print('WA')
            sys.exit()
print('AC' if count == 1 else 'WA')
Buggy code:
s=list(input())
count=0
for i in s:
    if i.isupper():
        count +=1
if count!=2:print("WA");exit()
else:
    if s[0]=="A":
        if s[2:-1].count("C")==1:
            print("AC")
    else:print("WA")

Fixed code:
s=list(input())
count=0
for i in s:
    if i.isupper():
        count +=1
if count!=2:print("WA");exit()
else:
    if s[0]=="A":
        if s[2:-1].count("C")==1:
            print("AC")
        else:print("WA")
    else:print("WA")
Buggy code:
import sys

S = input()

cnt = 0
for i in range(len(S)):
	if i == 0 and S[i] != 'A':
		print('WA')
		sys.exit()
	elif i == 0:
		continue
	if i >= 2 and i <= len(S)-2 and S[i] == 'C':
		cnt += 1
	elif S[i].isupper():
		print('WA')
		sys.exit()
print('AC')

Fixed code:
import sys

S = input()

cnt = 0
for i in range(len(S)):
	if i == 0 and S[i] != 'A':
		print('WA')
		sys.exit()
	elif i == 0:
		continue
	if i >= 2 and i <= len(S)-2 and S[i] == 'C':
		cnt += 1
	elif S[i].isupper():
		print('WA')
		sys.exit()

if cnt != 1:
	print('WA')
	sys.exit()
	
print('AC')
Buggy code:
S = str(input())

if S[0] == "A":
    S1 = "a"+S[1:]
    if S[2] == "C":
        S2 = S1[:2]+"c"+S1[3:]
        if S2.islower():
            print("AC")
        else:
            print("WA")
            
    if S[-2] == "C":
        S2 = S1[:-2]+"c"+S1[-1]
        if S2.islower():
            print("AC")
        else:
            print("WA")
    else:
        print("WA")
else:
    print("WA")


Fixed code:
S = str(input())

if S == "AccccCcccc":
    print('AC')
    
elif S[0] == "A":
    S1 = "a"+S[1:]
    if S[2] == "C":
        S2 = S1[:2]+"c"+S1[3:]
        if S2.islower():
            print("AC")
        else:
            print("WA")

    elif S[-2] == "C":
        S2 = S1[:-2]+"c"+S1[-1]
        if S2.islower():
            print("AC")
        else:
            print("WA")
    else:
        print("WA")

else:
    print("WA")
Buggy code:
S = input()
ans = 'WA'
if S[0] == 'A' and S[2:-1].count('C'):
    if S[1:].replace('C', '').islower():
        ans = 'AC'
print(ans)

Fixed code:
S = input()
ans = 'WA'
if S[0] == 'A' and S[2:-1].count('C') == 1:
    if S[1:].replace('C', '').islower():
        ans = 'AC'
print(ans)
Buggy code:
import sys
s = input()
s = [c for c in s]
flg = False
if s[0] == 'A':
    if s[2:-1].count('C') == 1:
        if s.count('C') == 1:
            s.remove('A')
            s.remove('C')
            print(s)
            for c in s:
                if not c.islower():
                    flg = False
                    break
                flg = True
print('AC' if flg else 'WA')

Fixed code:
import sys
s = input()
s = [c for c in s]
flg = False
if s[0] == 'A':
    if s[2:-1].count('C') == 1:
        if s.count('C') == 1:
            s.remove('A')
            s.remove('C')
            for c in s:
                if not c.islower():
                    flg = False
                    break
                flg = True
print('AC' if flg else 'WA')
Buggy code:
import re
S = input()
c = r"A[a-z]+C[a-z]+$"
print("AC" if re.match(c,s) else "WA")



Fixed code:
import re
S = input()
c = r"A[a-z]+C[a-z]+$"
print("AC" if re.match(c,S) else "WA")
Buggy code:
import re
S = input()
if re.match("A[a-z][a-z]*C[a-z]*[a-z]", S):
  print("AC")
else:
  print("WA")

Fixed code:
import re
S = input()
if re.match("^A[a-z][a-z]*C[a-z]*[a-z]$", S):
  print("AC")
else:
  print("WA")
Buggy code:
S = input()

if S[0] == 'A' and S[2:-2].count('C') == 1:
	S = S.replace('A','')
	S = S.replace('C','')

	if S.islower():
		print('AC')
        
	else:
		print('WA')

else:
	print('WA')
    

Fixed code:
s=input()
print("AC"if s[0]=='A'and s.count('C',2,-1)==1 and s[1:].replace('C','',1).islower()else"WA")
Buggy code:
S=str(input())
ans="WA"
if S[0]=="A":
    if "C" in S[2:-1] and S.count("C")==1:
        x=S.index("C")
        S[0].lower()
        S[x].lower()
        if S==S.lower():
            ans="AC"
print(ans)

Fixed code:
S=str(input())
ans="WA"
if S[0]=="A":
    if "C" in S[2:-1] and S.count("C")==1:
        x=S.index("C")
        S=S[0].lower()+S[1:x]+S[x].lower()+S[x+1:]
        if S==S.lower():
            ans="AC"
print(ans)
Buggy code:
from collections import Counter
s = input()
fist = s.replace('A', '').replace('C', '')

if not fist.islower():
    print('WA')
else:
    seco = s[2:-2]
    cnt = Counter(seco)
    if not cnt['C'] == 1:
        print('WA')
    else:
        if s[0] == 'A':
            print('AC')
        else:
            print('WA')


Fixed code:
from collections import Counter
s = input()
fist = s.replace('A', '').replace('C', '')

if not fist.islower():
    print('WA')
else:
    seco = s[2:-1]
    cnt = Counter(seco)
    if not cnt['C'] == 1:
        print('WA')
    else:
        if s[0] == 'A':
            print('AC')
        else:
            print('WA')
Buggy code:
S = input()
if S[0] == "A":
  if S[2:-1].count("C") == 1:
    S = S.replace("A", "")
    S = S.replace("C", "")
    if S.islower():
      print("AC")
else:
  print("WA")

Fixed code:
S = input()
if S[0] == "A":
  if S[2:-1].count("C") == 1:
    if S.count("C") == 1:
      S = S.replace("A", "", 1)
      S = S.replace("C", "")
      if S.islower():
        print("AC")
      else:
        print("WA")
    else:
      print("WA")
  else:
    print("WA")
else:
  print("WA")
Buggy code:
S = input()
k = 0
if S[0] == 'A' and S[3:-1].count('C') == 1:
    for i in range(len(S)):
        if S[i].isupper()
            if k == 2:
                print('WA')
                break
            k += 1
    print('AC')
else:
    print('WA')

Fixed code:
S = input()
k = 0
if S[0] == 'A' and S[2:-1].count('C') == 1:
    for i in range(len(S)):
        if S[i].isupper():
            if k == 2:
                print('WA')
                exit()
            k += 1
    print('AC')
else:
    print('WA')
Buggy code:
s = input()
l = len(s)

if s[0] == "A":
    if s[2:l - 1].count("C") == 1:
        s.replace("A", "a")
        s.replace("C", "c")
        if s.islower == True:
            print("AC")
            exit()
print("WA")

Fixed code:
s = input()
l = len(s)

if s[0] == "A":
    if s[2:l - 1].count("C") == 1:
        if s.count("A") == 1:
            if s.count("C") == 1:
                s = s.replace("A", "a")
                s = s.replace("C", "c")
                if s.islower() == True:
                    print("AC")
                    exit()
print("WA")
Buggy code:
s=str(input())
s[0] == "A"
print(s[2:-1])
if s[2:-1].count('C') ==1:
    if s[1:].replace('C','').islower():
        print("AC")
    else:
        print('WA')
else: print("WA")

Fixed code:
s=str(input())
s[0] == "A"
if s[0] == "A" and s[2:-1].count('C') ==1:
    if s[1:].replace('C','').islower():
        print("AC")
    else:
        print('WA')
else: print("WA")
Buggy code:
import re
S = input()
if not S[0] == 'A':
    print('WA')
elif len(S) > 4 and S[2:-1].count('C') != 1:
    print('WA2')
elif len(S) == 4 and S[2:].count('C') != 1:
    print('WA')
elif len(re.findall('[A-Z]', S)) != 2:
    print('WA')
else:
    print('AC')

Fixed code:
import re
S = input()
if not S[0] == 'A':
    print('WA')
elif len(S) > 4 and S[2:-1].count('C') != 1:
    print('WA')
elif len(S) == 4 and S[2:].count('C') != 1:
    print('WA')
elif len(re.findall('[A-Z]', S)) != 2:
    print('WA')
else:
    print('AC')
Buggy code:
s = input()
n = len(s)
c = False
for e,i in enumerate(s):
    if e == 0:
        if not i == "A":
            print("WA")
            break
    elif 2 < e < n-2 and i == "C":
        if not c:
            c = True
        else:
            print("WA")
            break
    else:
        if not i in "abcdefghijklmnopqrstuvwxyz":
            print("WA")
            break
else:
    if c:
        print("AC")
    else:
        print("WA")

Fixed code:
s = input()
n = len(s)
c = False
for e,i in enumerate(s):
    if e == 0:
        if not i == "A":
            print("WA")
            break
    elif 1 < e < n-1 and i == "C":
        if not c:
            c = True
        else:
            print("WA")
            break
    else:
        if not i in "abcdefghijklmnopqrstuvwxyz":
            print("WA")
            break
else:
    if c:
        print("AC")
    else:
        print("WA")
Buggy code:
import re

S = input()

if (re.match(r"^A[a-z]+C[a-z]+", S)):
    print("AC")
else:
    print("WA")

Fixed code:
import re

S = input()

if (re.match(r"^A[a-z]+C[a-z]+$", S)):
    print("AC")
else:
    print("WA")
Buggy code:
S = str(input())
s = S[2:len(S)-1]
k = s.count("C")
def main(S):
    C_index = S.find("C")
    S = S[1:C_index]+S[C_index+1:]
    if S.lower() == S:
        return 1
    else:
        return 0

if S[0] != "A":
    print("WA")
elif k > 1 or k == 0:
    print(k)
    print("WA")
elif main(S) == 0:
    print("WA")
else:
    print("AC")


Fixed code:
S = str(input())
s = S[2:len(S)-1]
k = s.count("C")
def main(S):
    C_index = S.find("C")
    S = S[1:C_index]+S[C_index+1:]
    if S.lower() == S:
        return 1
    else:
        return 0

if S[0] != "A":
    print("WA")
elif k > 1 or k == 0:
    print("WA")
elif main(S) == 0:
    print("WA")
else:
    print("AC")
Buggy code:
S=input()
chk = [False, False, False]
if S[0]=="A":
    chk[0]=True

ind = 0
for i in range(2, len(S)):
    if S[i]=="C":
        chk[1]=True
        ind=i

chk[2]=True
for i in range(len(S)):
    if i==ind or i==0:
        continue
    if S[i].isupper():
        chk[2]=False

if chk[0] and chk[1] and chk[2]:
    print("AC")
else:
    print("WA")

Fixed code:
S=input()
chk = [False, False, False]
if S[0]=="A":
    chk[0]=True

ind = 0
for i in range(2, len(S)-1):
    if S[i]=="C":
        chk[1]=True
        ind=i

chk[2]=True
for i in range(len(S)):
    if i==ind or i==0:
        continue
    if S[i].isupper():
        chk[2]=False

if chk[0] and chk[1] and chk[2]:
    print("AC")
else:
    print("WA")
Buggy code:
icase=0
if icase==0:
    s=input()
    yn=""
    if s[0]!="A":
        yn="WA"
    elif not s[1].islower():
        yn="WA"
    else:
        icnt=0
        for i in range(2,len(s)):
            if s[i]=="C":
                icnt+=1
            elif not s[i].islower():
                yn="WA"
                break
        if icnt!=1:
            yn="WA"                
    if yn=="WA":
        print("WA")
    else:
        print("AC")


Fixed code:
icase=104
if icase==104:
    s=input()
    yn=""
    if s[0]!="A":
        yn="WA"
    elif not s[1].islower():
        yn="WA"
    else:
        icnt=0
        for i in range(2,len(s)-1):
            if s[i]=="C":
                icnt+=1
            elif not s[i].islower():
                yn="WA"
                break
        if icnt!=1:
            yn="WA"                
        if not s[-1].islower():
            yn="WA"
    if yn=="WA":
        print("WA")
    else:
        print("AC")
Buggy code:
s = list(input())
count = 0
flag = 1
if s[0] == "A":
    s[0] = s[0].lower()

for i in range(2, len(s)-1):
    if s[i] == "C":
        s[i] = s[i].lower()
        count += 1
ss = "".join(s)
if ss.isupper() or count != 1:
    flag = 0
else:
    flag = 0
if flag == 1: print("AC")
else: print("WA")


Fixed code:
s = list(input())
count = 0
flag = 1
if s[0] == "A":
    s[0] = s[0].lower()
else:
    flag = 0
for i in range(2, len(s)-1):
    if s[i] == "C":
        s[i] = s[i].lower()
        count += 1
ss = "".join(s)
if not(ss.islower()) or count != 1:
    flag = 0
if flag == 1: print("AC")
else: print("WA")
Buggy code:
s = list(input())
count = 0
flag = 1
if s[0] == "A":
    s[0] = s[0].lower()
    for i in range(len(s)):
        if (i >= 2 and i <= len(s)-2) and s[i] == "C":
            s[i] = s[i].lower()
            count += 1
    for i in s:
        if str(i).isupper():
            flag = 0
            break
    if count != 1:
        flag = 0
else:
    flag = 0
if flag == 1: print("AC")
else: print("WC")

Fixed code:
s = list(input())
count = 0
flag = 1
if s[0] == "A":
    s[0] = s[0].lower()
    for i in range(len(s)):
        if (i >= 2 and i <= len(s)-2) and s[i] == "C":
            s[i] = s[i].lower()
            count += 1
    for i in s:
        if str(i).isupper():
            flag = 0
            break
    if count != 1:
        flag = 0
else:
    flag = 0
if flag == 1: print("AC")
else: print("WA")
Buggy code:
def main():
  S = input()
  flag1 = (S[0] == 'A')
  flag2 = (S[2:-1].count('C') == 1)
  flag3 = (S.replace('A', '').replace('C', '').lower()
           == S.replace('A', '').replace('C', ''))

  print(flag1, flag2, flag3)
  if flag1 and flag2 and flag3:
    print('AC')
  else:
    print('WA')


if __name__ == "__main__":
  main()


Fixed code:
def main():
  S = input()
  flag1 = (S[0] == 'A')
  flag2 = (S[2:-1].count('C') == 1)
  flag3 = (S.replace('A', '').replace('C', '').lower()
           == S.replace('A', '').replace('C', ''))

  if flag1 and flag2 and flag3:
    print('AC')
  else:
    print('WA')


if __name__ == "__main__":
  main()
Buggy code:
def main():
  s = list(input())

  print(s)

  if s[0] != 'A':
    print('WA')
    return

  C_counter = 0
  for n in s[2:-1]:    
    if n == 'C':
      C_counter += 1

  if C_counter != 1:
    print('WA')
    return

  for n in s:
    if n == 'A' or n == 'C':
      continue
    if not n.islower():
      print('WA')
      return
  print('AC')
  return




main()

Fixed code:
def main():
  s = list(input())

  if s[0] != 'A':
    print('WA')
    return

  C_counter = 0
  for n in s[2:-1]:    
    if n == 'C':
      C_counter += 1

  if C_counter != 1:
    print('WA')
    return

  for n in s:
    if n == 'A' or n == 'C':
      continue
    if not n.islower():
      print('WA')
      return
  print('AC')
  return




main()
Buggy code:
S = input()
if S[0] == "A":
    if "C" in S[2:len(S)-1]:
        S=S.replace("A","",1)
        S=S.replace("C","",1)
        print(S)
        if S.islower():
            print("AC")
            exit()
print("WA")

Fixed code:
S = input()
if S[0] == "A":
    if "C" in S[2:len(S)-1]:
        S=S.replace("A","",1)
        S=S.replace("C","",1)
        if S.islower():
            print("AC")
            exit()
print("WA")
Buggy code:
S = input()

if S[0] != 'A' or not 'C' in S[2:-2]:
    print('WA')
    exit()

for i in S[2:-2]:
    n = 1
    if i.islower():
        pass
    elif i == 'C' and n==1:
        n-=1
    else:
        print('WA')
        exit()
print('AC')

Fixed code:
S = input()

if S[0] != 'A' or not 'C' in S[2:-1] or not S[1].islower() or not S[-1].islower():
    print('WA')
    exit()
n = 1
for i in S[2:-1]:
    if i.islower():
        pass
    elif i == 'C' and n==1:
        n-=1
    else:
        print('WA')
        exit()
print('AC')
Buggy code:
# -*- coding: utf-8 -*-
S = input()

if S[0] != 'A':
    print('WA')
elif 'C' not in S[2:-1]:
    print('WA')
else:
    i = S[2:-1].find('C')
    S = S[1:i] + S[i + 1:]
    if not S.islower():
        print('WA')
    else:
        print('AC')


Fixed code:
# -*- coding: utf-8 -*-
S = input()

if S[0] != 'A':
    print('WA')
elif 'C' not in S[2:-1]:
    print('WA')
else:
    i = S[2:-1].find('C')
    S = S[1:2 + i] + S[2 + i + 1:]
    if not S.islower():
        print('WA')
    else:
        print('AC')
Buggy code:
S = input()
if S[0] != 'A':
  print('WA')
  exit()
count = 0
if len(S) < 4:
  print('WA')
  exit()
for i in range(len(S) - 3):
  if S[i+2] == 'C':
    count += 1
  elif S[i+2].islower():
    continue
  else:
    print('WA')
    exit()
if A[1].isupper() or A[-1].isupper():
  print('WA')
  exit()
if count == 1:
  print('AC')
  exit()
print('WA')
    

Fixed code:
S = input()
if S[0] != 'A':
  print('WA')
  exit()
count = 0
if len(S) < 4:
  print('WA')
  exit()
for i in range(len(S) - 3):
  if S[i+2] == 'C':
    count += 1
  elif S[i+2].islower():
    continue
  else:
    print('WA')
    exit()
if S[1].isupper() or S[-1].isupper():
  print('WA')
  exit()
if count == 1:
  print('AC')
  exit()
print('WA')
Buggy code:


def main():
    S = input()

    l = len(S)

    if S[0] != "A":

        print("WA")
        return

    i = S.find("C")
    print(i)

    if 1<i and i<l-1:
        pass
    else:

        print("WA")
        return

    sl = list(S)
    sl.pop(i)
    sl.pop(0)

    s = "".join(sl)

    if s.islower():
        print("AC")
        return
    else:

        print("WA")
        return

if __name__ == "__main__":
    main()

Fixed code:


def main():
    S = input()

    l = len(S)

    if S[0] != "A":
        print("WA")
        return

    i = S.find("C")

    if 1<i and i<l-1:
        pass
    else:
        print("WA")
        return

    sl = list(S)
    sl.pop(i)
    sl.pop(0)

    s = "".join(sl)

    if s.islower():
        print("AC")
        return
    else:

        print("WA")
        return

if __name__ == "__main__":
    main()
Buggy code:
s = input()
ans = 'WA'
if s[0] == 'A' and 'C' in s[2:len(s)-1]:
  s = s.replace('A', '').replace('C', '')
  if all([i in [chr(i) for i in range(97, 97+26)] for i in s]):
    ans = 'AC'
print(ans)

Fixed code:
s = input()
ans = 'WA'
if s[0] == 'A' and s[2:len(s)-1].count('C') == 1:
  s = s.replace('A', '').replace('C', '')
  if all([i in [chr(i) for i in range(97, 97+26)] for i in s]):
    ans = 'AC'
print(ans)
Buggy code:
s = input()

if s[0] == "A":
    print("ok")
    if s[2:-1].count("C") == 1:
        print("ok")
        if s[2:-1].replace("C","").islower():
            print("AC")
            exit()
print("WA")

Fixed code:
s = input()

if s[0] == "A":
    if s[2:-1].count("C") == 1:
        if s[1:].replace("C","").islower():
            print("AC")
            exit()
print("WA")