Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
A,B = map(int,input().split())
from fractions import gcd
C = gcd(A,B)
num = []
for i in range(2,int(C**0.5)+1):
    while C%i==0:
        num.append(i)
        C //= i
if C != 1:
    num.append(C)
    from collections import Counter
CC = Counter(num)
print(len(CC)+1)

Fixed submission:
import fractions
import collections
A,B = map(int,input().split())
p = fractions.gcd(A,B)
#print(p)
num = []
for i in range(2,int(p**0.5)+1):
    while p%i==0:
        num.append(i)
        p //= i
if p != 1:
    num.append(p)
#print(num)
pp = collections.Counter(num)
print(len(pp)+1)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
import collections
A,B = map(int,input().split())
p = fractions.gcd(A,B)
#print(p)
num = []
for i in range(2,p+1):
    while p%i==0:
        num.append(i)
        p //= i
#print(num)
pp = collections.Counter(num)
print(len(pp)+1)

Fixed submission:
import fractions
import collections
A,B = map(int,input().split())
p = fractions.gcd(A,B)
#print(p)
num = []
for i in range(2,int(p**0.5)+1):
    while p%i==0:
        num.append(i)
        p //= i
if p != 1:
    num.append(p)
#print(num)
pp = collections.Counter(num)
print(len(pp)+1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
if N==1:
    print(0)
else:
    print(sum([i for i in range(1,N)]))

Fixed submission:
N = int(input())
if N==1:
    print(0)
else:
    print((N-1)*N//2)
Buggy python submission (verdict: Runtime Error):
N=int(input())
v = list(map(int,inut().split()))
v.sort(reverse=True)
print(v[0]*v[1]//2)

Fixed submission:
N=int(input())
v = list(map(int,input().split()))
from heapq import heappop,heappush,heapify
heapify(v)
ans = heappop(v)
for i in range(N-1):
    ans = (ans+heappop(v))/2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
L,R = map(int,input().split())

ans = 2019
for i in range(L,R):
  for j in range(i+1,R+1):
    ans = min(ans,(i*j)%2019)

print(ans)

Fixed submission:
L,R = map(int,input().split())

ans = 2019
for i in range(L,min(L+2019,R)):
  for j in range(i+1,min(L+2019,R+1)):
    ans = min(ans,(i*j)%2019)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
b = K
r = N-K
mod = 10**9+7
# rのしきりr+1にi個いれる→(r+1)Ci
# bはしきりb-1にi-1個入れる→(b-1)C(i-1)

for i in range(1,K+1):
    ans = 1
    for j in range(1,i):
        ans *= (r+1)-(j-1)
        ans %= mod
        ans *= (b-1)-(j-1)
        ans %= mod
        ans *= pow(j,mod-2,mod)
        ans *= pow(j,mod-2,mod)
        ans %= mod
    ans *= (r+1)-(i-1)
    ans *= pow(i,mod-2,mod)
    ans %= mod
    print(ans)

Fixed submission:
N,K = map(int,input().split())
b = K
r = N-K
mod = 10**9+7
# rのしきりr+1にi個いれる→(r+1)Ci
# bはしきりb-1にi-1個入れる→(b-1)C(i-1)

ans = (r+1)
print(ans)
for i in range(2,K+1):
    ans *= (r+1)-(i-1)
    ans *= (b-1)-(i-2)
    ans *= pow(i,mod-2,mod)
    ans *= pow(i-1,mod-2,mod)
    ans %= mod
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
b = K
r = N-K
mod = 10**9+7
# rのしきりr+1にi個いれる→(r+1)Ci
# bはしきりb-1にi-1個入れる→(b-1)C(i-1)

for i in range(1,K+1):
    ans = 1
    for j in range(1,i):
        ans *= (r+1)-(j-1)
        ans *= (b-1)-(j-1)
        ans *= pow(j,mod-2,mod)
        ans *= pow(j,mod-2,mod)
        ans %= mod
    ans *= (r+1)-(i-1)
    ans *= pow(i,mod-2,mod)
    ans %= mod
    print(ans)

Fixed submission:
N,K = map(int,input().split())
b = K
r = N-K
mod = 10**9+7
# rのしきりr+1にi個いれる→(r+1)Ci
# bはしきりb-1にi-1個入れる→(b-1)C(i-1)

ans = (r+1)
print(ans)
for i in range(2,K+1):
    ans *= (r+1)-(i-1)
    ans *= (b-1)-(i-2)
    ans *= pow(i,mod-2,mod)
    ans *= pow(i-1,mod-2,mod)
    ans %= mod
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
b = K
r = N-K
mod = 10**9+7
# rのしきりr+1にi個いれる→(r+1)Ci
# bはしきりb-1にi-1個入れる→(b-1)C(i-1)

for i in range(1,K+1):
    ans = 1
    for j in range(1,i+1):
        ans *= (r+1)-(j-1)
        ans *= pow(j,mod-2,mod)
        ans %= mod
    for k in range(1,i):
        ans *= (b-1)-(k-1)
        ans *= pow(k,mod-2,mod)
        ans %= mod
    print(ans)

Fixed submission:
N,K = map(int,input().split())
b = K
r = N-K
mod = 10**9+7
# rのしきりr+1にi個いれる→(r+1)Ci
# bはしきりb-1にi-1個入れる→(b-1)C(i-1)

ans = (r+1)
print(ans)
for i in range(2,K+1):
    ans *= (r+1)-(i-1)
    ans *= (b-1)-(i-2)
    ans *= pow(i,mod-2,mod)
    ans *= pow(i-1,mod-2,mod)
    ans %= mod
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
b = K
r = N-K
mod = 10**9+7
# rのしきりr+1にi個いれる→(r+1)Ci
# bはしきりb-1にi-1個入れる→(b-1)C(i-1)

for i in range(1,K+1):
    ans = 1
    for j in range(1,i+1):
        ans *= (r+1)-(j-1)
        ans *= pow(j,mod-2,mod)
        ans %= mod
    for k in range(1,i):
        ans *= (b-1)-(k-1)
        ans *= pow(k,mod-2,mod)
        ans %= mod
    print(ans%mod)

Fixed submission:
N,K = map(int,input().split())
b = K
r = N-K
mod = 10**9+7
# rのしきりr+1にi個いれる→(r+1)Ci
# bはしきりb-1にi-1個入れる→(b-1)C(i-1)

ans = (r+1)
print(ans)
for i in range(2,K+1):
    ans *= (r+1)-(i-1)
    ans *= (b-1)-(i-2)
    ans *= pow(i,mod-2,mod)
    ans *= pow(i-1,mod-2,mod)
    ans %= mod
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
import heapq
ans = []
heapq.heapify(ans)
for a in A:
    for b in B:
        for c in C:
          heapq.heappush(ans,-(a+b+c))
for _ in range(K):
    i = heapq.heappop(ans)
    print(-i)

Fixed submission:
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

# A,B,Cのリストを降順にソート
A.sort(reverse =True)
B.sort(reverse =True)
C.sort(reverse =True)

# A,B,Cを上からp,q,r番目を選択した場合にp*q*rがKより大きい組み合わせがKより上位に来ることはない
# A,B,Cを上から参照していき。p*q*rがK以下の場合はリストにa+b+cを追加，K以上の場合はbreak
D = []
for p in range(1,X+1):
    for q in range(1,Y+1):
        for r in range(1,Z+1):
            if p*q*r<=K:
                D.append(A[p-1]+B[q-1]+C[r-1])
            else:
                break
D.sort(reverse=True)

for i in range(K):
    print(D[i])

Buggy python submission (verdict: Time Limit Exceeded):
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

ans = []
for a in A:
    for b in B:
        for c in C:
          ans.append(-(a+b+c))
        
import heapq
heapq.heapify(ans)
for _ in range(K):
    i = heapq.heappop(ans)
    print(-i)

Fixed submission:
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

# A,B,Cのリストを降順にソート
A.sort(reverse =True)
B.sort(reverse =True)
C.sort(reverse =True)

# A,B,Cを上からp,q,r番目を選択した場合にp*q*rがKより大きい組み合わせがKより上位に来ることはない
# A,B,Cを上から参照していき。p*q*rがK以下の場合はリストにa+b+cを追加，K以上の場合はbreak
D = []
for p in range(1,X+1):
    for q in range(1,Y+1):
        for r in range(1,Z+1):
            if p*q*r<=K:
                D.append(A[p-1]+B[q-1]+C[r-1])
            else:
                break
D.sort(reverse=True)

for i in range(K):
    print(D[i])
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int,input().split())
S = input()
lr = [list(map(int,input().split())) for _ in range(Q)]

dp = [0]*N
for i in range(N):
  if S[i:i+2]=="AC":
    dp[i+1] = dp[i] +1

for i in range(Q):
  print(sum(dp[lr[i][0]:lr[i][1]]))

Fixed submission:
N, Q = map(int,input().split())
S = input()
lr = [list(map(int,input().split())) for _ in range(Q)]

dp = [0]*(N+1)
for i in range(N):
  if S[i:i+2]=="AC":
    dp[i+1] = dp[i] +1
  else:
    dp[i+1] = dp[i]

for i in range(Q):
  print(dp[lr[i][1]-1]-dp[lr[i][0]-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int,input().split())
S = input()
lr = [list(map(int,input().split())) for _ in range(Q)]

for i in range(Q):
  ans = S[lr[i][0]-1:lr[i][1]].count("AC")
  print(ans)

Fixed submission:
N, Q = map(int,input().split())
S = input()
lr = [list(map(int,input().split())) for _ in range(Q)]

dp = [0]*(N+1)
for i in range(N):
  if S[i:i+2]=="AC":
    dp[i+1] = dp[i] +1
  else:
    dp[i+1] = dp[i]

for i in range(Q):
  print(dp[lr[i][1]-1]-dp[lr[i][0]-1])
Buggy python submission (verdict: Runtime Error):
A,B,K = map(int,input().split())

ans =[]
for i in range(1,100):
  if (A % i)== 0 and (B % i) == 0:
    ans.append(i)

ans_sort = ans[::-1]
print(ans_sort[K-1])


Fixed submission:
A,B,C = map(int,input().split())

if B < A*C:
  print(B//A)
else:
  print(C)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

print(gcd_list(A))

Fixed submission:
N = int(input())
A = list(map(int,input().split()))

from fractions import gcd
from functools import reduce

def gcd_list(numbers):
    return reduce(gcd, numbers)

print(gcd_list(A))

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = map(int,input().split())

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

print(gcd_list(A))

Fixed submission:
N = int(input())
A = list(map(int,input().split()))

from fractions import gcd
from functools import reduce

def gcd_list(numbers):
    return reduce(gcd, numbers)

print(gcd_list(A))

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = map(int,input().split())

import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

print(gcd_list(A))

Fixed submission:
N = int(input())
A = list(map(int,input().split()))

from fractions import gcd
from functools import reduce

def gcd_list(numbers):
    return reduce(gcd, numbers)

print(gcd_list(A))
Buggy python submission (verdict: Runtime Error):
s = int(input())
lis = []

def func(n):
    if n%2 == 0:
        return n//2
    else:
        return 3*n+1
 
while func(s) !=4:
    print(func(s))
    s = func(s)
    lis.append(s)
    
print(int(len(lis)+5))

Fixed submission:
a, b, c = map(int, input().split())
S = (1/2)*a*b*c/max(a,b,c)
print(int(S))
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))

memo = {0:0,1:abs(H[1]-H[0])}
def dp(n):
    if n in memo:
        return memo[n]

    memo[n] = min(dp(n-2) + abs(H[n-2]-H[n]),dp(n-1) + abs(H[n-1]-H[n]))

    return memo[n]

print(dp(N-1))

Fixed submission:
N = int(input())
H = list(map(int,input().split()))

dp = [0]*N
for i in range(N):
  if i == 0:
    dp[i] = 0
  elif i == 1:
    dp[i] = abs(H[i]-H[i-1])
  else:
    dp[i] = min((dp[i-1]+abs(H[i]-H[i-1])),dp[i-2]+abs(H[i]-H[i-2]))
print(dp[-1])

Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
# N = 4
# H = [10,30,40,20]
memo = {0:0,1:abs(H[1]-H[0])}
def dp(n):
    if n in memo:
        return memo[n]

    memo[n] = min(dp(n-2) + abs(H[n-2]-H[n]),dp(n-1) + abs(H[n-1]-H[n]))

    return memo[n]

print(dp(N-1))

Fixed submission:
N = int(input())
H = list(map(int,input().split()))

dp = [0]*N
for i in range(N):
  if i == 0:
    dp[i] = 0
  elif i == 1:
    dp[i] = abs(H[i]-H[i-1])
  else:
    dp[i] = min((dp[i-1]+abs(H[i]-H[i-1])),dp[i-2]+abs(H[i]-H[i-2]))
print(dp[-1])

Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int,input().split()))

