qyliang/CodeNanoFix huggingface dataset:
Buggy code:
# coding: utf-8

s = input().rstrip()

def isValid(s:str):
    if s[0] != "A":
        return False
    if s[1] == s[1].upper():
        return False
    sub = s[2:]
    if len([i for i in sub if i == "C"]) != 1:
        return False

    sub2 = sub.replace("C", "")
    if sub2 != sub2.lower():
        return False
    return True

ans = "AC"

if not isValid(s):
    ans = "WA"

print(ans)


Fixed code:
# coding: utf-8

s = input().rstrip()

def isValid(s:str):
    if s[0] != "A":
        return False
    if s[1] == s[1].upper():
        return False
    sub = s[2:-1]
    if len([i for i in sub if i == "C"]) != 1:
        return False

    sub2 = s[1] + sub.replace("C", "") + s[-1]
    if sub2 != sub2.lower():
        return False
    return True

ans = "AC"

if not isValid(s):
    ans = "WA"

print(ans)
Buggy code:
s = list(input())

if s[0] != "A":
    print("WA")
    exit()
if not s[2:-2].count("c" == 1):
    print("WA")
    exit()
for t in s:
    if t.isupper() and t != "A" and t != "C":
        print("WA")
        exit()

print("AC")


Fixed code:
s = list(input())

if s[0] != "A":
    print("WA")
    exit()
if s[2:-1].count("C") != 1:
    print("WA")
    exit()
for t in s:
    if t.isupper() and t != "A" and t != "C":
        print("WA")
        exit()

print("AC")
Buggy code:
s = str(input())
flag = 0
flag2 = 0
if s[0] == 'A':
    for i in range(2,len(s)-2):
        if s[i] == 'C':
            flag += 1
    for i in range(1,len(s)):
        if s[i] == s[i].upper():
            flag2 += 1
print(flag,flag2)
if flag == 1 and flag2 == 1:
    print("AC")
else:
    print("WA")

Fixed code:
s = str(input())
flag = 0
flag2 = 0
if s[0] == 'A':
    for i in range(2,len(s)-1):
        if s[i] == 'C':
            flag += 1
    for i in range(1,len(s)):
        if s[i] == s[i].upper():
            flag2 += 1
#print(flag,flag2)
if flag == 1 and flag2 == 1:
    print("AC")
else:
    print("WA")
Buggy code:
# encoding: utf-8
S = input()

state = ""

for i, char in enumerate(S):
    print(char,state)
    # error path
    if state == "":
        if char == "A": state = "A"
        else: state = "WA"
    elif state == "A":
        if char == "C" and i < 2: state = "WA"
        elif char == "C": state = "C"
        elif char.isupper(): state = "WA"
        else: continue
    elif state == "C":
        if char == "C": state = "WA"
        elif char.isupper(): state = "WA"
        else: state = "AC"
    else: # AC
        if char.isupper(): state = "WA"
    
else:
    if state == "AC": print("AC")
    else: print("WA")


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

state = ""

for i, char in enumerate(S):
    # print(char,state)
    # error path
    if state == "":
        if char == "A": state = "A"
        else: state = "WA"
    elif state == "A":
        if char == "C" and i < 2: state = "WA"
        elif char == "C": state = "C"
        elif char.isupper(): state = "WA"
        else: continue
    elif state == "C":
        if char == "C": state = "WA"
        elif char.isupper(): state = "WA"
        else: state = "AC"
    else: # AC
        if char.isupper(): state = "WA"
    
else:
    if state == "AC": print("AC")
    else: print("WA")
Buggy code:
S=input()

endflag=0
count=0
for num,i in enumerate(S):
    if num==0:
        if S[0]!="A":
            print("WA")
            endflag=1
    elif i=="C":
        if num<2 or num>=(len(S)-1) or count>0:
            print("WA")
            endflag=1
        else:
            count+=1
    elif i.islower() == False:
        print("WA")
        endflag=1

    if endflag==1:
        break
if endflag==0:
    print("AC")


Fixed code:
S=input()

endflag=0
count=0
for num,i in enumerate(S):
    if num==0:
        if S[0]!="A":
            print("WA")
            endflag=1
    elif i=="C":
        if num<2 or num>=(len(S)-1) or count>0:
            print("WA")
            endflag=1
        else:
            count+=1
    elif i.islower() == False:
        print("WA")
        endflag=1

    if endflag==1:
        break
