Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
J=list(input())
n=len(J)

def dfs_formula(i,f):
    if i==n-1:
        return [f]
    return dfs_formula(i+1,f+"+"+J[i+1])+dfs_formula(i+1,f+"-"+J[i+1])
    
def dfs_sum(i,f):
    if i==n-1:
        return f
    return str(dfs_sum(i+1,f+int(J[i+1])))+" "+str(dfs_sum(i+1,f-int(J[i+1])))

A=dfs_formula(0,J[0])
S=dfs_sum(0,int(J[0]))

for i in range(len(S)):
    if S[i]=='7':
        print(A[i]+"=7")
        break

Fixed submission:
J=list(input())
n=len(J)

def dfs(i,f,sum_num):
    if i==n-1:
        if sum_num==7:
            print(f+"=7")
            exit()
    else:
        dfs(i+1,f+"+"+J[i+1],sum_num+int(J[i+1]))
        dfs(i+1,f+"-"+J[i+1],sum_num-int(J[i+1]))
dfs(0,J[0],int(J[0]))
Buggy python submission (verdict: Time Limit Exceeded):
S=input()
S_len=len(S)
Word=['eraser','erase','dreamer','dream']

while True:
    if len(S)<4:
        break
    else:
        for i in Word:
            S = S.replace(i,"")
        if len(S)==S_len: #一つも文字が含まれなかった時break
            break
           
if len(S)==0:
    print('YES')
else:
    print('NO')

Fixed submission:
S=input()
Word=['eraser','erase','dreamer','dream']

while True:
    S_len=len(S)
    if S_len<5:
        break
    else:
        for i in Word:
            S = S.replace(i,"")
        if len(S)==S_len: #一つも文字が消えなかった時break
            break
           
if len(S)==0:
    print('YES')
else:
    print('NO')

Buggy python submission (verdict: Time Limit Exceeded):
S=input()
Word=['eraser','erase','dreamer','dream']

while True:
    if len(S)<4:
        break
    else:
        for i in Word:
          S = S.replace(i,"")
           
if len(S)==0:
    print('YES')
else:
    print('NO')

Fixed submission:
S=input()
Word=['eraser','erase','dreamer','dream']

while True:
    S_len=len(S)
    if S_len<5:
        break
    else:
        for i in Word:
            S = S.replace(i,"")
        if len(S)==S_len: #一つも文字が消えなかった時break
            break
           
if len(S)==0:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
def onigokko():
    A,V = map(int, input().split())
    B,W = map(int, input().split())
    T = int(input())
    
    if B < A:
        swap = A
        A = B
        B = swap
    
    for i in range(T):
        # Aから一番遠い所へ移動
        B += W

        # Aを動かす
        # 一番遠い所へ移動
        A += V

        # もし、A>=Bなら鬼の勝ち
        if A >= B:
            print('YES')
            return
    print('NO')

onigokko()

Fixed submission:
def onigokko():
    A,V = map(int, input().split())
    B,W = map(int, input().split())
    T = int(input())
    
    if B < A:
        swap = A
        A = B
        B = swap
    
    tikaduku = V - W
    
    # 遠ざかったらアウト
    if tikaduku < 1:
        return 'NO'
    
    kyori = B - A
    
    if kyori <= tikaduku * T:
        return 'YES'
    
    return 'NO'

print(onigokko())
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
An = map(int,input().split())

ans = 1
for i in An:
    ans *= i

if ans > 10 ** 18:
    print(-1)
else:
    print(ans)

Fixed submission:
def Multiplication_2():
    N = int(input())
    An = list(map(int,input().split()))

    if 0 in An:
        return 0
    
    over = 10 ** 18

    ans = 1
    
    for i in An:
        ans *= i
        if ans > over:
            return -1
        #print(ans)
    
    return ans

print(Multiplication_2())

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A=list(map(int, input().split()))
ans=1
for i in range(N):
    ans=ans*A[i]
if ans>10**18:
    print(-1)
else:
    print(ans)

Fixed submission:
N = int(input())
A=list(map(int, input().split()))
ans=1
if 0 in A:
    ans=0
    print(ans)
else:
    for i in range(N):
        if ans>10**18:
            break
        ans=ans*A[i]
    if ans>10**18:
        print(-1)
    else:
        print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
mul=1
key=0
for i in range(len(a)):
    if a[i]==0:
        key=1
        print(0)
        break;
if key==0:
    for i in range(len(a)):
        mul=mul*a[i]
        if mul>1000000000000000000:
        break
    if(mul<1000000000000000001):
        print(mul)
    else:
        print(-1)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