memo = {1:0,2:abs(H[1]-H[0])}
def K(n):
  if n in memo.keys():
    return memo[n]
  memo[n] = min(K(n-2)+abs(H[n]-H[n-2]),K(n-1)+abs(H[n]-H[n-1]))
  return memo[n]

print(K(N-1))

Fixed submission:
N = int(input())
H = list(map(int,input().split()))

dp = [0]*N
for i in range(N):
  if i == 0:
    dp[i] = 0
  elif i == 1:
    dp[i] = abs(H[i]-H[i-1])
  else:
    dp[i] = min((dp[i-1]+abs(H[i]-H[i-1])),dp[i-2]+abs(H[i]-H[i-2]))
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
N,W = map(int,input().split())
w_v = [list(map(int,input().split())) for _ in range(N)]
dp = [[0]*W for _ in range(N)]

for i in range(0,N):
  if i == 0:
    if W>=w_v[0][0]:
      for j in range(w_v[0][0]-1,W):
        dp[i][j] = w_v[0][1]
  else:
    for j in range(W):
      if j-w_v[i][0]>=0:
        dp[i][j] = max(dp[i-1][j],dp[i-1][j-w_v[i][0]]+w_v[i][1])
      else:
        dp[i][j] = dp[i-1][j]

print(max(dp[-1]))

