qyliang/CodeNanoFix huggingface dataset:
Buggy code:
s = 'HASFJGHOGAKZZFEGA'
rs = s[::-1]
x = s.index('A')
y = rs.index('Z')
print(len(s)-y-x)


Fixed code:
s = input()
rs = s[::-1]
x = s.index('A')
y = rs.index('Z')
print(len(s)-y-x)
Buggy code:
s = input()

ans_a = s.index("A")
ans_z = s.index("Z")

print(ans_z - ans_a + 1)

Fixed code:
s = input()

ans_a = s.index("A")
ans_z = s.rfind("Z")

print(ans_z - ans_a + 1)
Buggy code:
s = input()

st = 0
ed = 0
for i in range(len(s)):
  if s[i] == "A":
    st = i
    break
for i in range(len(s)):
  if s[-i] == "Z":
    ed = -i + len(s)
    break
print(ed-st)

Fixed code:
s = input()
s = s

st = 0
ed = 0
for i in range(len(s)):
  if s[i] == "A":
    st = i
    break
for i in range(len(s)):
  if s[-i + len(s) -1] == "Z":
    ed = -i + len(s) - 1
    break
print(ed-st+1)
Buggy code:
s = input()

sub = 0

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

print(sub)


Fixed code:
s = input()

sub = 0

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

print(sub)
Buggy code:
# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest053-B
#  https://beta.atcoder.jp/contests/abc053/tasks/abc053_b

def atozString(dataStr) :

	rangeFirstToEnd = range(0,len(dataStr),1)
	rangeEndToFirst = range(len(dataStr)-1,-1,-1)
	firstA = 0
	lastZ = len(dataStr)
	for i in rangeFirstToEnd:
		if dataStr[i] == 'A':
			firstA = i
			break

	for i in rangeEndToFirst:
		if dataStr[i] == 'Z':
			lastZ = i
			break

	print(dataStr[firstA:lastZ+1])
	answerInt = lastZ-firstA+1
	return answerInt


if __name__ == '__main__':
	inputLine = input()
	inputStr = inputLine
	ans=atozString(inputStr)
	print(ans)

Fixed code:
# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest053-B
#  https://beta.atcoder.jp/contests/abc053/tasks/abc053_b

def atozString(dataStr) :

	rangeFirstToEnd = range(0,len(dataStr),1)
	rangeEndToFirst = range(len(dataStr)-1,-1,-1)
	firstA = 0
	lastZ = len(dataStr)
	for i in rangeFirstToEnd:
		if dataStr[i] == 'A':
			firstA = i
			break

	for i in rangeEndToFirst:
		if dataStr[i] == 'Z':
			lastZ = i
			break

	answerInt = lastZ-firstA+1
	return answerInt


if __name__ == '__main__':
	inputLine = input()
	inputStr = inputLine
	ans=atozString(inputStr)
	print(ans)
Buggy code:
import sys
import re
s = str(input())
if len(s) < 0 or len(s) > 200000:
    sys.exit()

array_str = re.findall(r'A.*Z', s)
max = 0
for I in array_str:
    print(I)
    if len(I) > max:
        max = len(I)
print(max)


Fixed code:
import sys
import re
s = str(input())
if len(s) < 0 or len(s) > 200000:
    sys.exit()

array_str = re.findall(r'A.*Z', s)
max = 0
for I in array_str:
    if len(I) > max:
        max = len(I)
print(max)
Buggy code:
s = input ()
n = len (s)
print (n)
for i in range (n):
  if s[i] == 'A':
    x = i
    break
for i in range (n):
  print (s[-1-i])
  if s[-1-i] == 'Z':
    y = n-i-1
    break
print (x,y)
print (y-x+1)

Fixed code:
s = input ()
n = len (s)
for i in range (n):
  if s[i] == 'A':
    x = i
    break
for i in range (n):
  if s[-1-i] == 'Z':
    y = n-i-1
    break
print (y-x+1)
Buggy code:
s = "HASFJGHOGAKZZFEGA"
min_A = len(s)
max_Z = 0
for i in range(len(s)):
    if s[i] == "A":
        if min_A>i:
            min_A = i
    if s[i] == "Z":
        if max_Z < i:
            max_Z = i
print(max_Z-min_A+1)

