Problem:


Score : 200 points

Problem Statement

Snuke has decided to construct a string that starts with A and ends with Z, by taking out a substring of a string s (that is, a consecutive part of s).

Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with A and ends with Z.

Constraints

1 ≦ |s| ≦ 200{,}000

s consists of uppercase English letters.

There exists a substring of s that starts with A and ends with Z.

Input

The input is given from Standard Input in the following format:

s

Output

Print the answer.

Sample Input 1

QWERTYASDFZXCV

Sample Output 1

5

By taking out the seventh through eleventh characters, it is possible to construct ASDFZ, which starts with A and ends with Z.

Sample Input 2

ZABCZ

Sample Output 2

4

Sample Input 3

HASFJGHOGAKZZFEGA

Sample Output 3

12



Sample input:
QWERTYASDFZXCV


Sample output:
5

Submission status: Wrong Answer

Solution code:
s = list(input())

for i in s:
    if i == 'A':
        a = s.index(i)
        break
for i in s:
    if i == 'Z':
        z = s.index(i)
print(z-a+1)

Submission status: Wrong Answer

Solution 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))

Submission status: Wrong Answer

Solution code:
S = input()
len = len(S)
start = len
end = 0
for i in range(len):
  if(S[i] == "A"):
    temp_start = i+1
    start = min(start,temp_start)
  if(S[i] == "Z"):
    temp_end = i+1
    end = max(end,temp_end)
print(end-start)

Submission status: Wrong Answer

Solution code:
s = input()
lengs = s.rfind("Z") - s.find("A")
print(lengs)

Submission status: Wrong Answer

Solution 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]))

Submission status: Wrong Answer

Solution code:
a = input()
for i in range(len(a)):
    if a[i] == "A":
        b = i
        break
for j in range(b,len(a)):
    if a[j] == "Z":
        c = j
        break
print(c-b+1)

Submission status: Wrong Answer

Solution 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
        break
print(c-b+1)

Submission status: Wrong Answer

Solution 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)

Submission status: Wrong Answer

Solution code:
a=input()
b=a.find('A')
c=a.find('Z')
print(c-b+1)

Submission status: Wrong Answer

Solution code:
s = input()

for i in range(len(s)):
  if s[i] == "A":
    st = i-1
    break
for i in range(len(s)):
  if s[-i] == "Z":
    en = len(s)-i
    break;
print(en - st)

Submission status: Wrong Answer

Solution 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(r - l + 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution 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()

Submission status: Wrong Answer

Solution code:
a=input()
for i in range(len(a)):
  if a[i]=="A":
    b=i
    break
for i in range(len(a)):
  if a[len(a)-i-1]:
    c=i
    break
print(c-b)

Submission status: Wrong Answer

Solution 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)

Submission status: Wrong Answer

Solution code:
s = input()

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

Submission status: Wrong Answer

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

s = list(input())

tmp_str =""
output=""
start = False
end = False
for ss in s:
    if ss == 'A' and start == False:
        tmp_str = ss
        start = True
    elif ss == 'Z' and start == True:
        tmp_str += ss
        if len(output) < len(tmp_str):
            output = tmp_str
        end = True
    elif end == True:
        start = end = False
        if len(output) < len(tmp_str):
            output = tmp_str
    elif start == True:
        tmp_str += ss

print(len(output))

Submission status: Wrong Answer

Solution code:
s = input()
a = s.index('A')
print(s[a:].index('Z')+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=list(input())
a=0
z=0

print(len(s))

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

print(a)

S=list(reversed(s))
for j in range(len(S)):
    if S[j]=="Z":
        z=j
        break
print(z)

print(len(s)-a-z)

Submission status: Wrong Answer

Solution code:
s=list(input())
a=0
z=0

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

ss=s.reverse()
for i in range(len(s)):
    if i=="Z":
        z=i
        break
    
print(len(s)-(a+z))

Submission status: Wrong Answer

Solution 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)

Submission status: Wrong Answer

Solution code:
import re

letter = str(input())
pattern = 'A(.*)Z'
target = re.search(pattern, letter).group()
print(target)

Submission status: Wrong Answer

Solution code:
string = input()
index_of_A = string.index("A")
index_of_Z = string.index("Z", index_of_A)

print(index_of_Z - index_of_A + 1)

Submission status: Wrong Answer

Solution code:
string = input()
index_of_A = string.index("A")
index_of_Z = string.index("Z", index_of_A+1)