Fixed submission:
N,W = map(int,input().split())
w_v = [list(map(int,input().split())) for i in range(N)]
INF = float("inf")
dp = [[INF]*100001 for i in range(N+1)]
dp[0][0]=0

for i in range(N):
  for j in range(100001):
    if j >= w_v[i][1]:
      dp[i+1][j] = min(dp[i][j],dp[i][j-w_v[i][1]]+w_v[i][0])
    else:
      dp[i+1][j] = dp[i][j]
    
ans = 0
for j in range(100001):
  if dp[-1][j] <= W:
    ans = max(ans,j)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())

A = []
for i in range(20):
    if 6**i<=N:
        A.append(6**i)
for i in range(1,20):
    if 9**i<=N:
        A.append(9**i)
AA = sorted(A,reverse=True)
        
INF = float("inf")
dp=[INF]*(N)
dp[0]=1

for i in range(N):
    for j in AA:
        if i>=j:
        dp[i]=min(dp[i-j]+1,dp[i])
    
#print(dp)
print(dp[-1])

Fixed submission:
N = int(input())

A = []
for i in range(20):
    if 6**i<=N:
        A.append(6**i)
for i in range(1,20):
    if 9**i<=N:
        A.append(9**i)
AA = sorted(A,reverse=True)
#print(AA)
        