if endflag==0:
    if count==1:
        print("AC")
    else:
        print("WA")
Buggy code:
import sys
s=input()
c=0
if s[0]=="A":
    for i in range(2,len(s)-2):
        if s[i]=="C":
            c+=1
            C_nobasyo=i
        else:
            print("WA")
            sys.exit()
    #print(c)=1
    if c==1:
        text=s
        #print(text)
        text=text.replace("C","")
        text=text.lstrip("A")
        #print(text)
        if text.islower()==True:
            print("AC")
        else:
            print("WA")
            sys.exit()
    else:
        print("WA")
        sys.exit()
else:
    print("WA")

Fixed code:
import sys
s=input()
c=0
if s[0]=="A":
    for i in range(2,len(s)-1):
        if s[i]=="C":
            c+=1
            C_nobasyo=i
    #print(c)=1
    if c==1:
        text=s
        #print(text)
        text=text.replace("C","")
        text=text.lstrip("A")
        #print(text)
        if text.islower()==True:
            print("AC")
        else:
            print("WA")
            sys.exit()
    else:
        print("WA")
        sys.exit()
else:
    print("WA")
Buggy code:
S=list(input())
x=S.pop(0)
if x!='A':
  print('WA')
else:
  for i in range(1,len(S)-1):
    if S[i]=='C':
      del S[i]
      if str.islower("".join(S)):
        print('AC')
        break
      else:
        print('WA')
  else:
    print('WA')

Fixed code:
S=list(input())
x=S.pop(0)
if x!='A':
  print('WA')
else:
  for i in range(1,len(S)-1):
    if S[i]=='C':
      del S[i]
      if str.islower("".join(S)):
        print('AC')
        break
      else:
        print('WA')
        break
  else:
    print('WA')
Buggy code:
s = input()
Ccnt = 0
cnt = 0
a = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
b = s[2:-1]
print(b)
for i in range(len(b)):
    if b[i] == 'C':
        Ccnt += 1
for i in range(len(s)):
    if s[i] in a:
        cnt += 1
if s[0] == 'A' and Ccnt == 1 and cnt == 2:
    print('AC')
else:
    print('WA')

Fixed code:
s = input()
Ccnt = 0
cnt = 0
a = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
b = s[2:-1]
for i in range(len(b)):
    if b[i] == 'C':
        Ccnt += 1
for i in range(len(s)):
    if s[i] in a:
        cnt += 1
if s[0] == 'A' and Ccnt == 1 and cnt == 2:
    print('AC')
else:
    print('WA')
Buggy code:
from collections import Counter

def main():

    S = list(input())
    head = S.pop(0)
    cList = []
    flag  = False
    flag1 = False
    flag2 = False

    if head == 'A':
        flag = True
    
    for i,j in enumerate(S[1:-2]):
        if j=='C':
            cList=S.pop(i)
    if len(cList)==1:
        flag1=True
    
    if ''.join(S).islower():
        flag2 = True
    
    if flag and flag1 and flag2:
        print('AC')
    else:
        print('WA')


    
if __name__== "__main__":
    main() 











Fixed code:
from collections import Counter

def main():

    S = list(input())
    head = S.pop(0)
    cList = []
    flag  = False
    flag1 = False
    flag2 = False

    if head == 'A':
        flag = True
    
    for i,j in enumerate(S[1:-1]):
        if j=='C':
            cList.append(i+1)
    if len(cList)==1:
        flag1=True
        S.pop(cList[0])
        
    if ''.join(S).islower():
        flag2 = True
    
    if flag and flag1 and flag2:
        print('AC')
    else:
        print('WA')


    
if __name__== "__main__":
    main()
Buggy code:
import sys
N = list(input())
komoji = 0
oomoji = 0
if N[0] == 'A':
    if N[1].islower():
        for i in range(2, len(N)-1):
            if N[i] == 'C':
                oomoji += 1
            if N[i].islower():
                komoji += 1
if oomoji == 1 and komoji == len(N) - 3:
    print("AC")
else:
    print("WA")

Fixed code:
import sys
N = list(input())
komoji = 0
oomoji = 0
if N[0] == 'A':
    if N[1].islower():
        for i in range(2, len(N)-1):
            if N[i] == 'C':
                oomoji += 1
            if N[i].islower():
                komoji += 1
        if N[-1].islower():
            komoji += 1