print(index_of_Z - index_of_A + 1)

Submission status: Wrong Answer

Solution code:
string = input()
index = string.index("A")
count = 0
i = index
while string[i] != "Z":
  count +=1
  i+=1
print(count)

Submission status: Wrong Answer

Solution code:
string = input()
index = string.index("A")
count = 0
i = index
while string[i] != "Z":
  count +=1
  i+=1
print(count+1)

Submission status: Wrong Answer

Solution code:
string = input()
index = string.index("A")
count = 1
i = index
while string[i] != "Z":
  count +=1
  i+=1
print(count+1)

Submission status: Wrong Answer

Solution code:
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

s = input()
state = False
chk2 = False
chk = 0
for i in range(len(s)):
    if state == False and s[i] == "A":
        state = True
        chk += 1
    elif state == True and s[i] == "Z":
        chk += 1
        if ans < chk:
            ans = chk
            chk2 = True
        chk = 0
        state = False
    elif state == False and s[i] == "Z" and chk2 == True:
        ans += 1
    elif state == False and chk2 == True:
        chk2 = False
    elif state == True:
        chk += 1
print(ans)

Submission status: Wrong Answer

Solution 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)

Submission status: Wrong Answer

Solution 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 +1)

Submission status: Wrong Answer

Solution 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])

Submission status: Wrong Answer

Solution code:
S = input()

N = len(S)
Aflag = 0
Zflag = 0
for i in range(N):
    if Aflag == 0 and S[i] == 'A':
        Aflag = i
    elif S[i] == 'Z':
        Zflag = i

print(Zflag-Aflag+1)

Submission status: Wrong Answer

Solution code:
s = str(input())
start = 0
end = 0
for i in range(len(s)):
    if s[i]=='A' and start==0:
        start = i
    if s[-(i+1)]=='Z' and end==0:
        end = len(s)-i
    if start != 0 and end != 0:
        break
print(end-start)

Submission status: Wrong Answer

Solution code:
s = str(input())
start = 0
end = 0
for i in range(len(s)):
    if s[i]=='A' and start==0:
        start = i
    if s[-(i+1)]=='Z' and end==0:
        end = len(s)-i
print(end-start)

Submission status: Wrong Answer

Solution code:
a = input("")
a_num = a.index("A")
for i in range(len(a)-1,-1,-1):
    if a[i]=="Z":
        z_num = i+1
        break
print(i)

Submission status: Wrong Answer

Solution code:
a = input("")
a_num = a.index("A")
for i in range(len(a)-1,-1,-1):
    if a[i]=="Z":
        z_num = i+1
        break
print("num:" + str(len(a[a_num:z_num])) + \
    "text:" + a[a_num:z_num])

Submission status: Wrong Answer

Solution code:
S = input()

st = 0
en = 0

for i in range(len(S)):
    if S[i] == "A" and st == 0:
        st = i

    if S[i] == "Z":
        en = i

print(en - st + 1)

Submission status: Wrong Answer

Solution 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)

Submission status: Wrong Answer

Solution code:
N = list(input())
ans = 0

for i in range(len(N)):
  if N[len(N)-1-i] == "Z":
    ans = len(N) - i
    break
  else:
    pass
  
  for j in range(len(N)):
    if N[j] == "A":
      ans -= (j - 1)
      break
    else:
      pass
    
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
print(s.rfind('Z') - s.find('A'))

Submission status: Wrong Answer

Solution 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)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()
#Aの探索
for i in range(len(S)):
    if S[i] == "A":
        S = S[i:]
        break

#Zの探索
for i in range(1, len(S)+1):
    if S[-i] == "Z":
        S = S[:-i+1]
        break
print(len(S))

Submission status: Wrong Answer

Solution code:
s = input()

ans = 0
tmp = 0
flag = 0
for i in range(len(s)-1):
    if s[i] == "A":
        flag = 1
    
    if flag:
        tmp += 1
    
    if s[i] == "Z" and s[i+1] != "Z":
        flag = 0
        ans = max(tmp, ans)

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()

ans = 0
flag = 0
for i in s:
    if i == "A":
        flag = 1
    
    if flag:
        ans += 1
    
    if i == "Z":
        flag = 0

print(ans)

Submission status: Wrong Answer

Solution code:
s = list(input())
start = 0
end = 0
for i in range(len(s)):
  if s[i] == "A":
    start = i
for i in reversed(range(len(s))):
  if s[i] == "Z":
    end = i