INF = float("inf")
dp=[INF]*(N+1)
dp[0]=0

for i in range(N+1):
    for j in AA:
        if i>=j:
            dp[i]=min(dp[i-j]+1,dp[i])
        else:
            dp[i]=dp[i]
    
#print(dp)
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
X = list(map(int,input().split()))
from statistics import median
for i in range(N):
    B = X[:i]+X[i+1:]
    print(median(B))

Fixed submission:
import statistics
from bisect import bisect_left
N = int(input())
X = list(map(int,input().split()))
Y = sorted(X)
a,b = statistics.median_low(Y),statistics.median_high(Y)
for i in X:
    Z = bisect_left(Y,i)
    if Z<N//2:
        print(b)
    else:
        print(a)
Buggy python submission (verdict: Runtime Error):
N,Y = map(int,input().split())

change = False

for i in range(N+1):
    for j in range(N+1-i):
        if i*10000+j*5000+(N-i-j)*1000==Y:
            print(i,j,N-i-j)
            change = True
            break
else:
    break
            
if change != True:
    print("-1 -1 -1")

Fixed submission:
N,Y = map(int,input().split())

for x in range(N+1):
  for y in range(N+1-x):
    z = N - x - y
    if 10000*x+5000*y+1000*z == Y:
        print(x,y,z)
        exit()
