Harryxun/stf_run huggingface dataset:
N = int(input())
L = [int(i) for i in input().split()]

counter = 0

max_n = 0

for i in range(N-1):
	if L[i] <= L[i-1]:
		counter += 1
	else:
		max_m = max(max_n,counter)
		ct = 0
			
print(max(max_n,counter))

### FIXED CODE ###

S = input()
T = input()

counter = 0

for i in range(0,3):
  if S[i] == T[i]:
    counter += 1
    
print(counter)
a,b=map(int,input().split())
s=input()
f=s.index("-")
l=len(s)-s.index("-")-1
print("Yes" if a==f and b==l else "No")

### FIXED CODE ###

a,b = map(int,input().split())
s = input()
for i in range(a):
    if s[i] == '-':
        print('No')
        exit(0)
 
if s[a] != '-':
    print('No')
    exit(0)
 
for i in range(a+1,a+b):
    if s[i] == '-':
        print('No')
        exit(0)
 
print('Yes')
import math
A, B = map(int, input().split())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

gcd = math.gcd(A, B)
divisors = make_divisors(gcd)

def is_prime(n):
    if n == 1: return True

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

count = 0
for i in range(len(divisors)):
    if is_prime(divisors[i]):
        count += 1

print(count)

### FIXED CODE ###

from fractions import gcd
import math
A, B = map(int, input().split())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

gcd = gcd(A, B)
divisors = make_divisors(gcd)

def is_prime(n):
    if n == 1: return True

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

count = 0
for i in range(len(divisors)):
    if is_prime(divisors[i]):
        count += 1

print(count)
N = int(input())
    a = 0
    lst = []
    for i in range(N):
        lst.append(str(raw_input()))
    M = int(input())
    for j in range(M):
        T = str(raw_input())
        if (T in lst) == True:
            if a == 0:
                a = 1
                print "Opened by " + T
            else:
                a = 0
                print "Closed by " + T
        else:
            print "Unknown " + T

### FIXED CODE ###

N = int(input())
a = 0
lst = []
for i in range(N):
    lst.append(str(raw_input()))
M = int(input())
for j in range(M):
    T = str(raw_input())
    if (T in lst) == True:
        if a == 0:
            a = 1
            print "Opened by " + T
        else:
            a = 0
            print "Closed by " + T
    else:
        print "Unknown " + T
print(int(input())*int(input()))


### FIXED CODE ###

data = input().split()
print(int(data[0])*int(data[1]))
import math
a,b = map(int,input().split())
ans = a*b/math.gcd(a,b)
print(int(ans))

#LCM = X*Y/GCD
#LCM = 最小公倍数
#GCD = 最大公約数

### FIXED CODE ###

import fractions
a,b = map(int,input().split())
ans = a*b/fractions.gcd(a,b)
print(int(ans))

#LCM = X*Y/GCD
#LCM = 最小公倍数
#GCD = 最大公約数
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,M=map(int,input().split())
    d=defaultdict(int)
    x=2
    while M>1:
        if M%x==0:
            d[x]+=1
            M//=x
        else:
            x+=1
    def COMinit(n,MOD):
        fac,finv,inv=[0]*max(2,n+1),[0]*max(2,n+1),[0]*max(2,n+1)
        fac[0]=fac[1]=1
        finv[0]=finv[1]=1
        inv[1]=1
        for i in range(2,(n+1)):
            fac[i]=fac[i-1]*i%MOD
            inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
            finv[i]=finv[i-1]*inv[i]%MOD
        return fac,finv,inv
    
    fac,finv,inv=COMinit(N*2,MOD)
    
    def COM(n, k, MOD=MOD):
        if n<k or n<0 or k<0:
            return 0
        return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD
    
    ans=1
    for v in d.values():
        ans*=COM(N-1+v,v,MOD)
        ans%=MOD
    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