print(end - start + 1)

Submission status: Wrong Answer

Solution 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)

Submission status: Wrong Answer

Solution 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)

Submission status: Wrong Answer

Solution code:
s = input()
print(s.index('Z')-s.index('A')+1)

Submission status: Wrong Answer

Solution code:
s=input()

a=s.find('A')
z=s.rfind('Z')

print(z-a)

Submission status: Wrong Answer

Solution code:
s = input()

a = s.find("A")
z = s.rfind("Z")

print(s[a:z + 1])

Submission status: Wrong Answer

Solution code:
s = input()
a = s.index('A')
z = s.index('Z')
print(z-a+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
l = len(s)
for i in range(l):
    if s[i] == 'A':
        a = i
        break
for i in range(l - 1, -1, -1):
    if s[i] == 'Z':
        z = i
        break
print(z - a)

Submission status: Wrong Answer

Solution code:
s = input()
A = None
Z = None
for i, c in enumerate(s):
  if c == 'A':
    A = i
  if c == 'Z':
    Z = i

print(Z-A+1)

Submission status: Wrong Answer

Solution code:
s = input()
A = None
Z = None
for i in range (len(s)):
  if s[i] == 'A':
    A = i
  if s[i] == 'Z':
    Z = i

print(Z-A+1)

Submission status: Wrong Answer

Solution code:
s = input()
A = 0
Z = 0
for i in range (len(s)):
  if s[i] == "A":
    A = i
  if s[i] == "Z":
    Z = i

print(Z-A+1)

Submission status: Wrong Answer

Solution code:
s = input()
A = 0
for i in range (len(s)):
  if s[i] == "A":
    A = i

Z= 0
for i in range (len(s)):
  if s[i] == "Z":
    Z = i

print(Z-A+1)

Submission status: Wrong Answer

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

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

print(Z-A+1)

Submission status: Wrong Answer

Solution code:
S=input()
print(S.rfind('z')-S.find('a')+1)

Submission status: Wrong Answer

Solution code:
S=input()
print(S.find('a')-S.rfind('z')+1)

Submission status: Wrong Answer

Solution code:
s = input()

a = s.find("A")
z = s.find("Z")
print(z-a+1)

Submission status: Wrong Answer

Solution 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)

Submission status: Wrong Answer

Solution 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)

Submission status: Wrong Answer

Solution code:
s = str.upper(input())

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


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

Submission status: Wrong Answer

Solution code:
s = str.upper(input())

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


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

Submission status: Wrong Answer