print(-1,-1,-1)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
A = list(map(int,input().split()))

import collections
A_c = collections.Counter(A)
A_A = A_c.most_common()

ans = 0
for i in range(len(A_A)):
  if i >K-1:
    ans += list(A_A[i])[1]

if A_A<=K:
  print(0)
else:
  print(ans)

Fixed submission:
N,K = map(int,input().split())
A = list(map(int,input().split()))

import collections
A_c = collections.Counter(A)
A_A = A_c.most_common()

ans = 0
for i in range(len(A_A)):
  if i >K-1:
    ans += list(A_A[i])[1]

if len(A_A)<=K:
  print(0)
else:
  print(ans)
Buggy python submission (verdict: Runtime Error):
import bisect
N = int(input())
ABC = [sorted(list(map(int,input().split()))) for i in range(3)]

for b in ABC[1]:
  ans += bisect.bisect_left(ABC[0],b)*(N-bisect.bisect_right(ABC[2],b))
print(ans)


Fixed submission:
import bisect
N = int(input())
ABC = [sorted(list(map(int,input().split()))) for i in range(3)]

ans = 0
for b in ABC[1]:
  ans += bisect.bisect_left(ABC[0],b)*(N-bisect.bisect_right(ABC[2],b))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ABC = [sorted(list(map(int,input().split()))) for i in range(3)]

ans = 0
for i in range(N):
  for j in range(N):
    if ABC[0][i]>=ABC[1][j]:
      continue
    else:
      for k in range(N):
        if ABC[1][j]>=ABC[2][k]:
          continue
        else:
          ans += 1
    
print(ans)

Fixed submission:
import bisect
N = int(input())
ABC = [sorted(list(map(int,input().split()))) for i in range(3)]

ans = 0
for b in ABC[1]:
  ans += bisect.bisect_left(ABC[0],b)*(N-bisect.bisect_right(ABC[2],b))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ABC = [list(map(int,input().split())) for i in range(3)]

ans = 0
ans_line = 0

for i in range(N):
  for j in range(N):
    if ABC[0][i]<ABC[1][j]:
      for k in range(N):
        if ABC[1][j]<ABC[2][k]:
          ans += 1

for i in range(N):
  if ABC[0][i]<ABC[1][i] and ABC[1][i]<ABC[2][i]:
    ans_line += 1

print(ans)

Fixed submission:
import bisect
N = int(input())
ABC = [sorted(list(map(int,input().split()))) for i in range(3)]