Fixed code:
s = input()
min_A = len(s)
max_Z = 0
for i in range(len(s)):
    if s[i] == "A":
        if min_A>i:
            min_A = i
    if s[i] == "Z":
        if max_Z < i:
            max_Z = i
print(max_Z-min_A+1)
Buggy code:
s = input()
start = len(s)
end = 0

for i in range(s):
    if s[i] == "A":
        start = min(start,i)
    if s[len(s)-1-i] == "Z":
        end = max(end,i)

print(len(s)-start-end)

Fixed code:
s = input()
start = len(s)
end = len(s)

for i in range(len(s)):
    if s[i] == "A":
        start = min(start,i)
    if s[len(s)-1-i] == "Z":
        end = min(end,i)

print(len(s)-start-end)
Buggy code:
S=input()
start=0
last=0
for i in range(len(S)):
    if S[i]=='A':
        start=i
        break

for j in range(1,len(S)+1):
    if S[-j]=='Z':
        last=len(S)-j
        
    
print(last-start+1)

Fixed code:
S=input()
start=0
last=0
for i in range(len(S)):
    if S[i]=='A':
        start=i
        break

for j in range(1,len(S)+1):
    if S[-j]=='Z':
        last=len(S)-j
        break
    
print(last-start+1)
Buggy code:
s = input().strip()

a = []
b = []

for i in range(len(s)):
    if s[i] == 'A':
        a.append(i)
    elif s[i] == 'Z':
        b.append(i)
print(b.max()-a.min()+1)


Fixed code:
s = input().strip()

a = []
b = []

for i in range(len(s)):
    if s[i] == 'A':
        a.append(i)
    elif s[i] == 'Z':
        b.append(i)
print(max(b)-min(a)+1)
Buggy code:
A=input()
print(A.find("Z")-A.find("A")+1)

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

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

Fixed code:
s = input()
A = s.index('A')
Z = s.rfind('Z')
print(Z - A + 1)
Buggy code:
S=input()
N=len(S)
for i in range(N):
  if S[i]=='A':
    A=i
    break
for i in range(N,0):
  if S[i]=='Z':
    Z=i
    break
ans=Z-A+1

print(ans)

Fixed code:
S=input()
N=len(S)
A=0
Z=0
for i in range(N):
  if S[i]=='A':
    A=i
    #print(A)
    break
    
for i in range(N)[::-1]:
  if S[i]=='Z':
    Z=i
    #print(Z)
    break
    
ans=Z-A+1
print(ans)
Buggy code:
"""
author : halo2halo
date : 25,Oct,2019
"""

import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

S = readline().rstrip()
print()
print(abs(S.find('A')-S.rfind('Z')))


Fixed code:
"""
author : halo2halo
date : 25,Oct,2019
"""

import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

S = readline().rstrip()
print()
print(abs(S.find('A')-S.rfind('Z'))+1)
Buggy code:
"""
author : halo2halo
date : 25,Oct,2019
"""

import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

S = readline().rstrip()
print(S.index('A'))
print(len(S)-(S[::-1].index('Z')+1))
print(abs(S.index('A')-(len(S)-(S[::-1].index('Z')+1)))+1)


Fixed code:
"""
author : halo2halo
date : 25,Oct,2019
"""

import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

S = readline().rstrip()
print(abs(S.index('A')-(len(S)-(S[::-1].index('Z')+1)))+1)
Buggy code:
s=list(input())
a=200000
z=0

for i in range(len(s)):
  if i=='A'and a>i:
    a=i
  if 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:
string = input()
string_list = [s for s in string]

def find(s, slist):
  index = []
  for i, st in enumerate(slist):
    if st == s:
      index.append(i)

index_of_a = find("A", string_list)
index_of_z = find("Z", string_list)

print(index_of_z[-1] - index_of_a[0]+1)

Fixed code:
string = input()
string_list = [s for s in string]
 
def find(s, slist):
  index = []
  for i, st in enumerate(slist):
    if st == s:
      index.append(i)
  return index
 
index_of_a = find("A", string_list)
index_of_z = find("Z", string_list)
 
print(index_of_z[-1] - index_of_a[0]+1)
Buggy code:
s=list(input())
x=s.index('A')
t=reversed(s)
y=t.index('Z')
print(len(s)-x-y)

Fixed code:
s=list(input())
x=s.index('A')
t=list(reversed(s))
y=t.index('Z')
print(len(s)-x-y)
Buggy code:
str = input('')
start = 0
end = 0
for x in range(len(str)):
  if str[x] == 'A' and start != 0:
    start = x
  elif str[x] == 'Z':
    end = x