Solution code:
s = input()
a = s.index('A')
z = s.index('Z')
print(len(s[a:z+1]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S=input()

count = 0
maxCount = 0
for k,i in enumerate(list(S)):
  if i == "A"  and count == 0:
    count+=1

  elif i == "Z" and count > 0 and k<len(S)-1 :
    count +=1
    if S[k+1] != "Z":
      maxCount = max(maxCount, count)
      count = 0
  elif i == "Z" and count > 0:
    count +=1
    maxCount = max(maxCount, count)
    count = 0

  elif count > 0 :
    count +=1

  else :
    None

print(maxCount)

Submission status: Wrong Answer

Solution code:
S=input()

count = 0
maxCount = 0
for k,i in enumerate(list(S)):
  if i == "A"  and count == 0:
    count+=1

  elif  i == "Z" and count > 0 and k<len(S)-1 :
    count +=1
    if S[k+1] != "Z":
      maxCount = max(maxCount, count)
      count = 0
  elif i == "Z" and count > 0:
    count +=1
    maxCount = max(maxCount, count)
    count = 0

  elif count > 0 :
    count +=1

  else :
    None



print(maxCount)

Submission status: Wrong Answer

Solution code:
S=input()

count = 0
maxCount = 0
for k,i in enumerate(list(S)):
  if i == "A"  and count == 0:
    count+=1

  elif  i == "Z" and count > 0 and k<len(S)-1 :
    count +=1
    if S[k+1] != "Z":
      maxCount = max(maxCount, count)
      count = 0
  elif i == "Z" and count > 0:
    count +=1
    maxCount = max(maxCount, count)
    count = 0

  elif count > 0 :
    count +=1
    print(i, count)

  else :
    None



print(maxCount)

Submission status: Wrong Answer

Solution code:
S=input()

count = 0
maxCount = 0
flag = False
for i in list(S):
  if i == "A" and flag == False:
    flag = True
    count+=1

  elif i == "Z" and flag:
    count +=1 
    flag = False
    maxCount = max(maxCount, count)
    count = 0

  elif flag :
    count +=1

  else :
    None



print(maxCount)

Submission status: Wrong Answer

Solution code:
s=input()
i=s.find('A')
j=s.rfind('Z')

print(abs(i-j+1))

Submission status: Wrong Answer

Solution code:
s=input()
i=s.find('A')
j=s.rfind('Z')

print(i)
print(j)

print(abs(i-j+1))

Submission status: Wrong Answer

Solution code:
s = input()
aidx = -1
zidx = -1
for i in range(len(s)):
  if aidx == -1 and s[i] == 'A':
    aidx = i
  if zidx == -1 and s[len(s)-1-i] == 'Z':
    zidx = len(s)-1-i
  if aidx != -1 and zidx != -1:
    break
print(zidx-aidx)

Submission status: Wrong Answer

Solution code:
#文字列ｓのうちA～Zまでを取り出す
s = list(input())
sa = s.index("A")
m = [i for i, x in enumerate(s) if x == 'Z']
mz = int(m[-1])
p = (s[sa:mz])
print(len(p))

Submission status: Wrong Answer

Solution code:
s=input()
ans=0
x=0
y=len(s)-1
for i in range(len(s)):
    if s[i]=='A':
        x=i
        break
for i in range(len(s)-1,0,-1):
    if s[-i]=='Z':
        y=i
        break

print(y-x+1)

Submission status: Wrong Answer

Solution code:
s=input()
ans=0
x=0
y=len(s)-1
for i in range(len(s)):
    if s[i]=='A':
        x=i
    break
for i in range(len(s)-1,0,-1):
    if s[-i]=='Z':
        y=i

print(y-x+1)

Submission status: Wrong Answer

Solution code:
import sys

s = str(input())
ans = ""

for i in range(0,len(s)):
  if s[i] == "A":
    for j in range(i,len(s)):
      if s[j] != "Z":
        ans = ans +s[j]
      else:
        ans = ans + "Z"
        print (len(ans))
        sys.exit()

Submission status: Wrong Answer

Solution code:
import sys

s = str(input())
ans = ""

for i in range(0,len(s)):
  if s[i] == "A":
    for j in range(i,len(s)):
      if s[j] != "Z":
        ans = ans +s[j]
      else:
        ans = ans + "Z"
        print(ans)
        print (len(ans))
        sys.exit()

Submission status: Wrong Answer

Solution 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)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=list(input())
ans,c,f=0,0,0
for i in range(len(s)):
    if s[i]=='A' and f==0:f=1
    if f==1: c+=1
    if f==1 and s[i]=='Z':
        ans=max(ans,c)
        if i<len(s)-1:
            if s[i+1]!='Z':
                c=0;f=0
print(ans)

Submission status: Wrong Answer

Solution code:
s=list(input())
ans,c,f=0,0,0
for i in range(len(s)):
    if s[i]=='A' and f==0:f=1
    if f==1: c+=1
    if i<len(s)-1:
        if s[i]=='Z' and s[i+1]!='Z' and f==1:
            ans=max(ans,c); c=0
    if i==len(s)-1 and s[i]=='Z':
        ans=max(ans,c)
print(ans)

Submission status: Wrong Answer

Solution code:
s=list(input())
ans,c,f=0,0,0
for i in range(len(s)):
    if s[i]=='A' and f==0:f=1
    if f==1: c+=1
    if i<len(s)-1:
        if s[i]=='Z' and s[i+1]!='Z' and f==1:
            ans=max(ans,c); c=0
print(ans)

Submission status: Wrong Answer

Solution code:
s=list(input())
n=len(s)
print(s)
a=s.index("A")
for i in range(n,0,-1):
  print(i)
  if s[i-1]=='Z':
    z=i
    break
sum=z-a
print(sum)

Submission status: Wrong Answer

Solution code:
s = input()
start = 0
for i in range(len(s)):
  if s[i] == 'A' and start == 0:
    start = i
stop = 0
for i in range(len(s), start, -1):
   if s[i -1] == 'Z' and stop == 0:
     stop = i

Submission status: Wrong Answer

Solution code:
s = input()
start = 0
for i in range(len(s)):
  if s[i] == 'A' and start == 0:
    start = i
print(start)
stop = 0
for i in range(len(s), start, -1):
   if s[i -1] == 'Z' and stop == 0:
     stop = i
print(stop)
print(stop - start)

Submission status: Wrong Answer

Solution code:
#B
Str = input()
A_flag = False
Z_flag = False
ans = 0
cnt = 0
for s in Str:
    if s == "A" and A_flag == False:
        A_flag = True
    if A_flag:
        #print(s)
        cnt += 1
        #print(cnt)
    if Z_flag:
        if s == "Z":
            cnt += 1
        else:
            ans = max(ans,cnt)
            Z_flag = False
            cnt = 0
    if A_flag and s == "Z":
        A_flag = False
        Z_flag = True
if Z_flag == True:
    ans = max(cnt,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
  s=input()
  start=0
  end=len(s)
  for i in range(0,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
main()

Submission status: Wrong Answer

Solution 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")]))

Submission status: Wrong Answer

Solution code:
s = input()
x = ""
for i,k in enumerate(s):
    if k == "A":
        x = s[i:][::-1]
        for j,t in enumerate(x):
            if t == "Z":
                x = x[j:]
                
print(len(x))

Submission status: Wrong Answer

Solution code:
s = input()
x = ""
for i,k in enumerate(s):
    if k == "A":
        x = s[i:][::-1]
        for i,t in enumerate(x):
            if t == "Z":
                x = x[i:]
                
print(len(x))

Submission status: Wrong Answer

Solution code:
s=input()
print(len(s[s.find("A"):s.find("Z")+1]))

Submission status: Wrong Answer

Solution code:
s=input()
print(s.find("Z")-s.find("A")+1)

Submission status: Wrong Answer

Solution code:
s=input()
r_s=s[::-1]
a=0
b=0
n=len(s)
for i in range(n):
    if s[i]=="A":
        a=i
        break
for j in range(n):
    if r_s[j]=="Z":
        z=j
        break
print(len(s[a:-z]))

Submission status: Wrong Answer

Solution 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)

Submission status: Wrong Answer

Solution code:
s = input()
stack = []
best_length = -float('inf')
for i,w in enumerate(s):
  if w=='A':
    stack.append(i)
  elif w=='Z' and stack:
    start = stack.pop()
    length = i - start + 1
    if length > best_length:
      best_length = length
print(best_length if best_length > 0 else 0)

Submission status: Wrong Answer

Solution code:
s = input()
stack = []
best_length = -float('inf')
for i,w in enumerate(s):
  if w=='A':
    stack.append(i)
  if w=='Z' and stack:
    start = stack.pop()
    length = i - start + 1
    if length > best_length:
      best_length = length
print(best_length)

Submission status: Wrong Answer

Solution code:
s = input()
ans = 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
print(ans)

Submission status: Wrong Answer

Solution 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)

Submission status: Wrong Answer

Solution code:
s=str(input())
s=list(s)
for i in range(0,len(s)):
  if s[i]=="A":
    temp1=i
    break    
for j in range(temp1+1,len(s)):
  if s[j]=="Z":
    temp2=j
    break 
print(temp2-temp1+1)

Submission status: Wrong Answer

Solution code:
s = input()

a = s.index('A')
for i in range(len(s)):
  if s[-i] == 'Z':
    z = len(s) - i
    break

print(z - a + 1)

Submission status: Wrong Answer

Solution code:
s = input()

a = s.index('A')
for i in range(len(s)):
  if s[-i] == 'Z':
    z = len(s) - i

print(z - a + 1)

Submission status: Wrong Answer

Solution code:
s = input()
t = []
u = []
for i in range(len(s)):
    if s[i] == 'A':
        t.append(i)
    if s[i] == 'Z':
        u.append(i)
print(t)
print(u)
print(max(u) - min(t) + 1)

Submission status: Wrong Answer

Solution code:
s = input()

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

print(ans_z - ans_a + 1)

Submission status: Wrong Answer

Solution code:
s = input()

ans = 0
for i in range(len(s)):
    ans_a = 0
    ans_z = 0
    if (s[i] == "A"):
        ans_a = i
    if (s[-(i+1)] == "Z"):
        ans_z = len(s) - i
    if(ans_z - ans_a + 1 > ans):
        ans = ans_z - ans_a + 1
    
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
aNum = s.index("A")
for i in range(len(s)):
    if s[-i] == "Z":
        zNum = len(s) - i
        break
print(zNum - aNum +1)

Submission status: Wrong Answer

Solution code:
s=input()
for i in range(len(s)):
    if s[i]=="A":
        x=i#"A"のインデックス番号
        break
for i in range(len(s)):
    if s[-i]=="Z":
        y=len(s)-i#"Z"のインデックス番号
        break
ans=y-x+1
print(ans)

Submission status: Wrong Answer

Solution code:
s = list(input())
for i in range(len(s)):
    if s[i] == "A":
        a = i
    elif s[i] == "Z":
        z = i

print(len(s[a:z]))

Submission status: Wrong Answer

Solution 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)

