Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

#!/usr/bin/env python3
import sys


def solve(s: str):
    
    s = s.replace('BC', 'X', len(s))

    ans = 0
    while('AX' in s):
        ans += s.count('AX')
        s = s.replace('AX', 'XA', len(s))
        

    print(ans)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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()


### FIXED CODE ###

#!/usr/bin/env python3
import sys


def solve(s: str):
    
    s = s.replace('BC', 'X')

    ans = 0
    cur = 0
    for i in range(len(s)):
        if(s[i] == 'A'):
            cur += 1
        elif(s[i] == 'X'):
            ans += cur
        else:
            cur = 0    

    print(ans)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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()
### BUGGY CODE ###

import sys
s,t=list(input()),list(input())
n=len(s)

for i in range(n):
  ss = [j for j, x in enumerate(s) if x == s[i]]
  tt = [j for j, x in enumerate(t) if x == t[i]]
  if ss!=tt:
    print('No')
    sys.exit()
print('Yes')

### FIXED CODE ###

import sys
s0,t0=input(),input()
s,t=list(s0),list(t0)
n=len(s)
sn=set(s)
tn=set(t)
if len(sn)!=len(tn) or len(s)!=len(t):
  print('No')
  sys.exit()
for i in range(n):
  if s[i]!=t[i]:
    if s.index(s[i])!=t.index(t[i]):
      print('No')
      sys.exit()
print('Yes')
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
mod = 1000000007
res = 0

for i in range(n - 1):
    for j in range(n - (i + 1)):
        res =  (res + a[i] * a[i + (j + 1)] % mod) % mod

print(res)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
mod = 1000000007
res = 0
a_sum = sum(a)

for i in range(n - 1):
    main = a[i]
    a_sum = a_sum - main
    res =  (res + main * a_sum % mod) % mod
print(res)
### BUGGY CODE ###

def main():
    import sys
    input = sys.stdin.readline

    s = input()
    s = s[0:len(s)-1]
    Q = int(input())

    flg = 0 # 0:sonomama 1:gyakuten
    for _ in range(Q):
        q = input().split()
        if q[0] == "1":
            if flg == 0:
                flg = 1
            else:
                flg = 0
        elif q[0]=="2":
            index,tmp = q[1],q[2]
            if (index == "1" and flg ==0) or (index == "2" and flg ==1):
                s = "".join([tmp,s])
            elif (index == "2" and flg == 0) or (index == "1" and flg == 1):
                s = "".join([s,tmp])

    if flg==1:
        print(s[::-1])
    else:
        print(s)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.readline

    s = input()
    s = s[0:len(s)-1]
    Q = int(input())
    head = []
    tail = []

    flg = 0 # 0:sonomama 1:gyakuten
    for _ in range(Q):
        q = input().split()
        if q[0] == "1":
            if flg == 0:
                flg = 1
            else:
                flg = 0
        elif q[0]=="2":
            index,tmp = q[1],q[2]
            if (index == "1" and flg ==0) or (index == "2" and flg ==1):
                head.append(tmp)
            elif (index == "2" and flg == 0) or (index == "1" and flg == 1):
                tail.append(tmp)

    s1 = "".join(head)
    s1 = s1[::-1]
    s2 = "".join(tail)
    ans = s1 + s + s2
    if flg == 1:
        ans = ans[::-1]

    print(ans)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline
def main():
    h, n = (int(x) for x in input().split())
    ab = []
    for _ in range(n):
        a, b = (int(x) for x in input().split())
        ab.append([a, b])
    dp = [float('inf')] * (h)
    for a, b in ab:
        for i in range(h):
            if i < a:
                dp[i] = min(dp[i], b)
            else:
                dp[i] = min(dp[i], dp[i - a] + b)
    print(dp[h - 1])
if __name__=='__main__':
    main()

### FIXED CODE ###

h, n = (int(x) for x in input().split())
ab = []
for _ in range(n):
    a, b = (int(x) for x in input().split())
    ab.append([a, b])
max_a = max(a for a, _ in ab)
dp = [0] * (h + max_a)
for i in range(1, h + 1):
    dp[i] = min(dp[i - a] + b for a, b in ab)
print(dp[h])
### BUGGY CODE ###