mul=1
key=0
for i in range(len(a)):
    if a[i]==0:
        key=1
        print(0)
        break;
if key==0:
    for i in range(len(a)):
        mul=mul*a[i]
        if mul>1000000000000000000:
            break
    if(mul<1000000000000000001):
        print(mul)
    else:
        print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
mul=1
for i in range(len(a)):
    mul=mul*a[i]
    if mul==0:
      break
if(mul<1000000000000000001):
    print(mul)
else:
    print(-1)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
mul=1
key=0
for i in range(len(a)):
    if a[i]==0:
        key=1
        print(0)
        break;
if key==0:
    for i in range(len(a)):
        mul=mul*a[i]
        if mul>1000000000000000000:
            break
    if(mul<1000000000000000001):
        print(mul)
    else:
        print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
mul=1
for i in range(len(a)):
    mul=mul*a[i]
if(mul<1000000000000000001):
    print(mul)
else:
    print(-1)
    

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
mul=1
key=0
for i in range(len(a)):
    if a[i]==0:
        key=1
        print(0)
        break;
if key==0:
    for i in range(len(a)):
        mul=mul*a[i]
        if mul>1000000000000000000:
            break
    if(mul<1000000000000000001):
        print(mul)
    else:
        print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

n = int(input())
s = list(input())

num_list = []

for i in range(n):
    num_list.append(s[i+1:].count('E') + s[:i].count('W'))

print(min(num_list))

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

n = int(input())
s = list(input())

answer_sum = [0] * n
e_sum = [0] * (n+1)
w_sum = [0] * (n+1)

for i in range(n):
    w_sum[i+1] = (s[i] == 'W') + w_sum[i]
    e_sum[i+1] = (s[i] == 'E') + e_sum[i]

for i in range(n):
    answer_sum[i] = w_sum[i] + (e_sum[n] - e_sum[i+1])

print(min(answer_sum))
Buggy python submission (verdict: Runtime Error):
X, N = map(int, input().split())
if N == 0:
    print(X)
    exit()

P = list(map(int, input().split()))
minmin = []
minn = 101
for i in range(1, 101):
    if i in P:
        continue
    abs1 = abs(i - X)
    if minn >= abs1:
        minn = abs1
        minmin.append(i)

if len(minmin) > 2 and abs(X - minmin[-1]) == abs(X - minmin[-2]):
    print(minmin[-2])
    exit()
print(minmin[-1])


Fixed submission:
X, N = map(int, input().split())
if N == 0:
    print(X)
    exit()

P = list(map(int, input().split()))

for i in range(101):
    p = X - i not in P
    p1 = X + i not in P
    if p1 or p:
        if p:
            print(X - i)
            exit()
        print(X + i)
        exit()

Buggy python submission (verdict: Runtime Error):
X, N = map(int, input().split())
if N == 0:
    print(X)
    exit()

P = list(map(int, input().split()))
minmin = []
minn = 101
for i in range(1, 101):
    abs1 = abs(i - X)
    if not i in P and minn >= abs1:
        minn = abs1
        minmin.append(i)

if len(minmin) > 2 and abs(X - minmin[-1]) == abs(X - minmin[-2]):
    print(minmin[-2])
    exit()
print(max(minmin))


Fixed submission:
X, N = map(int, input().split())
if N == 0:
    print(X)
    exit()

P = list(map(int, input().split()))

for i in range(101):
    p = X - i not in P
    p1 = X + i not in P
    if p1 or p:
        if p:
            print(X - i)
            exit()
        print(X + i)
        exit()

Buggy python submission (verdict: Runtime Error):
X, N = map(int, input().split())
if N == 0:
    print(X)
    exit()

P = list(map(int, input().split()))
minmin = []
minn = 101
for i in range(1, 101):
    abs1 = abs(i - X)
    if not i in P and minn > abs1:
        minn = abs1
        minmin.append(i)

print(max(minmin))


Fixed submission:
X, N = map(int, input().split())
if N == 0:
    print(X)
    exit()

P = list(map(int, input().split()))

for i in range(101):
    p = X - i not in P
    p1 = X + i not in P
    if p1 or p:
        if p:
            print(X - i)
            exit()
        print(X + i)
        exit()
Buggy python submission (verdict: Runtime Error):
import math

A, B, H, M = map(int, input().split())

KA = H / 12 * 360 + ((M / 60) * (360 / 12))
KB = M / 60 * 360

K = abs(KA - KB)
if K > 180:
    K = 360 - K
