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

s = input()
mod = 10 ** 9 + 7
table = [[0] * 13 for _ in range(len(s) + 2)]
d = 0
table[0][0] = 1
dd = 1
for c in s[::-1]:
    dd = (10 ** d) % 13
    if c == "?":
        for n in range(10):
            for i in range(13):
                table[d + 1][(i + n * dd) % 13] += table[d][i]
    else:
        for i in range(13):
            table[d + 1][(i + int(c) * dd) % 13] += table[d][i]
    d += 1

    for j in range(13):
        table[d + 1][j] %= mod
print(table[d][5] % mod)

### FIXED CODE ###

s = input()
s = s[::-1]
mod = 10 ** 9 + 7
table = [[0] * 13 for _ in range(len(s) + 2)]
table[0][0] = 1
dd = 1
for c in range(len(s)):
    if s[c] == "?":
        for n in range(10):
            for i in range(13):
                table[c + 1][(i + n * dd) % 13] += table[c][i]
                table[c + 1][(i + n * dd) % 13] %= mod
    else:
        num = int(s[c])
        for i in range(13):
            table[c + 1][(i + num * dd) % 13] += table[c][i]
            table[c + 1][(i + num * dd) % 13] %= mod
    dd = (dd * 10) % 13
print(table[c + 1][5])
### BUGGY CODE ###

import sys
n=int(input())
a=[int(input()) for _ in range(n)]
l=[1]
i=0
aa=1
while True:
    aa=a[aa-1]
    if aa == 2:
        print(i+1)
        sys.exit()
    if aa in l:
        print(-1)
        sys.exit()
    l.append(aa)
    i+=1
print(-1)

### FIXED CODE ###

import sys
import cProfile
input = sys.stdin.readline
def main():
    n=int(input())
    a=[int(input()) for _ in range(n)]
    l=[1]
    i=0
    aa=1
    while True:
        aa=a[aa-1]
        if aa == 2:
            print(i+1)
            sys.exit()
        if i>n:
            print(-1)
            sys.exit()
        i+=1
main()
### BUGGY CODE ###

n = int(input())
string = input()

r=g=b=0

for idx, s in enumerate(string):
    if s == 'R':
        r+=1
    elif s == 'B':
        b+=1
    elif s == 'G':
        g+=1

ans = r*g*b