print(end - start + 1)

Fixed code:
str = input('')
start = -1
end = -1
for x in range(len(str)):
  if str[x] == 'A' and start == -1:
    start = x
  elif str[x] == 'Z':
    end = x
print(end - start + 1)
Buggy code:
s = input()
a_index = 0
z_index = 0

for i in range(0, len(s)):
    if s[i] == "A":
        a_index = i
        break
        
for i in range(0, len(s)):
    if s[len(s)-i-1] == "Z":
        z_index = len(s)-i
        break
print(s[a_index:z_index])

Fixed code:
s = input()
a_index = 0
z_index = 0

for i in range(0, len(s)):
    if s[i] == "A":
        a_index = i
        break
        
for i in range(0, len(s)):
    if s[len(s)-i-1] == "Z":
        z_index = len(s)-i-1
        break
print(z_index - a_index +1)
Buggy code:
line = input()
a = 20000000
z = 0
for i in range(len(line)):
  if line[i] == 'A':
    min(a,i)
  elif line[i] == 'Z':
    max(z,i)
print(z-a+1)

Fixed code:
line = input()
a = 20000000
z = 0
for i in range(len(line)):
  if line[i] == 'A':
    a = min(a,i)
  elif line[i] == 'Z':
    z = max(z,i)
print(z-a+1)
Buggy code:
s = input()
print(len(s) - 1 - s[::-1].index('Z') - s.index('A'))

Fixed code:
s = list(input())
print(len(s) - s.index('A') - s[::-1].index('Z'))
Buggy code:
s = input()

k = s[::-1]

print(k)

for i in range(len(s)):
    if s[i]=='Z':
        z_num = i 
    if k[i]=='A':
        a_num = i

ans = a_num + z_num + 2 - len(s)

print(ans)


Fixed code:
s = input()

k = s[::-1]

for i in range(len(s)):
    if s[i]=='Z':
        z_num = i 
    if k[i]=='A':
        a_num = i

ans = a_num + z_num + 2 - len(s)

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

found_a = True
high = 0
low = 0

for index, word in enumerate(s):
    if found_a == False:
        if word == 'A':
            low = index
            found_a = True
    if word == 'Z':
        high = index

print(high - low)

Fixed code:
s = input()

found_a = False
high = 0
low = 0

for index, word in enumerate(s):
    if found_a == False:
        if word == 'A':
            low = index
            found_a = True
    if word == 'Z':
        high = index

print(high - low + 1)
Buggy code:
s = str(input())
Alst = []
Zlst = []
for i in range(len(s)):
    if s[i]=='A':
        Alst.append(i)
    elif s[i]=='Z':
        Zlst.append(i)
print(max(Zlst)-min(Alst))

Fixed code:
s = str(input())
Alst = []
Zlst = []
for i in range(len(s)):
    if s[i]=='A':
        Alst.append(i)
    elif s[i]=='Z':
        Zlst.append(i)
print(max(Zlst)-min(Alst)+1)
Buggy code:
s = input()
start = end = 0
for i in range(len(s)):
    if s[i] == 'A':
        start = i
for i in range(len(s)-1, -1, -1):
    if s[i] == 'Z':
        end = i + 1
print(end - start)

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)-1, 0, -1):
    if s[i] == 'Z':
        end = i + 1
        break
print(end - start)
Buggy code:
s=input()
print(len(s[s.find("A"):s.find("Z")+1]))

Fixed code:
s=input()
print(len(s[s.find("A"):s.rfind("Z")+1]))
Buggy code:
text = input()
a_list = []
z_list = []
for i, x in enumerate(text):
    if x == "A":
        a_list.append(i)
    if x == "Z":
        z_list.append(i)

print(a_list)
print(z_list)
a_z_len = max(z_list) - min(a_list) + 1
print(a_z_len)

Fixed code:
text = input()
a_list = []
z_list = []
for i, x in enumerate(text):
    if x == "A":
        a_list.append(i)
    if x == "Z":
        z_list.append(i)

a_z_len = max(z_list) - min(a_list) + 1
print(a_z_len)
Buggy code:
s = input()
A = s.find('A')
Z = s.find('Z')
print(Z-A+1)


Fixed code:

s = input()
A = s.find('A')
Z = s.rfind('Z')
print(Z-A+1)
Buggy code:
s = input()
i, j = 0, len(s)-1
while(1):
    if s[i] == "A":
        start = i
        break
    i += 1
while(1):
    if s[j] == "Z":
        end = j + 1
        break
    j -= 1
print(s[start:end])

Fixed code:
s = input()
i, j = 0, len(s)-1
while(1):
    if s[i] == "A":
        start = i
        break
    i += 1
while(1):
    if s[j] == "Z":
        end = j + 1
        break
    j -= 1
print(end - start)
Buggy code:
s = input()
ans = 0
flg = 0
for i in range(len(s)):
  if s[i] == 'A' and flg == 0:
    ans += 1
  elif flg == 1 and s[i] == 'Z':
    flg = 2
    ans += 1
  elif flg == 1:
    ans += 1
print(ans)

Fixed code:
s = input()
ans = 0
tmp = 0
flg = 0
for i in range(len(s)):
  if s[i] == 'A' and flg == 0:
    ans += 1
    flg = 1
  elif flg == 1 and s[i] == 'Z':
    flg = 2
    ans += 1
  elif flg == 1:
    ans += 1
  elif flg == 2 and s[i] == 'Z':
    ans += tmp+1
    tmp = 0
  elif flg == 2:
    tmp += 1
print(ans)
Buggy code:
s=list(input())
for i in range(len(s)):
    if s[i]=='A':
        a=i
for i in range(len(s)-1,0,-1):
    if s[i]=='Z':
        b=i
print(b-a+1)


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

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

for i in range(len(s)):
    if s[i] == 'A':
        tmp1 = i
        
for i in range(1,len(s)):
    if s[-i] == 'Z':
        tmp2 = len(s) - i
   
print((tmp2-tmp1)+1)
        

Fixed code:
s = list(input())

for i in range(len(s)):
    if s[i] == 'A':
        tmp1 = i
        break
        
for i in range(1,len(s)):
    if s[-i] == 'Z':
        tmp2 = len(s) - i
        break

   
print((tmp2+1)-tmp1)
Buggy code:
A = input()
count = 0
p = len(A)
min_=200000
max_=0
for i in range(p):
  if (A[i] == 'A'):
    min_ = min(i,min_)
    print(min_)
  if (A[i] == 'Z'):
    max_ = max(i,max_)
    print(max_)
print(max_-min_+1)

Fixed code:
A = input()
count = 0
p = len(A)
min_=200000
max_=0
for i in range(p):
  if (A[i] == 'A'):
    min_ = min(i,min_)
  if (A[i] == 'Z'):
    max_ = max(i,max_)
print(max_-min_+1)
Buggy code:
s = [i for i in input()]
index_Z = [i for i, x in enumerate(s) if x == 'Z']

print(max(index_Z) - s.index('A'))

Fixed code:
s = [i for i in input()]
index_Z = [i for i, x in enumerate(s) if x == 'Z']

print(max(index_Z) - s.index('A') + 1)
Buggy code:
s=input()
flag1=0
flag2=0

for i in range(len(s)):
    if s[i]=='A' and flag1==0:
        start=i
        flag1=1
    elif s[i]=='Z' and flag1==1 and flag2==0:
        flag2=1
        finish=i

print(finish-start+1)


Fixed code:
s=input()
flag1=0

for i in range(len(s)):
    if s[i]=='A' and flag1==0:
        start=i
        flag1=1
    elif s[i]=='Z' and flag1==1:
        finish=i

print(finish-start+1)
Buggy code:
sample = input()
new = list(sample)
#if "A" in new:
a_pos = new.index('A')
#if "Z" in new:
z_pos = new.index('Z')
print(z_pos-a_pos+1)




Fixed code:
sample = input()
#new = list(sample)
#if "A" in new:
a_pos = sample.index('A')
#if "Z" in new:
z_pos = sample.rfind('Z')
print(z_pos-a_pos+1)
Buggy code:
s = input()

sl = list(s)

for i in range(0,len(sl)-1):
    if sl[i] == "A":
        st = i

for j in range(len(sl),0,-1):
    if sl[j-1] =="Z":
        en = j-1


print (en-st+1)

Fixed code:
s = input()

sl = list(s)

for i in range(0,len(sl)-1):
    if sl[i] == "A":
        st = i+1
        break
