qyliang/CodeNanoFix huggingface dataset:
Buggy code:
s = input()
n = len(s)

for i in range(n-1):
  if s[i] == "A":
    break
    
for j in range(n-1)[::-1]:
  if s[j] == "Z":
    break
    
print(len(s[i:j+1]))

Fixed code:
s=input()
n=len(s)
for i in range(n):
  if(s[i]=='A'):
    break
    
for j in range(n)[::-1]:
   if(s[j]=='Z'):
      break
  
print(j-i+1)
Buggy code:
# -*- coding: utf-8 -*-

s = input()
print(s)
for i in range(len(s)):
    if s[i] == 'A':
        s = s[i:]
        break

s = s[::-1]
print(s)

for i in range(len(s)):
    if s[i] == 'Z':
        s = s[i:]
        print(len(s))
        break


Fixed code:
# -*- coding: utf-8 -*-

s = input()
for i in range(len(s)):
    if s[i] == 'A':
        s = s[i:]
        break

s = s[::-1]

for i in range(len(s)):
    if s[i] == 'Z':
        s = s[i:]
        print(len(s))
        break
Buggy code:
s = input()

for i in range(n):
  if s[i] == "A":
    l = i
    break
for i in range(n-1,-1,-1):
  if s[i] == "Z":
    r = i
    break
print(s[l:r+1])

Fixed code:
s = input()
n = len(s)
for i in range(n):
	if s[i] == "A":
		l = i
		break
for i in range(n-1,-1,-1):
	if s[i] == "Z":
		r = i
		break
print(r-l+1)
Buggy code:
s = input()
indexA = s.find("A")
indexZ = s.rfind("Z")
ans = s[indexA:indexZ + 1]
print(ans)

Fixed code:
s = input()
indexA = s.find("A")
indexZ = s.rfind("Z")
ans = len(s[indexA:indexZ + 1])
print(ans)
Buggy code:
s=input()
print(len(s)-s[::-1].find('Z')-s.find('A')+1)

Fixed code:
s=input()
print(len(s)-s[::-1].find('Z')-s.find('A'))
Buggy code:
import sys

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline
    ss=readline().strip()
    n=0
    a=100000000
    z=0
    for s in sss:
        if s=="A":
            a=min(a,n)
        elif s=="Z":
            z=n
        n+=1
    print(z-a+1)
    return


resolve()


Fixed code:
import sys

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline
    ss=readline().strip()
    n=0
    a=100000000
    z=0
    for s in ss:
        if s=="A":
            a=min(a,n)
        elif s=="Z":
            z=n
        n+=1
    print(z-a+1)
    return


resolve()
Buggy code:
import sys, re
input = sys.stdin.readline

pattern = re.compile('A.*?Z')
ans = 2 ** 18

s = input()

for m in pattern.findall(s):
  length = len(m)
  if length < ans:
    ans = length
    
print(ans)

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

pattern = re.compile('A.*Z')
ans = 2 ** 18

s = input()

for m in pattern.findall(s):
  length = len(m)
  if length < ans:
    ans = length
    
print(ans)
Buggy code:
s=input()
for i in range(len(s)):
  if s[i]=='A':
    a=i
    break
for i in range(len(s)):
  if s[len(s)-1-i]=='Z':
    z=len(s)-i
print(z-a)

Fixed code:
s=input()
for i in range(len(s)):
  if s[i]=='A':
    a=i
    break
for i in range(len(s)):
  if s[len(s)-1-i]=='Z':
    z=len(s)-i
    break
print(z-a)
Buggy code:
#53 B
data=list(input())
i=0
j=0
while data[i]!='A':
    i=i+1
while data[-j]!='Z':
    j=j+1
print(len(data)-i-j+1)

Fixed code:
#53 B
data=list(input())
i=0
j=1
while data[i]!='A':
    i=i+1
while (data[-j]!='Z' and len(data)-j>i):
    j=j+1
print(len(data)-i-j+1)
Buggy code:
S = input()
num_first = 0
num_last = 0
for i in range(len(S)):
    if S[i] == 'A':
        num_first = i
        break
for j in range (num_first, len(S)+1):
    if S[j] == 'Z':
        num_last = j
        break
print(num_last - num_first + 1)


Fixed code:
S = list(input())
num_first = 0
num_last = 0
for i in range(len(S)):
    if S[i] == 'A':
        num_first = i
        break