if oomoji == 1 and komoji == len(N) - 3:
    print("AC")
else:
    print("WA")
Buggy code:
#coding:utf-8
s = input()

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

cnt = 0
print (s[2:-1])
for char in s[2:-1]:
    if char=='C':
        cnt += 1
if cnt!=1:
    print ('WA')
    exit()

cnt_upper = 0
for char in s:
    cnt_upper += char.isupper()
if cnt_upper != 2:
    print ('WA')
    exit()

print ('AC')


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

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

cnt = 0
for char in s[2:-1]:
    if char=='C':
        cnt += 1
if cnt!=1:
    print ('WA')
    exit()

cnt_upper = 0
for char in s:
    cnt_upper += char.isupper()
if cnt_upper != 2:
    print ('WA')
    exit()

print ('AC')
Buggy code:
A=list(input())
n=len(A)
if(A[0]!="A"):print("WA")
elif(A.count("C")!=1):print("WA")
elif(A.index("C")<2 or A.index("C")>n-2):print("WA")
else:
  A.pop(A.index("C"))
  A.pop(0)
  if(A.islower()):print("AC")
  else:print("WA")

Fixed code:
A=list(input())
n=len(A)
if(A[0]!="A"):print("WA")
elif(A.count("C")!=1):print("WA")
elif(A.index("C")<2 or A.index("C")>n-2):print("WA")
else:
  A.pop(A.index("C"))
  A.pop(0)
  S="".join(A)
  if(S.islower()):print("AC")
  else:print("WA")
Buggy code:
S = input()
if S[0] == 'A' and S[2:-1].count('C') == 1:
    S2 = S[1] + S[2:-1].replace('C', '')
    if S2 == S.lower():
        print('AC')
        exit()
print('WA')

Fixed code:
S = input()
if S[0] == 'A' and S[2:-1].count('C') == 1:
    S = S[1] + S[2:-1].replace('C', '') + S[-1]
    if S == S.lower():
        print('AC')
        exit()
print('WA')
Buggy code:
S = input()

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


Fixed code:
S = input()

if S[0] != 'A':
    print("WA")
    exit()
if S[2:-1].count('C') != 1:
    print("WA")
    exit()
if S.replace("A", "").replace("C", "").islower() == False:
    print("WA")
    exit()
print("AC")
Buggy code:
s=list(input())
print(s[2:-1])

def check(S):
    if not S[0]=="A":
        return False
    if not S[2:-1].count("C")==1:
        return False
    NG=[0, S.index("C")]
    for i,s in enumerate(S):
        if i in NG:
            continue
        if s.isupper():
            return False
    return True

print("AC") if check(s) else print("WA")



Fixed code:
s=list(input())

def check(S):
    if not S[0]=="A":
        return False
    if not S[2:-1].count("C")==1:
        return False
    NG=[0, S.index("C")]
    for i,s in enumerate(S):
        if i in NG:
            continue
        if s.isupper():
            return False
    return True

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

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

Fixed code:
s = input()
if s[0] == 'A':
  t = ''
  c_cnt = 0
  for i in range(1, len(s)):
    if s[i] != 'C':
      t += s[i]
    else:
      c_cnt += 1
  if t.islower() and 'C' in s[2:-1] and c_cnt == 1:
    print('AC')
  else:
    print('WA')
else:
  print('WA')
Buggy code:
s = input()

if s[0] == 'A' and s[2:-1].count('C') == 1:
  for letter in s[1:]:
    if letter != letter.lower():
      print('WA')
      break
  else:
    print('AC')
else:
  print('AC')

Fixed code:
s = input()

if s[0] == 'A' and s[2:-1].count('C') == 1:
  for letter in s[1:]:
    if letter != letter.lower() and letter != 'C':
      print('WA')
      break
  else:
    print('AC')
else:
  print('WA')
Buggy code:
def check_string(s):
  if(a_exist(s)):
    c_index = c_find(s)
    if(c_index != False):
      if(is_lower(s,c_index)):
        return 'AC'
  return 'WA'

def a_exist(s):
  if(s[0] == 'A'):
    return True
  else:
    return False

def c_find(s):
  c = len(s) - 3
  c_cnt = 0
  for i in range(c):
    if(i < 2):
      continue
    if(s[i] == 'C'):
      c_cnt += 1
      index = i
  if(c_cnt == 1):
    return index
  else:
    return False