for j in range(len(sl),0,-1):
    if sl[j-1] =="Z":
        en = j
        break

print (en-st+1)
Buggy code:
s = list(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] == 'Z':
    Z = i
    
print(Z - A)

Fixed code:
s = list(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] == 'Z':
    Z = i
    
print(Z - A + 1)
Buggy code:
s=list(input())
for i in range(len(s)):
    if s[i]=="A":
        k=i
        break
for i in range(len(s)-1,1,-1):
    if s[i]=="Z":
        l=i
        break
print(k,l)
print(l-k+1)

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

Aindex = s.find("A")
Zindex = -1

for index,character in enumerate(s[Aindex:]):
    if character == "Z":
        Zindex = index

print(s[Aindex:Zindex+1])

Fixed code:
s=input()
Aindex = s.find("A")
Zindex = -1
for index,character in enumerate(s[Aindex:]):
    if character == "Z":
        Zindex = index + Aindex
print(len(s[Aindex:Zindex+1]))
Buggy code:
if __name__ == "__main__":
    S = input().split()
    A = 2 ** 100
    Z = 2 ** 100
    res = 0
    for x,y in enumerate(S):
        if y == 'A':
            A = x
        if y == 'Z':
            Z = x
            res = max(res, (Z - A) + 1)
    print (res)


Fixed code:
if __name__ == "__main__":
    S = input()
    A = 2 ** 100
    Z = 2 ** 100
    res = 0
    for x,y in enumerate(S):

        if y == 'A':
            A = min(A,x)
        if y == 'Z':
            Z = x
            res = max(res, (Z - A) + 1)
    print (res)
Buggy code:
s = input()
print(s[1:-1])
r_s = s[::-1]

if r_s.index("Z")==0:
    print(len(s[s.index("A"):]))
else:
    print(len(s[s.index("A"):-r_s.index("Z")]))

Fixed code:
s = input()
r_s = s[::-1]

if r_s.index("Z")==0:
    print(len(s[s.index("A"):]))
else:
    print(len(s[s.index("A"):-r_s.index("Z")]))
Buggy code:
s = str(input())
print(s.find("Z")-s.find("A")+1)

Fixed code:
s = str(input())
print(s.rfind('Z') - s.find('A') + 1)
Buggy code:
s = str(input())

a = 0
z = 0

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

    elif s[i]  = "Z":
        z = max(z,i)

print(z - a + 1)

Fixed code:
s = str(input())

a = 199999
z = 0

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

    elif s[i]  == "Z":
        z = max(z,i)

print(z - a + 1)
Buggy code:
# -*- coding: utf-8 -*-

x = input()

a = 0
z = 0

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

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

print(x[a:z])


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

x = input()

a = 0
z = 0

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

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

print(len(x[a:z]))
Buggy code:

s=input()

ds=list(s)


c1=0
while ds[c1]!='A'
  c1+=1

c2=-1
while ds[c2]!='Z':
  c2-=1

print(s[c1:c2])



Fixed code:
s=input()
 
ds=list(s)
 
 
c1=0
while ds[c1]!='A':
  c1+=1
 
c2=-1
while ds[c2]!='Z':
  c2-=1
 
print(len(s[c1:c2])+1)
Buggy code:
s = input()
start = -1
end = -1
for i in range(len(s)):
    if s[i] == "A":
        start = i
        break
for i in range(len(s)):
    if s[-i] == "Z":
        end = len(s) - i
        break
print(end - start + 1)

Fixed code:
s = input()
start = -1
end = -1
for i in range(len(s)):
    if s[i] == "A":
        start = i
        break
for i in range(1,len(s)):
    if s[-i] == "Z":
        end = len(s) - i
        break
print(end - start + 1)
Buggy code:
s=input()
for i in range(len(s)):
  if s[i]=="A":
    pA = i
for i in range(len(s)):
  if s[-i-1] == "Z":
    pZ = i
print(len(s)-pA-pZ-1)

Fixed code:
s=input()
for i in range(len(s)):
  if s[i]=="A":
    pA = i
    break
for i in range(len(s)):
  if s[-i-1] == "Z":
    pZ = i
    break
print(len(s)-pA-pZ)
Buggy code:
s=input()
for i in range(len(s)):
    if s[i]=="A":
        a=i
for i in range(a+1,len(s)):
    if s[i]=="Z":
        z=i