# if K == 180:
#     print(A + B)
#     exit()
# if K == 0:
#     print(abs(B - A))
#     exit()
# cosB = round(math.cos(math.radians(K)), 13)
cosB = math.cos(math.radians(K)), 13
cc = A ** 2 + B ** 2 - (2 * B * A * cosB)
print(math.sqrt(cc))


Fixed submission:
import math

a, b, h, m = map(int, input().split())

if h * 360 / 12 + m * 360 / 60 / 12 > m * 360 / 60:
    r = (h * 360 / 12 + m * 360 / 60 / 12) - m * 360 / 60
else:
    r = m * 360 / 60 - (h * 360 / 12 + m * 360 / 60 / 12)

if r > 180:
    r = 360 - r

# if r == 90:
#     t = a ** 2 + b ** 2
#     print(math.sqrt(t))
# else:
c = a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(r))
print(math.sqrt(c))
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
H = list(map(int, input().split()))

a = []
for i in range(M):
    A, B = map(int, input().split())
    a.append([A, B])

count = 0

for i in range(1, N + 1):
    h_i = H[i - 1]
    a_i = []
    for j in a:
        if j[0] == i:
            a_i.append(j[1])
        elif j[1] == i:
            a_i.append(j[0])
    flg = True
    for k in a_i:
        if h_i <= H[k - 1]:
            flg = False
    if flg:
        count = count + 1

print(count)


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

r = [1] * len(H)
a = []
for i in range(M):
    A, B = map(int, input().split())
    if H[A - 1] >= H[B - 1]:
        r[B - 1] = 0
    if H[B - 1] >= H[A - 1]:
        r[A - 1] = 0

print(r.count(1))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
d = list(map(int, input().split()))
for j in range(1, N+1):
    count = 0
    for i in range(len(d)):
        if j == d[i]:
            count += 1
    print(count)

Fixed submission:
N = int(input())
d = list(map(int, input().split()))
p = [0] * N
for i in range(N - 1):
    p[d[i] - 1] += 1
for i in range(N):
    print(p[i])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
d = list(map(int, input().split()))
for j in range(1, N+1):
    count = 0
    for i in range(len(d)):
        if j == d[i]:
            count += 1
    print(count)

Fixed submission:
N = int(input())
d = list(map(int, input().split()))
p = [0] * N
for i in range(N - 1):
    p[d[i] - 1] += 1
for i in range(N):
    print(p[i])
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce


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


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


K = int(input()) + 1
sum = 0
for i in range(1, K):
    for j in range(1, K):
        for k in range(1, K):
            sum += gcd(i, j, k)

print(sum)


Fixed submission:
import math
from functools import reduce


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


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


K = int(input()) + 1
sum = 0
for i in range(1, K):
    for j in range(1, K):
        for k in range(1, K):
            sum += gcd(i, j, k)

print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())

cm = N
if N % K == 0:
    print(0)
    exit()
while True:
    cm = min(cm, abs(N - K))
    if cm >= N:
        break
    N = cm

print(cm)


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

cm = N
k = N % K
if k == 0:
    print(0)
    exit()
print(min(abs(k-K), N))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
K = []
S = []
for m in range(M):
    inp = list(map(int, input().split()))
    # K.append(inp[0])
    S.append(inp[1:])

P = list(map(int, input().split()))

X = []


def dfs(A):
    if N == len(A):
        X.append(A.copy())
        return
    for i in [0, 1]:
        A.append(i)
        dfs(A)
        A.pop()


dfs([])


def s(m, x):
    s = 0
    for mm in m:
        s += x[mm - 1]
    return s


count = 0
for x in X:
    flg = True  # 一つでも点灯しないものがあったらFalse
    for m, p in zip(S, P):  # 電球ループ
        su = s(m, x)
        if su % 2 != p:
            flg = False
    if flg:
        count += 1

print(count)


Fixed submission:
N, M = map(int, input().split())
K = []
S = []
for m in range(M):
    inp = list(map(int, input().split()))
    # K.append(inp[0])
    S.append(inp[1:])

P = list(map(int, input().split()))

X = []


def dfs(A):
    if N == len(A):
        X.append(A.copy())
        return
    for i in [0, 1]:
        A.append(i)
        dfs(A)
        A.pop()


dfs([])


def s(m, x):
    s = 0
    for mm in m:
        s += x[mm - 1]
    return s


count = 0
for x in X:
    flg = True  # 一つでも点灯しないものがあったらFalse
    for m, p in zip(S, P):  # 電球ループ
        su = s(m, x)
        if su % 2 != p:
            flg = False
    if flg:
        count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
S = input()

