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: Accepted

Solution code:
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

# Written by NoKnowledgeGG @YlePhan

#import math
#mod = 10**9+7
def main():
  s = input()
  s_l = len(s)
  
  for i in range(s_l):
    if s[i] == 'A':
      st = i
      break
  for i in range(s_l-1,-1,-1):
    if s[i] == 'Z':
      en = i
      break
  print(en - st + 1)
  
  
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
# coding: utf-8

s = input()

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

Submission status: Accepted

Solution code:
s = list(input())

for i, j in enumerate(s):
    if j == "A":
        temp = i
        break
for i, j in enumerate(reversed(s)):
    if j == "Z":
        temp2 = len(s) - i
        break

print(len("".join(s[temp:temp2])))

Submission status: Accepted

Solution code:
s = list(input())
a = s.index('A')
s.reverse()
b = s.index('Z')
c = len(s) -b
print(c-a)

Submission status: Accepted

Solution code:
S = input()
flag = False
start = 0
for i in range(len(S)):
    s = S[i]
    if s == 'A' and not flag:
        flag = True
        start = i
    if flag and s == 'Z':
        end = i
ans = end - start + 1
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
line = input()
num = len(line)
dust = []
for i in line:
  if i != "A":
    dust.append(i)
  else:
    break
for j in reversed(line):
  if j != "Z":
    dust.append(j)
  else:
    break
answer = num - len(dust)
print(answer)

Submission status: Accepted

Solution code:
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

S = input()
L = len(S)
a = -1
for i in range(L):
    if S[i] == 'A':
        a = i
        break

z = -1
for i in range(L):
    if S[-(i + 1)] == 'Z':
        z = i
        break

print(L - z - a)

Submission status: Accepted

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

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

print(zn-an+1)

Submission status: Accepted

Solution code:
s=input()
for i,j in enumerate(s):
    if j=="Z":
        ans=i
for i,j in enumerate(s):
    if j=="A":
        ans-=i-1
        break
print(ans)

Submission status: Accepted

Solution code:
s=input()
fdl=s.find("A")
fdr=s.rfind("Z")

print((fdr-fdl)+1)

Submission status: Accepted

Solution code:
s=list(input())
a=s.index('A')
s.reverse()
z=s.index('Z')
z=len(s)-s.index('Z')
print(z-a)

Submission status: Accepted

Solution code:
s = input()
ai = 0
for t in s:
	if t == 'A':
		break
	ai = ai + 1
zi = 0
for r in s[::-1]:
	if r == 'Z':
		break
	zi = zi + 1
print(len(s) - zi - ai)

Submission status: Accepted

Solution code:
S = input()

first_i_a = S.find('A')
last_i_z = S.rfind('Z')
len_AZ = last_i_z - first_i_a + 1
print(len_AZ)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# B - A to Z String
# 標準入力の取得
s = input()

# 左から"A"、右から"Z"を検索すると、その位置の差が最大の長さになる
max_length = s.rfind("Z") - s.find("A") + 1
print(max_length)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()

start = s.index("A")
end = s[::-1].index("Z")
print(len(s)-start-end)

Submission status: Accepted

Solution code:
s=input()
leng=len(s)
a=s.index("A")+1
z=leng-list(reversed(s)).index("Z")+1
print(z-a)

Submission status: Accepted

Solution code:
s = input()
a = s.find('A')
z = s[::-1].find('Z')
ans = len(s)-a-z

print(ans)

#print(*ans, sep='\n')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
pos=-1
ans=0
for i,c in enumerate(s):
    if c=='Z' and pos!=-1:
        ans=max(ans,i-pos+1)
    if c=='A' and pos==-1:
        pos=i
print(ans)

Submission status: Accepted

Solution code:
s = input()

start = s.find("A")
end = s.rfind("Z")

print(end-start+1)

Submission status: Accepted

Solution code:
s = input()

start = s.index("A")
goal = [i for i,x in enumerate(s) if x == "Z"][-1]

print(goal - start + 1)

Submission status: Accepted

Solution code:

import math
import itertools
import statistics
#import collections
s = input()
start = -1
end = -1

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

