Harryxun/stf_run huggingface dataset:
N = int(input())
s_cnt = []
for i in range(N):
    cnt = {}
    s = input()
    for si in s:
        if si in cnt:
            cnt[si] += 1
        else:
            cnt[si] = 1
    s_cnt.append(cnt)
#from collections import defaultdict
#min_ = defaultdict(int)
min_ = {}
for i in s_cnt:
    for j in i:
        for i in range(N):
        if j not in s_cnt[n]:
            continue
        if j not in min_:
            min_[j] = i[j]
        else:
            min_[j] = min(min_[j], i[j])
string = ''
for i in min_:
    #list_.append(i * min_[i])
    string += i * min_[i]
s = sorted(string)
print(''.join(s))

### FIXED CODE ###

N = int(input())
s_cnt = []
for i in range(N):
    cnt = {}
    s = input()
    for si in s:
        if si in cnt:
            cnt[si] += 1
        else:
            cnt[si] = 1
    s_cnt.append(cnt)
min_ = {}
for i in s_cnt:
    for j in i:
        if any([j not in s_cnt[k] for k in range(N)]):
               continue
        if j not in min_:
            min_[j] = i[j]
        else:
            min_[j] = min(min_[j], i[j])
string = ''
for i in min_:
    #list_.append(i * min_[i])
    string += i * min_[i]
s = sorted(string)
print(''.join(s))
n = int(input())
L = []
for i in range(n):
    L.append(input())

def num(a,b,c):
    s = {a,b,c}
    return len(s)-1
cnt = 0
for i in range(n):
    cnt += num(L[0][i],L[1][i],L[2][i])
print(cnt)


### FIXED CODE ###

n = int(input())
L = []
for i in range(3):
    L.append(input())

cnt = 0
for i in range(n):
    s = set((L[0][i],L[1][i],L[2][i]))
    cnt += len(s)-1
print(cnt)
n,k=map(int,input().split())
s=input()
print(s[:k]+s[k].lower()+s[k+1:])

### FIXED CODE ###

n, k = map(int, input().split())
s = list(input())
ans = ''
for i in range(len(s)):
    if i == k-1:
        ans += s[i].lower()
    else:
        ans += s[i]
print(ans)
n, k = map(int, input().split())
if n % k == 0:
  print(0)
else:
  print(abs(n-(n%K)))

### FIXED CODE ###

n, k = map(int, input().split()) #n:煎餅, k:人数
if n % k == 0:
  print(0)
else:
  print(1)
from collections import deque
n,m = map(int,input().split())
visited = [-1 for _ in range(n)]
g = [[] for _ in range(m)]
for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)
pos = 0
que = deque([])
if g[0]:
    visited[0] = 0
    for nx in g[0]:
        que.append((nx, 0))
while que:
    to, now = que.popleft()
    if visited[to] != -1:
        continue
    else:
        visited[to] = now
        for nx in g[to]:
            que.append((nx, to))
visited = visited[1:]
if -1 in visited:
    print('No')
else:
    print('Yes')
    for k in visited:
        print(k+1)

### FIXED CODE ###

from collections import deque
n,m = map(int,input().split())
visited = [-1 for _ in range(n)]
g = [[] for _ in range(n)]
for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)
pos = 0
que = deque([])
if g[0]:
    visited[0] = 0
    for nx in g[0]:
        que.append((nx, 0))
while que:
    to, now = que.popleft()
    if visited[to] != -1:
        continue
    else:
        visited[to] = now
        for nx in g[to]:
            que.append((nx, to))
visited = visited[1:]
if -1 in visited:
    print('No')
else:
    print('Yes')
    for k in visited:
        print(k+1)
S=input();s=set(S);print('NYoe s'[len(s)==2 and S.count(s[0])==2::2])

### FIXED CODE ###

S=input();s=set(S);print('NYoe s'[len(s)==2 and S.count(list(s)[0])==2::2])
S = input()
li = []
for s in S:
    li.append(int(s))

count = 0
first = li[0]i
for i in range(len(li)):
    if i % 2 == 0:
        if li[i] != first:
            count += 1
    else:
        if li[i] == first:
            count += 1

count2 = 1
for i in range(len(li)):
    if i % 2 == 0:
        if li[i] == first:
            count2 += 1
    else:
        if li[i] != first:
            count += 1