res = []
tmp = []
for s in S:
    if s == 'A' or s == 'C' or s == 'G' or s == 'T':
        tmp.append(s)
    else:
        res.append(len(tmp))
        tmp = []

print(max(res))


Fixed submission:
S = input()

res = []
tmp = []
for s in S:
    if s == 'A' or s == 'C' or s == 'G' or s == 'T':
        tmp.append(s)
    else:
        res.append(len(tmp))
        tmp = []
res.append(len(tmp))
print(max(res))

Buggy python submission (verdict: Runtime Error):
S = input()

res = []
tmp = ['']
for s in S:
    if s == 'A' or s == 'C' or s == 'G' or s == 'T':
        tmp.append(s)
    else:
        res.append(len(tmp))
        tmp = ['']

print(max(res))


Fixed submission:
S = input()

res = []
tmp = []
for s in S:
    if s == 'A' or s == 'C' or s == 'G' or s == 'T':
        tmp.append(s)
    else:
        res.append(len(tmp))
        tmp = []
res.append(len(tmp))
print(max(res))

Buggy python submission (verdict: Runtime Error):
S = input()

res = []
tmp = []
for s in S:
    if s == 'A' or s == 'C' or s == 'G' or s == 'T':
        tmp.append(s)
    else:
        res.append(len(tmp))
        tmp = []

print(max(res))


Fixed submission:
S = input()

res = []
tmp = []
for s in S:
    if s == 'A' or s == 'C' or s == 'G' or s == 'T':
        tmp.append(s)
    else:
        res.append(len(tmp))
        tmp = []
res.append(len(tmp))
print(max(res))
Buggy python submission (verdict: Time Limit Exceeded):
import sys

N, K = map(int, input().split())
H = list(map(int, input().split()))
DP = [0] * N  # N番目までに使用する最小エネルギ-
for n in range(1, N):
    if n == 1:
        DP[1] = abs(H[1] - H[0])
    else:
        min_value = sys.maxsize
        for j in range(1, K + 1 if K < n else n+1):
            tmp_dpn = abs(H[n] - H[n - j]) + DP[n - j]
            if tmp_dpn < min_value:
                min_value = tmp_dpn
        DP[n] = min_value
print(DP[-1])


Fixed submission:
import sys

N, K = map(int, input().split())
H = list(map(int, input().split()))
DP = [0] * N  # N番目までに使用する最小エネルギ-
for n in range(1, N):
    if n == 1:
        DP[1] = abs(H[1] - H[0])
    else:
        min_value = sys.maxsize
        for j in range(1, K + 1 if K < n else n+1):
            tmp_dpn = abs(H[n] - H[n - j]) + DP[n - j]
            if tmp_dpn < min_value:
                min_value = tmp_dpn
        DP[n] = min_value
print(DP[-1])
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input.split())
print("Even" if a*b %2 == 0 else "Odd")

Fixed submission:
a, b = map(int, input().split())
print("Even") if (a * b) % 2 == 0 else print("Odd")
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())
count = 0
for i in range(K + 1):
    for j in range(K + 1):
        for k in range(K + 1):
            if i + j + k == S:
                count = count + 1

print(count)


Fixed submission:
K, S = map(int, input().split())
count = 0
for x in range(K + 1):
    for y in range(K + 1):
        z = S - x - y
        if 0 <= z <= K:
            count = count + 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())
count = 0
for i in range(K + 1):
    for j in range(K + 1):
        for k in range(K + 1):
            if i + j + k == S:
                count = count + 1

print(count)


Fixed submission:
K, S = map(int, input().split())
count = 0
for x in range(K + 1):
    for y in range(K + 1):
        z = S - x - y
        if 0 <= z <= K:
            count = count + 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())

X = []


def dfs(A):
    if len(A) == 3:
        if A[0] + A[1] + A[2] == S:
            X.append(A.copy())
        return
    for i in range(K + 1):
        A.append(i)
        dfs(A)
        A.pop()


dfs([])
print(len(X))


Fixed submission:
K, S = map(int, input().split())
count = 0
for x in range(K + 1):
    for y in range(K + 1):
        z = S - x - y
        if 0 <= z <= K:
            count = count + 1

print(count)

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

X = []


def dfs(A):
    if len(A) == 3:
        if A[0] + A[1] + A[2] == S:
            X.append(A.copy())
        return
    for i in range(K + 1):
        A.append(i)
        dfs(A)
        A.pop()


dfs([])
print(len(X))