ans = 0
for b in ABC[1]:
  ans += bisect.bisect_left(ABC[0],b)*(N-bisect.bisect_right(ABC[2],b))
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
from collections import Counter
AA = Counter(A)
B = []
C = []
for k,v in AA.items():
    if v>=2:
        B.append(k)
    if v>=4:
        C.append(k)
B.sort(reverse=True)
C.sort(reverse=True)
if len(B)<=1 and len(C)==0:
    print(0)
else:
    if len(B)<=1:
        print(C[0]*C[0])
    else:
        print(max(B[0]*B[1],C[0]*C[0]))

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
from collections import Counter
AA = Counter(A)
B = []
C = []
for k,v in AA.items():
    if v>=2:
        B.append(k)
    if v>=4:
        C.append(k)
B.sort(reverse=True)
C.sort(reverse=True)
if len(B)<=1 and len(C)==0:
    print(0)
else:
    if len(B)<=1:
        print(C[0]*C[0])
    elif len(C)==0:
        print(B[0]*B[1])
    else:
        print(max(B[0]*B[1],C[0]*C[0]))

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
from collections import Counter
AA = Counter(A)
B = []
C = []
for k,v in AA.items():
    if v>=2:
        B.append(k)
    if v>=4:
        C.append(k)
B.sort(reverse=True)
C.sort(reverse=True)
if len(B)<2:
    print(0)
else:
    print(max(B[0]*B[1],C[0]*C[0]))

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
from collections import Counter
AA = Counter(A)
B = []
C = []
for k,v in AA.items():
    if v>=2:
        B.append(k)
    if v>=4:
        C.append(k)
B.sort(reverse=True)
C.sort(reverse=True)
if len(B)<=1 and len(C)==0:
    print(0)
else:
    if len(B)<=1:
        print(C[0]*C[0])
    elif len(C)==0:
        print(B[0]*B[1])
    else:
        print(max(B[0]*B[1],C[0]*C[0]))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