Submission status: Wrong Answer

Solution code:
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    s =     _in[0]   # type:str
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    str_ = s[s.find('A'):s.rfind('Z')+1]
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(str_)

Submission status: Wrong Answer

Solution code:
s = input()
sa = 0
sz = 0
for i in range(len(s)):
    if sa == 0 and s[i] == "A":
        sa = i
    if s[i] == "Z":
        sz = i
print(sz-sa+1)

Submission status: Wrong Answer

Solution code:
s=input()
a=s.index("A")
z=s[::-1].index("Z")
print(len(s[a:-z]))

Submission status: Wrong Answer

Solution code:
s = input()
for a in range(len(s)):
  if s[a]=='A':
    break
s = s[::-1]
for z in range(len(s)):
  if s[z] =='Z':
    break
s= s[::-1]
print(len(s[a:-z]))

Submission status: Wrong Answer

Solution code:
s = input()
for a in range(len(s)):
  if s[a]=='A':
    break
s = s[::-1]
for z in range(len(s)):
  if s[z] =='Z':
    break
s= s[::-1]
print(s[a:-z+1])

Submission status: Wrong Answer

Solution code:
s = list(input())
n = len(s)
left = 0
for i,c in enumerate(s):
    if c == "A":
        left = i
right = 0
for i,c in enumerate(reversed(s)):
    if c == "Z":
        right = n-i
