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

s=input()
table=[1]+[0 for _ in range(3)] 
abc='ABC'
mod=10**9+7
for i in range(len(s)):
    if s[i]=='?':
        for j in range(3,0,-1):
            table[j]=(3*table[j]+table[j-1])
        table[0]=3*table[0]
    else:
        for j in range(3):
            if s[i]==abc[j]:
                table[j+1]+=table[j]
#print(table)
print(table[3]%mod)


### FIXED CODE ###

s=input()
table=[[0 for _ in range(4)] for _ in range(len(s)+1)]
table[0][0]=1
abc='ABC'
for i in range(len(s)):
    for j in range(4):
        if s[i]=='?' and j!=0:
            table[i+1][j]=(3*table[i][j]+table[i][j-1])%(10**9+7)
        elif s[i]=='?':
            table[i+1][0]=3*table[i][0]%(10**9+7)
        elif s[i]==abc[j-1] and j!=0:
            table[i+1][j]=(table[i][j]+table[i][j-1])%(10**9+7)
        else:
            table[i+1][j]=table[i][j]%(10**9+7)
#print(table)
print(table[i+1][j]%(10**9+7))
### BUGGY CODE ###

from fractions import gcd
from functools import reduce

mod = 10 ** 9 + 7

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

# print('input >>')
N = int(input())
A = list(map(int,(input().split())))

lcmn = lcm(A)