N,M,R = map(int,input().split())
r = list(map(int,input().split()))
from itertools import permutations
t = [[float('inf') for i in range(N)] for j in range(N)]

for i in range(M):
    a,b,c = map(int, input().split())
    t[a-1][b-1] = t[b-1][a-1] = c

for i in range(N):
    for j in range(N):
        for k in range(N):
            if t[i][j] > t[j][k] + t[k][j]:
                t[i][j] = t[j][k] + t[k][j]

def c(l):
    ret = 0
    for i in range(R-1):
        ret += t[l[i]-1][l[i+1]-1]
    return ret

print(min([c(i) for i in permutations(r)]))

### FIXED CODE ###

N,M,R = map(int,input().split())
r = list(map(int,input().split()))
from itertools import permutations
from scipy.sparse.csgraph import dijkstra
t = [[float('inf') for i in range(N)] for j in range(N)]

for i in range(M):
    a,b,c = map(int, input().split())
    t[a-1][b-1] = t[b-1][a-1] = c
t=dijkstra(t).astype(int)
def c(l):
    ret = 0
    for i in range(R-1):
        ret += t[l[i]-1][l[i+1]-1]
    return ret

print(min([c(i) for i in permutations(r)]))
### BUGGY CODE ###

from collections import defaultdict
def inpl(): return [int(i) for i in input().split()]

path = defaultdict(lambda: [])
N = int(input())
for _ in range(N-1):
    a, b, c = inpl()
    path[a].append((b,c))
    path[b].append((a,c))

Q, K = inpl()
now = {K}
dist = [0 for _ in range(N+1)]
visited = [False for _ in range(N+1)]
visited[K] = visited[0] = True
while True:
    for na in now.copy():
        na = now.pop()
        for nb, nc in path[na]:
            dist[nb] = dist[na] + nc
            visited[nb] = True
            path[nb].remove((na,nc))
            now.add(nb)
    if all(visited):
        break
for i in range(Q):
    x, y = inpl()
    print(dist[x]+dist[y])

### FIXED CODE ###

from collections import defaultdict
def inpl(): return [int(i) for i in input().split()]

path = defaultdict(lambda: [])
N = int(input())
for _ in range(N-1):
    a, b, c = inpl()
    path[a].append((b,c))
    path[b].append((a,c))

ctr = 1
Q, K = inpl()
now = [K]
dist = [0 for _ in range(N+1)]
while True:
    for na in now.copy():
        na = now.pop()
        for nb, nc in path[na]:
            dist[nb] = dist[na] + nc
            path[nb].remove((na,nc))
            now.append(nb)
            ctr += 1
    if ctr >=  N:
        break
for i in range(Q):
    x, y = inpl()
    print(dist[x]+dist[y])
### BUGGY CODE ###

n=int(input())
l=list(map(int,input().split()))
l=sorted(l)
ans=0
for i in range(n):
    a=l[i]
    for j in range(i+1,n):
        b=l[j]
        for k in range(j+1,n):
            c=l[k]
            if c>=a+b:
                break
            if a<b+c and b<a+c and c<a+b:
                ans+=1
print(ans)

### FIXED CODE ###

import bisect
n=int(input())
l=list(map(int,input().split()))
l=sorted(l)
ans=0
for i in range(n):
    a=l[i]
    for j in range(i+1,n):
        b=l[j]
        idx=bisect.bisect_left(l,a+b)
        t=idx-j-1
        if t>0:
            ans+=t
print(ans)
### BUGGY CODE ###

from scipy.misc import comb

mod = 998244353

n, a, b, k = map(int, input().split())