def is_lower(s,index):
  for i in range(len(s)):
    if(i == 0):
      continue
    if(i == index):
      continue
    if(s[i].lower == False):
      return False
  return True

if __name__ == '__main__':
  s = input()
  print(check_string(s))

Fixed code:
def check_string(s):
  if(a_exist(s)):
    c_index = c_find(s)
    if(c_index != False):
      if(is_lower(s,c_index)):
        return 'AC'
  return 'WA'

def a_exist(s):
  if(s[0] == 'A'):
    return True
  else:
    return False

def c_find(s):
  c_cnt = 0
  for i in range(len(s)):
    if(i < 2):
      continue
    if(i == len(s)-1):
      continue
    if(s[i] == 'C'):
      c_cnt += 1
      index = i
  if(c_cnt == 1):
    return index
  else:
    return False

def is_lower(s,index):
  for i in range(len(s)):
    if(i == 0):
      continue
    if(i == index):
      continue
    if(s[i].islower() == False):
      return False
  return True

if __name__ == '__main__':
  s = input()
  print(check_string(s))
Buggy code:
s = input()
if s[0] != 'A':
    print("WA")
    exit()
cnt = 0
for i in range(2, len(s) - 1):
    if s[i] == 'C':
        cnt += 1
s.replace('A', '', 1)
s.replace('C', '', 1)
if not s.islower():
    print("WA")
    exit()
if cnt != 1:
    print("WA")
else:
    print("AC")


Fixed code:
s = input()
if s[0] != 'A':
    print("WA")
    exit()
cnt = 0
for i in range(2, len(s) - 1):
    if s[i] == 'C':
        cnt += 1
s = s.replace('A', '', 1)
s = s.replace('C', '', 1)
if not s.islower():
    print("WA")
    exit()
if cnt != 1:
    print("WA")
else:
    print("AC")
Buggy code:
s = input()
ans = "WA"

if s[0] == "A" and a[2:-2].count("C") == 1:
  tmp = s[1:]
  tmp.replace("C","")
  ans = "AC" if tmp.islower() else "WA"
  
print(ans)

Fixed code:
s = input()
ans = "WA"

if s[0] == "A" and s[2:-1].count("C") == 1:
  tmp = s[1:]
  tmp = tmp.replace("C","")
  ans = "AC" if tmp.islower() else "WA"
  
print(ans)
Buggy code:
s = input()
ac = True
c = True
if s[0] != "A":
  ac = False
if not ord("a") <= ord(s[1]) <= ord("z"):
  ac = False
if not ord("a") <= ord(s[-1]) <= ord("z"):
  ac = False
for i in range(2, len(s)-1):
  if s[i] == "C":
    if c:
      c = False
    else:
      ac = False
  else:
    if not ord("a") <= ord(s[i]) <= ord("z"):
    ac = False
if ac:
  print("AC")
else:
  print("WA")

Fixed code:
s = input()
ac = True
c = True
if s[0] != "A":
  ac = False
if not ord("a") <= ord(s[1]) <= ord("z"):
  ac = False
if not ord("a") <= ord(s[-1]) <= ord("z"):
  ac = False
for i in range(2, len(s)-1):
  if s[i] == "C":
    if c:
      c = False
    else:
      ac = False
  else:
    if not ord("a") <= ord(s[i]) <= ord("z"):
      ac = False
if c:
  ac = False
if ac:
  print("AC")
else:
  print("WA")
Buggy code:
S = input()

if S[0] != "A":
  print("WA")
  exit()
if "C" not in S:
  print("WA")
  exit()
x = S.index("C")
if S[1:x]+S[x+1:] != (S[1:x]+S[x+1:]).lower():
  print("WA")
  exit()

print("AC")


Fixed code:
S = input()

if S[0] != "A":
  print("WA")
  exit()
if S[1] == "C":
  print("WA")
  exit() 
if S[-1] == "C":
  print("WA")
  exit() 
if "C" not in S:
  print("WA")
  exit()
x = S.index("C")
if "C" in S[x+1:]:
  print("WA")
  exit()
if S[1:x]+S[x+1:] != (S[1:x]+S[x+1:]).lower():
  print("WA")
  exit()

print("AC")
Buggy code:
import sys
S=input()
first=S[0]
second=S[1]
last=S[len(S)-1]
cnt=0
moji=[i for i in "abcdefghijklmnopqrstuvwxyz"]
# print(len(moji))