ans = 0
for i in range(len(A)):
    ans += (lcmn // A[i])
    if i % 5 == 0:
        ans %= mod

# print('-----output-----')
print(int(ans%mod))

### FIXED CODE ###

from fractions import gcd
from functools import reduce

mod = 10 ** 9 + 7

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

# print('input >>')
N = int(input())
A = list(map(int,(input().split())))

lcmn = lcm(A)

ans = 0
for i in range(len(A)):
    ans += lcmn // A[i]

# print('-----output-----')
print(int(ans%mod))
### BUGGY CODE ###

N, Ma, Mb = map(int, input().split())
items = []
for i in range(N):
    a, b, c = map(int, input().split())
    items.append((a, b, c))

inf = float("inf")
dp = [[[inf for _ in range(411)] for _ in range(411)] for i in range(N+1)]
dp[0][0][0] = 0

for i in range(N):
    for a in range(401):
        for b in range(401):
            dp[i + 1][a][b] = min(dp[i + 1][a][b], dp[i][a][b])
            dp[i + 1][a + items[i][0]][b + items[i][1]] = min(dp[i + 1][a + items[i][0]][b + items[i][1]],
                                                              dp[i][a][b] + items[i][2])
ans = inf
for a in range(1, 401):
    for b in range(1, 401):
        if a * Mb == b * Ma:
            ans = min(ans, dp[N][a][b])
if ans != inf:
    print(ans)
else:
    print(-1)

### FIXED CODE ###

N, Ma, Mb = map(int, input().split())
items = []
for i in range(N):
    a, b, c = map(int, input().split())
    items.append((a, b, c))

a_sum = sum([item[0] for item in items])
b_sum = sum([item[1] for item in items])
inf = float("inf")
dp = [[[inf for _ in range(a_sum + 100)] for _ in range(b_sum + 100)] for i in range(N+1)]
dp[0][0][0] = 0

for i in range(N):
    for a in range(a_sum + 1):
        for b in range(b_sum + 1):
            dp[i + 1][a][b] = min(dp[i + 1][a][b], dp[i][a][b])
            dp[i + 1][a + items[i][0]][b + items[i][1]] = min(dp[i + 1][a + items[i][0]][b + items[i][1]],
                                                              dp[i][a][b] + items[i][2])
ans = inf
for a in range(1, a_sum + 1):
    for b in range(1, b_sum + 1):
        if a * Mb == b * Ma:
            ans = min(ans, dp[N][a][b])
if ans != inf:
    print(ans)
else:
    print(-1)
### BUGGY CODE ###

import math

A, B, N = map(int, input().split())
result = []
cnt = 0

for _ in range(N):
  cnt += 1
  result.append(math.floor(A*cnt/B)-A*math.floor(cnt/B))
  
print(max(result))

### FIXED CODE ###

A, B, N = map(int, input().split())
cnt = min(B-1, N)
result = int(A*cnt/B)-A*int(cnt/B)
  
print(result)
### BUGGY CODE ###

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

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

ans = [str(i+1) for i in range(N)]

for i in range(M):
    a, b = map(int, input().split())
    if H[a-1] > H[b-1]:
        try:
            ans.remove(str(b))
        except Exception as e:
            continue
    elif H[b-1] > H[a-1]:
        try:
            ans.remove(str(a))
        except Exception as e:
            continue
    else:
        try:
            ans.remove(str(a))
            try:
                ans.remove(str(b))
            except Exception as e:
                continue
        except Exception as e:
            try:
                ans.remove(str(b))
            except Exception as e:
                continue

print(len(ans))

### FIXED CODE ###

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

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

ans = {}

for _ in range(M):
    a, b = map(int, input().split())
    if H[a-1] > H[b-1]:
        ans[str(b)] = 1
    elif H[b-1] > H[a-1]:
        ans[str(a)] = 1
    else:
        ans[str(a)] = 1
        ans[str(b)] = 1

print(N - len(ans))
### BUGGY CODE ###

from sys import stdin

import time
import numpy as np
import math


############################################

# read data for n sequences.
temp = stdin.readline().split()
N = int(temp[0])+1

out = 0
for i in range(1,N):
    for j in range(1,N):
        for k in range(1,N):
            part = math.gcd(j,k)
            out += math.gcd(part,i)
print(out)

### FIXED CODE ###

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

from sys import stdin

import time
import numpy as np
import math

############################################

# read data for n sequences.
temp = stdin.readline().split()
N = int(temp[0])+1

out = 0
for i in range(1,N):
    for j in range(1,N):
        part = np.gcd(j,i)
        #for k in range(1,N):       
        out += np.sum(np.gcd(part,np.arange(1,N)))
print(out)
### BUGGY CODE ###

import sys

K = int(input())
A = [int(x) for x in input().split()]

if A[-1] != 2:
    print(-1)
    sys.exit()

r = set([2, 3])

for i in range(len(A) - 2, -1, -1):
    m = A[i]
    nr = set([])
    for x in r:
        if x % m == 0:
            nr |= set(range(x, x + m))
    r = nr
    if len(r) == 0:
        print(-1)
        sys.exit()

print(min(r), max(r))



### FIXED CODE ###

import sys

K = int(input())
A = [int(x) for x in input().split()]

if A[-1] != 2:
    print(-1)
    sys.exit()

minn = 2
maxn = 3

for i in range(len(A) - 2, -1, -1):
    m = A[i]
    a = (minn + m - 1) // m * m
    b = maxn // m * m
    if b < a:
        print(-1)
        sys.exit()
    minn = a
    maxn = b + m - 1

print(minn, maxn)
### BUGGY CODE ###

A,V=map(int,input().split())
B,W=map(int,input().split())
K=int(input())
Apos=A
Bpos=B
count=0
rev=False
if B>A:
    pass
else:
    rev=True

if rev==False:

    while K>count:
        
        Apos=Apos+V
        Bpos=Bpos+W
        if Apos>=Bpos:
            print("YES")
            exit()
        count+=1
        

else:
    while K>count:
        
        Apos=Apos-V
        Bpos=Bpos-W
        if Apos<=Bpos:
            print("YES")
            exit()
        count+=1

print("NO")

### FIXED CODE ###

A,V=map(int,input().split())
B,W=map(int,input().split())
K=int(input())
Apos=A
Bpos=B
count=0
rev=False
if B>A:
    pass
else:
    rev=True

if rev==False:

    
        
    A=A+V*K
    B=B+W*K
    if A>=B:
        print("YES")
        exit()
    
        

else:
    A=A-V*K
    B=B-W*K
    if A<=B:
        print("YES")
        exit()

print("NO")
### BUGGY CODE ###

import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N = INT()
    A = LIST()

    if N == 2:
        print(abs(A[1] - A[0]))
        sys.exit()

    ans = INF
    for i in range(N-2):
        ans = min(ans, abs(sum(A[:i+1]) - sum(A[i+1:])))

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul, add
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N = INT()
    A = LIST()

    if N == 2:
        print(abs(A[1] - A[0]))
        sys.exit()

    t = list(accumulate(A, add))
    r = list(accumulate(reversed(A), add))

    ans = INF
    for i in range(N-2):
        ans = min(ans, abs(t[i] - r[-2-i]))

    print(ans)


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

n,m = map(int,input().split())
First = []
Second = []
for i in range(m):
    ab = [int(j) for j in input().split()]
    if ab[0] == 1:
        First.append(ab)
    if ab[1] == n:
        Second.append(ab)
if any (i[1]==j[0] for i in First for j in Second):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


### FIXED CODE ###

n,m = map(int,input().split())
route = [0]*(n+10)
for i in range(m):
    a,b = map(int,input().split())
    if a == 1:
        route[b] += 1
    if b == n:
        route[a] += 1
if 2 in route:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
ctr = 0
for i in range (N):
  ck = 0
  for j in range (i, N):
    ck += A[j]
    if ck == 0:
      ctr += 1
print(ctr)

### FIXED CODE ###

from collections import Counter
N = int(input())
A = list(map(int, input().split()))
for i in range (1, N):
  A[i] += A[i-1]
A = Counter(A)
k = 0
for j in A.values():
  k += j*(j-1)//2
k += A.get(0,0)
print(k)
### BUGGY CODE ###

import itertools
N, M, R = map(int, input().split())
rs = list(itertools.permutations(list(map(lambda x: int(x) - 1, input().split()))))
dist = [[10**9 for _ in range(N)] for _ in range(N)]
for _ in range(M):
    v1, v2, d = map(int, input().split())
    dist[v1-1][v2-1] = dist[v2-1][v1-1] = d
for i in range(N):
    dist[i][i] = 0
for k in range(N):
    for i in range(N):
        for j in range(N):
            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
ans = 10**9
for r in rs:
    t = 0
    for i in range(R-1):
        t += dist[r[i]][r[i+1]]
    ans = min(t, ans)
print(ans)

### FIXED CODE ###

from itertools import permutations
N, M, R = map(int, input().split())
rs = map(lambda x: int(x) - 1, input().split())
dist = [[10**9 for _ in range(N)] for _ in range(N)]
for _ in range(M):
    v1, v2, d = map(int, input().split())
    dist[v1-1][v2-1] = dist[v2-1][v1-1] = d
for i in range(N):
    dist[i][i] = 0
for k in range(N):
    for i in range(N):
        for j in range(N):
            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
ans = 10**9
for r in permutations(rs):
    t = 0
    for i in range(R-1):
        t += dist[r[i]][r[i+1]]
        if t > 10**9:
            break
    ans = min(t, ans)
print(ans)
### BUGGY CODE ###

import itertools
import math
N = int(input())

n_max = int(math.sqrt(N))
l = [i for i in range(1, n_max)]
cand = []
score = []
for c in itertools.combinations_with_replacement(l, 3):
  cand.append(c[0]**2 + c[1]**2 + c[2]**2 + c[0]*c[1] + c[0]*c[2] + c[1]*c[2])
  if len(set(c)) == 3:
    score.append(6)
  elif len(set(c)) == 2:
    score.append(3)
  else:
    score.append(1)

for n in range(1, N+1):
  ans = 0
  if n in cand:
    ans += score[cand.index(n)]
  print(ans)

### FIXED CODE ###

import itertools
import math
import numpy as np

N = int(input())

n_max = int(math.sqrt(N))
l = [i for i in range(1, n_max)]
score = np.zeros([10000]).astype(np.uint8)
for c in itertools.combinations_with_replacement(l, 3):
  sum = c[0]**2 + c[1]**2 + c[2]**2 + c[0]*c[1] + c[0]*c[2] + c[1]*c[2]
  if sum <= 10000:
    if len(set(c)) == 3:
      score[sum-1] += 6
    elif len(set(c)) == 2:
      score[sum-1] += 3
    else:
      score[sum-1] += 1
    
for n in range(1, N+1):
  ans = 0
  print(score[n-1])
### BUGGY CODE ###

n = int(input())


ans = 0
for i in range(n):
    for j in range(n):
        if str(i+1)[0] == str(j+1)[-1] and str(i+1)[-1] == str(j+1)[0]:
            ans += 1

print(ans)

### FIXED CODE ###

n = int(input())

array = [0] * 100

for i in range(1,n+1):
    array[int(str(i)[0])*10+int(str(i)[-1])] += 1


ans = 0
for i in range(1,10):
    for j in range(1,10):
        ans += array[i*10+j] * array[j*10+i]

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


class Job(object):
    def __init__(self, day, reward):
        self.day = day
        self.reward = reward
        self.is_used = False


class MyJobs(object):
    def __init__(self, num_elements_in_array):
        self.heap = [[] for _ in range(100000)]

    def append(self, priority, value):
        self.heap[priority].append(value)

    def get_best(self, priority):
        day = -1
        reward = -1
        for i in range(priority + 1):
            for j in range(len(self.heap[i])):
                if self.heap[i][j].is_used:
                    continue
                cur = self.heap[i][j].reward
                if not (0 > day):
                    best = self.heap[day][reward].reward
                if (0 > day) or (cur > best):
                    day = i
                    reward = j
        if (0 > day):
            return 0
        self.heap[day][reward].is_used = True
        return self.heap[day][reward].reward


(n, m) = map(int, input().split())
jobs = MyJobs(m)
for _ in range(n):
    (a, b) = map(int, input().split())
    jobs.append(a - 1, Job(a - 1, b))

sum = 0
for i in range(m):
    sum += jobs.get_best(i)
print(sum)


### FIXED CODE ###

import heapq

(n, m) = map(int, input().split())
jobs = {}
for _ in range(n):
    (a, b) = map(int, input().split())
    if not a in jobs:
        jobs[a] = []
    jobs[a].append(-b)

heap = []
sum = 0
for i in range(1, m + 1):
    if i in jobs:
        for j in jobs[i]:
            heapq.heappush(heap, j)
    if 0 < len(heap):
        sum -= heapq.heappop(heap)
print(sum)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

N=int(input())
A=[int(input()) for i in range(N)]
SUM=sum(A)
MAX=(SUM-1)//2

mod=998244353
from collections import Counter

DPLIST=[[0]*301 for i in range(MAX+2)]
DPLIST[0][0]=1
ANS=0

for a in A:
    for i in range(299,-1,-1):
        for j in range(MAX+1,-1,-1):
            DPLIST[min(j+a,MAX+1)][i+1]+=DPLIST[j][i]

ANS=(pow(3,N,mod)-3*pow(2,N,mod))%mod
MINUS=0

for i in range(N-1):
    MINUS+=3*(pow(2,(N-i),mod)-2)*DPLIST[MAX+1][i]

print((ANS-MINUS+3)%mod)

### FIXED CODE ###

import sys
input = sys.stdin.readline

N=int(input())
A=[int(input()) for i in range(N)]
SUM=sum(A)
MAX=(SUM-1)//2

mod=998244353

DPLIST=[0]*(MAX+2)
DPLIST[0]=1

for a in A:
    for i in range(MAX+1,-1,-1):
        if i==MAX+1:
            DPLIST[i]=DPLIST[i]*3%mod
        else:
            DPLIST[min(i+a,MAX+1)]=(DPLIST[min(i+a,MAX+1)]+DPLIST[i])%mod
            DPLIST[i]=DPLIST[i]*2%mod

if SUM%2==1:
    print((sum(DPLIST)-DPLIST[-1]*3)%mod)
    sys.exit()

MAX=SUM//2
       
DPLIST2=[0]*(MAX+2)
DPLIST2[0]=1

for a in A:
    for i in range(MAX+1,-1,-1):
        DPLIST2[min(i+a,MAX+1)]=(DPLIST2[min(i+a,MAX+1)]+DPLIST2[i])%mod

        
print((sum(DPLIST)-DPLIST[-1]*3+DPLIST2[-2]*3)%mod)
### BUGGY CODE ###

import numpy as np
K=int(input())
result=0
for a in range(1,K+1):
    for b in range(a+1,K+1):
        for c in range(b+1,K+1):
            result+=np.gcd.reduce([a,b,c])*6
    b=a
    for c in range(1,K+1):
        result+=np.gcd.reduce([a,b,c])*3
    result-=a*2
print(result)

### FIXED CODE ###

from math import gcd
K=int(input())
result=0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            result+=gcd(gcd(a,b),c)
print(result)
### BUGGY CODE ###

import functools
import math

a,b = input().split()


def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

a = divisor(int(a))
b = divisor(int(b))
ans_list = list(set(a) & set(b))

# print(ans_list)
an = 0

for i in range(len(ans_list)):
    hantei = []
    hantei = divisor(ans_list[i])
#     print(hantei)
    if len(hantei) == 2 or len(hantei) == 1:
#         print("1")
        an += 1
print(an)

### FIXED CODE ###

import functools
import math

a,b = input().split()


def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

a = divisor(int(a))
b = divisor(int(b))
ans_list = list(set(a) & set(b))

# print(ans_list)
an = 1

for i in range(len(ans_list)):
    if is_prime(ans_list[i]):
#         print(ans_list[i])
        an += 1

print(an)
### BUGGY CODE ###

def ev(d0, d1, d2, d3):
    if d0 == n:
        return 0
    tp = (d1, d2, d3)
    if tp in memo:
        return memo[tp]
    re = [1]
    if d1 > 0:
        re += [ev(d0 + 1, d1 - 1, d2, d3) * d1 / n]
    if d2 > 0:
        re += [ev(d0, d1 + 1, d2 - 1, d3) * d2 / n]
    if d3 > 0:
        re += [ev(d0, d1, d2 + 1, d3 - 1) * d3 / n]
    re = sum(re) * n / (n - d0)
    memo[tp] = re
    return re


memo = {}
n = int(input())
a = list(map(int, input().split()))
ds = [0, 0, 0, 0]
for i in range(1, 4):
    ic = a.count(i)
    ds[i] = ic
print(ev(0, ds[1], ds[2], ds[3]))


### FIXED CODE ###

import sys
from collections import Counter

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    n = int(input())
    aa = list(map(int, input().split()))
    cnt_aa = Counter(aa)
    nc3 = cnt_aa[3]
    nc2 = cnt_aa[2]
    nc1 = cnt_aa[1]
    dp = [[[0] * (n + 1) for _ in range(nc3 + nc2 + 1)] for _ in range(nc3 + 1)]
    for c3 in range(nc3 + 1):
        for c2 in range(nc2 + nc3 - c3 + 1):
            if c3 + c2 > n: break
            for c1 in range(n + 1):
                s = c1 + c2 + c3
                if s > n: break
                if c1 > 0: dp[c3][c2][c1] += (dp[c3][c2][c1 - 1] + n / s) * c1 / s
                if c2 > 0: dp[c3][c2][c1] += (dp[c3][c2 - 1][c1 + 1] + n / s) * c2 / s
                if c3 > 0: dp[c3][c2][c1] += (dp[c3 - 1][c2 + 1][c1] + n / s) * c3 / s
    print(dp[nc3][nc2][nc1])

main()
### BUGGY CODE ###

n = int(input())

w = {}
ans = []
m_cnt = 0
for _ in range(n):
    s = input()
    w[s] = w.get(s, 0) + 1
    if w[s] > m_cnt:
        m_cnt = w[s]
        ans = [s,]
    elif s not in ans and w[s] == m_cnt:
        ans.append(s)

for i in sorted(ans):
    print(i)


### FIXED CODE ###

n = int(input())
s = list(input() for _ in range(n))
s.sort()
now = s[0]
ans = [s[0],]
cnt = 0
m_cnt = 0

for i in range(n):
    word = s[i]
    if word == now:
        cnt +=1
        if cnt > m_cnt:
            ans = [word,]
            m_cnt = cnt
        elif cnt == m_cnt:
            ans.append(word)
    else:
        cnt = 1
        now = word
        if cnt > m_cnt:
            ans = [word,]
            m_cnt = cnt
        elif cnt == m_cnt:
            ans.append(word)

for k in sorted(ans):
    print(k)
### BUGGY CODE ###

S = input()
li = []
is_A = False
now_state = 0
for ind,s in enumerate(S):
    if(is_A):
        if(now_state==1):
            now_state = 0
            continue
        else:
            if(s=='A'):
                li[-1] += 'A'
            elif(S[ind:ind+2]=='BC'):
                li[-1] += 'B'
                now_state = 1
            else:
                is_A = False
    elif(s=='A'):
        is_A = True
        now_state = 0
        li.append('A')
cnt = 0
for i in li:
    for ind,s in enumerate(i):
        if(s=='A'):
            cnt += i[ind+1:].count('B')

print(cnt)


### FIXED CODE ###

def main():
    S = input()
    li = []
    li_append = li.append
    is_A = False
    now_state = 0
    for ind,s in enumerate(S):
        if(is_A):
            if(now_state==1):
                now_state = 0
                continue
            else:
                if(s=='A'):
                    li[-1].append(0)
                elif(S[ind:ind+2]=='BC'):
                    li[-1][-1] += 1
                    now_state = 1
                else:
                    is_A = False
        elif(s=='A'):
            is_A = True
            now_state = 0
            li_append([0])
    cnt = 0
    for i in li:
        cnt_b = sum(i)
        for j in i:
            cnt += cnt_b
            cnt_b -= j
            
    print(cnt)

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

A,B,C,N=map(int, input().split())
count=0
for x in range(N+1):
    for y in range(N-x*A+1):
        for z in range(N-y*B-x*A+1):
            if N==x*A+y*B+z*C:
                count+=1
                
print(count)

### FIXED CODE ###

A,B,C,N=map(int, input().split())
count=0
for x in range(N+1):
  for y in range(N-x*A+1):
    b=(N-x*A-y*B)
    if b>=0 and b%C==0:
      count+=1
                
print(count)
### BUGGY CODE ###

s = input()
leng = len(s)


while ('01' in s) or ('10' in s):
    s = s.replace('10','')
    s = s.replace('01','')

print(leng-len(s))


### FIXED CODE ###

s = input()
leng = len(s)
zero = s.count('0')
one = s.count('1')
print(2*min(zero, one))
### BUGGY CODE ###

N, K = map(int, input().split())
A_list = list(map(int, input().split()))

place = [0]

while True:
    next_place = A_list[place[-1]] - 1
    if next_place in place:
        idx = place.index(next_place)
        loop = place[idx:]
        break
    place.append(next_place)

if K < len(place):
    print(place[K] + 1)
else:
    print(loop[(K-idx)%len(loop)] + 1)

### FIXED CODE ###

N, K = map(int, input().split())
A_list = list(map(int, input().split()))

place = [0]
table = [0] * N
table[0] = 1

while True:
    next_place = A_list[place[-1]] - 1
    if table[next_place] == 1:
        idx = place.index(next_place)
        loop = place[idx:]
        break
    table[next_place] = 1
    place.append(next_place)

if K < len(place):
    print(place[K] + 1)
else:
    print(loop[(K-idx)%len(loop)] + 1)
### BUGGY CODE ###

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

answerList = []

for i in range(N[0]):
    answerList.append(0)

for i in range(N[0]):
    for j in range(N[0]):
        if j + 1 > i > 0:
            calculateList = [abs(j + 1 - i),
                             abs(N[1] - i) + 1 + abs(j + 1 - N[2]),
                             abs(N[2] - i) + 1 + abs(j + 1 - N[1])]
            answerList[min(calculateList)] = answerList[min(calculateList)] + 1

for i in range(N[0] - 1):
    print(answerList[i+1])


### FIXED CODE ###

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

answerList = []

for i in range(N[0]):
    answerList.append(0)

for i in range(N[0]):
    if i > 0:
        for j in range(N[0]):
            if j + 1 > i > 0:
                calculateList = [abs(j + 1 - i),
                                 abs(N[1] - i) + 1 + abs(j + 1 - N[2]),
                                 abs(N[2] - i) + 1 + abs(j + 1 - N[1])]
                answer = min(calculateList)
                answerList[answer] = answerList[answer] + 1

for i in range(N[0] - 1):
    print(answerList[i + 1])