print(min(count,count2))

### FIXED CODE ###

S = input()
li = []
for s in S:
    li.append(int(s))

count = 0
first = li[0]
for i in range(len(li)):
    if i % 2 == 0:
        if li[i] != first:
            count += 1
    else:
        if li[i] == first:
            count += 1

count2 = 1
for i in range(len(li)):
    if i % 2 == 0:
        if li[i] == first:
            count2 += 1
    else:
        if li[i] != first:
            count2 += 1

print(min(count, count2))
A, B, X = map(int, raw_input().split())

def price(i, A, B):
    Dig = len(str(i))
    return A * i + B * Dig

l = 0
r = 10**9 + 1

while (r-l) > 1:
    c = (r+l)/2
    Pri = price(c, A, B)
    if Pri <= X:
        l = c
    else:
        r = c




### FIXED CODE ###

Day = {"SUN":7,
       "MON":6,
       "TUE":5,
       "WED":4,
       "THU":3,
       "FRI":2,
       "SAT":1}

S = raw_input()

print Day[S]
def main():
	n = int(input())
	a = list(map(int, input().split()))
	dp = [[0] * n for _ in range(n)]
	for i in range(n):
    	dp[i][i] = a[i]

	for i in range(n - 2, -1, -1):
    	for j in range(i + 1, n):
        	dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1])
	print(dp[0][n - 1])
main()

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
dp = [[0] * n for _ in range(n)]
for i in range(n):
    dp[i][i] = a[i]

for i in range(n - 2, -1, -1):
    for j in range(i + 1, n):
        dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1])

print(dp[0][n - 1])
from collections import defaultdict
N = int(input())
a = [int(i) for i in input().split()]
b = []
for x in a:
    num = 0
    if x%2 == 0:
        x = x//2
        num += 1
        if x%2 == 0:
            num += 1
    b.append(num)
if b.count(0) <= b.count(2):
    print('Yes')
else:
    if b.count(0) == b.count(2)+1 and len(b) == b.count(0)+b.count(2):
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

# -*- coding: utf-8 -*-

n,m = map(int,input().split())

print(max(0,(n-1)*(m-1)))
import math
import numpy as np

values = np.array(input().split(" "), dtype=np.int64)
result = np.prod(values)

print(math.floor(result))

### FIXED CODE ###

import math
import decimal

A, B = input().split(" ")
A = decimal.Decimal(A)
B = decimal.Decimal(B)

print(math.floor(A * B))
n, k = [int(i) for i in input().split()]
while true:
    if abs(n - k) < n:
        n = abs(n - k)
    else:
        break
print(n)


### FIXED CODE ###

n, k = [int(i) for i in input().split()]

if n >= k:
    result = min(n % k, k - (n % k))
elif 2 * n >= k > n:
    n = abs(k - n)
    result = n
else:
    result = n

print(result)
def fibona(x):
    import math
    return (((1/2+math.sqrt(5)/2)**(x+1))-((1/2-math.sqrt(5)/2)**(x+1)))//math.sqrt(5)

def main():
    n, m = map(int,input().split())
    mlis = []
    for _ in range(m):
        a = int(input())
        mlis.append(a)
    ans = 1
    mae = -1

    for i in range(m):
        broken = mlis[i]
        if mae == broken - 1:
            print(0)
            exit()
        nobori = broken - 1 - (mae + 1)
        if nobori == 0:
            ans *= 1
            mae = broken
        else:
            ans *= fibona(nobori)
            ans %= (10 ** 9 + 7)
            #print(i, broken, nobori, ans) 
            mae = broken
    nobori = n - (mae+1)
    ans *= fibona(nobori) 
    ans %= (10 ** 9 + 7)
    print(ans)

        
        



if __name__ == "__main__":
    main()


### FIXED CODE ###

from itertools import product

def mat2_mul(X, Y):
	z = [[0, 0], [0, 0]]
	for (i, j, k) in product(range(2), range(2), range(2)):
		z[i][j] += X[i][k] * Y[k][j]
	return z

def mat2_pow(X, n):
	if n == 0:
		return [[1, 0], [0, 1]]
	elif n % 2:
		return mat2_mul(X, mat2_pow(X, n - 1))
	else:
		half_pow = mat2_pow(X, n / 2)
		return mat2_mul(half_pow, half_pow)