if first=="A":
  for i in range(2,len(S)-1):
    print(i)
    if S[i]=="C":
      cnt+=1
    else:
      if (S[i] in moji)==False:
        print("WA")
        sys.exit()

  if cnt==1 and ((last in moji)==True) and ((second in moji)==True):
    print("AC")
  else:
    print("WA")
        
else:
  print("WA")

Fixed code:
import sys
S=input()
first=S[0]
second=S[1]
last=S[len(S)-1]
cnt=0
moji=[i for i in "abcdefghijklmnopqrstuvwxyz"]
# print(len(moji))

if first=="A":
  for i in range(2,len(S)-1):
  
    if S[i]=="C":
      cnt+=1
    else:
      if (S[i] in moji)==False:
        print("WA")
        sys.exit()

  if cnt==1 and ((last in moji)==True) and ((second in moji)==True):
    print("AC")
  else:
    print("WA")
        
else:
  print("WA")
Buggy code:
S = input()
cnt = 0
if S[0] == "A":
    for i in S[1: len(S) - 1]:
        if i == "C":
            cnt += 1
sr = S.replace("A", "")
src = sr.replace("C", "")
if src.islower() and cnt == 1:
    print("AC")
else:
    print("WA")

Fixed code:
S = input()
cnt = 0
if S[0] == "A":
    for i in S[2: len(S) - 1]:
        if i == "C":
            cnt += 1
sr = S.replace("A", "")
src = sr.replace("C", "")
if src.islower() and cnt == 1:
    print("AC")
else:
    print("WA")
Buggy code:
S = input()

if S[0] == 'A' and S[2:-1].count('C') == 1 and sum([c.isupper for c in S]) == 2:
    print('AC')
else:
    print('WA')


Fixed code:
S = input()

if S[0] == 'A' and S[2:-1].count('C') == 1 and sum([c.isupper() for c in S]) == 2:
    print('AC')
else:
    print('WA')
Buggy code:
from sys import stdin

S = stdin.readline().rstrip()

cond1 = S[0] == 'A'
cond2 = S.count('C', 2, -2) == 1
cond3 = S.replace('A', '').replace('C', '').islower()

if cond1 and cond2 and cond3:
    print('AC')
else:
    print('WA')


Fixed code:
from sys import stdin

S = stdin.readline().rstrip()

cond1 = S[0] == 'A'
cond2 = S.count('C', 2, -1) == 1
cond3 = S.replace('A', '').replace('C', '').islower()

if cond1 and cond2 and cond3:
    print('AC')
else:
    print('WA')
Buggy code:
s = input()
if len(s) < 4:
    print('WA')
    exit()
count = 0
for i in range(len(s)):
    if i == 0:
        if s[i] != 'A':
            break
    elif i>1 and i < len(s)-1 :
        if s[i]=='C':
            if count == 0:
                count += 1
                continue
            else:
                break
        elif s[i].islower():
            continue
        else:
            break
    elif s[i].islower():
        print("AC")
        exit()
    else:
        break
print("WA")

Fixed code:
s = input()
count = 0
for i in range(len(s)):
    if i == 0:
        if s[i] != 'A':
            break
    elif i == 1:
        if s[i].islower():
            pass
        else:
            break
    elif i>1 and i < len(s)-1 :
        if s[i]=='C':
            if count == 0:
                count += 1
            else:
                break
        elif s[i].islower():
            pass
        else:
            break
    elif i == len(s)-1 :
        if s[i].islower():
            if count ==1:
                print("AC")
                exit()
print("WA")
Buggy code:
s = input()
if s[0] == 'A' and s[2:-1].count('C')==1:
    c=0
    for i in s:
        if i.islower():c+=1
    if c==2:
        print('AC')
    else:
        print('WA')
else:
    print('WA')

Fixed code:
s = input()
if s[0] == 'A' and s[2:-1].count('C')==1:
    c=0
    for i in s:
        if i.isupper():c+=1
    if c==2:
        print('AC')
    else:
        print('WA')
else:
    print('WA')
Buggy code:
import re

S = input()

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

if S[2:-1].count('C') != 1:
  print('WA')
  exit()

if re.match(r'A[a-z]+C[a-z]+', S) == None:
  print('WA')
  exit()


Fixed code:
import re

S = input()

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

if S[2:-1].count('C') != 1:
  print('WA')
  exit()