ans = 0
for i in range(n+1):
    Num = (k-a*i)
    if (0 <= Num//b) and (Num//b <= n) and (Num%b == 0):
      j = Num//b
      ans += comb(n, i, exact=True) * comb(n, j, exact=True)
print(ans%mod)

### FIXED CODE ###

mod = 998244353

def comb(n, r):
    if 2 * r > n: return comb(n, n-r)
    return fac[n] * inv[r] * inv[n-r] % mod

n, a, b, k = map(int, input().split())

fac = [1] * (n+2)
inv = [1] * (n+2)
for i in range(2, n+1):
    fac[i] = fac[i-1] * i % mod
inv[n] = pow(fac[n], mod - 2, mod)
for i in range(n-1, 1, -1):
    inv[i] = inv[i + 1] * (i + 1) % mod

ans = 0
for i in range(n+1):
    Num = (k-a*i)
    if (0 <= Num//b) and (Num//b <= n) and (Num%b == 0):
      j = Num//b 
      ans += comb(n, i) * comb(n, j) 
print(ans%mod)
### BUGGY CODE ###

import numpy as np
from numpy.fft import rfft, irfft
N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
X = np.zeros(10**5+1)
l = 2*(10**5)+10
for i in range(N):
    X[A[i]] += 1
data = irfft(rfft(X, l)**2 )
num = 0
ans = 0
for i in range(len(data) -1 ,0,-1):
    if int(round(data[i])) != 0:
        if num + int(round(data[i])) >= M:
            ans += (M - num) * i
            break
        else:
            ans += int(round(data[i]))*i
            num += int(round(data[i]))
print(ans)

### FIXED CODE ###

import bisect
N, M = list(map(int,input().split()))
data = list(map(int,input().split()))
data.sort()
def cost(x):
    re = 0
    for i in range(N):
        idx = bisect.bisect_left(data,x - data[i])
        re += N - idx
    return re
#binery_search
lb = 0
ub = 2*max(data) + 1
while ub - lb > 1:
    mid = (ub+lb)//2
    if cost(mid) >= M:
        lb = mid
    else:
        ub = mid
ans = 0 - (cost(lb) - M)* lb
cum_data = [0]*(N+1)
for i in range(1,N+1):
    cum_data[i] = cum_data[i -1] + data[i-1]
data_idx = [0]*N
for i in range(N):
    idx = bisect.bisect_left(data,lb - data[i])
    data_idx[i] = idx
for i in range(N):
    ans += (N - data_idx[i]) * data[i]
    ans += cum_data[N] - cum_data[data_idx[i]]
print(ans)
### BUGGY CODE ###

n, s = map(int, input().split())
a = list(map(int, input().split()))

dp = [[0]*(s+1) for _ in range(n+1)]
mod = 998244353

dp[0][0] = 1
for i in range(n):
  for j in range(s+1):
    dp[i+1][j] += dp[i][j] * 2
    dp[i+1][j] %= mod
    if j+a[i] <= s:
      dp[i+1][j+a[i]] += dp[i][j]
      dp[i+1][j+a[i]] %= mod
      
print(dp[n][s])

### FIXED CODE ###

n, s = map(int, input().split())
a = list(map(int, input().split()))

dp = [[0]*(s+1) for _ in range(n+1)]
mod = 998244353

dp[0][0] = 1
for i in range(n):
  for j in range(s+1):
    dp[i+1][j] += dp[i][j] * 2
    dp[i+1][j] %= mod
    if j+a[i] <= s:
      dp[i+1][j+a[i]] += dp[i][j]
      dp[i+1][j+a[i]] %= mod
      
print(dp[n][s])
### BUGGY CODE ###

# 頂点を3回ずつに持つ (x歩目の着地）
# 最短路

import sys
import numpy as np
from scipy.sparse import *
input = sys.stdin.readline
N,M = map(int,input().split())
if M == 0:
  print(-1)
  exit()
UV = np.array([input().split() for _ in range(M)], dtype=np.int32)
U = UV[:,0] * 3
V = UV[:,1] * 3
S,T = map(int,input().split())

rows = np.zeros(3*M, dtype=np.int32)
cols = np.zeros(3*M, dtype=np.int32)

rows[:M] = U
rows[M:2*M] = U + 1
rows[2*M:] = U + 2
cols[:M] = V + 1
cols[M:2*M] = V + 2
cols[2*M:] = V

graph = csr_matrix((np.ones_like(rows), (rows, cols)), (3*N+3, 3*N+3))
dist = csgraph.dijkstra(graph, indices = 3*S, unweighted=True)

answer = -1 if dist[3*T] > 3*N else int(dist[3*T]//3)
print(answer)

### FIXED CODE ###

# 頂点を3回ずつに持つ (x歩目の着地）
# 最短路

import sys
input = sys.stdin.readline
N,M = map(int,input().split())
if M == 0:
  print(-1)
  exit()
edge = [[] for _ in range(N+1)]
for _ in range(M):
  u,v = map(int,input().split())
  edge[u].append(v)
S,T = map(int,input().split())

INF = 10 ** 9
dist = [[INF,INF,INF] for _ in range(N+1)]

d = 0
q = [S]
while q:
  d += 1
  r = d % 3
  qq = []
  for u in q:
    for v in edge[u]:
      if dist[v][r] == INF:
        dist[v][r] = d
        qq.append(v)
  q = qq

d = dist[T][0]
answer = -1 if d == INF else d // 3
print(answer)
### BUGGY CODE ###


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

    for i in range(N):
        A[i]=A[i]-i-1

    val1 = 0
    val2=0
    for i in A:
        val1 += abs(i - 1)
        val2+=abs(i+1)
    if val1<val2:

        minval = 10 ** 50
        j=0
        temp = 10**50
        while True:
            val=0
            for i in A:
                val+=abs(i-j)
            if val>=temp:
                break
            else:
                temp=val
                minval=min(minval,val)
                j+=1

    else:

        minval = 10 ** 50
        j=0
        temp = 10**50
        while True:
            val=0
            for i in A:
                val+=abs(i+j)
            if val>=temp:
                break
            else:
                temp=val
                minval=min(minval,val)
                j+=1
    print(minval)
resolve()

### FIXED CODE ###

# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
import numpy as np
#import statistics
#import sys
#sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():
    N=int(input())
    A=np.array(list(map(int,input().split())))

    for i in range(N):
        A[i]-=i+1

    B=abs(A-np.median(A))
    print(int(sum(B)))
resolve()
### BUGGY CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
for i in range(n):
    if max(a) > a[i]:
        print(max(a))
    else:
        if a.count(a[i]) > 1:
            print(a[i])
        else:
            print(sorted(a)[-2])


### FIXED CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
b = sorted(a)
max_a = max(a)
max_cnt = a.count(max_a)
for i in range(n):

    if max_a > a[i]:
        print(max_a)
    else:
        if max_cnt > 1:
            print(a[i])
        else:
            print(b[-2])
### BUGGY CODE ###

n, ww = map(int, input().split())
w, v = [0] * n, [0] * n
for i in range(n):
    w[i], v[i] = map(int, input().split())

dp = [[0] * (100100) for i in range(110)]

for i in range(n):
    for j in range(ww + 1):
        if j - w[i] >= 0:
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i])

        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])