def fibona(n):
	if n == 0:
		return 0
	else:
		f = [[0, 1], [1, 1]]
	return mat2_pow(f, n - 1)[1][1]

def main():
    n, m = map(int,input().split())
    mlis = []
    for _ in range(m):
        a = int(input())
        mlis.append(a)
    ans = 1
    mae = 0

    infi = 10 ** 9 + 7
    for num in mlis:
        ans *= fibona(num-mae)
        ans %= infi
        mae = num + 1

    nobori = n - mae + 1
    ans *= fibona(nobori) 
    ans %= infi
    print(int(ans))
    



if __name__ == "__main__":
    main()
import bisect

input()
A=sorted([int(i) for i in input().split()])
B=sorted([int(i) for i in input().split()])
C=sorted([int(i) for i in input().split()])

ans=0
for b in B:
  ans+=bisect.bisect_left(A,b)*(N-bisect.bisect_right(C,b))

print(ans)

### FIXED CODE ###

import bisect

N=int(input())
A=sorted([int(i) for i in input().split()])
B=sorted([int(i) for i in input().split()])
C=sorted([int(i) for i in input().split()])

ans=0
for b in B:
  ans+=bisect.bisect_left(A,b)*(N-bisect.bisect_right(C,b))

print(ans)
arr = input().split()
arr = list(map(int, arr))

if a <= x and x <= a+b:
    print('YES')
else:
    print('NO')


### FIXED CODE ###

arr = input().split()
arr = list(map(int, arr))
a = arr[0]
b = arr[1]
x = arr[2]

if a <= x and x <= a+b:
    print('YES')
else:
    print('NO')
n=int(input())
flag=0
ans=0

for i in range(n):
    d1,d2=map(int,input().split())
    if d1==d2:
        flag+=1
        if flag==3:
            ans=1
    else:
        flag=0
if ans!=1:
    print("No")
else:
    print("Yes")
    

### FIXED CODE ###

s=input()
if s[len(s)-1]=="s":
    print(s+"es")
else:
    print(s+"s")
def abc177d():
    n, m = map(int, input().split())
    check = [-1] * n
    group_no = 0
    group = {}
    for i in range(m):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        if check[a] == check[b] != -1: continue
        if check[a] == check[b] == -1:
            group[group_no] = {a, b}
            check[a] = check[b] = group_no
            group_no += 1
        elif check[a] == -1 or check[b] == -1:
            max_g = max(check[a],check[b])
            group[max_g] |= {a,b}
            check[b] = check[a] = max_g
        else:
            re = min(check[a], check[b])
            de = max(check[a], check[b])
            for v in group[de]:
                check[v] = re
            group[re] |= group[de]
            del group[de]
    max_val = max(map(len, group.values()))
    print(max(1,max_val))


abc177d()

### FIXED CODE ###

def abc177d():
    n, m = map(int, input().split())
    if m ==0:
        print(1)
        return 
    check = [-1] * n
    group_no = 0
    group = {}
    for i in range(m):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        if check[a] == check[b] != -1: continue
        if check[a] == check[b] == -1:
            group[group_no] = {a, b}
            check[a] = check[b] = group_no
            group_no += 1
        elif check[a] == -1 or check[b] == -1:
            max_g = max(check[a],check[b])
            group[max_g] |= {a,b}
            check[b] = check[a] = max_g
        else:
            re = min(check[a], check[b])
            de = max(check[a], check[b])
            for v in group[de]:
                check[v] = re
            group[re] |= group[de]
            del group[de]
    max_val = max(map(len, group.values()))
    print(max(1,max_val))


abc177d()
import math
n = int(input())
s = int(input())

if n < s:
    print (-1)
    exit()