for j in range(len(S)):
    if S[j] == 'Z':
        num_last = j
print(num_last - num_first + 1)
Buggy code:
S = input()
print(S.find('Z') - S.rfind('A') + 1)


Fixed code:
S = input()

print(S.rfind("Z")-S.find("A")+1)
Buggy code:
s = input()
start = 0
end = 0
flag1 = True
flag2 = True
for i in range(len(s)):
    if s[i] == "A" and flag1 == True:
        start = i
        flag1 = False
    elif s[i] == "Z" and start != 0 and flag2 == True:
        end = i
        flag2 = False
slNnm = (end + 1) - start
print(slNnm)


Fixed code:
s = input()
start = 0
end = 0
flag1 = True
flag2 = True
for i in range(len(s)):
    if s[i] == "A" and flag1 == True:
        start = i
        flag1 = False
    elif s[i] == "Z":
        end = i
slNnm = (end + 1) - start
print(slNnm)
Buggy code:
s_list = list(input())
a_num = 0
z_num = 0
for i,a in enumerate(s_list):
    if a == 'A':
        a_num = i
        break
rs_list = reversed(s_list)
for j,z in enumerate(rs_list):
    if z == 'Z':
        z_num = j
        break
print(a_num,z_num,)
if z_num == 0:
    print(len(s_list[a_num:]))
else:
    print(len(s_list[a_num:-z_num]))

Fixed code:
s_list = list(input())
a_num = 0
z_num = 0
for i,a in enumerate(s_list):
    if a == 'A':
        a_num = i
        break
rs_list = reversed(s_list)
for j,z in enumerate(rs_list):
    if z == 'Z':
        z_num = j
        break
if z_num == 0:
    print(len(s_list[a_num:]))
else:
    print(len(s_list[a_num:-z_num]))
Buggy code:
s = list(input())
a = 200000
z = 0
for i in range(len(s)):
  if s[i] = 'A' and a > i:
    a = i
  if s[i] = 'Z' and z < i:
    z = i
print(z-a+1)

Fixed code:
s = list(input())
a = 200000
z = 0
for i in range(len(s)):
  if s[i] == 'A' and a > i:
    a = i
  if s[i] == 'Z' and z < i:
    z = i
print(z-a+1)
Buggy code:
s=input()
m=s.find("A")
n=s.find("Z",m)
print(m)
print(n)
if m<n:
    ans=(n-m)+1
    print(ans)
else:
    pass

Fixed code:
s=input()
m=s.find("A")
n=s.rfind("Z")
if m<n:
    ans=(n-m)+1
    print(ans)
else:
    pass
Buggy code:
s=input()

A = 0
Z = 0

for index, i in enumerate(s):
  if i == 'A':
    A = index
  if i == 'Z':
    Z = index

print((Z - A) + 1) 

Fixed code:
s=input()

A = -1
Z = 0

for index, i in enumerate(s):
  if i == 'A' and A == -1:
    A = index
  if i == 'Z':
    Z = index

print((Z - A) + 1)
Buggy code:
s = input()
a = z =  ''
for i, v in enumerate(s):
    if not a:
        if v == 'A':
            a = i
    if not z:
        if s[len(s) - i -1] == 'Z':
            z = len(s) - i
            
    if a >= 0 and z >= 0:
        print(z - a)
        exit()

Fixed code:
s = input()
a = z = -1
for i, v in enumerate(s):
    if a == -1:
        if v == 'A':
            a = i
    if z == -1:
        if s[len(s) - i -1] == 'Z':
            z = len(s) - i
            
    if a >= 0 and z >= 0:
        print(z - a)
        exit()
Buggy code:
s=input()
st=s.find("A")
ed=s.rfind("Z")
print(s[st:ed+1])

Fixed code:
s=input()
st=s.find("A")
ed=s.rfind("Z")
print(len(s[st:ed+1]))
Buggy code:
s = input()
x = len(s)
y = 0
z = 0
while(y <= x):
  if (s[y] == "A"):
    z = y
    break
  y += 1
while(y <= x):
  if (s[y]  == "Z"):
    print(str(y - z + 1))
    break
  y += 1

Fixed code:
s = input()
x = len(s)
y = 0
z = 0
a = x - 1
while(y <= x):
  if (s[y] == "A"):
    z = y
    break
  y += 1