print(dp[n][ww])

### FIXED CODE ###

n, ww = map(int, input().split())
w, v = [0] * n, [0] * n
for i in range(n):
    w[i], v[i] = map(int, input().split())

dp = [[0] * (100100) for i in range(110)]

for i in range(n):
    for j in range(ww + 1):
        if j - w[i] >= 0:
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i])

        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])

print(dp[n][ww])
### BUGGY CODE ###

import numpy as np
n=input()
data=list(map(int,input().split()))
is_i=0
num=sorted(data)
count=0
for i in range(num[1]+1)[::-1]:
    is_i=0
    if all([x%i==0 for x in data]):
        print(i)
        break
    elif count==0:
        for j in range(len(data)):
            if data[j]%i!=0:
                is_i+=1
        if is_i==1:
            print(i)
            break

### FIXED CODE ###

from fractions import gcd
import numpy as np
n=int(input())
data=list(map(int,input().split()))
left=np.zeros(n+1,dtype=np.int)
right=np.zeros(n+1,dtype=np.int)
kotae=1
for i in range(n):
    left[i+1]=gcd(left[i],data[i])
    right[n-i-1]=gcd(right[n-i],data[n-i-1])
for j in range(n):
    num=gcd(left[j],right[j+1])
    kotae=max(num,kotae)
print(kotae)
### BUGGY CODE ###

X,Y,Z,K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = sorted(list(map(int, input().split())), reverse=True)

AB = []
for i in range(X):
	for j in range(Y):
		AB.append(A[i]+B[j])

AB.sort(reverse = True)
AB = AB[:min(K,len(AB))]

ABC = []
for i in range(min(K,len(AB))):
	for j in range(Z):
		ABC.append(AB[i]+C[j])