from collections import defaultdict
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,M=map(int,input().split())
    d=defaultdict(int)
    x=2
    while M>1:
        if M%x==0:
            d[x]+=1
            M//=x
        else:
            x+=1
    def COMinit(n,MOD):
        fac,finv,inv=[0]*max(2,n+1),[0]*max(2,n+1),[0]*max(2,n+1)
        fac[0]=fac[1]=1
        finv[0]=finv[1]=1
        inv[1]=1
        for i in range(2,(n+1)):
            fac[i]=fac[i-1]*i%MOD
            inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
            finv[i]=finv[i-1]*inv[i]%MOD
        return fac,finv,inv
    
    fac,finv,inv=COMinit(10**6,MOD)
    
    def COM(n, k, MOD=MOD):
        if n<k or n<0 or k<0:
            return 0
        return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD
    
    ans=1
    for v in d.values():
        ans*=COM(N-1+v,v,MOD)
        ans%=MOD
    print(ans)

if __name__ == '__main__':
    main()
S = input()
K = int(input())
if S[0] != "1":
    print(S[0])
else:
    i = 0
    count = 0
    while S[i] == "1":
        count += 1
        i += 1
    if K <= count:
        print(1)
    else:
        print(S[i])

### FIXED CODE ###

S = input()
K = int(input())


if S[0] != "1":
    print(S[0])
else:
    i = 0
    count = 0
    while i < len(S) and S[i] == "1":
        count += 1
        i += 1
    if K <= count:
        print(1)
    else:
        print(S[i])
def input():
    return sys.stdin.readline()[:-1]
a, b= input().split()
a = int(a)
b = int(b.replace(".", ""))
output = a * b // 100
print(output)

### FIXED CODE ###

a,b = map(int, input().split())
c = a * b
print(c)
N = int(input())
H = np.array([int(i) for i in input().split(' ')])
length = 0
max_length=0
for i in range(N-1):
    if H[i+1] - H[i] >= 0:
        length +=1
    else:
        max_length = length
        length = 0
print(length)
        

### FIXED CODE ###

import numpy as np
N = int(input())
H = np.array([int(i) for i in input().split(' ')])
length = 0
max_length=0
for i in range(N-1):
    if H[i+1] - H[i] <= 0:
        length +=1
    else:
        length = 0
        if max_length < length:
            max_length = length
    if max_length < length:
        max_length = length
print(max_length)
s = input()
k = int(input())

value = 5000000000000000
pos = 0

if k <= value:
     while True:
         if s[pos] != '1':
             print(s[pos])
             break
         else:
             pos += 1

else:
    tmp = 0
    pos = 0
    while True:
        if s[pos] != '1':
            if int(s[pos]) + tmp > k // value:
                print(s[pos])
                break
            else:
                pos += 1
                tmp += int(s[pos])

### FIXED CODE ###

S = input()
K = int(input())

if S[:K].count('1') == K:
    print(1)
else:
    for s in S[:K]:
        if s != '1':
            print(s)
            break
import sys
import math
def input():
    return sys.stdin.readline()[:-1]

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def trial_division(n):
    factor = []
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    if n!=1:
        factor.append(n)
    return factor

n,m=map(int,input().split())
mod=10**9+7
li=trial_division(m)
tmp=li[0]
countli=[]
count=1
for i in range(1,len(li)):
    if tmp!=li[i]:
        countli.append(count)
        count=1
    else:
        count+=1
    tmp=li[i]
countli.append(count)
ans=1
for i in range(len(countli)):
    ans*=combinations_count(countli[i]+n-1,countli[i])
print(ans)

### FIXED CODE ###

import sys
import math
def input():
    return sys.stdin.readline()[:-1]

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def trial_division(n):
    factor = []
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    if n!=1:
        factor.append(n)
    return factor

n,m=map(int,input().split())
mod=10**9+7
if m==1:
    print(1)
    quit()
li=trial_division(m)
tmp=li[0]
countli=[]
count=1
for i in range(1,len(li)):
    if tmp!=li[i]:
        countli.append(count)
        count=1
    else:
        count+=1
    tmp=li[i]
countli.append(count)
ans=1
for i in range(len(countli)):
    ans*=combinations_count(countli[i]+n-1,countli[i])
print(ans%mod)
list = map(int, input().split())
area = list[0] * list[1]
perimeter = list[0] * 2 + list[1] * 2
print(area)
print(perimeter)
# print('{0} {1}.format(area, perimeter))



### FIXED CODE ###