while(y <= x):
  if (s[a]  == "Z"):
    print(str(a - z + 1))
    break
  a -= 1
  y += 1
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 LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    s=SI()
    for i in range(len(s)):
        if s[i]=="a":break
    for j in range(len(s)-1,-1,-1):
        if s[j]=="z":break
    print(j-i+1)

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 LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    s=SI()
    for i in range(len(s)):
        if s[i]=="A":break
    for j in range(len(s)-1,-1,-1):
        if s[j]=="Z":break
    print(j-i+1)

main()
Buggy code:

s=str(input())
atoz=[]
for i in range(len(s)):
	if(s[i]=="A"):
		a=i
		break
#print(a)


for i in range(a,len(s)):
	atoz.append(s[i])

s_l=list(atoz)
#print(s_l)

r_s=[]
s_l_kep=s_l
for i in (reversed(s_l)):
	#print(i)
	if(i!="Z"):
		s_l.pop()
#		print(s_l)
	else:
		break
#	r_s.append(i)
#print(s_l)
str_s_l=''.join(s_l)
print(str_s_l)

Fixed code:

s=str(input())
atoz=[]
for i in range(len(s)):
	if(s[i]=="A"):
		a=i
		break
#print(a)


for i in range(a,len(s)):
	atoz.append(s[i])

s_l=list(atoz)
#print(s_l)

r_s=[]
s_l_kep=s_l
for i in (reversed(s_l)):
	#print(i)
	if(i!="Z"):
		s_l.pop()
#		print(s_l)
	else:
		break
#	r_s.append(i)
#print(s_l)
str_s_l=''.join(s_l)
#print(str_s_l)
print(len(str_s_l))
Buggy code:
s=input()
x=s.find('A')
y=s.find('Z')
print(y-x+1)

Fixed code:
s=input()
x=s.find('A')
y=s.rfind('Z')
print(y-x+1)
Buggy code:
S = input()
min_ = 0
max_ = 0
flag_min = False
for i in len(S):
  if flag_min:
    if S[i] == "A":
      min_ = i
      flag_min = True
  else:
    if S[i] == "Z":
      max_ = i
      
print(max_ - min_ + 1)

Fixed code:
S = input()
min_ = 0
max_ = 0
flag_min = True
for i in range(len(S)):
  if flag_min:
    if S[i] == "A":
      min_ = i
      flag_min = False
  else:
    if S[i] == "Z":
      max_ = i
      
print(max_ - min_ + 1)
Buggy code:
s=input()
a=0
z=0
i=0
j=0
while a==0:
    if s[i]=="a":
        a=1
    else:
        i+=1
while z==0:
    if s[len(s)-1-j]=="z":
        z=1
    else:
        j+=1
print(j-i+1)

Fixed code:
s=input()
a=0
z=0
i=0
j=len(s)-1
while a==0 :
    if s[i]=="A":
        a=1
    else:
        i+=1
while z==0:
    if s[j]=="Z":
        z=1
    else:
        j-=1
print(j-i+1)
Buggy code:
A=str(input())
a=A.index("A")
Z=[]
for i in enumerate(A):
    if i[1]=="Z":
        Z.append(i[0])
if len(Z)>=2:
    b=max(Z)
else:
    b=A.index("B")
print(len(A[a:b+1]))

Fixed code:
A=str(input())
a=A.index("A")
Z=[]
for i in enumerate(A):
    if i[1]=="Z":
        Z.append(i[0])
if len(Z)>=2:
    b=max(Z)
else:
    b=A.index("Z")

print(len(A[a:b+1]))
Buggy code:
import sys
input = sys.stdin.readline
s=input().strip()
for i in range(len(s)):
    if s[i]=="A":
        sa=i
for i in range(len(s)):
    if s[i]=="Z":
        sz=i
print(len(s[si:sz+1]))


Fixed code:
import sys
input = sys.stdin.readline
s=input().strip()
for i in range(len(s)):
    if s[i]=="A":
        sa=i
        break
for i in range(len(s)):
    if s[i]=="Z":
        sz=i
print(len(s[sa:sz+1]))
Buggy code:
from sys import stdin
s = (stdin.readline().rstrip())
A = 10**9
Z = -10**9
for ind,i in enumerate(s):
    if i == "A" and ind < A:
        A = ind
    if i == "Z" and ind > Z:
        A = ind