def f(b, n):
    if n < b:
        return n
    else:
        return f(b, n//b) + n%b

if s == n:
    print (n+1)
    exit()

if n == 1:
    print (-1)
    exit()

for i in range(2, int(math.sqrt(n))+2):
    if f(i, n) == s:
        print (i)
        exit()

for p in range(1, int(math.sqrt(n))+2):
    b = (n-s)//p + 1
    if f(b, n) == s:
        print (b)
        exit()
print (-1)

### FIXED CODE ###

import math
import sys
sys.setrecursionlimit(10**5)
n = int(input())
s = int(input())

if n < s:
    print (-1)
    exit()

def f(b, n):
    if n < b:
        return n
    else:
        return f(b, n//b) + n%b

if s == n:
    print (n+1)
    exit()

if n == 1:
    print (-1)
    exit()

for i in range(2, int(math.sqrt(n))+2):
    if f(i, n) == s:
        print (i)
        exit()

for p in range(int(math.sqrt(n))+1, 0, -1):
    b = (n-s)//p + 1
    if b != 1 and f(b, n) == s:
        print (b)
        exit()
print (-1)

# for i in range(2, 100):
#     print (i, f(i,100))
n = int(input())
ns = map(input().split(), int)

c = 0
for i in range(1, n):
  if sorted([ns[i-1], ns[i], ns[i+1]])[2] == ns[i]:
    c += 1
    
print(c)

### FIXED CODE ###

a = input()
b = list(set(list(a)))
print('Yes' if len(b) == 2 and a.count(b[0]) == 2 and a.count(b[1]) == 2 else 'No')
n_max = 100000

bs = [(6 ** i, 6) for i in range (1, 10)]
bs.extend([(9 ** i, 9) for i in range (1, 10)])
bs = list(sorted(filter(lambda x: x[0] <= n_max, bs)))
bms = []
s = 5
for b, i in bs:
    s += b * (i - 1)
    bms.append((b, i, s))

#print(bs)
#print(bms, len(bms))

#m = 44852
m = int(input())

stack = [(m, 0, len(bms) - 1)]
#print("search start!")
result = 10000
while stack:
    m, n, bms_i = stack.pop()
    steps += 1
    b, i, s = bms[bms_i]
    #print(m, n, bms_i, b, i, s)

    if n > result:
        #print("skip!", m, n, bms_i)
        continue
    if m > s:
        continue
    if bms_i < 0:
        if m <= 6 and m + n < result:
            result = m + n
        #    print('get result!', result)
        continue

    for j in range(i):
        next_m = m - b * j
        if next_m >= 0 and n + j < result:
            stack.append((next_m, n + j, bms_i - 1))

print(result)


### FIXED CODE ###

n_max = 100000

bs = [(6 ** i, 6) for i in range (1, 10)]
bs.extend([(9 ** i, 9) for i in range (1, 10)])
bs = list(sorted(filter(lambda x: x[0] <= n_max, bs)))
bms = []
s = 5
for b, i in bs:
    s += b * (i - 1)
    bms.append((b, i, s))

#print(bs)
#print(bms, len(bms))

#m = 44852
m = int(input())

stack = [(m, 0, len(bms) - 1)]
#print("search start!")
result = 10000
while stack:
    m, n, bms_i = stack.pop()
    b, i, s = bms[bms_i]
    #print(m, n, bms_i, b, i, s)

    if n > result:
        #print("skip!", m, n, bms_i)
        continue
    if m > s:
        continue
    if bms_i < 0:
        if m <= 6 and m + n < result:
            result = m + n
        #    print('get result!', result)
        continue

    for j in range(i):
        next_m = m - b * j
        if next_m >= 0 and n + j < result:
            stack.append((next_m, n + j, bms_i - 1))

print(result)
from collections import Counter
n = int(input())
S = [str(sorted(input())) for _ in range(N)]

print(sum(map(lambda x: x * (x - 1) // 2, Counter(S).values())))

### FIXED CODE ###

from collections import Counter
n = int(input())
S = [str(sorted(input())) for _ in range(n)]

print(sum(map(lambda x: x * (x - 1) // 2, Counter(S).values())))
import numpy as np
import sys
import copy


def xnxn(n=0, flag="v"):
    """
    args:
        int n: a number of lows to read
    example:
        input   1
        retrun  1

        input   1 2 3
        return  [1,2,3]
        input   1 2 3
                4 
        return  [[1,2,3],
                [4]]
    """
    if n == 0:
        temp = list(map(int, input().split()))
        if len(temp) == 1:
            if flag == "l":
                return temp
            else:
                return temp[0]
        elif len(temp) > 1:
            return temp
    else:
        temp = [list(map(int, input().split())) for _ in range(n)]
        return temp


def sp_xnxn(n=0):
    """
    args:
        int n: a number of lows to read
    example
        input   1
        retrun  [1]

        input   123
        return  [1,2,3]

        input   123
                4 
        return  [[1,2,3],
                [4]]
    """
    if n == 0:
        return [int(k) for k in xsxs()]
    else:
        return [[int(k) for k in xsxs()] for _ in range(n)]


def xsxs(n=0):
    """
    args:
        int n: a number of lows to read 
    example:
        input   AA
        retrun  AA

        input   A BBB CC
        return  ["A","BBB","CC"]

        input   A BB CCC
                D
        return  [["A","BBB","CC"],
                ["D"]]
    """
    if n == 0:
        temp = list(input().split())
        if len(temp) == 1:
            return temp[0]
        elif len(temp) > 1:
            return temp
    else:
        return [list(input().split()) for _ in range(n)]


def sp_xsxs(n=0):
    """
    args:
        int n: a number of lows to read 
        example:
            input   A
            retrun  ["A"]

            input   ABC
            return  ["A","B","C"]

            input   ABC
                    D
            return  [["A","B","C"],
                    ["D"]]
    """
    if n == 0:
        return [s for s in xsxs()]
    else:
        return [[s for s in xsxs()] for _ in range(n)]


n, k = xnxn()
a = xnxn()
a = [1] + a
for _ in range(k):
    tmp = copy.copy(a)
    for i in range(1, n + 1):
        idx = []
        c = 0
        for k in range(1, n + 1):
            if k - tmp[k] - 0.5 < i < k + tmp[k] + 0.5:
                c += 1
        a[i] = c

for i in a[1:]:
    print(i, end=" ")


### FIXED CODE ###

s = input()

print(s[0:3])
# -*- coding: utf-8 -*-

import sys

#          x  1  2  3  4  5  6  7  8  9
num     = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
rev_num = [0, 6, 7, 3, 6, 5, 4, 5, 5, 2]

inf = 10000000000

def main():
    sp = [int(e) for e in input().split(" ")]
    n = sp[0]
    m = sp[1]

    # 使える桁が入る
    A = [int(e) for e in input().split(" ")]

    # 最大桁を求める
    # マッチ数が同じ場合、桁の大きい方で順位づけする
    # 0 <= i < n において、マッチ i 本をちょうど使って作成できる最大の桁を求める
    dp = [0] * (n+1)

    for i in range(1, n+1):
        max = 0
        matched = False
        for j in A:
            if dp[i-num[j]] == -inf or i-num[j] < 0:
                continue
            matched = True
            tmp = dp[i-num[j]] + 1
            if tmp > max:
                max = tmp
        if not matched:
            dp[i] = -inf
        else:
            dp[i] = max

    A.sort()
    A.reverse()

    # print(dp[n], dp)

    n2 = n;
    while n2 != 0:
        # print("--- n = {} --".format(n2))
        for e in A:
            # print("e = {}, dp[n-num(e)] = {}, dp[n]-1 = {}".format(e, dp[n2-num[e]], dp[n2]-1))
            if dp[n2-num[e]] == dp[n2]-1:
                # print('select = {} ({})'.format(e, num[e]))
                n2 -= num[e]
                print(e, end="")
                break
    print()

main()


### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

MATCH_NUM = [-1, 2, 5, 5, 4, 5, 6, 3, 7, 6]

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))

    # N 本で作れる桁の数
    dp = [-1 for _ in range(N+1)]
    dp[0] = 0
    for i in range(N+1):
        for a in A:
            if i < MATCH_NUM[a]:
                continue
            dp[i] = max(dp[i], dp[i-MATCH_NUM[a]] + 1)

    max_digit_num = dp[N]

    res = ''
    for _ in range(max_digit_num):
        m = -1
        for a in A:
            if N < MATCH_NUM[a]:
                continue
            if dp[N-MATCH_NUM[a]] == dp[N]-1:
                if a > m:
                    m = a
        res += str(m)
        N -= MATCH_NUM[m]
    print(res)
main()
N=input()
for i in range(3):
  if N[i]=="1":
    N[i]=9
  else:
    N[i]=1

### FIXED CODE ###

L=[0]*3
N=input()
for i in range(3):
  if N[i]=="1":
    L[i]=9
  else:
    L[i]=1
print((L[0]*100)+(L[1]*10)+L[2])
S = int(input())
N = len(S) - 1
ans = 0

for i in range(2 ** N):
    k = 0
    for j in range(N):
        if (i >> j) & 1:
            ans += int(S[k:j + 1])
            k = j + 1
    ans += int(S[k:])
print(ans)


### FIXED CODE ###

S = input()
N = len(S) - 1
ans = 0

for i in range(2 ** N):
    k = 0
    for j in range(N):
        if (i >> j) & 1:
            ans += int(S[k:j + 1])
            k = j + 1
    ans += int(S[k:])
print(ans)
import copy
h,w = map(int, input().split())
s = [list(input()) for _ in range(h)]
t = copy.deepcopy(s)
for i in range(h):
    count = 0
    for j in range(w):
        if (s[i][j]=='.'):
            count += 1
            
        else:
            for k in range(j-1,j-count-1,-1):
                s[i][k]=count
            count = 0
    for k in range(w-1,w-count-1,-1):
        s[i][k]=count
    count = 0

for i in range(w):
    count = 0
    for j in range(h):
        if (t[j][i]=='.'):
            count += 1
            
        else:
            for k in range(j-1,j-count-1,-1):
                t[k][i]=count
            count = 0
    for k in range(h-1,h-count-1,-1):
        t[k][i]=count
    count = 0

ans = 0
for i in range(h):
    for j in range(w):
        if (s[i][j]!="#"):
            if (s[i][j]+t[i][j]-1 > ans):
                ans = s[i][j]+t[i][j]-1
print(ans)

### FIXED CODE ###

p,q,r = map(int, input().split())
print(min(p+q,p+r,q+r))
import numpy as np
N=int(input())
h=list(map(int,input().split()))

#N=4
#h=[10,30,40,20]

dp=np.zeros(N)
print(dp)
dp[1]=abs(h[1]-h[0])
print(dp)

for i in range(N-2):
  dp[i+2]=min(abs(h[i+2]-h[i])+dp[i],abs(h[i+2]-h[i+1])+dp[i+1])
  print(dp)
  #dp[2]=min(h[2]-h[0],h[1]-h[0])

#total

print(dp[-1]







### FIXED CODE ###

import numpy as np
N=int(input())
h=list(map(int,input().split()))

#N=4
#h=[10,30,40,20]

dp=np.zeros(N)
#print(dp)
dp[1]=abs(h[1]-h[0])
#print(dp)

for i in range(N-2):
  dp[i+2]=min(abs(h[i+2]-h[i])+dp[i],abs(h[i+2]-h[i+1])+dp[i+1])
 # print(dp)
  #dp[2]=min(h[2]-h[0],h[1]-h[0])

#total

print(int(dp[-1]))
s = input()
pos = 0
str_len = len(s)
count = 0
seq_a = 0
seq_d = 0

if len(s) < 3:
    print(0)
    quit()

if "BC" in s:
    s = s.replace("BC", "D")
else:
    print(0)
    quit()

while pos < str_len:
    if s[pos] == "A":
        while pos < str_len and s[pos] == "A":
            seq_a += 1
            pos += 1
        if s[pos] == "D":
            while pos < str_len and s[pos] == "D":
                seq_d += 1
                pos += 1
            count += seq_a * seq_d
            if pos < str_len and s[pos] != "A":
                seq_a = 0
            seq_d = 0
        else:
            pos += 1
            seq_a = 0
    else:
        pos += 1
        seq_a = 0

print(count)


### FIXED CODE ###

s = input()
pos = 0
str_len = len(s)
count = 0
seq_a = 0
seq_bc = 0

while pos < str_len:
    if s[pos] == "A":
        while pos < str_len and s[pos] == "A":
            seq_a += 1
            pos += 1
        if pos + 1 < str_len and s[pos] == "B" and s[pos+1] == "C":
            while pos < str_len and s[pos] == "B" and pos + 1 < str_len and s[pos+1] == "C":
                seq_bc += 1
                pos += 2
            count += seq_a * seq_bc
            if pos < str_len and s[pos] != "A":
                seq_a = 0
            seq_bc = 0
        else:
            pos += 1
            seq_a = 0
    else:
        pos += 1
        seq_a = 0

print(count)
#abc118c

import functools
import math

n=int(input())
l=list(map(int,input().split()))
print(functools.reduce(math.gcd,l))


### FIXED CODE ###

#abc118c
import functools

def gcd(a,b):
 while b:
  a,b=b,a%b
 return a

n=int(raw_input())
l=map(int,raw_input().split())
print functools.reduce(gcd,l)