l = list(map(int, input().split()))
area = l[0] * l[1]
perimeter = l[0] * 2 + l[1] * 2
print('{0} {1}'.format(area, perimeter))
S = input()
import re
regex = re.compile(r"[ATGC]+")
mo = regex.findall(S)
l=[]
for item in mo:
    l.append(len(item))
print(max(l))

### FIXED CODE ###

S = input()
import re
regex = re.compile(r"[ATGC]+")
mo = regex.findall(S)
l=[]
for item in mo:
    l.append(len(item))
if l ==[]:
    print("0")
else:
    print(max(l))
#129_C
n,m=map(int,input().split())
a=[int(input()) for _ in range(m)]
mod=10**9+7
dp=[1 for i in range(n+1)]
for i in range(1,n+1):
    if i in a:
        dp[i]=0
    elif i==1:
        dp[i]=dp[i-1]
    else:
        dp[i]=(dp[i-1]+dp[i-2])%mid
        
print(dp[n]%mod)

### FIXED CODE ###

#129_C
n,m=map(int,input().split())
a={int(input()) for _ in range(m)}
mod=10**9+7
dp=[0 for i in range(n+1)]
dp[0]=1
for i in range(1,n+1):
    if i in a:
        dp[i]=0
    else:
        dp[i]=(dp[i-1]+dp[i-2])%mod
        
print(dp[n])
n = int(input())
a = list(int,input().split()))

for i in range(n):
	print(a.count(i + 1))

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
answer = [0] * n

for i in range(n - 1):
  answer[a[i] - 1] += 1
    
for i in range(n):
  print(answer[i])
N = int(input())
UVW = [list(map(int, input().split())) for _ in range(N-1)]

nbors = [[] for _ in range(N+1)]
for uvw in UVW:
    u,v,w = uvw[0], uvw[1], uvw[2]
    nbors[u].append((v, w))
    nbors[v].append((u, w))

dist = [-1] * (N+1)
dist[1] = 0
def dfs(now, nxt, w):
    if dist[nxt] >= 0:
        return
    dist[nxt] = dist[now] + w
    for nbor in nbors[nxt]:
        nxt2, w = nbor[0], nbor[1]
        dfs(nxt, nxt2, w)

for nbor in nbors[1]:
    nxt, w = nbor[0], nbor[1]
    dfs(1, nxt, w)

for i in range(1, N+1):
    if dist[i] % 2 == 0:
        print(0)
    else:
        print(1)


### FIXED CODE ###

import sys
sys.setrecursionlimit(500*500)

N = int(input())
UVW = [list(map(int, input().split())) for _ in range(N-1)]

nbors = [[] for _ in range(N+1)]
for uvw in UVW:
    u,v,w = uvw[0], uvw[1], uvw[2]
    nbors[u].append((v, w))
    nbors[v].append((u, w))

dist = [-1] * (N+1)
dist[1] = 0
def dfs(now, nxt, w):
    if dist[nxt] >= 0:
        return
    dist[nxt] = dist[now] + w
    for nbor in nbors[nxt]:
        nxt2, w = nbor[0], nbor[1]
        dfs(nxt, nxt2, w)

for nbor in nbors[1]:
    nxt, w = nbor[0], nbor[1]
    dfs(1, nxt, w)

for i in range(1, N+1):
    if dist[i] % 2 == 0:
        print(0)
    else:
        print(1)
N = int(input())
A = list(map(int,input().split()))
Adic={}
for i in range(N):
  if A[i] not in Adic:
    Adic[A[i]] = 1
  else:
    Adic[A[i]] += 1
Aset = set(A)
if 1 in Aset: #1がある場合
  if Adic[1] == 1:
    print(1)
  else:
    print(0)
  exit()
ans = 0
for j in range(N):
  Flag = True
  temp = A[j]
  i = 2
  if Adic[temp] >= 2:
    continue
  while i*i <= temp:
    #print(i,temp)
    if temp%i == 0:
      #print(i,temp//i,temp)
      if i in Aset or temp//i in Aset:
        Flag = False
        #print(i,temp//i,"X")
        break
    i += 1
  if not Flag:
    continue
  ans += 1
print(ans)

### FIXED CODE ###