print(Z-A+1)

Fixed code:
from sys import stdin
s = (stdin.readline().rstrip())
A = 10**9
Z = -10**9
for ind,i in enumerate(s):
    if i == "A" and ind < A:
        A = ind
    if i == "Z" and ind > Z:
        Z = ind
print(Z-A+1)
Buggy code:
S = input()
list_A = []
list_Z = []
for i in range(len(S)):
  if s[i] == 'A':
    list_A.append(i)
  if s[i] == 'Z':
    list_Z.append(i)
a = list_A[0]
z = list_Z[-1]
print(z - a + 1)

Fixed code:
S = input()
list_A = []
list_Z = []
for i in range(len(S)):
  if S[i] == 'A':
    list_A.append(i)
  if S[i] == 'Z':
    list_Z.append(i)
a = list_A[0]
z = list_Z[-1]
print(z - a + 1)
Buggy code:
s = str(input())
print(len(s))
for i in range(len(s)):
    if s[i] == 'A':
        min = i
        break
for i in reversed(range(len(s))):
    if s[i] =='Z':
        max = i
        break

print(max)print(max-min+1)

Fixed code:
s = str(input())
for i in range(len(s)):
    if s[i] == 'A':
        min = i
        break
for i in reversed(range(len(s))):
    if s[i] =='Z':
        max = i
        break

print(max-min+1)
Buggy code:
s = input()
n = len(s)
ans = 0
for i in range(n):
    if s[i] == 'A':
        ans -= i
        break

for j in range(n-1, 0):
    if s[j] == 'Z':
        ans += j
        break

print(ans)


Fixed code:
s = input()
n = len(s)
ans = 0
for i in range(n):
    if s[i] == 'A':
        ans -= i
##        print('i')
        break

for j in reversed(range(0, n)):
    if s[j] == 'Z':
        ans += j
        break

print(ans + 1)
Buggy code:
s =input()
A=0
Z=0

for i in range(len(s)):
  s[i] =="A":
    A=i+1
    break

    
for j in range(len(s)):
  s[-(j+1)] =="Z":
    Z=len(s)-j
    break
    
print(Z-A+1)
    
    

Fixed code:
s =input()
A=0
Z=0

for i in range(len(s)):
  if s[i] =="A":
    A +=(i+1)
    break

    
for j in range(len(s)):
  if s[-(j+1)] =="Z":
    Z +=len(s)-j
    break
    
print(Z-A+1)
Buggy code:
s=list(input())

a=0
for i in range(len(s)):
    if s[i]=='A':
        a=i
        break
b=0
for i in range(len(s)):
    if s[n-i-1]=='Z':
        b=n-i-1
        break
print(a-b+1)

Fixed code:
s=list(input())

a=0
for i in range(len(s)):
    if s[i]=='A':
        a=i
        break
b=0
for i in range(len(s)):
    if s[len(s)-i-1]=='Z':
        b=len(s)-i-1
        break
print(b-a+1)
Buggy code:
s = input()
a=0
b=0
for i in range(len(s)):
  if s[i]=='A':
    a = i
    break
for i in range(len(s),-1,-1):
  if s[i] == 'Z':
    b = i
    break
print(b-a+1)
  

Fixed code:
s = input()
a=0
b=0
for i in range(len(s)):
  if s[i]=='A':
    a = i
    break
for i in range(len(s)-1,-1,-1):
  if s[i] == 'Z':
    b = i
    break
print(b-a+1)
Buggy code:
S = input()
pos_a = -1
pos_z = -1
for i in range(len(S)):
  if S[i] == 'A' and pos_a < 0:
    pos_a = i
  if S[len(S)-i] == 'Z' and pos_z < 0:
    pos_z = len(S)-i
  if pos_a >= 0 and pos_z > 0:
    break
print(pos_z-pos_a+1)

Fixed code:
S = input()
pos_a = -1
pos_z = -1
for i in range(len(S)):
  if S[i] == 'A' and pos_a < 0:
    pos_a = i
  if S[len(S)-i-1] == 'Z' and pos_z < 0:
    pos_z = len(S)-i-1
  if pos_a >= 0 and pos_z > 0:
    break