if re.match(r'A[a-z]+C[a-z]+\Z', S) == None:
  print('WA')
  exit()

print('AC')
Buggy code:
s = input()

f = 1
c = 0

for i in range(len(s)):
    on = 0
    if i==0:
        if not s[i]=='A':
            f = 0
            on = 1
    elif i>=2 and i<=len(s)-2:
        if s[i] == 'C':
            c += 1
            on = 1
            
    if on == 0 and s[i].islower()==False:
        f = 0
        
if c!=1:
    f=0
    
if f==0:
    print("WA")
else:
    print("AC")

Fixed code:
s = input()

f = 1
c = 0

for i in range(len(s)):
    on = 0
    if i==0:
        if not s[i]=='A':
            f = 0
        else:
            on = 1
    elif i>=2 and i<=len(s)-2:
        if s[i] == 'C':
            c += 1
            on = 1
            
    if on == 0 and s[i].islower()==False:
        f = 0
        
if c!=1:
    f=0
    
if f==0:
    print("WA")
else:
    print("AC")
Buggy code:
S = list(input())
count = 0
if S[0] == 'A':
    for i in range(2,len(S)-1):
        if S[i] == 'C':
            count += 1
        elif S[i].lower != S[i]:
            print('WA')
            exit()
    if count == 1:
        print('AC')
    else:
        print('WA')
else:
    print('WA')

Fixed code:
S = list(input())
count = 0
if S[0] == 'A':
    S[0] = S[0].lower()
else:
    print('WA')
    exit()

count = 0
for i in range(2,len(S)-1):
    if S[i] == 'C' and count == 0:
        count += 1
        S[i] = S[i].lower()

if count == 0:
    print('WA')
    exit()

for i in range(len(S)):
    if S[i] != S[i].lower():
        print('WA')
        exit()
print('AC')
Buggy code:
import sys

S = input()

if S[0] == 'A' and S[2:-1].count('C') == 1:
    S.replace('A', 'a', 1).replace('C', 'c', 1)
    if S == S.lower():
        print('AC')
        sys.exit()

print('WA')

Fixed code:
import sys

S = input()

if S[0] == 'A' and S[2:-1].count('C') == 1:
    s = S.replace('A', 'a', 1).replace('C', 'c', 1)
    if s == S.lower():
        print('AC')
        sys.exit()

print('WA')
Buggy code:
s = input()
part_of_s = s[2:-2]
sub_s = s.replace('A','')
sub_s = sub_s.replace('C','')

if s[0] != 'A' or part_of_s.count('C') != 1 or sub_s != sub_s.lower():
    print('WA')
    exit()

print('AC')

Fixed code:
s = input()
part_of_s = s[2:-1]
sub_s = s.replace('A','')
sub_s = sub_s.replace('C','')

if s[0] != 'A' or part_of_s.count('C') != 1 or sub_s != sub_s.lower():
    print('WA')
    exit()

print('AC')
Buggy code:
import re

s = input()
test = re.match(r"^A[a-z]{2,}C[a-z]+$", s)
if test:
    print('AC')
else:
    print('WA')


Fixed code:
import re

s = input()
test = re.match(r"^A[a-z]+C[a-z]+$", s)
if test:
    print('AC')
else:
    print('WA')
Buggy code:
S = input()

a = S.find('A')

s1 = S[2:-1]
s_count = s1.count('C')

if a != 0:
  return False

if s_count != 1:
  return False

c = s1.find('C')

y = S[1:c-1]
z = S[c+1:]


if y.islower() and z.islower:
  print('AC')
else:
  print('WA')


Fixed code:
S = input()
     
a = S.find('A')
c = S.find('C')
     
s1 = S[2:-1]
s_count = s1.count('C')
   
y = S[1:c-1]
z = S[c+1:]

if c == 2:
	y = S[1]   

if a != 0:
	print('WA')

elif s_count != 1:
	print('WA')
     
else:
	if y.islower() and z.islower():
			print('AC')
	else:
		print('WA')
Buggy code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

S = input()

if S[0] == "A" and S[2:-2].count("C") == 1:
    S = S.replace("A", "")
    S = S.replace("C", "")
    if S == S.lower():
        print('AC')
        quit()
print('WA')


Fixed code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

S = input()

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

Fixed code:
s=input()
print("AC" if (s[0]=="A") and ("C" in s[2:-1]) and (s[1:].replace("C","",1).islower()) else "WA")