Fixed submission:
K, S = map(int, input().split())
count = 0
for x in range(K + 1):
    for y in range(K + 1):
        z = S - x - y
        if 0 <= z <= K:
            count = count + 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())
K = K + 1
count = 0
for i in range(K):
    for j in range(K):
        for k in range(K):
            if i + j + k > S:
                continue
            if i + j + k == S:
                count += 1
print(count)


Fixed submission:
K, S = map(int, input().split())
count = 0
for x in range(K + 1):
    for y in range(K + 1):
        z = S - x - y
        if 0 <= z <= K:
            count = count + 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())
K = K + 1
count = 0
for i in range(K):
    for j in range(K):
        for k in range(K):
            if i + j + k == S:
                count += 1
print(count)


Fixed submission:
K, S = map(int, input().split())
count = 0
for x in range(K + 1):
    for y in range(K + 1):
        z = S - x - y
        if 0 <= z <= K:
            count = count + 1

print(count)
Buggy python submission (verdict: Runtime Error):
S = int(input())
W = int(input())
if S <= W:
  print('unsafe')
else:
  print('safe')

Fixed submission:
S = list(map(int, input().split()))
if S[0] <= S[1]:
  print('unsafe')
else:
  print('safe')
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = [input() for i in range(N)]
S.sort()
c = 1
for i in range(N-1):
  if S[i] == S[i+1]:
    continue
  else: 
    c++
print(c)

Fixed submission:
N = int(input())
S = [input() for i in range(N)]
S.sort()
c = 1
for i in range(N-1):
  if S[i] == S[i+1]:
    continue
  else:
    c += 1
print(c)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = [input() for i in range(N)]
S.sort()
c = 1
for i in range(N-1):
  if S[i] == S[i+1]:
    continue
  else c++:
print(c)

Fixed submission:
N = int(input())
S = [input() for i in range(N)]
S.sort()
c = 1
for i in range(N-1):
  if S[i] == S[i+1]:
    continue
  else:
    c += 1
print(c)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = [input() for i in range(N)]
S.sort()
c = 1
for i in range(N-1):
  if S[i] == S[i+1]:
  else c++:
print(c)

Fixed submission:
N = int(input())
S = [input() for i in range(N)]
S.sort()
c = 1
for i in range(N-1):
  if S[i] == S[i+1]:
    continue
  else:
    c += 1
print(c)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = [input() for i in range(N)]
S.sort()
c = 1
for i in range(N-1):
  if S[i] == S[i+1]
  else c++
print(c)


Fixed submission:
N = int(input())
S = [input() for i in range(N)]
S.sort()
c = 1
for i in range(N-1):
  if S[i] == S[i+1]:
    continue
  else:
    c += 1
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
#--management

member = int(input())
mem_number = [int(i) for i in input().split()]

ans = []

for i in range(member):
  ans.append(0)

for j in range(1,member):
  k = mem_number.count(j)
  ans[j-1] = k

for i in  range(member):
  print(ans[i])



Fixed submission:
#--management
from collections import Counter

member = int(input())
mem_number = [int(i) for i in input().split()]

ans = []

ans = [0] * member

mycounter = Counter(mem_number)

for i in range(member):
  ans[i] = mycounter[i+1]
  print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

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

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

number = int(input())
sumx = 0
for i in range(1,number+1):
  for j in range(1,number+1):
    for k in range(1,number+1):
#      print("i",i)
#      print("j",j)
#      print("k",k)
#      print(gcd(i,j,k))
      sumx = sumx + gcd(i, j, k)

print (sumx)
  

Fixed submission:
import math

number = int(input())
sumx = 0
N = number+1
for i in range(1,N):
  for j in range(1,N):
    for k in range(1,N):
      sumx = sumx + math.gcd(math.gcd(i,j), k)

print (sumx)
Buggy python submission (verdict: Runtime Error):
#--Count ABC

N = int(input())
S = list(input())

A_list = [i for i, x in enumerate(S) if x == 'A']
A_num = len(A_list)

k = 0
for j in range(A_num):
  if(A_list[j] < N-1):
    pp = A_list[j]
    if(S[pp+1]=="B" and S[pp+2]=="C"):
      k = k + 1
    else:
      pass
  else:
    pass

print(k)


Fixed submission:
#--Count ABC

N = int(input())
S = list(input())

A_list = [i for i, x in enumerate(S) if x == 'A']
A_num = len(A_list)

k = 0
for j in range(A_num):
  if(A_list[j] < N-2):
    pp = A_list[j]
    if(S[pp+1]=="B" and S[pp+2]=="C"):
      k = k + 1
    else:
      pass
  else:
    pass

print(k)