ABC.sort(reverse = True)

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

### FIXED CODE ###

X,Y,Z,K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = sorted(list(map(int, input().split())), reverse=True)

AB = []
for i in range(X):
	for j in range(Y):
		AB.append(A[i]+B[j])

AB.sort(reverse = True)
AB = AB[:min(K,len(AB))]

ABC = []
for i in range(min(K,len(AB))):
	for j in range(Z):
		ABC.append(AB[i]+C[j])

ABC.sort(reverse = True)

for i in range(K):
	print(ABC[i])
### BUGGY CODE ###

S=input()
ans=0

while True:
    befere_S=S
    S=S.replace('10','').replace('01','')
    ans+=len(befere_S)-len(S)
    if befere_S == S:
        break
print(ans)


### FIXED CODE ###

S=list(input())
ans=0

print(len(S)-abs(S.count('0')-S.count('1')))
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
A.sort()
cnt = 0
onaji = 0

for i in range(len(A)):
    if i >= len(A)-1:
        break
    for j in range(len(A)-1,i,-1):
        if A[i] == A[j]:
            onaji = 1
        if A[j] % A[i] == 0:
            del A[j]
            
    if onaji == 1:
        del A[i]
        onaji = 0

print(len(A))

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
OKlist = [0]*(10**6+100)
A.sort()
for i in range(len(A)-1):
    if A[i] == A[i+1]:
        OKlist[A[i]] += 1
    else:
        for j in range(10**6+10):
            if A[i]*j > 10**6:
                break
            else:
                OKlist[A[i]*j] += 1
OKlist[max(A)] += 1
cnt = 0
for i in A:
    if OKlist[i] == 1:
        cnt += 1
        
print(cnt)
### BUGGY CODE ###

A,B,K=map(int,input().split())
for i in range(A,B+1):
  if i<A+K or B-K<i:
    print(i)    

### FIXED CODE ###

A,B,K=map(int,input().split())
if A+K-1<B-K+1:
  for i in range(A,A+K):
    print(i)
  for i in range(B-K+1,B+1):
    print(i)
else:
  for i in range(A,B+1):
    print(i)
### BUGGY CODE ###

n = int(input())
xlist = [int(x) for x in input().split()]
sxlist = sorted(xlist)
for i in range(n):
    index = sxlist.index(xlist[i])
    if index < n/2:
        print(sxlist[int(n/2)])
    else:
        print(sxlist[int(n/2)-1])

### FIXED CODE ###

n = int(input())
xlist = [int(x) for x in input().split()]
sxlist = sorted(xlist)
mid = sxlist[int(n/2)]
mid2 = sxlist[int(n/2)-1]
for i in range(n):
    if xlist[i] < mid:
        print(mid)
    else:
        print(mid2)
### BUGGY CODE ###

x=input()
while "ST" in x:x=x.replace("ST","")
print(len(x))

### FIXED CODE ###

l=[]
for i in input():
    if i=="S":l.append("S")
    elif len(l)==0 or l[-1]=="T":l.append("T")
    else:l.pop()
print(len(l))
### BUGGY CODE ###

import itertools

def main():
    N = int(input())
    S = [input() for _ in range(N)]
    memo = []
    count = 0
    for s in S:
        if s in memo:
            count += 1
        else:
            memo.append(s)
        
    print(N - count)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys, itertools
input = sys.stdin.readline

def main():
    N = int(input())
    S = [s.rstrip() for s in sys.stdin.readlines()]
    count = 0

    memo = sorted(S)

    for i in range(N - 1):
        if memo[i] == memo[i + 1]:
            count += 1
        
    print(N - count)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

# coding=utf-8


def calc_weights(weight):
    weights_list = []
    counter = 0
    while weight > 0:
        if weight % 2 == 0:
            weight /= 2
        else:
            weights_list.append(2**counter)
        counter += 1
    print(' '.join(map(str, weights_list)))


if __name__ == '__main__':
    while True:
        try:
            W = int(input())
            calc_weights(W)
        except EOFError:
            break



### FIXED CODE ###

# coding=utf-8


def calc_weights(weight):
    weights_list = []
    counter = 0
    while weight > 0:
        if weight % 2 == 0:
            weight /= 2
        else:
            weights_list.append(2**counter)
            weight = (weight - 1)/2
        counter += 1
    print(' '.join(map(str, weights_list)))