print(right-left)

Submission status: Wrong Answer

Solution code:
s = list(input())

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

for i, ltr in enumerate(s, 1):
  if ltr == 'A':
    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)

Submission status: Wrong Answer

Solution code:
s = list(input())

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

for i, ltr in enumerate(s, 1):
  if ltr == 'A':
    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)

Submission status: Wrong Answer

Solution code:
s = list(input())

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

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

print(length)

Submission status: Wrong Answer

Solution code:
s = list(input())

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

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

print(length)

Submission status: Wrong Answer

Solution code:
s = str(input())
k = 1
a = 0
b = 0
num = 0

for i in range(len(s)):
    if s[i] == 'A':
        if k == 1:
            a = i
            k = 2
    if s[i] == 'Z':
        if k == 2:
            b = i - a + 1
            k = 1
            if num < b:
                num = b

print(num)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
a = s.find("A")
z = s. find("Z")
print(z - a + 1)

Submission status: Wrong Answer

Solution code:
s = (input())
sa = s.find("a")
sz = int(s.rfind("z"))
print(sz-sa+1)

Submission status: Wrong Answer

Solution code:
S = input()
resA=0
resZ=0
for i in range(len(S)):
	if S[i]=='A' and resA==0:
		resA=i
	elif S[i]=='Z':
		resZ=i
if resA !=0 and resZ !=0:
	print(resZ-resA+1)
else:
	print(0)

Submission status: Wrong Answer

Solution code:
S = input()
resA=0
resZ=0
for i in range(len(S)):
	if S[i]=='A' and resA==0:
		resA=i
	elif S[i]=='Z':
		resZ=i
print(resZ-resA+1)

Submission status: Wrong Answer

Solution code:
S = input()
resA=0
resZ=0
for i in range(len(S)):
	if S[i]=='A':
		resA=i
	elif S[i]=='Z':
		resZ=i
print(resZ-resA+1)

Submission status: Wrong Answer

Solution code:

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

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

ans = max(0,r-l)
print(ans)

Submission status: Wrong Answer

Solution code:

s = list(input())
n = len(s)
l = 0
r = 0
ans = 0

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

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

ans = max(0,r-l)
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
for i in range(len(s)):
    if s[i] == 'A':
        head = i
        break
for i in range(len(s)):
    if s[-(1+i)] == 'Z':
        tail = len(s)-i-1
        break
print('tail=' + str(tail))
print('head=' + str(head))
print(tail - head + 1)

Submission status: Wrong Answer

Solution 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

Submission status: Wrong Answer

Solution 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)