print(pos_z-pos_a+1)
Buggy code:
s=input()
for i in range(len(s)):
  if s[i]==`A`:
    a=i
    break
for i in reversed(range(len(s))):
  if s[i]==`Z`:
    b=i
    break
print(b-a)

Fixed code:
s=input()
for i in range(len(s)):
  if s[i]=="A":
    a=i
    break
for i in reversed(range(len(s))):
  if s[i]=="Z":
    b=i
    break
print(b-a+1)
Buggy code:
s = input()
for i in range(len(s)):
    if s[i] == 'A':
        p = i
        break
for i in range(1,len(s)+1):
    if s[-i] == 'Z':
        q = i-1
print(len(s) -(p+q))

Fixed code:
s = input()
for i in range(len(s)):
    if s[i] == 'A':
        p = i
        break
for i in range(1,len(s)+1):
    if s[-i] == 'Z':
        q = i-1
        break
print(len(s) -(p+q))
Buggy code:
s=list(input())
l,r=0,len(s)
for i in range(len(s)):
    if s[i]=='A':l=i;break
for i in range(len(s)):
    if s[len(s)-(i+1)]=='Z':r=len(s)-(i+1);break
print(r-l)

Fixed code:
s=list(input())
l,r=0,len(s)
for i in range(len(s)):
    if s[i]=='A':l=i;break
for i in range(len(s)):
    if s[len(s)-(i+1)]=='Z':r=len(s)-(i+1);break
print(r-l+1)
Buggy code:
l = list(input())

for i in range(len(l)):
  if l[i] == "A":
    a = i
    break
for i in range(len(l)):
  if l[-1-i] == "Z":
    b = i
    break
print(b-a+1)

Fixed code:
l = list(input())

for i in range(len(l)):
  if l[i] == "A":
    a = i
    break
for i in range(len(l)):
  if l[-1-i] == "Z":
    b = len(l)-i
    break
print(b-a)
Buggy code:
s = list(input())
flag = 0
start = 0
end = 0
for i in range(len(s)):
    if s[i] == 'A':
        flag = 1
        start = i

    if flag == 1 and s[i] == 'Z':
        end = i
        break
print(end - start + 1)

Fixed code:
s = list(input())
flag = 0
start = 0
end = 0
for i in range(len(s)):
    if flag == 0 and s[i] == 'A':
        flag = 1
        start = i

    if flag == 1 and s[i] == 'Z':
        end = i
print(end - start + 1)
Buggy code:
s=input()
for i in range(len(s)):
    if s[i]=='A':
        f=i
        for j in range(i,len(s)):
            if s[j]=='Z':
                ans=(j+1)-f
                break
print(ans)

Fixed code:
s=input()
for i in range(len(s)):
    if s[i]=='A':
        f=i
        break
for i in range(len(s)-1,-1,-1):
    if s[i]=='Z':
        ans=(i+1)-f
        break
print(ans)
Buggy code:
#!/usr/bin/env python3
if __name__ == '__main__':
  s = str(input())
  L = len(s)
  beg = -1
  end = -1
  for i in range(0,L):
    if s[i]=='A' and beg==-1:
      beg = i
    elif s[i]=='Z':
      end = i
  print(s[beg:end-beg+1])


Fixed code:
#!/usr/bin/env python3
if __name__ == '__main__':
  s = str(input())
  L = len(s)
  beg = -1
  end = -1
  for i in range(0,L):
    if s[i]=='A' and beg==-1:
      beg = i
    elif s[i]=='Z':
      end = i
  print(end-beg+1)
Buggy code:
s = input()
a, z, ans = (0, 0, 0)

a = s.find("A")
z = s.rfind("Z")
ans = z - a + 3
print(ans)

Fixed code:
s = input()
a, z, ans = (0, 0, 0)
 
a = s.find("A")
z = s.rfind("Z")
ans = z - a + 1
print(ans)
Buggy code:
s = input()
start = -float('inf')
best_length = -float('inf')
for i,w in enumerate(s):
  if w=='A' and start < 0:
    start = i
  elif w=='Z':
    length = i - start + 1
    if length > best_length:
      best_length = length
print(best_length if best_length > 0 else 0)

Fixed code:
s = input()
start = -float('inf')
best_length = -float('inf')
for i,w in enumerate(s):
  if w=='A' and start < 0:
    start = i
  elif w=='Z' and start >= 0:
    length = i - start + 1
    if length > best_length:
      best_length = length