for i in range(n):
    for k in range(i+1, n):
        if string[i] != string[k]:
            if (k+i)%2 == 0 and len(set([string[i], string[k], string[(k+i)//2]])) ==3:
                ans -= 1

print(ans)
            



### FIXED CODE ###

n = int(input())
string = input()
r = 0
g = 0
b = 0
for c in string:
    if c == 'R':
        r += 1
    elif c == 'G':
        g += 1
    else:
        b += 1
ans = r*g*b
for i in range(n):
    for j in range(i+1, n):
        if 2*j - i >= n:
            break
        
        if string[i] != string[j] and string[i] != string[2*j-i] and string[j] != string[2*j-i]:
            ans -= 1
print(ans)
### BUGGY CODE ###

import math

from operator import mul
from functools import reduce

N = int(input())
A = [int(s) for s in input().split()]
B = [0 for i in range(N)]
idx = []
for i in range(N):
  B[A[i]-1] += 1
  if B[A[i]-1] >= 2 and not A[i]-1 in idx:
    idx.append(A[i]-1)

def nCr(n,r):
    if n == 1:
        return 0
    r = min(n-r,r)
    if r == 0:
        return 1
    ov = reduce(mul, range(n, n-r, -1))
    un = reduce(mul, range(1, r+1))
    return ov // un

Cs = []
C = []
Ctot = 0
for j in idx:
  if B[j]-1 >= 2:
    Cs.append(nCr(B[j]-1, 2))
  else:
    Cs.append(0)
  tmp = nCr(B[j], 2)
  C.append(tmp)
  Ctot += tmp
for i in range(N):
  current_idx = A[i]-1
  if current_idx in idx:
    count = Ctot + Cs[idx.index(current_idx)]-C[idx.index(current_idx)]
  else:
    count = Ctot
  print(count)

### FIXED CODE ###

N = int(input())
A = [int(s) for s in input().split()]
B = [0 for i in range(N)]
def nC2(n):
  return n*(n-1)//2
for i in range(N):
  B[A[i]-1] += 1
Ctot = 0
for i in range(N):
  Ctot += nC2(B[i])
for i in range(N):
  current_idx = A[i]-1
  if B[current_idx] == 1:
    count = Ctot
  else:
    count = Ctot + nC2(B[current_idx]-1) - nC2(B[current_idx])
  print(count)
### BUGGY CODE ###

X,Y,A,B,C=map(int,input().split())
P=sorted(list(map(int,input().split())))
Q=sorted(list(map(int,input().split())))
R=sorted(list(map(int,input().split())))
P_=P[A-X:]
Q_=Q[B-Y:]
while min(P_[0],Q_[0])<R[-1]:
    min(P_,Q_).pop(0)
    min(P_,Q_).append(R.pop(-1))
    if len(R)==0:
        break
print(sum(P_)+sum(Q_))

### FIXED CODE ###

X,Y,A,B,C=map(int,input().split())
P=sorted(list(map(int,input().split())))
Q=sorted(list(map(int,input().split())))
R=sorted(list(map(int,input().split())))
S=sorted(P[A-X:]+Q[B-Y:])
ans=sum(S)
for i in range(min(len(R),len(S))):
    if S[i]<R[-1-i]:
        S[i]=R[-1-i]
    else:
        break
print(sum(S))
### BUGGY CODE ###

sent1 = input()
sent2 = input()

l = len(sent1)

for i in range(l-1):
    for j in range(i,l):
        if sent1[i] == sent1[j] and sent2[i] != sent2[j] or sent1[i] != sent1[j] and sent2[i] == sent2[j]:
            print("No")
            exit(0)
print("Yes")

### FIXED CODE ###

s = input()
t = input()

s2 = []
t2 = []

sdic = {}
tdic = {}

cnt = 0
for c in s:
    if c in sdic:
        s2.append(sdic[c])
    else:
        s2.append(cnt)
        sdic[c] = cnt
        cnt += 1

cnt = 0
for c in t:
    if c in tdic:
        t2.append(tdic[c])
    else:
        t2.append(cnt)
        tdic[c] = cnt
        cnt += 1

print("Yes" if s2 == t2 else "No")
### BUGGY CODE ###

import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
S =sum(A)
cut = []
for k in range(N):
  cut.append(K*A[k]//S)

length = []
ans = 0
for k in range(N):
  length.append([A[k] / (cut[k]+1), k])

length.sort(key = lambda x: x[0], reverse=True)

C = sum(cut)
res = K - C
length = length[:res+1]
for k in range(res):
  cut[length[0][1]] += 1
  length[0][0] = length[0][0]*cut[length[0][1]]/(cut[length[0][1]]+1)
  length.sort(key = lambda x: x[0], reverse=True)

print(math.ceil(length[0][0]))

### FIXED CODE ###

import math
from collections import deque
N, K = map(int, input().split())
A = list(map(int, input().split()))
S =sum(A)
cut = []
for k in range(N):
  cut.append(K*A[k]//S)

length = []
for k in range(N):
  length.append([A[k] / (cut[k]+1), k])

length.sort(key = lambda x: x[0], reverse=True)

def nibun_insert(lis, item):
  end = len(lis)
  start = 0
  now = (end+start)//2
  while end > start+1:
    if lis[now][0] > item[0]:
      start = 0 + now
      now = (now + end)//2
    else:
      end = 0 + now
      now = (now + start)//2
  return deque(lis[:now+1] + [item] + lis[now+1:])
  

C = sum(cut)
res = min(K - C, N)
length = length[:res+1]
length = deque(length)
for k in range(res):
  a = length.popleft()
  cut[a[1]] += 1
  a[0] = a[0]*cut[a[1]]/(cut[a[1]]+1)
  if a[0] <= length[-1][0]:
    length.append(a)
  elif a[0] >= length[0][0]:
    length.appendleft(a)
  else:
    length = nibun_insert(list(length), list(a))
  length.pop()

print(math.ceil(length.popleft()[0]))
### BUGGY CODE ###

from collections import deque
H,W = map(int,input().split())
S = [list(input()) for i in range(H)]
blacklist = []
for h in range(H):
    for w in range(W):
        if S[h][w] == '#':
            blacklist.append((h,w))
count = 0
alr = []
h1 = [0,0,1,-1]
w1 = [1,-1,0,0]
for h,w in blacklist:
    que = deque()
    que.append((h,w,True))
    alr.append((h,w))
    alr2 = [(h,w)]
    while que:
        hn,wn,black = que.popleft()
        black = not black
        for i in range(4):
            if 0 <= hn+h1[i] <= H-1 and 0 <= wn+w1[i] <= W-1 and (hn+h1[i],wn+w1[i]) not in alr2:
                if (not black) and S[hn+h1[i]][wn+w1[i]] == '.':
                    if (hn+h1[i],wn+w1[i]) not in alr:
                        count += 1
                    que.append((hn+h1[i],wn+w1[i],black))
                    alr2.append((hn+h1[i],wn+w1[i]))
                elif black and S[hn+h1[i]][wn+w1[i]] == '#':
                    que.append((hn+h1[i],wn+w1[i],black))
                    alr2.append((hn+h1[i],wn+w1[i]))
print(count)
                        

### FIXED CODE ###

from collections import deque
H,W = map(int,input().split())
S = [list(input()) for i in range(H)]
blacklist = []
for h in range(H):
    for w in range(W):
        if S[h][w] == '#':
            blacklist.append((h,w))
ans = 0
alr = [[0 for i in range(W)] for j in range(H)]
h1 = [0,0,1,-1]
w1 = [1,-1,0,0]
for h,w in blacklist:
    if alr[h][w] == 0:
        bcount = 1
        wcount = 0
        que = deque()
        que.append((h,w,True))
        alr[h][w] = 1
        while que:
            hn,wn,black = que.popleft()
            black = not black
            for i in range(4):
                if 0 <= hn+h1[i] <= H-1 and 0 <= wn+w1[i] <= W-1 and not alr[hn+h1[i]][wn+w1[i]]:
                    if (not black) and S[hn+h1[i]][wn+w1[i]] == '.':
                        wcount += 1
                        que.append((hn+h1[i],wn+w1[i],black))
                        alr[hn+h1[i]][wn+w1[i]] = 1
                    elif black and S[hn+h1[i]][wn+w1[i]] == '#':
                        bcount += 1
                        que.append((hn+h1[i],wn+w1[i],black))
                        alr[hn+h1[i]][wn+w1[i]] = 1
        ans += wcount*bcount
print(ans)
### BUGGY CODE ###

def cost(a):
    la = len(a)
    if la == 1:
        return 0
    if la == 2:
        return a[0] + a[1]
    if a in memo:
        return memo[a]
    re = []
    for i in range(1, la):
        re += [cost(a[:i]) + cost(a[i:]) + sum(a)]
    re = min(re)
    memo[a] = re
    return re


memo = {}
n = int(input())
a = tuple(map(int, input().split()))
print(cost(a))


### FIXED CODE ###

def f(n, a):
    inf = float("inf")
    dp = [[0] * n for _ in range(n)]
    for i in range(n - 2, -1, -1):
        s = a[i]
        dpi = dp[i]
        for j in range(i + 1, n):
            mn = inf
            s += a[j]
            for d in range(i, j):
                k = dpi[d] + dp[d + 1][j]
                if k < mn:
                    mn = k
            dpi[j] = mn + s
    return dp[0][-1]


n = int(input())
a = tuple(map(int, input().split()))
print(f(n, a))
### BUGGY CODE ###

N,K=map(int,input().split())
p=list(map(int,input().split()))
v=[0]*(N-K+1)
for i in range(N-K+1):
    v[i]=(sum(p[i:i+K])+K)/2
print(max(v))

### FIXED CODE ###

N,K=map(int,input().split())
p=list(map(int,input().split()))
ans=(sum(p[0:K])+K)/2
temp=ans
for i in range(1,N-K+1):
    temp-=(p[i-1]+1)/2
    temp+=(p[i+K-1]+1)/2
    if temp>ans:
        ans=temp
print(ans)
### BUGGY CODE ###

import sys

input = sys.stdin.readline

n,k = map(int,input().split())
h = [int(i) for i in input().split()]
dp = [float('inf')]*n
dp[0] = 0
for i in range(n):
    for j in range(1,k+1):
        m = i + j
        if m < n:
            dp[m] = min(dp[m],dp[i] + abs(h[i]-h[m]))

print(dp[-1])
    

### FIXED CODE ###

n,k = map(int,input().split())
h = [int(i) for i in input().split()]
dp = [float('inf')]*n
dp[0] = 0
for i in range(n):
    for j in range(1,k+1):
        m = i + j
        if m < n:
            dp[m] = min(dp[m],dp[i] + abs(h[i]-h[m]))

print(dp[-1])
### BUGGY CODE ###

S=list(input())
Q=int(input())
ls=[list(input().split()) for _ in range(Q)]
for i in range(Q):
  if ls[i][0]=="1":
    S.reverse()
  else:
    if ls[i][1]=="1":
      S.insert(0,ls[i][2])
    else:
      S.append(ls[i][2])
print("".join(S))

### FIXED CODE ###

from collections import deque
S=list(input())
Q=int(input())
ls=[list(input().split()) for _ in range(Q)]
D=deque()
for i in range(len(S)):
  D.append(S[i])  
a=1
for i in range(Q):
  if ls[i][0]=="1":
    a*=(-1)
  else:
    if (ls[i][1]=="1" and a==1) or (ls[i][1]=="2" and a==-1):
      D.appendleft(ls[i][2])
    else:
      D.append(ls[i][2])
if a==1:
  while D:
    print(D.popleft(), end="")
else:    
  while D:
    print(D.pop(), end="")
### BUGGY CODE ###

import numpy as np

X, Y, Z, K = map(int,input().split())
A_list = list(map(int,input().split()))
B_list = list(map(int,input().split()))
C_list = list(map(int,input().split()))

E_list = []
for i in A_list:
    for j in B_list:
        # print(i+j)
        E_list.append(i+j)

E_list = np.array(E_list)
E_list = np.sort(E_list)[::-1]

sum_list = []
for i in E_list[:K]:
    for j in C_list:
        sum_list.append(i+j)

sum_list = np.array(sum_list)
sum_list = np.sort(sum_list)[::-1]

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


### FIXED CODE ###

X, Y, Z, K = map(int,input().split())
A_list = sorted(list(map(int,input().split())), reverse=True)
B_list = sorted(list(map(int,input().split())), reverse=True)
C_list = sorted(list(map(int,input().split())), reverse=True)

E_list = sorted([ai+bi for ai in A_list for bi in B_list], reverse=True)[:K]
sum_list = sorted([ei+ci for ei in E_list for ci in C_list], reverse=True)[:K]

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

import bisect

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

def cnt(a, m):
  cnt_tmp = 0
  for aa in a:
    bi = bisect.bisect_left(a, m - aa)
    #print(a, m, m - aa, bi)
    cnt_tmp += N - bi
  return cnt_tmp

A.sort()

l = 0
r = 10**16

while 1:
  mid = (l + r) // 2
  cnt_loop1 = cnt(A, mid)
  cnt_loop2 = cnt(A, mid+1)
  #print(mid, cnt_loop1, cnt_loop2)
  
  if cnt_loop1 >= M and cnt_loop2 < M:
    break
  if cnt_loop1 >= M:
    l = mid
  else:
    r = mid
#print(mid, cnt_loop1, cnt_loop2)

S = [0] * (N+1)
for i in range(1, N+1):
  S[i] = S[i-1]+A[i-1]
#print(S[N])

answer = 0
for aa in A:
  bi = bisect.bisect_left(A, mid - aa)
  answer += S[N] - S[bi] + (N - bi) * aa
print(answer-(cnt_loop1-M)*mid)



### FIXED CODE ###

from bisect import bisect_left

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

A.sort()
left = 0
right = max(A) * 2 + 1

while left + 1 < right:
  mid = (left + right) // 2
  
  cnt = 0
  for i in range(N):
    cnt += N - bisect_left(A, mid - A[i])
  if cnt >= M:
    left = mid
  else:
    right = mid

Acum = [0]
for a in A:
  Acum.append(Acum[-1] + a)

answer = 0
cnt = 0
for i in range(N):
  bi = bisect_left(A, left - A[i])
  answer += (Acum[-1] - Acum[bi]) + (N - bi) * A[i]
  cnt += (N - bi)
answer -= (cnt - M) * left

print(answer)
### BUGGY CODE ###

from collections import deque
n,m = map(int,input().split())

b = [[] for i in range(n)]
for i in range(m):
    a=list(map(int,input().split()))
    b[a[1]-1].append(a[0])
    b[a[0]-1].append(a[1])
    
c = [-1 for i in range(n)]
c[0] = 0
q = deque([1])
now = 0
count = 0
while q:
    #print(c,q, now)
    count = count + 1
    if count > n:
        print("No")
        exit()
    now = q.popleft() - 1
    for i in range(len(b[now])):
        if c[b[now][i] - 1] == -1 and b[now][i] not in q:
            q.append(b[now][i])
            c[q[-1] - 1] = now + 1
            #print(c)
            
#print(c)
print("Yes")
for i in range(1,len(c)):
    print(c[i])

### FIXED CODE ###

from collections import deque
n,m = map(int,input().split())

b = [[] for i in range(n)]
for i in range(m):
    a=list(map(int,input().split()))
    b[a[1]-1].append(a[0])
    b[a[0]-1].append(a[1])
    
c = [-1 for i in range(n)]
c[0] = 0
q = deque([1])
now = 0
count = 0
while q:
    #print(c,q, now)
    count = count + 1
    if count > n:
        print("No")
        exit()
    now = q.popleft() - 1
    for i in range(len(b[now])):
        #count = count + 1
        #print(now+1, "=>", b[now][i])
        if c[b[now][i] - 1] == -1:
            q.append(b[now][i])
            c[q[-1] - 1] = now + 1
            #print(c)
            
#print(count)
print("Yes")
for i in range(1,len(c)):
    print(c[i])
### BUGGY CODE ###

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

rs = {}
gs = {}
bs = {}

for i, e in enumerate(s):
  if e == 'R':
    rs[i] = ''
  if e == 'G':
    gs[i] = ''
  if e == 'B':
    bs[i] = ''
   
      
saidai = len(rs) * len(gs) * len(bs)
if saidai == 0:
  print('0')
else:
  for i in rs.keys():
    for j in gs.keys():
      mi = i if i < j else j
      ma = j if i < j else i
      p = [mi - (ma - mi), mi + (ma - mi)/2, ma + (ma - mi)]
      for e in p:
        if e%1 != 0 or e < 0 or e > len(s):
          continue
        if e in bs:
          saidai -= 1
  print(int(saidai))

### FIXED CODE ###

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

rs = {}
gs = {}
bs = {}

for i, e in enumerate(s):
  if e == 'R':
    rs[i] = ''
  if e == 'G':
    gs[i] = ''
  if e == 'B':
    bs[i] = ''
    
saidai = len(rs) * len(gs) * len(bs)
if saidai == 0:
  print('0')
else:
  a = max(bs.keys())
  b = min(bs.keys())
  for i in rs.keys():
    for j in gs.keys():
      mi = i if i < j else j
      ma = j if i < j else i
      p = [mi - (ma - mi), mi + (ma - mi)/2, ma + (ma - mi)]
      for e in p:
        if e%1 != 0 or e < b or e > a:
          continue
        if e in bs:
          saidai -= 1
  print(int(saidai))
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
f=0
s=0
mx=max(a)
cnt=[0]
for i in range(mx+1):
  x=a.count(i)
  if x>=2:
    if x>=4:
      f=i
      s=i
    else:
      s=f
      f=i
print(f*s)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
ans=0
b=-1
for i in a:
  if i==b:
    if ans!=0:
      ans*=i
      break
    else:
      ans=i
      b=-1
      continue
  b=i
print(ans)
### BUGGY CODE ###

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

idx = 0
ans = 0
while 1:
  if idx >= len(A):
    break
  elif A[idx] == idx+1:
    idx += 1
  else:
    A.pop(idx)
    ans += 1

if len(A) == 0:
  print(-1)
else:
  print(ans)

### FIXED CODE ###

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

k = 1
ans = 0

if 1 not in A:
  print(-1)
  exit()

for a in A:
  if a == k:
    k += 1
  else:
    ans += 1

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

# ABC 152 C
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
snm = lambda: map(str, input().split())
nl = lambda: list(map(int, input().split()))
n=ni()
p=nl()
s=[]
ans=0
for i in range(n):
    if i==0:
        ans+=1
        s.append(p[i])
        continue
    if p[i]<=min(s):
        ans+=1
    s.append(p[i])
print(ans)

### FIXED CODE ###

# ABC 152 C
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
snm = lambda: map(str, input().split())
nl = lambda: list(map(int, input().split()))
n=ni()
p=nl()
s=[]
ans=0
min_v=10**6
for i in range(n):
    if i==0:
        ans+=1
        s.append(p[i])
        min_v=min(min_v,p[i])
        continue
    if p[i]<=min_v:
        ans+=1
    s.append(p[i])
    min_v=min(min_v,p[i])
print(ans)
### BUGGY CODE ###

H,W,M = map(int, input().split())
mx=[0] * W
my=[0] * H
bs =[[] for i in range(H)]
mxx = 0
myy = 0
for i in range(M):
    y,x = map(int, input().split())
    mx[x-1] += 1
    my[y-1] += 1
    mxx = max(mx[x-1], mxx)
    myy = max(my[y-1], myy)
    bs[y-1].append(x-1)

vx = []
vy = []
for i,x in enumerate(mx):
    if x == mxx:
        vx.append(i)
for i,y in enumerate(my):
    if y == myy:
        vy.append(i)

a = 1

for i in vx:
    for j in vy:
        if i not in bs[j]:
            a = 0
            break
    else:
        continue
    break

ans = mxx + myy - a
print(ans)


### FIXED CODE ###

H,W,M = map(int, input().split())
mx=[0] * W
my=[0] * H
bs ={}
mxx = 0
myy = 0
for i in range(M):
    y,x = map(int, input().split())
    mx[x-1] += 1
    my[y-1] += 1
    mxx = max(mx[x-1], mxx)
    myy = max(my[y-1], myy)
    if y-1 in bs:
        bs[y-1].add(x-1)
    else:
        bs[y-1] = set([x-1])

vx = []
vy = []
for i,x in enumerate(mx):
    if x == mxx:
        vx.append(i)
for i,y in enumerate(my):
    if y == myy:
        vy.append(i)

a = 1

for i in vx:
    for j in vy:
        if i not in bs[j]:
            a = 0
            break
    else:
        continue
    break

ans = mxx + myy - a
print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    K = int(input())
    S = input()
    
    M = len(S)
    N = M + K
    MAXN = N + 2
    fact = [1]
    for i in range(1,MAXN + 1):
        fact.append(fact[-1]*i%MOD)
    inv_fact = [-1] * (MAXN + 1)
    inv_fact[-1] = pow(fact[-1],MOD - 2,MOD)
    for i in range(MAXN - 1,-1,-1):
        inv_fact[i] = inv_fact[i + 1]*(i + 1)%MOD
    
    nck = lambda N,K: 0 if K > N or K < 0 else fact[N]*inv_fact[N - K]*inv_fact[K]%MOD
    
    power25 = [1]
    power26 = [1]
    for i in range(N):
        power25.append(power25[-1]*25%MOD)
        power26.append(power26[-1]*26%MOD)
    
    ans = 0
    for i in range(M,N + 1):
        ans += nck(i - 1,M - 1) * power25[i - M] * power26[N - i] % MOD
        ans %= MOD
    print(ans)
if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    K = int(input())
    S = input()
    
    M = len(S)
    N = M + K
    MAXN = N + 2
    fact = [1]
    for i in range(1,MAXN + 1):
        fact.append(fact[-1]*i%MOD)
    inv_fact = [-1] * (MAXN + 1)
    inv_fact[-1] = pow(fact[-1],MOD - 2,MOD)
    for i in range(MAXN - 1,-1,-1):
        inv_fact[i] = inv_fact[i + 1]*(i + 1)%MOD
    
    nck = lambda N,K: 0 if K > N or K < 0 else fact[N]*inv_fact[N - K]*inv_fact[K]%MOD
    
    power25 = [1]
    power26 = [1]
    for i in range(N):
        power25.append(power25[-1]*25%MOD)
        power26.append(power26[-1]*26%MOD)
    
    ans = 0
    for i in range(M,N + 1):
        ans += nck(i - 1,M - 1) * power25[i - M] * power26[N - i] % MOD
        ans %= MOD
    print(ans)
if __name__ == '__main__':
    main()
### BUGGY CODE ###

# -*- coding: utf-8 -*-
x,y,z,k = map(int, input().split())

a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

v = []
count = 0


for i in range(x):
    for j in range(y):
        v.append(a[i]+b[j])

v = sorted(v, reverse=True)
c = sorted(c, reverse=True)

vv = []
for i in range(len(v)):
    for j in range(z):
        vv.append(v[i]+c[j])

vv = sorted(vv, reverse=True)

for i in vv[0:k]:
    print(i)


### FIXED CODE ###

# -*- coding: utf-8 -*-
x,y,z,k = map(int, input().split())

a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)


d = [e1+e2 for e1 in a for e2 in b]
d.sort(reverse=True)
d = d[:k]

e = [e1+e2 for e1 in d for e2 in c]
e.sort(reverse=True)


for i in range(k):
    print(e[i])
### BUGGY CODE ###

def maxElem( lis ):
  '''
  与えられたリストの中に、最も多く存在する要素を返す
  (最大の数の要素が複数ある場合、pythonのsetで先頭により近い要素を返す)
  '''
  L = lis[:]#copy
  S = set(lis)
  S = list(S)
  MaxCount=0
  ret='nothing...'

  for elem in S:
    c=0
    while elem in L:
      ind = L.index(elem)
      foo = L.pop(ind)
      c+=1
    if c>MaxCount:
      MaxCount=c
      ret = elem
  return ret


if __name__ == "__main__" :
    n = int(input())
    array = list(map(int, input().split()))

    for i in range(0, n):
        array[i] = array[i] - i - 1
    elem = int(maxElem(array))
    # print(maxElem(array))
    # print(array)
    
    for i in range(0, n):
        array[i] = abs(array[i] - elem)

    # sum_n = sum(array)

    # if sum_n > n:
    #     for j in range(0, n):
    #         array[j] = array[j] * array[j]
    sum_n = sum(array)

    print(sum_n)

### FIXED CODE ###

import collections
from statistics import median

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

for i in range(0, n):
    array[i] = array[i] - (i + 1)
c = collections.Counter(array)
elem = int(c.most_common()[0][0])

# print(c.most_common()[0][0])
# print(array)
# print(elem)
# if c.most_common()[0][1] != 1:
#     # print("test")
#     for j in range(0, n):
#         array[j] = abs(array[j] - elem)
# else:
#     for j in range(0, n):
#         array[j] = abs(array[j])
b = int(median(array))
for j in range(0, n):
    array[j] = int(abs(array[j] - b))

print(sum(array))