#print(s[start:end+1])
print(end-start+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())
sr = s[::-1]

print((len(s)-sr.index("Z")) - s.index("A"))

Submission status: Accepted

Solution code:
s = input()
n = len(s)
print(n-s.find('A')-s[::-1].find('Z'))

Submission status: Accepted

Solution code:
s = input()
ans=0
j=1
for i in range(len(s)):
    if s[i]=="A":
        while s[-j] != "Z":
            j += 1
        ans = len(s)-j-i+1
        break
    else:
        continue

print(ans)

Submission status: Accepted

Solution code:

s=input()

num = -1
for ss in s:
    num +=1
    if ss == "A":
        a=num
        break

num=0
for ss in reversed(s):
    num -=1
    if ss == "Z":
        z=num
        break

len=len(s[a:z])
print(len+1)

Submission status: Accepted

Solution code:
#ABC53.B
s = input()
ans = len(s)-s.find('A')-s[::-1].find('Z')
print(ans)

Submission status: Accepted

Solution code:
S = input()
a_min_ind = None
for i, s in enumerate(S):
    if s == 'A' and a_min_ind is None:
        a_min_ind = i
    if s == 'Z':
        z_max_ind = i

print(z_max_ind - a_min_ind + 1)

Submission status: Accepted

Solution code:
s=input()
N=len(s)

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