print(best_length if best_length > 0 else 0)
Buggy code:
s=input()
rev=s[::-1]
n=len(s)
print(n)
print((n-rev.find('Z')) - (s.find('A')))


Fixed code:
s=input().strip()
rev=s[::-1]
n=len(s)
#print(n)
print((n-rev.find('Z')) - (s.find('A')))
Buggy code:
s = input()
start = 0
end = 0
for i in range(len(s)):
  if s[i] == 'A':
    start = i
    break
for i in range(len(s)):
  if s[-(i+1)] == 'Z':
    end = -i
    break
print(len(s[start:end]))

Fixed code:
s = input()
start = 0
end = 0
for i in range(len(s)):
  if s[i] == 'A':
    start = i
    break
for i in range(len(s)):
  if s[-(i+1)] == 'Z':
    end = len(s)-i
    break
print(end - start)
Buggy code:
s = input()
length = range(0, len(s))
first_A = -1

for i in length:
    if s[i] == 'A':
        first_A = i
        break
    else:
        continue

last_Z = -1
for j in reversed(length):
    if s[j] == 'Z':
        last_Z = j
        break
    else:
        continue

max_diff = last_Z - first_A
print(max_diff)


Fixed code:
s = input()
length = range(0, len(s))
first_A = -1

for i in length:
    if s[i] == 'A':
        first_A = i
        break
    else:
        continue

last_Z = -1

for j in list(reversed(length)):
    if s[j] == 'Z':
        last_Z = j
        break
    else:
        continue

max_diff = last_Z - first_A
print(max_diff + 1)
Buggy code:
S=input()
ans=0
tmp=0
end=0
for i in range(len(S)):
	if S[i]=="A":
		tmp=i
		break
for i in range(1,len(S)):
	if S[-i]=="Z":
		end=len(S)-i
		break
print(tmp,end)
print(end-tmp+1)

Fixed code:
S=input()
ans=0
tmp=0
end=0
for i in range(len(S)):
	if S[i]=="A":
		tmp=i
		break
for i in range(1,len(S)):
	if S[-i]=="Z":
		end=len(S)-i
		break
print(end-tmp+1)
Buggy code:
S = input()

min_A = 0
max_Z = 0

for i, s in enumerate(S):
    if s == 'A' and min_A == 0:
        min_A = i
    elif s == 'Z':
        max_Z = i

print(max_Z - min_A)

Fixed code:
S = input()

min_A = 0
max_Z = 0

for i, s in enumerate(S):
    if s == 'A' and min_A == 0:
        min_A = i + 1
    elif s == 'Z':
        max_Z = i + 1

print(max_Z - min_A + 1)
Buggy code:
s = list(input())

cnt = 0
on = False
result = []
for a in s:
    if a is 'A':
        on = True
    elif a is 'Z':
        result.append(cnt)
        cnt += 1
    if on:
        cnt += 1

print(max(result))

Fixed code:
s = list(input())

cnt = 0
on = False
result = []
for a in s:
    if a is 'A':
        on = True
    if on:
        cnt += 1
    if a is 'Z':
        result.append(cnt)

print(max(result))
Buggy code:
s = input()
a_index = s.find("A")
z_index = s.find("Z")
print(z_index - a_index +1)


Fixed code:
s = input()
a_index = s.find("A")
z_index = s.rfind("Z")
print(z_index - a_index + 1)
Buggy code:
a = input()
for i in range(len(a)):
    if a[i] == "A":
        b = i
        print(b)
        break
for j in range(len(a)):
    if a[j] == "Z":
        c = j
        print(c)
        break
print(c-b+1)

Fixed code:
a = input()
for i in range(len(a)):
    if a[i] == "A":
        b = i
        break
for j in range(len(a)):
    if a[j] == "Z":
        c = j
print(c-b+1)
Buggy code:
# -*- coding: utf-8 -*-

# input
s = input()

# solve
for f in range(len(s)):
    if s[i] == 'A':
        a = i
        break

for f in reversed(range(len(s))):
    if s[i] == 'Z':
        z = i
        break

# output
print(z - a + 1)


Fixed code:
# -*- coding: utf-8 -*-

# input
s = input()