A = list(map(int,input().split()))
s = sum(A)
ans = 15-s
print(ans)
from collections import Counter
import fractions

N = int(input())
s=[0]*N
S = []
mydict = {}
flag=0
for i in range(N):
    s_sorted =''.join(map(str, sorted(str(input()))))
    S.append(s_sorted)
c = Counter(S)
dic = {k: v for k, v in c.items() if v !=1}
if dic == {}:
    print(0)
else:
    ans =0
    for i in range(len(list(dic.values()))):
        ans = ans+math.factorial(list(dic.values())[i])/math.factorial(2)/math.factorial(list(dic.values())[i]-2)
    print(int(ans))

### FIXED CODE ###

n = int(input())
strings_list = [list(input()) for i in range(n)]
counter = 0
dict = {}
 
for strings in strings_list:
    strings = "".join(sorted(strings))
    if strings in dict.keys():
        counter += dict[strings]
        dict[strings] += 1
    else:
        dict[strings] = 1
print(counter)
N = int(input())
a = {}
for i in range(N):
    a[i + 1] = int(input())

for i in range(N):
    if a[i] == 2:
        print(i + 1)
        exit(0)
print(-1)

### FIXED CODE ###

N = int(input())
a = {}
for i in range(N):
    a[i + 1] = int(input())

i = 1
cnt = 0
while True:
    next_i = a[i]
    cnt += 1
    if next_i < 1:
        print(-1)
        break
    elif next_i == 2:
        print(cnt)
        break

    a[i] = 0
    i = next_i
n = int(input())
a = int(input())
b = int(input())
if n==1:
    print('Hello World')
else:
    print(a+b)

### FIXED CODE ###

n = int(input())
if n==1:
    print('Hello World')
else:
    a = int(input())
    b = int(input())
    print(a+b)
n,p=map(int,input().split())
if n==1:
    print(p)
    exit()
ans=1
for i in range(p+1):
    tmp=pow(i+1,n)
    if tmp>p:
        print(ans)
        break
    if p%tmp==0:
        ans=i+1

### FIXED CODE ###

n,p=map(int,input().split())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