print(z-a+1)

Fixed code:
s=input()
for i in range(len(s)):
    if s[i]=="A":
        a=i
        break
for i in range(len(s)-1,0,-1):
    if s[i]=="Z":
        z=i
        break
print(z-a+1)
Buggy code:
s = input()
list_s = list(s)

a_num = -1
z_num = -1

for i in range(len(s)):
    if list_s[i] == "A":
        a_num = i

    if list_s[i] == "Z":
        z_num = i

print(z_num - a_num + 1)

Fixed code:
s = input()
list_s = list(s)

a_num = len(s)
z_num = -1

for i in range(len(s)):
    if list_s[i] == "A":
        if a_num > i:
            a_num = i

    if list_s[i] == "Z":
        z_num = i

print(z_num - a_num + 1)
Buggy code:
s=input()
l=len(s)
x,y=0
for i in range(l):
  if s[i]=='A':
    x=i
    break
for j in range(l-1,0,-1):
  if s[j]=='Z':
    y=j
    break
print(y-x+1)

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

count = 0
top = 0
end = 0

while True:
    if S[count] == 'A':
        top = count
        break
    count += 1

count = -1
while True:
    if S[count] == 'Z':
        end = count
        break
    count -= 1

print(S[top:end + 1])



Fixed code:
S = input()

count = 0
top = 0
end = 0

while True:
    if S[count] == 'A':
        top = count
        break
    count += 1

count = -1
while True:
    if S[count] == 'Z':
        end = count + 1
        break
    count -= 1

if end == 0:
    print(len(S[top:]))
else:
    print(len(S[top:end]))
Buggy code:
S = input()
N = len(S)
for s, i in enumerate(S):
    if s == 'A':
        a_index = i
        break
for s, i in enumerate(S[::-1]):
    if s == 'A':
        z_index = i
        break

print(N - z_index - a_index)


Fixed code:
S = input()
N = len(S)
for i, s in enumerate(S):
    if s == 'A':
        a_index = i
        break
for i, s in enumerate(S[::-1]):
    if s == 'Z':
        z_index = i
        break

print(N - z_index - a_index)
Buggy code:
s = list(input())

flag = 0
pos_a, pos_z = 1
length = 0

for i, ltr in enumerate(s, 1)
  if ltr == 'A':
    pos_a = i
    flag = 1
  elif ltr == 'Z':
    if flag == 1:
      pos_z = i
      if pos_z - pos_a > length:
        length = pos_z - pos_a
      else:
        flag = 0
        
print(length)

Fixed code:
s = list(input())

flag = 0
pos_a, pos_z = 1, 1
length = 0

for i, ltr in enumerate(s, 1):
  if ltr == 'A' and flag == 0:
    pos_a = i
    flag = 1
  elif ltr == 'Z' and flag == 1:
    pos_z = i
    if pos_z - (pos_a -1) > length:
      length = pos_z - (pos_a -1)
    else:
      flag = 0

print(length)
Buggy code:
s = input()
start = s.index('A')
end = s[::-1].index('Z')
print(len(s[start:end + 1]))



Fixed code:
s = input()
n = len(s)
start = s.index('A')
end = n - s[::-1].index('Z')
print(len(s[start:end]))
Buggy code:
# https://atcoder.jp/contests/abc053/tasks/abc053_b

s = input()
n = len(s)
for i in range(n):
    if s[i] == 'A':
        start = i
        break
for i in range(n - 1, -1):
    if s[i] == 'Z':
        end = i
        break
print(len(s[start:end+1]))


Fixed code:
# https://atcoder.jp/contests/abc053/tasks/abc053_b

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

Fixed code:
S=[x for x in input()]
T=S[::-1]
start=0
end=0
for i in range(len(S)):
  if S[i]=='A':
    start=i
    break
for i in range(len(T)):
  if T[i]=='Z':
    end=i
    break
    
print(len(S)-end-start)
Buggy code:
s=input()
a_min=0
z_max=0
for i in s:
  if s[i]=="A":
    a_min=i
    break
for i in s:
  if s[i]=="Z":
    z_max=i
print(z_max-a_min+1)

Fixed code:
s=input()
a_min=0
z_max=0
for i in range(len(s)):
  if s[i]=="A":
    a_min=i
    break
for i in range(len(s)):
  if s[i]=="Z":
    z_max=i
print(z_max-a_min+1)