i = 1
ans = 0
while i <= N ** 0.5:
  if N%i == 0:
    ans = len(str(N//i))
  i+1
print(ans)

Fixed submission:
N = int(input())
ans = 1
for i in range(1,int(N**0.5)+1):
    if N%i == 0:
        ans = max(ans,i)
print(len(str(int(N/ans))))
Buggy python submission (verdict: Runtime Error):
s = list(input())
print(reversed(s).index("Z")-s.index("A")+1)

Fixed submission:
s = list(input())
print(len(s)-s[::-1].index("Z")-s.index("A"))

Buggy python submission (verdict: Runtime Error):
s = list(input())
print(s.reverse().index("Z")-s.index("A")+1)

Fixed submission:
s = list(input())
print(len(s)-s[::-1].index("Z")-s.index("A"))

Buggy python submission (verdict: Runtime Error):
s = list(input())
print(s.reverse.index("Z")-s.index("A")+1)

Fixed submission:
s = list(input())
print(len(s)-s[::-1].index("Z")-s.index("A"))
Buggy python submission (verdict: Runtime Error):
import collections
N = int(input())
num = []
for i in range(2,N+1):
    for j in range(2,i+1):
        #print(j)
        while i%j==0:
            i //= j
            num.append(j)
#print(num)
A = collections.Counter(num)
#print(A)
ans = 1
for v in A.values():
    ans *= (v+1)%mod
print(ans%mod)

Fixed submission:
import collections
N = int(input())
num = []
mod = 10**9+7
for i in range(2,N+1):
    for j in range(2,i+1):
        #print(j)
        while i%j==0:
            i //= j
            num.append(j)
#print(num)
A = collections.Counter(num)
#print(A)
ans = 1
for v in A.values():
    ans *= (v+1)%mod
print(ans%mod)
Buggy python submission (verdict: Time Limit Exceeded):
K,S = map(int,input().split())

ans = 0
for a in range(K+1):
  for b in range(K+1):
    for c in range(K+1):
      if a+b+c == S:
        ans += 1

print(ans)

Fixed submission:
K,S = map(int,input().split())

ans = 0
for a in range(K+1):
  for b in range(K+1):
    if 0 <= S-a-b <= K:
        ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,x = map(int,input().split())
ans = 0
for i in range(b-a+1):
    if (a+i)%x==0:
        ans += 1
print(ans)

Fixed submission:
a,b,x = map(int,input().split())
ans = 0
if a%x==0:
    ans = (b-a)//x+1
else:
    c = (a//x+1)*x
    ans = (b-c)//x+1
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
import math
H,N = (int(x) for x in input().split())
A = np.array([0]*N)
B = np.array([0]*N)
C = np.array([0.]*N)
for i in range(N):
    A[i],B[i] = (int(x) for x in input().split())
    C[i] = float(A[i]) / float(B[i])

indexs = np.argsort(-C)
A=A[indexs]
B=B[indexs]
C=C[indexs]

V=[[0]*(H+1) for i in range(N+1)]
for h in range(H+1):
    V[0][h] = B[0]*math.ceil(h/A[0])

for i  in range(N):
    for h in range(H+1):
        if h < A[i]:
            V[i+1][h] = V[i][h]
        elif V[i][h] > (V[i][h-A[i]]+B[i]):
            V[i+1][h] = (V[i][h-A[i]]+B[i])
        else:
            V[i+1][h] = V[i][h]

print(V[N][H])

Fixed submission:
import math

H,A = (float(x) for x in input().split())
print(math.ceil(H/A))
Buggy python submission (verdict: Runtime Error):
N,M=(int(x) for x in input().split())

if N===M:
    print('Yes')
else:
    print('No')

Fixed submission:
N,M=(int(x) for x in input().split())

if N==M:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(a) for a in input().split()]
p = 10 ** 9 + 7

AA = [a % p for a in A]
sum = 0
for i in range(0, N - 1):
  for j in range(i + 1, N):
    sum += (AA[i] * AA[j]) % p
print(sum % p)

Fixed submission:
N = int(input())
A = [int(a) for a in input().split()]
p = 10 ** 9 + 7

S = [A[0]] * N
for i in range(1, N):
  S[i] = S[i - 1] + A[i]

sum = 0
for i in range(0, N - 1):
	sum += (A[i] * (S[N - 1] - S[i])) % p
print(sum % p)
Buggy python submission (verdict: Runtime Error):
N, X, T = (int(a) for a in input().split())
print(math.ceil(N / X) * T)

Fixed submission:
import math
N, X, T = (int(a) for a in input().split())
print(math.ceil(N / X) * T)
Buggy python submission (verdict: Runtime Error):
N, D = (int(a) for a in input().split())
X2Y2 = [[int(a) ** 2 for a in input().split()] for b in range(N)]
X2, Y2 = [list(i) for i in zip(*X2Y2)]

c = 0
DD = D ** 2
for i in range(N):
    if X2[i] + Y2[i] <= DD:
        c += 1
print(c)

Fixed submission:
K = int(input())
if (K % 5 == 0) | (K % 2 == 0):
  print(-1)

else:
  a = 7
  for i in range(K):
    if a % K == 0:
      print(i + 1)
      exit()
    a = (10 * a + 7) % K
  print(-1)
Buggy python submission (verdict: Runtime Error):
N = input()
turi = N % 1000
if turi != 0:
  turi = 1000 - turi
print(turi)

Fixed submission:
N = int(input())
turi = N % 1000
if turi != 0:
  turi = 1000 - turi
print(turi)

Buggy python submission (verdict: Runtime Error):
N = input()
turi = N mod 1000
if (turi <> 0):
	turi = 1000 - turi
print(turi)

Fixed submission:
N = int(input())
turi = N % 1000
if turi != 0:
  turi = 1000 - turi
print(turi)