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

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

k, s = map(int, input().split())

ans = 0

if s == 3*k:
    ans = 1
elif s > 3*k:
    ans = 0
elif  s < k:
    k = s
    for i in range(k+1):
        for j in range(k+1):
            for k in range(k+1):
                if i + j + k == s:
                    ans += 1
else:
    k = s
    for i in range(k+1):
        for j in range(k+1):
            for k in range(k+1):
                if i + j + k == s:
                    ans += 1

print(ans)


            

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Mon Aug  3 13:34:09 2020

@author: ito
"""


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

k, s = map(int, input().split())

ans = 0

for x in range(k+1):
    for y in range(k+1):
        
        sat_z = s - x - y
        
        if sat_z >= 0 and sat_z <= k:
            ans += 1
            
print(ans)
### BUGGY CODE ###

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

for i in range(1,N+1):
  print(np.count_nonzero(A == i))

### FIXED CODE ###

N = int(input())
A = map(int, input().split())
subs = [0] * N

for boss in A:
  subs[boss-1] += 1

for i in range(N):
  print(subs[i])
### BUGGY CODE ###

import sys
input = sys.stdin.readline

N,M = map(int,input().split())
S1 = [[]for i in range(N)]
for i in range(M):
    u,v = map(int,input().split())
    S1[u-1].append(v-1)
St,T = map(int,input().split())
S = [[]for i in range(N)]
for i in range(N):
    for k in S1[i]:
        for ken in S1[k]:
            for pa in S1[ken]:
                S[i].append(pa)
D = [float('inf')]*N
D[St-1] = 0
queue = [St-1]
hoge = [0]*N
while queue != []:
    l =0
    for q in queue:
        for i in S[q]:
            if D[i] > D[q]:
                D[i] = D[q]+1
                if not i in hoge[:l]:
                    hoge[l] = i
                    l += 1
    queue = hoge[:l]
if D[T-1] == float('inf'):
    print(-1)
else:
    print(D[T-1])

### FIXED CODE ###

import sys
input = sys.stdin.readline

N,M = map(int,input().split())
S = [[]for i in range(N)]
for i in range(M):
    u,v = map(int,input().split())
    S[u-1].append(v-1)
St,T = map(int,input().split())

D = [[float('inf')]*3 for i in range(N)]
D[St-1][0] = 0
queue = [St-1]
i = 0
while queue != []:
    i += 1
    hoge = []
    for q in queue:
        for s in S[q]:
            if D[s][i%3] > i:
                D[s][i%3] = i
                if not s in hoge:
                    hoge.append(s)
    queue = hoge[:]
    if D[T-1][0] != float('inf'):
        break
if D[T-1][0] == float('inf'):
    print(-1)
else:
    print(D[T-1][0]//3)
### BUGGY CODE ###

input_arr = [int(x) for x in input().split()]
 
L = input_arr[0]
R = input_arr[1]
 
min_ans = 10**18
for i in range(L,R):
    for j in range(i+1,R+1):
        ans = (i*j)%2019
        if ans < min_ans:
            min_ans = ans
print(min_ans)


### FIXED CODE ###

L,R = [int(x) for x in input().split()]
 
min_ans = 10**18

if R-L>=2019:
  min_ans=0
else:
  for i in range(L,R):
      for j in range(i+1,R+1):
          ans = (i*j)%2019

          if ans < min_ans:
              min_ans = ans
          if min_ans == 0:
              break
print(min_ans)
### BUGGY CODE ###

N,M = map(int, input().split())
A = list(map(int, input().split()))
for i in range(M):
    max_A = max(A)
    num_A= A.index(max_A)
    A[num_A] = max_A // 2

print(sum(A))



### FIXED CODE ###

import heapq as hq
N,M = map(int, input().split())
A =[-x for x in map(int, input().split())]

hq.heapify(A)
for i in range(M):
    m = A[0]
    hq.heappushpop(A, -((-m)//2))
print(-sum(A))
### BUGGY CODE ###

#!/usr/bin/env python3
N = int(input())
X = input()

x_num = int(X, 2)
cnt1 = X.count('1')


def f(cnt):
    if (cnt > 0):
        pcount = p_count(cnt)
        return f(cnt % pcount) + 1
    else:
        return 0


def p_count(x):
    cnt = 0
    while (x > 0):
        if x % 2 != 0:
            cnt += 1
        x //= 2
    return cnt


def f1(x):
    cnt = 0
    while (x > 0):
        x %= bin(x).count('1')
        cnt += 1
    return cnt


for i, x in enumerate(X):
    if (x == '1'):
        #x_num = int(''.join(X), 2)
        if (x_num - (2**(N-(i+1)))) != 0:
            print(f1((x_num - (2 ** (N - (i + 1)))) % (cnt1 - 1)) + 1)
        else:
            print(0)
    else:
        #x_num = int(''.join(X), 2)
        if (x_num + (2**(N-(i+1)))) != 0:
            print(f1((x_num + (2 ** (N - (i + 1)))) % (cnt1 + 1)) + 1)
        else:
            print(0)

### FIXED CODE ###

#!/usr/bin/env python3
N = int(input())
X = input()

x_num = int(X, 2)
cnt1 = X.count('1')

p_zero = x_num % (cnt1 + 1)
p_one = (x_num % (cnt1 - 1) if cnt1 - 1 > 0 else 1)


def f(cnt):
    if (cnt > 0):
        pcount = p_count(cnt)
        return f(cnt % pcount) + 1
    else:
        return 0


def p_count(x):
    cnt = 0
    while (x > 0):
        if x % 2 != 0:
            cnt += 1
        x //= 2
    return cnt


def f1(x):
    cnt = 0
    while (x > 0):
        x %= bin(x).count('1')
        cnt += 1
    return cnt


for i, x in enumerate(list(X)):
    if (x == '1'):
        #x_num = int(''.join(X), 2)
        if cnt1 - 1 > 0:
            xxx = (p_one - pow(2, (N - (i + 1)), cnt1 - 1)) % (cnt1 - 1)
            xxx += cnt1 - 1 if xxx < 0 else 0
            print(f1(xxx) + 1)
        else:
            print(0)
    else:
        #x_num = int(''.join(X), 2)
        xxx = (p_zero + pow(2, (N - (i + 1)), cnt1 + 1)) % (cnt1 + 1)
        xxx += cnt1 + 1 if xxx < 0 else 0
        print(f1(xxx) + 1)
### BUGGY CODE ###

import sys

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

ans = 1
for val in a:
    ans *= val

if ans > 1000000000000000000:
    print("-1")
else:
    print(ans)


### FIXED CODE ###

import sys

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

for val in a:
    if val == 0:
        print("0")
        exit(0)

ans = 1
for val in a:
    ans *= val
    if ans > 1000000000000000000:
        print("-1")
        exit(0)

print(ans)
### BUGGY CODE ###

n = int(input())
h = list(map(int,input().split()))
submax = 0

for i in range(n-1):
  for j in range(i+1,n):
    if h[i] - h[j] >= 2:
      submax = 1
      break
  if submax == 1:
    break

if submax == 1:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

n = int(input())
h = list(map(int,input().split()))
d = [1]+[0]*(n-1)

for i in range(n-1):
  if h[i] >= 2+ h[i+1]:
    print('No')
    exit()
  if d[i] == 1 and h[i] <= h[i+1]:
    d[i+1] = 1
  elif d[i] == 0:
    if h[i] +1 <=h[i+1]:
      d[i+1] = 1
    elif h[i] -1 == h[i+1]:
      print('No')
      exit()
      
print('Yes')
### BUGGY CODE ###

n,q = (int(i) for i in input().split())
s = input()
x = [tuple(i for i in input().split()) for i in range(q)]
l,r,s = 0,n+1,"#"+s+"#"
while l+1<r:
    now = (l+r)//2
    for i,j in x:
        if s[now]==i:
            if j=="L": now-=1
            else: now+=1
        if now*(now-n-1)==0: break
    if now: r = (l+r)//2
    else: l = (l+r)//2
L,l,r = l,0,n+1
while l+1<r:
    now = (l+r)//2
    for i,j in x:
        if s[now]==i:
            if j=="L": now-=1
            else: now+=1
        if now*(now-n-1)==0: break
    if now-n-1: l = (l+r)//2
    else: r = (l+r)//2
print(r-L-1)

### FIXED CODE ###

n,q = (int(i) for i in input().split())
s = input()
x = [[i for i in input().split()] for i in range(q)]
l,r,s = 0,n+1,"#"+s+"#"
for i,j in x[::-1]:
    if l<=n and s[l+1]==i and  j=="L": l+=1
    elif s[l]==i and j=="R": l-=1
    if s[r-1]==i and j=="R": r-=1
    elif s[r]==i and j=="L": r+=1
print(max(0,r-l-1))
### BUGGY CODE ###

l,r = map(int,input().split())
min = 2019
for i in range(l,r):
  for j in range(i+1,r+1):
    if min > (i*j)%2019:
      min = (i*j)%2019
print(min)


### FIXED CODE ###

L,R = map(int,input().split())
mn = 2018
if R - L >= 2018:
  print(0)
else:
  for i in range(L,R):
    for j in range(i+1,R+1):
      if (i*j)%2019 < mn:
        mn = (i*j)%2019
  print(mn)
### BUGGY CODE ###

import itertools
import math
n = int(input())
c = itertools.product(range(1, n + 1), repeat=3)
t = 0
for l in c:
    s = math.gcd(l[0], math.gcd(l[1], l[2]))
    t += s
print(t)


### FIXED CODE ###

import itertools
import math

n = int(input())
c1 = range(1, n + 1)
c2 = itertools.combinations(range(1, n + 1), 2)
c3 = itertools.combinations(range(1, n + 1), 3)

t1 = sum(list(c1))
t2 = sum(list(map(lambda x: math.gcd(x[0], x[1]), c2))) * 6
t3 = sum(list(map(lambda x: math.gcd(x[0], math.gcd(x[1], x[2])), c3))) * 6

print(sum([t1, t2, t3]))
### BUGGY CODE ###

N,P=map(int,input().split())
S=input()
ans=0
if P in (2,5):
    for i,s in enumerate(S):
        if int(s)%P==0:
            ans+=i+1
else:
    cnt=[0 for _ in range(P)]
    CS=0
    for i,s in enumerate(S[::-1]):
        CS=(CS+int(s)*(10**i))%P
        cnt[CS]+=1
        # print(CS)
        # print(cnt)
    for c in cnt:
        ans+=c*(c-1)//2
    ans+=cnt[0]
print(ans)

### FIXED CODE ###

#E
N,P=map(int,input().split())
S=input()
ans=0
if P in (2,5):
    for i,s in enumerate(S):
        if int(s)%P==0:
            ans+=i+1
else:
    cnt=[0 for _ in range(P)]
    CS=0
    PLC=1
    for s in S[::-1]:
        tmp=(int(s)*PLC)%P
        CS=(CS+tmp)%P
        cnt[CS]+=1
        PLC=(PLC*10)%P
        # print(CS)
        # print(cnt)
    for c in cnt:
        ans+=c*(c-1)//2
    ans+=cnt[0]
print(ans)
### BUGGY CODE ###

# coding: utf-8
# Your code here!

import bisect
from collections import defaultdict
import sys
sys.setrecursionlimit(int(1e6))
 
N, K = map(int, input().rstrip().split(' '))
X = sorted(list(map(int, input().rstrip().split(' '))))

i = bisect.bisect_left(X, 0)
X.insert(i, 0)

memo = defaultdict(lambda: defaultdict(lambda: -1))
 
def recursive(current_k, cost, i, left_i, right_i):
    if K == current_k:
        return cost
    if memo[current_k][i] != -1:
        return memo[current_k][i]
       
    left_cost = 1e10 
    if left_i >= 0:
        left_cost = recursive(current_k + 1, cost + X[i] - X[left_i], left_i, left_i - 1, right_i)
        
    right_cost = 1e10
    if right_i <= N:
        right_cost = recursive(current_k + 1, cost + X[right_i] - X[i], right_i, left_i, right_i + 1)
        
    min_cost = min(left_cost, right_cost)
    
    memo[current_k][i] = min_cost
    
    return min_cost
    
print(recursive(0, 0, i, i - 1, i + 1))


### FIXED CODE ###

# coding: utf-8
# Your code here!

N, K = map(int, input().rstrip().split(' '))
X = list(map(int, input().rstrip().split(' ')))

min_cost = int(1e10)
for i in range(K, N+1):
    min_cost = min(min_cost, X[i-1] - X[i-K] + min(abs(X[i-1]), abs(X[i-K])))
    
print(min_cost)
### BUGGY CODE ###

import sys
input = sys.stdin.buffer.readline
from collections import deque

def main():
    N,M = map(int,input().split())
    
    edge = [[] for _ in range(N)]
    begin = [True for _ in range(N)]
    for _ in range(M):
        x,y = map(int,input().split())
        edge[x-1].append(y-1)
        begin[y-1] = False
            
    def longest(s):
        INF = 10**10
        l = [-INF for _ in range(N)]
        l[s] = 0
        q = deque([s])
        while q:
            now = q.popleft()
            for fol in edge[now]:
                if l[fol] < l[now]+1:
                    l[fol] = l[now]+1
                    q.append(fol)
        return max(l)
    
    ans = 0
    for i,b in enumerate(begin):
        if b:
            ans = max(ans,longest(i))
            
    print(ans)
        
if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 9)

def main():
    N,M = map(int,input().split())
    
    edge = [[] for _ in range(N)]
    for _ in range(M):
        x,y = map(int,input().split())
        edge[x-1].append(y-1)
        
    dist = [-1 for _ in range(N)]
            
    def dfs(s):
        if dist[s] != -1:
            return dist[s]
        else:
            ret = 0
            for fol in edge[s]:
                ret = max(ret,dfs(fol)+1)
            dist[s] = ret
            return ret

    for i in range(N):
        dfs(i)
        
    print(max(dist))
    
if __name__ == "__main__":
    main()
### BUGGY CODE ###

from collections import defaultdict
n,p = [int(x) for x in input().split()]
s = input()
if p!=2 and p!=5:
  r = defaultdict(int)
  a = int(s)
  r[a%p]+=1
  b=pow(10,n-1)
  for i in range(n):
    a = a-int(s[i])*b
    r[a%p]+=1
    b=b//10
  #print(r)
  ans = 0
  cnt=1
  for i in r.values():
    ans+=i*(i-1)//2
  print(ans)
elif p==2:
  ans = 0
  for i in range(n):
    if int(s[i])%2==0:
      ans +=i+1
  print(ans)
elif p==5:
  ans = 0
  for i in range(n):
    if int(s[i])%5==0:
      ans +=i+1
  print(ans)

### FIXED CODE ###

from collections import defaultdict,deque
import itertools
n,p = [int(x) for x in input().split()]
s = list(input())
if p!=2 and p!=5:
  r = defaultdict(int)
  a =[]
  s1 = s[::-1]
  for i in range(n):
    a.append((int(s1[i])%p*pow(10,i,p))%p)
  a = [0]+a[::-1]
  b = list(itertools.accumulate(a))
  for i in b:
    r[i%p]+=1
  ans = 0
  for i in r.values():
    ans+=(i*(i-1))//2
  print(ans)
elif p==2:
  ans = 0
  for i in range(n):
    if int(s[i])%2==0:
      ans +=i+1
  print(ans)
elif p==5:
  ans = 0
  for i in range(n):
    if int(s[i])%5==0:
      ans +=i+1
  print(ans)
### BUGGY CODE ###

n,k = map(int,input().split())
ans = 0
for i in range(n):
    if i < k:
      c = i
      d=0
      while c<k:
        c = c*2
        d+=1
      ans -=float((2**d-1)/(n*(2**d)))
print(ans)

### FIXED CODE ###

n,k = map(int,input().split())
ans = 1
for i in range(1,n+1):
    if i < k:
      c = i
      d=0
      while c<k:
        c = c*2
        d+=1
      ans -=float((2**d-1)/(n*(2**d)))
print(ans)
### BUGGY CODE ###

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
    
K = int(input())
cnt = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            cnt += gcd(i,j,k)
            
print(cnt)

### FIXED CODE ###

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
    
K = int(input())
cnt = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            cnt += gcd(i,j,k)
            
print(cnt)
### BUGGY CODE ###

n,m=map(int,input().split())
a=[0]*n
for i in range(m):
  l,r=map(int,input().split())
  for k in range(l-1,r):
    a[k]+=1
ans=0
for i in range(n):
  if a[i]==m:
    ans+=1
print(ans)

### FIXED CODE ###

n,m=map(int,input().split())
low=1
high=n
for i in range(m):
  l,r=map(int,input().split())
  if l>low:
    low=l
  if r<high:
    high=r
if high>=low:
  print(high-low+1)
else:
  print(0)
### BUGGY CODE ###

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

ans = 1

for i in range(N):
    ans *= A[i]

if ans > 10 ** 18:
    ans = -1

print(ans)


### FIXED CODE ###

import sys

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

ans = 1

if 0 in A:
    print(0)
    sys.exit()

for i in range(N):
    ans *= A[i]
    if ans > 10 ** 18:
        ans = -1
        break

print(ans)
### BUGGY CODE ###

import numpy as np

n = int(input())

a = np.array(list(map(int, input().split())))
d = {}
s = {}

for i in set(a):
  d[i] = len(a[a==i])
  
sum = 0
for k in d.values():
  if k>1:
    sum += (k*(k-1))//2

for i in range(n):
  nd = d[a[i]]
  ans = sum-(nd*(nd-1))//2
  nd -= 1
  if nd>1:
    ans += (nd*(nd-1))//2
  print(ans)


### FIXED CODE ###

import numpy as np

n = int(input())

a = np.array(list(map(int, input().split())))
d = [0] * (n+1)
s = {}

for i in a:
  d[i] += 1
  
sum = 0
for k in d:
  if k>1:
    sum += (k*(k-1))//2

for i in range(n):
  ans=sum-d[a[i]]+1
  print(ans)
### BUGGY CODE ###

N = int(input())
li = [input() for x in range(N)]
ans = 0
for i in range(N):
    word = list(li[i])
    for j in range(i+1, N):
        comp = list(li[j])
        if sorted(word) == sorted(comp):
            ans += 1
print(ans)

### FIXED CODE ###

import collections
N = int(input())
li = [input() for x in range(N)]
ans = 0
di = dict()
for k in li:
    word = ''.join(sorted(list(k)))
    if word in di.keys():
        ans += di[word]
        di[word] += 1
    else:
        di[word] = 1
print(ans)
### BUGGY CODE ###

n = int(input())
lis = list(map(int, input().split()))
res = 1
for i in lis:
    res *= i
print(res if res <= 10**18 else -1)


### FIXED CODE ###

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

if 0 in lis:
    print(0)
    exit()

res = 1
for i in lis:
    if res > 10**18:
        print(-1)
        exit()
    else:
        res *= i
print(res if res <= 10**18 else -1)
### BUGGY CODE ###

'''
pythonの再帰は10^5timesですら厳しい
import sys
sys.setrecursionlimit(10000000)

def dfs(v,p,G,c):
    for u in G[v]:
        if u!=p:
            c[u]+=c[v]
            dfs(u,v,G,c) 
'''
from collections import deque

N,Q = list(map(int,input().split()))

G=[]
for i in range(N):
    G.append([])
for i in range(N-1):
    a,b = list(map(int,input().split()))
    a-=1
    b-=1
    G[a].append(b)
    G[b].append(a)

p=[0]*Q
x=[0]*Q
for i in range(Q):
    p[i],x[i] = list(map(int,input().split()))
    p[i]-=1
    
c=[0]*N
for i in range(Q):
    c[p[i]] += x[i]

stack=deque([0])
p = [-1]*N
a
while(stack):
    v = stack.pop()
    for u in G[v]:
        if u!=p[v]:
            c[u]+=c[v]
            p[u]=v
            stack.appendleft(u)


ans = ' '.join([str(x) for x in c])

print(ans)

### FIXED CODE ###

'''
pythonの再帰は10^5timesですら厳しい
import sys
sys.setrecursionlimit(10000000)

def dfs(v,p,G,c):
    for u in G[v]:
        if u!=p:
            c[u]+=c[v]
            dfs(u,v,G,c) 
'''
from collections import deque

N,Q = list(map(int,input().split()))

G=[]
for i in range(N):
    G.append([])
for i in range(N-1):
    a,b = list(map(int,input().split()))
    a-=1
    b-=1
    G[a].append(b)
    G[b].append(a)

p=[0]*Q
x=[0]*Q
c=[0]*N
for i in range(Q):
    p,x = list(map(int,input().split()))
    p-=1
    c[p] += x

stack=deque([0])
parent = [-1]*N

while(stack):
    v = stack.pop()
    for u in G[v]:
        if u!=parent[v]:
            c[u]+=c[v]
            parent[u]=v
            stack.appendleft(u)


ans = ' '.join([str(x) for x in c])

print(ans)
### BUGGY CODE ###

N, M = map(int, input().split())

L, R = map(int, input().split())
ans = set(range(L, R+1))
for _ in range(M-1):
    L, R = map(int, input().split())
    ans = ans & set(range(L, R+1))
print(len(ans))


### FIXED CODE ###

N, M = map(int, input().split())
left, right = map(int, input().split())
for _ in range(M-1):
    L, R = map(int, input().split())
    left = max(left, L)
    right = min(right, R)
print(max(right - left + 1, 0))
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
dic = {}
ans = {}
more_than_two = []

for num in A:
    if num in dic:
        dic[num] += 1
        if num not in more_than_two:
            more_than_two.append(num)
    else:
        dic[num] = 1

for num in A:
    if num in ans:
        print(ans[num])
    else:
        dic[num] -= 1
        total = 0
        for a in more_than_two:
            total += dic[a] * (dic[a]-1) / 2
        ans[num] = int(total)
        print(int(total))
        dic[num] += 1


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
dic = {}

for num in A:
    if num in dic:
        dic[num] += 1
    else:
        dic[num] = 1

total = 0
for value in dic.values():
    total += value * (value-1) / 2   # 使えないボールがない場合のtotal

for num in A:
    print(int(total - dic[num] + 1))
### BUGGY CODE ###

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    S = in_s()
    N = len(S)

    def abc_count():

        count = 0
        fa, fb = False, False
        for i in range(N):
            if S[i] == 'A':
                fa = True
            elif fa and S[i] == 'B':
                fb = True
            elif fb and S[i] == 'C':
                count += 1
                fa, fb = False, False
            else:
                fa, fb = False, False

        return count

    ans = 0
    while True:
        t = abc_count()
        if t == 0:
            break
        else:
            ans += t
            S = S.replace('ABC', 'BCA')

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def t(S):

    N = len(S)

    a = [0] * (N + 1)
    d = [0] * (N + 1)
    for i in range(N):
        if S[i] == 'A':
            a[i + 1] = 1
        else:
            d[i + 1] = 1

    for i in range(N):
        a[i + 1] += a[i]
        d[i + 1] += d[i]

    ans = 0
    for i in range(1, N):
        if S[i] == 'D':
            ans += a[i]

    return ans


def main():

    S = in_s()
    S = S.replace('BC', 'D')
    S = S.replace('B', ' ')
    S = S.replace('C', ' ')

    ans = 0
    for ts in S.split():
        ans += t(ts)

    print(ans)


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

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

total = sum(A)

ans = float("inf")
for i in range(1, N):
    cand = abs(2*sum(A[:i]) - total)
    ans = min(ans, cand)
print(ans)

### FIXED CODE ###

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

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

ans = float("inf")
for i in range(1, N):
    cand = abs(cumsum[i] - (cumsum[-1] - cumsum[i]))
    ans = min(ans, cand)

print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)


class Node:
    def __init__(self, index):
        self.index = index
        self.leaf = set()
        self.score = 0

    def set_parent(self, parent):
        self.leaf.remove(parent)
        for l in self.leaf:
            tree[l].set_parent(self.index)

    def add_score(self, score):
        self.score += score
        for l in self.leaf:
            tree[l].add_score(score)


N, Q = map(int, input().split())
tree = {i: Node(i) for i in range(1, N + 1)}
tree[1].leaf.add(1)

for i in range(N-1):
    n1, n2 = map(int, input().split())
    tree[n1].leaf.add(n2)
    tree[n2].leaf.add(n1)

tree[1].set_parent(1)

for _ in range(Q):
    p, x = map(int, input().split())
    tree[p].add_score(x)

print(' '.join([str(t.score) for t in tree.values()]))


### FIXED CODE ###

from collections import defaultdict

N, Q = map(int, input().split())
d = defaultdict(list)

for _ in range(N - 1):
    a, b = map(int, input().split())
    d[a].append(b)
    d[b].append(a)

c = defaultdict(int)

for _ in range(Q):
    p, x = map(int, input().split())
    c[p] += x

ans = [0 for i in range(N)]
que = [(1, 0, -1)]
while len(que) > 0:
    tmp = []
    for v, x, par in que:
        x += c[v]
        ans[v - 1] = str(x)
        for w in d[v]:
            if w != par:
                tmp.append((w, x, v))
    que = tmp

print(*ans)
### BUGGY CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
num=0
ans=[0]*n
def abs_1(num1):
    return(abs(num1))
for i in range(k):
    ans=[0]*n
    for j in range(n):
        for l in range(n):
            if abs_1(j-l)<=a[l]:
                ans[j]+=1
    a=ans
    if sum(a)==n**2:
        break
print(*a)


### FIXED CODE ###

import math
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=[0]*n
num=[]
if k>41:
    ans=[n]*n
    print(*ans)
else:
    def c(num1,num2,num3):
        num[max(0,num1-num2)]+=1
        num[min(num3,num1+num2+1)]-=1
    for i in range(k):
        num=[0]*(n+1)
        for j in range(n):
            c(j,a[j],n)
        num5=0
        for j in range(n):
            num5+=num[j]
            a[j]=num5
        if sum(a)==n*n:
            break
    print(*a)