# solve
for i in range(len(s)):
    if s[i] == 'A':
        a = i
        break

for i in reversed(range(len(s))):
    if s[i] == 'Z':
        z = i
        break

# output
print(z - a + 1)
Buggy code:
s = input()
num_A = 0
num_B = 0
for ind,i in enumerate(s):
  if(num_A == 0 and i == 'A'):
    num_A = ind
  if(i == 'Z'):
    num_Z = ind
print(num_B - num_A + 1)

Fixed code:
s = input()
num_A = -1
num_Z = -1
for ind,i in enumerate(s):
  if(num_A == -1 and i == 'A'):
    num_A = ind
  if(i == 'Z'):
    num_Z = ind
print(num_Z - num_A + 1)
Buggy code:
s = list(input())
r = list(reversed(s))

for i in range(len(s)):
    if s[i] == "A":
        a = i +1
        break
for i in range(len(r)):
    if s[i] == "Z":
        z = i +1
        break
print(z-a+2)
    

Fixed code:
s = list(input())
r = list(reversed(s))

for i in range(len(s)):
    if s[i] == "A":
        a = i +1
        break
for j in range(len(r)):
    if r[j] == "Z":
        z = len(r) - j
        break
print(z-a+1)
Buggy code:
import re
print(max(map(len, re.findall("A.*Z",input())))

Fixed code:
import re
print(max(map(len, re.findall("A.*Z", input()))))
Buggy code:
s=input()
x=0;y=0
for i in range(len(s)):
  if s[i]=="A":
    x=i+1
    break
for i in range(len(s)):
  if s[-i]=="Z":
    y=len(s)-i+1
    break
#print(x,y)
print(y-x+1)

Fixed code:
s=input()
x=0;y=0
for i in range(len(s)):
  if s[i]=="A":
    x=i+1
    break
t=s[::-1]
for i in range(len(t)):
  if t[i]=="Z":
    y=len(s)-i
    break
#print(x,y)
print(y-x+1)
Buggy code:
S=input()

print(S.rfind("Z")-S.find("A"+1))

Fixed code:
S=input()

print(S.rfind("Z")-S.find("A")+1)
Buggy code:
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush
import collections
import bisect

def main():
    S = input()

    l = 0
    r = 0
    for i in range(len(S)):
        if l==0 and S[i]=='A':
            l = i
        elif S[i]=='Z':
            r = i
    print(l, r)
    print(r - l + 1)


if __name__ == '__main__':
    main()


Fixed code:
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush
import collections
import bisect

def main():
    S = input()

    l = 0
    r = 0
    flag = False
    for i in range(len(S)):
        if not flag and S[i]=='A':
            l = i
            flag = True
        elif S[i]=='Z':
            r = i
    print(r - l + 1)


if __name__ == '__main__':
    main()
Buggy code:
din = str(input())
length = len(din)
first_A = -1
last_Z = -1
for i in range(length):
    if (din[i] == 'A' and first_A == -1):
        location_A = i
    elif din[i] == 'Z':
        last_Z = i
print(last_Z-first_A+1)

Fixed code:
din = str(input())
length = len(din)
first_A = -1
last_Z = -1
for i in range(length):
    if (din[i] == 'A' and first_A == -1):
        first_A = i
    elif din[i] == 'Z':
        last_Z = i
print(last_Z-first_A+1)
Buggy code:
s = input()
a=0
z=0

for i in range(len(s)):
    if s[i]=="A":
        a = i
        break

for i in range(len(s)):
    if s[-i-1]=="Z":
        z = len(s)-i-1

print(z-a+1)

Fixed code:
s = input()
a = 0
z = 0
s_num = len(s)
for i in range(s_num):
    if s[i] == 'A':
        a += i
        break
for i in range(s_num - 1, 0, -1):
    if s[i] == 'Z':
        z += i
        break
print(z - a + 1)
Buggy code:
def a2z_string(s: str)->int:
    a = s.find('a')
    z = s.rfind('z')
    return z - a + 1


if __name__ == "__main__":
    s = input()
    ans = a2z_string(s)
    print(ans)


Fixed code:
def a2z_string(s: str)->int:
    a = s.find('A')
    z = s.rfind('Z')
    return z - a + 1


if __name__ == "__main__":
    s = input()
    ans = a2z_string(s)
    print(ans)