if __name__ == '__main__':
    while True:
        try:
            W = int(input())
            calc_weights(W)
        except EOFError:
            break
### BUGGY CODE ###

import math
N = input()
A = list(map(int,input().split()))

for e in A:
    d = dict((i, A.count(i)) for i in set(A))
    d[e]-=1
    
    ans = 0
    for i in list(d):
        if d[i] < 2:
            continue
        ans += d[i]*(d[i]-1)/2
    print(int(ans))
    

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))

ad = {}
for i in range(n) :
    if a[i] in ad :
        ad[a[i]] += 1
    else :
        ad[a[i]] = 1

ans = 0
for v in ad.values():
    ans += v*(v-1)//2

for i in range(n):
    v = ad[a[i]]
    print(ans-v*(v-1)//2+(v-1)*(v-2)//2)
### BUGGY CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    s=input()
    dp_0=[[False]*1001 for _ in range(n+1)]
    dp_1=[[False]*1001 for _ in range(n+1)]
    dp_2=[[False]*1001 for _ in range(n+1)]
    dp_3=[[False]*1001 for _ in range(n+1)]
    dp_0[0][0]=True
    
    for k in range(1000):
        for i in range(n):
            if dp_0[i][k]==True:
                dp_0[i+1][k]=True
                dp_1[i+1][10*k+int(s[i])]=True
            if dp_1[i][k]==True:
                dp_1[i+1][k]=True
                dp_2[i+1][10*k+int(s[i])]=True
            if dp_2[i][k]==True:
                dp_2[i+1][k]=True
                dp_3[i+1][10*k+int(s[i])]=True
            if dp_3[i][k]==True:
                dp_3[i+1][k]=True            
    ans=0
    for i in range(1000):
        if dp_3[n][i]:
            ans+=1
    print(ans)

if __name__=='__main__':
    main()

### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    s=input()
    ans=0
    for i in range(10):
        for j in range(10):
            for k in range(10):
                if str(i) in s:
                    index_i=s.index(str(i))
                    s1=s[index_i+1:]
                    if str(j) in s1:
                        index_j=s1.index(str(j))
                        s2=s1[index_j+1:]
                        if str(k) in s2:
                            ans+=1
    print(ans)

if __name__=='__main__':
    main()
### BUGGY CODE ###

from fractions import gcd
from functools import reduce

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

n = int(input())
a = list(map(int, input().split()))
m = max(gcd_list(a[:i] + a[i + 1:]) for i in range(n))
print(m)

### FIXED CODE ###

from fractions import gcd

n = int(input())
a = list(map(int, input().split()))

rs, ls = [0], [0]
for i in range(n-1):
  rs.append(gcd(rs[i], a[i]))
  ls.append(gcd(ls[i], a[-i-1]))

print(max(gcd(r, l) for r, l in zip(rs, ls[::-1])))
### BUGGY CODE ###

# Problem D - Xor Sum 4

# input
N = int(input())
a_nums = list(map(int, input().split()))

# initialization
ans = 0
MOD = 10**9 + 7

# count
two_factor = 1
for i in range(60):
    tmp_count = 0
    one_count = 0
    zero_count = 0
    for j in range(N):
        if (a_nums[j]>>i)&1==1:
            one_count += 1
        else:
            zero_count += 1
    tmp_count = (one_count * zero_count)%MOD
    ans += (tmp_count * two_factor)%MOD
    two_factor = (two_factor * 2)%MOD

# output
print(ans%MOD)


### FIXED CODE ###

# Problem D - Xor Sum 4

# input
N = int(input())
a_nums = list(map(int, input().split()))

# initialization
ans = 0
MOD = 10**9 + 7

# count
two_factor = 1
for i in range(60):
    tmp_count = 0
    one_count = 0
    zero_count = 0
    for j in range(N):
        if (a_nums[j]>>i)&1==1:
            one_count += 1
        else:
            zero_count += 1
    tmp_count = (one_count * zero_count)%MOD
    ans += (tmp_count * two_factor)%MOD
    two_factor = (two_factor * 2)%MOD

# output
print(ans%MOD)