print(j-i+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=1e9
for j,i in enumerate(input()):
 if i=='A':x=min(x,j)
 if i=='Z':y=j
print(y-x+1)

Submission status: Accepted

Solution code:
s = input()

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

for j in range(len(s)):
    if s[len(s)-1-j]=='Z':
        end=len(s)-1-j
        break

print(end-start+1)

Submission status: Accepted

Solution code:
s=input()
print(len(range(s.find('A'),s.rfind('Z')+1)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=list(input())
N=len(S)
pos_Z=N-S[::-1].index("Z")
pos_A=S.index("A")
print(pos_Z-pos_A)

Submission status: Accepted

Solution code:
s , e = -1 , 0
c =  0
for i in input():
    if i == 'A':
        if s == -1:
            s = c
        
    if i == 'Z':
        e = c

    c += 1

print(e-s+1)

Submission status: Accepted

Solution code:
s = input()

i = 0
while True:
    if s[i] == "A":
        a = i
        break
    i = i + 1

i = -1
while True:
    if s[i] == "Z":
        z = i
        break
    i = i - 1

ans = len(s) - a + (z + 1)
print(ans)

Submission status: Accepted

Solution code:
s= input()

number = s.rfind("Z") - s.find("A")
print(number+1)

Submission status: Accepted

Solution code:
s = list(input())

a = -1
z = 0
for i in range(len(s)):
  if s[i] == "A" and a == -1:
    a = i
  elif s[i] == "Z":
    z = i
print(z - a + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

s = STR()
strt = 0
end = len(s) - 1
for i in range(len(s)):
    if s[i] == 'A':
        strt = i
        break
for i in reversed(range(len(s))):
    if s[i] == 'Z':
        end = i
        break
print(end - strt + 1)

Submission status: Accepted

Solution code:
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    S = input().strip()
    l = -1
    for i in range(len(S)):
        if S[i] == "A":
            l = i
            break
    for i in range(len(S)):
        if S[-(i+1)] == "Z":
            r = len(S)-i
            break
    print(r-l)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# B
s = input()

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

Submission status: Accepted

Solution code:
s = input()
a = []
z = []
for i in range(len(s)):
    if s[i] == "A":
        a.append(i)
    if s[i] == "Z":
        z.append(i)
print(int(z[-1]) - int(a[0]) + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

s = input()

a_index = s.find("A")
z_index = s.rfind("Z")

print("{}".format(z_index - a_index + 1))

Submission status: Accepted

Solution code:
s = input()

for i in range(len(s)):
    if s[i]=='A':
        left = i
        break
for i in range(len(s)):
    if s[-i-1]=='Z':
        right = len(s)-i
        break
print(right-left)

Submission status: Accepted

Solution code:
s=input()
a,z=len(s),0
for i in range(len(s)):
  if s[i]=="A":
    a=min(i,a)
  elif s[i]=="Z":
        z=max(i,z)
print(z-a+1)

Submission status: Accepted

Solution code:
import sys

s = input()
c = 0
C = 0

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

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

Submission status: Accepted

Solution code:
s = input()
a_index = s.index('A')
z_index_ = s[::-1].index('Z')+1
z_index = len(s)-z_index_
print(z_index - a_index + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
n = len(s)
for i in range(n):
    if s[i] == "A":
        t = i
        break
for j in range(n):
    if s[n-j-1] == "Z":
        u = n-j
        break
print(u-t)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

ans = len(s) + end - start
print(ans)

Submission status: Accepted

Solution code:
s = input()
l = -1
for i, c in enumerate(s):
    if c == 'A' and l == -1:
        l = i
    if c == 'Z':
        r = i
print(r - l + 1)

Submission status: Accepted

Solution code:
# coding: utf-8


s = input().rstrip()

a_index = -1
b_index = -1

for i in range(len(s)):
    if s[i] == "A":
        if a_index < 0:
            a_index = i
    elif s[i] == "Z":
        b_index = i

print(b_index-a_index+1)

Submission status: Accepted

Solution code:


def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    s=input()
    a=s.find("A")
    z=s.rfind("Z")
    print(z-a+1)
    

main()

Submission status: Accepted

Solution code:
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    S=list(input())
    print(len(S[S.index('A'):[i for i ,x in enumerate(S) if x == 'Z'][-1]+1]))


resolve()

Submission status: Accepted

Solution code:
i = list(input())
a = []
z = []
for k,s in enumerate(i):
  if s == "A":
    a.append(k+1)
  elif s == "Z":
    z.append(k+1)
print(max(z)-min(a)+1)

Submission status: Accepted

Solution code:
import re

s = input()
res = re.search('A[A-Z]+Z', s)
print(res.end() - res.start())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
t =s[::-1]
a = s.index('A')
z = t.index('Z')

print(len(s)-a-z)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()

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

Submission status: Accepted

Solution code:
s = str(input())
start = len(s)
stop = 0
for i in range(len(s)):
  if s[i] == 'A':
    start =  min(i,start)
  elif s[i] == 'Z':
    stop = max(i, stop)
  else:
    pass
print(stop-start+1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Problem B - A to Z String

# input process
s = input()
s_len = len(s)

# initizalization
a_pos = 0
z_pos = 0

# first a search
for i in range(s_len):
    a = s[i]
    if a=='A':
        a_pos = i
        break

# second z search
for i in range(s_len):
    z = s[i]
    if z=='Z':
        z_pos = i

print(z_pos - a_pos + 1)

Submission status: Accepted

Solution code:
import re
s = input()
found = re.findall("A.*Z", s)
strings = found[0]
count = 0
for i in strings:
    count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
A, Z = [], []
for i in range(len(s)):
    if s[i]=="A":
        A.append(i)
    elif s[i]=="Z":
        Z.append(i)
A, Z = min(A), max(Z)
print(len(s[A:Z+1]))

Submission status: Accepted

Solution code:
s=input()
li=[str(i) for i in s]
startA=li.index("A")+1

li.reverse()
endZ=len(li)-li.index("Z")+1

print(endZ-startA)

Submission status: Accepted

Solution code:
#53B A to Z String
s=list(input())
flag=0
for i in range(len(s)):
    if s[i]=="A":start=i;break
for j in range(len(s)-1,0,-1):
    if s[j]=="Z":finish=j;break
s2=len(s[start:finish+1])
print(s2)

Submission status: Accepted

Solution code:
s = input()
n = s.index("A")
s_reverse_list = list(reversed(s))
s_reverse = "".join(s_reverse_list)
m = s[n:len(s) - s_reverse.index("Z")]
print(len(m))

Submission status: Accepted

Solution code:
# import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools
# import collections # queue
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

def main():
    s = input()
    l = 0
    r = len(s)
    for i in range(len(s)):
        if (s[i]=='A'):
            l = i
            break
    for i in range(len(s)-1,-1,-1):
        if (s[i]=='Z'):
            r = i
            break
    ans = r - l + 1
    print(ans)
    return

if __name__=='__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
s_r = reversed(s)
s = list(s)
s_r = list(s_r)

a_ind = s.index("A")
z_ind = s_r.index("Z")
z_ind = len(s) - z_ind

ans = z_ind - a_ind

print(ans)

Submission status: Accepted

Solution code:
s = list(input())

a_ind = [i for i, v  in enumerate(s) if v == "A"]
z_ind = [i for i, v in enumerate(s) if v == "Z"]


ans = z_ind[-1] - a_ind[0] + 1

print(ans)

Submission status: Accepted

Solution code:
# Problem https://atcoder.jp/contests/abc053/tasks/abc053_b
# Python 3rd Try
import copy


def solver(givenstring):
    result = 0
    usestrA = copy.copy(givenstring)
    usestrZ = copy.copy(givenstring)
# a position
    apos = usestrA.index('A')+1
    usestrrevZ = usestrZ[::-1]
    zpos = len(givenstring) - usestrrevZ.index('Z')
    result = zpos - apos + 1
    return result


if __name__ == "__main__":
    s = input()
    print("{}".format(solver(s)))

Submission status: Accepted

Solution code:
S = list(input())
ans = []
for i in range(len(S)):
    if S[i]=="A":
        ans.append(i)
        break
T = S[::-1]
for i in range(len(T)):
    if T[i]=="Z":
        ans.append(i)
        break
print((len(S)-ans[0])-ans[1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
ans, val = 0, -200001
for c in s:
    if c == 'A' and val < 0:
        val = 1
    elif c == 'Z':
        val += 1
        ans = max(ans, val)
    else:
        val += 1
print(ans)

Submission status: Accepted

Solution code:
# Problem https://atcoder.jp/contests/abc053/tasks/abc053_b
# Python 2nd Try


def solver(string):
    result = 200000
    aposi = 0
    zposi = len(string)
    for j in range(0, len(string), 1):
        if string[j] == 'A':
            aposi = j
            break
    for j in range(len(string)-1, -1, -1):
        if string[j] == 'Z':
            zposi = j
            break
    result = zposi - aposi + 1
    return result


if __name__ == "__main__":
    s = input()
    print('{}'.format(solver(s)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())
i , j= 0, len(s) - 1
while True:
    if s[i] == "A":
        break
    i += 1
while True:
    if s[j] == "Z":
        break
    j -= 1
print(j - i + 1)

Submission status: Accepted

Solution code:
s=input()
words=[a for a in s]
kazu=len(words)
count=1
for a in words:
    if not a=='A':
        count+=1
    else:
        break
usiro=1
for b in reversed(words):
    if not b=='Z':
        usiro+=1
    else:
        break
print(kazu+2-count-usiro)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())
a_ind = []
z_ind = []
for i, v in enumerate(s):
    if v == "A":
        a_ind.append(i)

    if v == "Z":
        z_ind.append(i)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re
s = input()
print(len(re.findall("A(.+)Z", s)[0]) + 2)

Submission status: Accepted

Solution code:
s=input()
ia=None
iz=None
for i,c in enumerate(s):
  if ia==None and c=="A":
    ia=i
  if c=="Z":
    iz=i
print(iz-ia+1)

Submission status: Accepted

Solution code:
S = input()

start = 0
end = 0

for i, s in enumerate(S):
  if s == 'A' and start == 0:
    start = i + 1
  if s == 'Z' and start > 0 :
    end = i+1
      
print(end - start + 1)

Submission status: Accepted

Solution code:
s = input().rstrip('\r')
start = -1
end = -1
for i, c in enumerate(s):
    if c == 'A' and start == -1:
        start = i
    if c == 'Z':
        end = i
print(end-start+1)

Submission status: Accepted

Solution code:
s = list(str(input()))
f = 0
ans = ""
first = s.index("A")
last = s.index("Z")
for i in range(len(s)):
    if s[i] == "Z":
        last = i
print(last - first + 1)

Submission status: Accepted

Solution code:
# Problem https://atcoder.jp/contests/abc053/tasks/abc053_b
# Python 1st Try
import copy


class Problem:
    def __init__(self, stringdata):
        self.stringdata = stringdata

    def solver(self):
        strcont = copy.copy(self.stringdata)
        result = 0
        rightposition = 0
        leftposition = len(strcont)
        j = 0
        while True:
            if strcont[j] == 'A':
                rightposition = j
                break
            else:
                j = j + 1
        j = leftposition - 1
        while True:
            if strcont[j] == 'Z':
                leftposition = j
                break
            else:
                j = j - 1

        result = leftposition - rightposition + 1
        return result


if __name__ == "__main__":
    s = input()
    print("{}".format(Problem(s).solver()))

Submission status: Accepted

Solution code:
l = list(input())
m = list(reversed(l))
x,y = [],[]
x = l.index('A')
y = m.index('Z')
print(len(l)-y - x)

Submission status: Accepted

Solution code:
s=list(input())
flag=True
for i in range(len(s)):
    if flag==True and s[i]=="A":
        start=i
        flag=False
    if s[i]=='Z':
        goal=i
print(goal-start+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

print(len(s)-i-j)

Submission status: Accepted

Solution code:
#053_B
s=list(input())
print(len(s)-s[::-1].index('Z')-s.index('A'))

Submission status: Accepted

Solution code:
s = input()
t = 0
u = 0
n = len(s)
for i in range(n):
  if s[i] == "A":
    t = i
    break
for j in range(n):
  if s[n-j-1] == "Z":
    u = n-j-1
    break
print(u-t+1)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(s: str):
    print(s.rindex("Z") - s.index("A") + 1)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    solve(s)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

s=input().strip()

for i,word in enumerate(s):
    if word == "A":
        start = i
        break

for i,word in enumerate( reversed(s) ):
    if word == "Z":
        end = len(s)-1-i
        break

print( end-start+1 )

Submission status: Accepted

Solution code:
S = input()
print(len(S) - S[::-1].index('Z') - S.index('A'))

Submission status: Accepted

Solution code:
s = input()
a = -1

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

print(z - a + 1)

Submission status: Accepted

Solution code:
s=list(map(str,input()))
#print(s)
for i in range(len(s)):
    if s[i]=='A':
        sa=i
        break

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

print(zg-sa+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
A,Z=len(s),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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    string = input()
    begin_index = -1
    end_index = 0
    for i in range(len(string)):
        if string[i] == "A" and begin_index < 0:
            begin_index = i
        elif string[i] == "Z":
            end_index = i
    print(end_index - begin_index + 1)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import bisect
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
s = readline().rstrip().decode('utf-8')
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-start+1)

Submission status: Accepted

Solution code:
s = str(input())
Acount = 3000000
Zcount = 0
for i in range (len(s)):
    if (s[i] == 'A' and i < Acount):
        Acount = i

for j in range (len(s)):
    if (s[j] == 'Z' and j > Zcount):
        Zcount = j

print(Zcount - Acount +1)

Submission status: Accepted

Solution code:
s = input()
i = 0
while s[i]!="A":
    i += 1
j = -1
while s[j]!="Z":
    j -= 1
print(len(s)-i+j+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ABC053

s = input()
a = s.index("A")

b = max([i for i,x in enumerate(s) if x == "Z"])

print(b-a+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
s=input()
Flg=True
for i in range(len(s)):
    if Flg:
        if s[i]=='A':
            ia=i
            Flg=False
    if s[i]=='Z':
        iz=i
print(iz-ia+1)

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
s=input()

while s[0]!="A":
    s=s[1:]

while s[-1]!="Z":
    s=s[:-1]

print(len(s))

Submission status: Accepted

Solution code:
s = input()
left = 0
right = len(s) - 1
while True:
    if s[left] == "A":
        break
    else:
        left += 1
while True:
    if s[right] == "Z":
        break
    else:
        right -= 1
print(right - left + 1)

Submission status: Accepted

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