lst=factorization(p)
# print(lst)
ans=1
for a,b in lst:
    if b>=n:
        ans*=pow(a,b//n)
print(ans)
import numpy as np

def solve(n, m, a, b):
    p = [-1] * (n+1)
    u = [1] * (n+1)
    def find(x):
        if p[x] == -1:
            return x
        else:
            return find(p[x])
    def size(x):
        px = find(x)
        return u[px]
    total = n * (n-1) // 2
    res = [total]
    for x, y in zip(a[::-1], b[::-1]):
        px = find(x)
        py = find(y)
        if px != py:
            n1 = size(x)
            n2 = size(y)
            p[py] = px
            u[px] = n1 + n2
            total -= n1 * n2
        res.append(total)
    return res[::-1][1:]

n, m = map(int, input().split())
a = np.zeros(m, dtype=int)
b = np.zeros(m, dtype=int)
for i in range(m):
    a[i], b[i] = map(int, input().split())
print("\n".join(map(str, solve(n, m, a, b))))




### FIXED CODE ###

import numpy as np

def solve(n, m, a, b):
    p = [-1] * (n+1)
    u = [1] * (n+1)
    def find(x):
        if p[x] == -1:
            return x
        else:
            return find(p[x])
    total = n * (n-1) // 2
    res = [total]
    for i in range(m-1, 0, -1):
        x, y = a[i], b[i]
        px = find(x)
        py = find(y)
        if px > py:
            px, py = py, px
        if px != py:
            n1 = u[px]
            n2 = u[py]
            p[py] = px
            u[px] = n1 + n2
            total -= n1 * n2
        res.append(total)
    return res[::-1]

n, m = map(int, input().split())
a = np.zeros(m, dtype=int)
b = np.zeros(m, dtype=int)
for i in range(m):
    a[i], b[i] = map(int, input().split())
print("\n".join(map(str, solve(n, m, a, b))))
N = int(input())
count = 0

for i in range(1,N+1):
  if len(i)%2 == 1:
    count+=1
print(count)

### FIXED CODE ###

N = int(input())
count = 0

for i in range(1,N+1):
  if len(str(i))%2 == 1:
    count+=1
print(count)
N, K = map(int, input().split())
S = [input().split() for _ in range(N+K-1)]
new_list = []
for i in range(0,K*2,2):
    for j in S[i]:
        new_list.append(j)
new_list = set(new_list)
print(N - len(new_list))


### FIXED CODE ###

N, K = map(int, input().split())
S = [input().split() for _ in range(K*2)]
new_list = []
for i in range(5):
    S.append([])
S.append([])
for i in range(1,len(S)-2,2):
    for j in S[i]:
        new_list.append(j)

new_list = set(new_list)
print(N - len(new_list))
a,b,c,d=map(int,input().split())
print(max[a*b,c*d])

### FIXED CODE ###

a,b,c,d=map(int,input().split())
print(max([a*b,c*d]))
# -*- coding: utf-8 -*-

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

A = 0
B = 0
if n%2 == 0:
    r = int(n/2)
    for i in range(0,r):
        A += max(a)
        a.remove(max(a))
        B += max(a)
        a.remove(max(a))
else:
    r = int(n/2)
    for i in range(0,r):
        A += max(a)
        a.remove(max(a))
        B += max(a)
        a.remove(max(a))
    A += max(a)

print(A-B)

### FIXED CODE ###

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

n = int(input())
a = int(input())

if n%500==0:
    print("Yes")
elif n%500 < a:
    print("Yes")
elif n%500 == a:
    print("Yes")
elif n%500 > a:
    print("No")
else:
    pass
n = int(input())
s = input()
t = input()

if s == t:
    print(n)
    return

r = 0
for i in range(0, n):
    if s[-(i + 1)] != t[i]:
        break
    r += 1

print((n * 2) - r)


### FIXED CODE ###

n = int(input())
s = input()
t = input()

r = n
for i in range(0, n):
    if s[i:] == t[:(n-i)]:
            break
    r += 1

print(r)
H,W=map(int,input().split())
M=[[0 for i in range(W)] for i in range(H)]
for _ in range(H):
    s=input()
    for i in range(W):
        if s[i]=='#':
            M[_][i]=1
dp=[[10**6 for i in range(W)] for i in range(H)]
if M[0][0]==1:
    dp[0][0]=1
else:
    dp[0][0]=0
for j in range(W-1):
    if M[j+1][0]==0:
        dp[j+1][0]=dp[j][0]
    else:
        if M[j][0]==1:
            dp[j+1][0]=dp[j][0]
        else:
            dp[j+1][0]=dp[j][0]+1
for i in range(H-1):
    if M[0][i+1]==0:
        dp[0][i+1]=dp[0][i]
    else:
        if M[0][i]==1:
            dp[0][i+1]=dp[0][i]
        else:
            dp[0][i+1]=dp[0][i]+1
for i in range(1,H):
    for j in range(W-1):
        if M[i][j+1]==0:
            if M[i-1][j+1]==0:
                dp[i][j+1]=min(dp[i-1][j+1],dp[i][j])
            else:
                dp[i][j+1]=min(dp[i-1][j+1],dp[i][j])
        elif M[i][j+1]==1:
            if M[i-1][j+1]==1:
                if M[i][j]==1:
                    dp[i][j+1]=min(dp[i-1][j+1],dp[i][j])
                else:
                    dp[i][j+1]=min(dp[i-1][j+1],dp[i][j]+1)
            else:
                if M[i][j]==1:
                    dp[i][j+1]=min(dp[i-1][j+1]+1, dp[i][j])
                else:
                    dp[i][j+1]=min(dp[i-1][j+1]+1,dp[i][j]+1)
print(dp[H-1][W-1])

### FIXED CODE ###

H,W=map(int,input().split())
M=[[0 for i in range(W)] for i in range(H)]
for _ in range(H):
    s=input()
    for i in range(W):
        if s[i]=='#':
            M[_][i]=1
dp=[[10**6 for i in range(W)] for i in range(H)]
if M[0][0]==1:
    dp[0][0]=1
else:
    dp[0][0]=0
for j in range(W-1):
    if M[0][j+1]==0:
        dp[0][j+1]=dp[0][j]
    else:
        if M[0][j]==1:
            dp[0][j+1]=dp[0][j]
        else:
            dp[0][j+1]=dp[0][j]+1
for i in range(H-1):
    if M[i+1][0]==0:
        dp[i+1][0]=dp[i][0]
    else:
        if M[i][0]==1:
            dp[i+1][0]=dp[i][0]
        else:
            dp[i+1][0]=dp[i][0]+1
for i in range(1,H):
    for j in range(0,W-1):
        if M[i][j+1]==0:
            dp[i][j+1]=min(dp[i-1][j+1],dp[i][j])
        elif M[i][j+1]==1:
            if M[i-1][j+1]==1:
                if M[i][j]==1:
                    dp[i][j+1]=min(dp[i-1][j+1],dp[i][j])
                else:
                    dp[i][j+1]=min(dp[i-1][j+1],dp[i][j]+1)
            else:
                if M[i][j]==1:
                    dp[i][j+1]=min(dp[i-1][j+1]+1, dp[i][j])
                else:
                    dp[i][j+1]=min(dp[i-1][j+1]+1,dp[i][j]+1)
print(dp[H-1][W-1])
K,S=map(int,input().split)
ans=0
for x in range(K+1):
  for y in range(K+1):
    for z in range(K+1):
      if x+y+z==S:
        ans+=1

print(ans)

### FIXED CODE ###

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

print(ans)
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
S = np.array(list('_' + sr()))
Q = ir()
K = lr()
isD = (S == 'D')
isM = (S == 'M')
isC = (S == 'C')
cumD = isD.cumsum()
cumM = isM.cumsum()

for k in K:
    x = cumD.copy()
    x[k:] -= cumD[:-k]
    x *= isM
    x[k+1:] -= isD[1:-k] * (cumM[k:-1] - cumM[:-k-1])
    answer = (x.cumsum() * isC).sum()
    print(answer)
# 05

### FIXED CODE ###

import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
S = np.array(list('_' + sr()))
Q = ir()
K = lr()
isD = (S == 'D')
isM = (S == 'M')
isC = (S == 'C')
cumD = isD.cumsum()
cumM = isM.cumsum()

for k in K:
    x = cumD.copy()
    x[k:] -= cumD[:-k]
    x *= isM
    x[k+1:] -= isD[1:-k] * (cumM[k:-1] - cumM[:-k-1])
    answer = (x.cumsum() * isC).sum()
    print(answer)
# 05
def main():
    mod = 998244353
    a, b, c, d = map(int, input().split())
    dp = [[0]*(d+1) for _ in [0]*(c+1)]
    dp[a][b] = 1
    for i in range(a+b+1, c+d+1):
        for p in range(c, a-1, -1):
            q = i-p
            if q > d:
                break
            dp[p][q] = (q*dp[p-1][q]+p*dp[p][q-1] -
                        (p-1)*(q-1)*dp[p-1][q-1]) % mod
    print(dp[c][d])


main()


### FIXED CODE ###

def main():
    mod = 998244353
    a, b, c, d = map(int, input().split())
    dp = [[0]*(d+1) for _ in [0]*(c+1)]
    dp[a][b] = 1
    for i in range(a+b+1, c+d+1):
        for p in range(c, a-1, -1):
            q = i-p
            if q > d:
                break
            if q < 0:
                continue
            dp[p][q] = (q*dp[p-1][q]+p*dp[p][q-1] -
                        (p-1)*(q-1)*dp[p-1][q-1]) % mod
    print(dp[c][d])


main()
N, M = map(int, input().split())
A = [0] * M
B = [0] * M
for i in range(M):
    A[i], B[i] = map(int, input().split())

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]
    
u = UnionFind(N)
for i in range(M):
    u.union(A[i], B[i])
    
ans = 1
for i in range(1, N+1):
    print("{}の属するグループは{}人です。".format(i, u.size(i)))
    ans = max(ans, u.size(i))
print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
A = [0] * M
B = [0] * M
for i in range(M):
    A[i], B[i] = map(int, input().split())

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * (n+1)

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]
    
u = UnionFind(N)
for i in range(M):
    u.union(A[i], B[i])
    
ans = 1
for i in range(1, N+1):
    ans = max(ans, u.size(i))
print(ans)