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

n,k,q=map(int,input().split())
ans=[k]*n
for i in range(q):
  a=int(input())
  for j in range(n):
    if a-1!=j:
      ans[j]=ans[j]-1
for i in range(n):
  if ans[i]<=0:
    print("No")
  else:
    print("Yes")


### FIXED CODE ###

n,k,q=map(int,input().split())
ans=[k-q]*n
a=[0]*q
for i in range(q):
  a[i]=int(input())
for i in range(q):
  ans[a[i]-1]=ans[a[i]-1]+1
for i in range(n):
  if ans[i]<=0:
    print("No")
  else:
    print("Yes")
### BUGGY CODE ###

from copy import deepcopy
import bisect
n, k = map(int, input().split())
a = list(map(int, input().split()))

for _ in range(k):
    b = [1] * n
    for i in range(n):
        for j in range(1, a[i]+1):
            if i-j >= 0: b[i-j] += 1
            if i+j < n: b[i+j] += 1
    a = deepcopy(b)
    
    if bisect.bisect_left(a, n) == 0: break
        
print(*a)

### FIXED CODE ###

from copy import deepcopy
import bisect
n, k = map(int, input().split())
a = list(map(int, input().split()))

for _ in range(k):
    b = [0] * (n+1)
    for i in range(n):
        b[max(0, i-a[i])] += 1
        b[min(n, i+a[i]+1)] -= 1
    for i in range(n-1):
        b[i+1] += b[i]
    b.pop()
    a = deepcopy(b)
    
    if bisect.bisect_left(a, n) == 0: break
    
print(*a)
### BUGGY CODE ###

#D問題
mod = 1000000007
S = str(input())
N = len(S)

dp = [[0 for i in range(13)] for j in range(N+1)]
dp[0][0] = 1
for i in range(N):
    if S[i] == "?":
        for j in range(10):
            for k in range(13):
                ind = (10*k+j)%13
                dp[i+1][ind] += dp[i][k]
    else:
        s = int(S[i])
        for k in range(13):
            ind = (10*k+s)%13
            dp[i+1][ind] += dp[i][k]
            
print(dp[N][5]%mod)

### FIXED CODE ###

#D問題
mod = 1000000007
S = str(input())
N = len(S)


dp = [[0 for i in range(13)] for j in range(N+1)]
dp[0][0] = 1
for i,s in enumerate(S):
    if s == "?":
        for j in range(10):
            for k in range(13):
                ind = (10*k+j)%13
                dp[i+1][ind] += dp[i][k]
    else:
        j = int(s)
        for k in range(13):
            ind = (10*k+j)%13
            dp[i+1][ind] += dp[i][k]

    for k in range(13):
        dp[i+1][k]%=mod
            
print(dp[N][5]%mod)
### BUGGY CODE ###

from itertools import permutations

inf = float("inf")
n,m,r = map(int,raw_input().split())
arr = map(int,raw_input().split())
d = [[inf for i in range(n)] for j in range(n)]

for i in range(n):
	d[i][i] = 0

for i in range(m):
	f,t,c = map(int,raw_input().split())
	d[f-1][t-1] = c
	d[t-1][f-1] = c

for i in range(n):
	for j in range(n):
		for k in range(n):
			d[i][j] = min(d[i][j], d[i][k] + d[k][j])


ans = inf
for i in permutations(arr):
	distance = 0
	for j in range(r-1):
		distance += d[i[j]-1][i[j+1]-1]

	ans = min(ans,distance)

print ans

### FIXED CODE ###

from itertools import permutations
import sys

def main():
    
    N, M, R = map(int, sys.stdin.readline().split())
    r = [i - 1 for i in map(int, sys.stdin.readline().split())]
    
    d = [[float('inf')] * N for _ in range(N)]
    
    for i in range(N):
        d[i][i] = 0
        
    for i in range(M):
        a, b, c = map(int,sys.stdin.readline().split())
        d[a-1][b-1] = c
        d[b-1][a-1] = c
        
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if d[i][j] > d[i][k] + d[k][j]:
                    d[i][j] = d[i][k] + d[k][j]
    
    ans = 10**12
    
    for each in permutations(r):
        t_dis = 0
        for i in range(R-1):
            t_dis += d[each[i]][each[i+1]]  
        
        ans = min(ans, t_dis)
    
    print(ans)

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

n, k = map(int, input().split())
a = list(map(int, input().split()))
now = 1
path = [now]

for i in range(k):
    now = a[now-1]
    if now in set(path):
        now = path[path.index(now) + (k-i-1)%(len(path) - path.index(now))]
        break
    path.append(now)

print(now)


### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
alr = [0 for i in range(n)]
now = 1
path = [now]

for i in range(k):
    now = a[now-1]
    # if now in path:
    #     now = path[path.index(now) + (k-i-1)%(len(path) - path.index(now))]
    #     break
    if alr[now-1] != 0:
        now = path[path.index(now) + (k-i-1)%(len(path) - path.index(now))]
        break
    path.append(now)
    alr[now-1] += 1

print(now)
### BUGGY CODE ###

from itertools import permutations as perm
N, M, R = (list)(map(int, input().split()))

dest = (list)(map(lambda x: (int)(x)-1, input().split()))

inf = 10**10
mat = [[inf]*N for _ in range(N)]
for i in range(N):
    mat[i][i] == 0
for _ in range(M):
    a, b, c = (list)(map(int, input().split()))
    mat[a-1][b-1] = c
    mat[b-1][a-1] = c

for i in range(N):
    mat[i][i] == 0

for i in range(N):
    for j in range(N):
        for k in range(N):
            mat[j][k] = min(mat[j][k], mat[j][i]+mat[i][k])


ans = inf
for l in perm(dest):
    tmp = 0
    for i in range(R-1):
        tmp += mat[l[i]][l[i+1]]
    ans = min(ans, tmp)

print(ans)


### FIXED CODE ###

from itertools import permutations
import sys


input = sys.stdin.readline


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

dest = [x-1 for x in map(int, input().split())]


inf = float('inf')
mat = [[inf]*N for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    mat[a-1][b-1] = mat[b-1][a-1] = c


for i in range(N):
    for j in range(N):
        for k in range(N):
            mat[j][k] = min(mat[j][k], mat[j][i]+mat[i][k])


ans = inf
for l in permutations(dest):
    tmp = 0
    for u, v in zip(l, l[1:]):
        tmp += mat[u][v]
    ans = min(ans, tmp)

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

import sys
sys.setrecursionlimit(300000) #上限上げないと引っかかる
n,q = map(int, sys.stdin.readline().rstrip().split())
sco = [0]*(n+1)
G =[[] for _ in range(n+1)]
for i in range(n-1):
    a,b = map(int, sys.stdin.readline().rstrip().split())
    G[a].append(b)
    G[b].append(a)

for j in range(q):
    p,x = map(int, sys.stdin.readline().rstrip().split())
    sco[p]+=x


#本体
seen = [False for _ in range(n+1)]
def dfs(G,V,score):
    global sco
    sco[V] +=score

    seen[V] = True
    for next_V in G[V]:
        if (seen[next_V]):
            continue
        dfs(G, next_V,sco[V])

#入力受け取り
#例
dfs(G,1,0)
print(*sco[1:])
#単にdfs(G,0)だと、木構造でないとき(頂点1つでない時)不正解


### FIXED CODE ###

import sys
sys.setrecursionlimit(300000) #上限上げないと引っかかる
n,q = map(int, sys.stdin.readline().rstrip().split())
sco = [0]*(n+1)
G =[[] for _ in range(n+1)]
for i in range(n-1):
    a,b = map(int, sys.stdin.readline().rstrip().split())
    G[a].append(b)
    G[b].append(a)

for j in range(q):
    p,x = map(int, sys.stdin.readline().rstrip().split())
    sco[p]+=x


#本体
seen = [False for _ in range(n+1)]
def dfs(G,V,score):
    global sco
    sco[V] +=score

    seen[V] = True
    for next_V in G[V]:
        if (seen[next_V]):
            continue
        dfs(G, next_V,sco[V])

#入力受け取り
#例
dfs(G,1,0)
print(*sco[1:])
#単にdfs(G,0)だと、木構造でないとき(頂点1つでない時)不正解
### BUGGY CODE ###

import copy

N = int(input())

A = []
for n in range(N):
    a = int(input())
    A.append(a)

for n in range(N):
    temp = copy.deepcopy(A)
    del temp[n]
    print(max(temp))


### FIXED CODE ###

import copy

N = int(input())

A = []
for n in range(N):
    a = int(input())
    A.append(a)

m = max(A)
flag = 1
for n in range(N):
    if flag == 1 and A[n] == m:
        t = copy.deepcopy(A)
        del t[n]
        print(max(t))
        flag = 0
        continue

    print(m)
### BUGGY CODE ###

s=list(input())
q=int(input())
for _ in range(q):
  query=input()
  if query=="1":
    s.reverse()
  else:
    t,f,c=query.split()
    if f=="1":
      s=[c]+s
    else:
      s=s+[c]
    
print("".join(s))

### FIXED CODE ###

s=list(input())
q=int(input())
sc=0
lhs=[]
rhs=[]
for _ in range(q):
  query=input()
  if query=="1":
    sc+=1
  else:
    t,f,c=query.split()
    if f=="1":
      if sc%2==0:
        lhs.append(c)
      else:
        rhs.append(c)
    else:
      if sc%2==0:
        rhs.append(c)
      else:
        lhs.append(c)

lhs.reverse()
s=lhs+s+rhs
if sc%2!=0:
  s.reverse()
print("".join(s))
### BUGGY CODE ###

import numpy as np
N,M=map(int,input().split(" "))
#Nはポーンの数 Mは入力の数
A=list(sorted(map(int,input().split(" "))))
L=np.array([A[s]-A[s+1] for s in range(M-1)])

if M<=N:
    print(0)
else:
    for s in range(N-1):
        L[np.argmin(L)]=0
    print(abs(sum(L)))

### FIXED CODE ###

N,M=map(int,input().split(" "))
A=list(sorted(map(int,input().split(" "))))
L=[A[s]-A[s+1] for s in range(M-1)]
if M>N:
    print(abs(sum(sorted(L)[N-1:])))
else:
    print(0)
### BUGGY CODE ###

N, P=map(int,input().split())
S = list(map(int,list(input())))
dp = [0]*P
ret = 0
for i in range(N):
  dp_ = [0]*P
  b = S[i]%P
  for j in range(P):
    dp_[(j*10+b)%P] += dp[j]
  dp_[b] += 1
  ret += dp_[0]
  dp = dp_[:]
print(ret)    

### FIXED CODE ###

N, P=map(int,input().split())
S = list(map(int,list(input())))

def ma25():
  ret = 0
  for i in range(N):
    if S[i]%P == 0:
      ret+=(i+1)
  print(ret)

def ma():
  dp = [0]*P
  dp[0] = 1
  r = 0
  for i in range(N-1,-1,-1):
    r = ((S[i]*pow(10,N-1-i,P))+r)%P
    dp[r] += 1
  ret = 0
  for m in dp:
    ret += m*(m-1)//2
  print(ret)

if P == 2 or P == 5:
  ma25()
else:
  ma()
### BUGGY CODE ###

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

ans = 1
thres = pow(10, 18)
for i in A:
  ans = i * ans

if ans > thres:
  print(-1)
else:
  print(ans)


### FIXED CODE ###

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

ans = 1
thres = 10**18

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

for i in A:
  ans = i * ans
  if ans > thres:
    print(-1)
    sys.exit()

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

k = int(input())
start, found = 7, -1
for i in range(1, 100000):
  if start % k == 0:
    found = i
    break
  start = (start *10) + 7
print(found)

### FIXED CODE ###

n = int(input())
x, found = 0, False
for i in range(1, n + 1):
  x = ((10 * x) + 7)%n
  if x == 0:
    print(i)
    found = True
    break

if not found:
  print(-1)
### BUGGY CODE ###

'''
着想：大きいaほど左右の端に移動したい、小さいaを先に端にやるより必ず大きくなるから
問題：単純に貪欲に大きいaから左端(x-1)と右端(N-x)の大きい方に移動すると、
      残りのaの組み合わせ的に最適でない場合がある
      アイテムの左右端の単純な割り振りはO(2^N)
解決策の着想：大きい順のk個を(k=L+R)となる
    　　左L個右R個にどのように割り振っても(k+1)個目の最適な割り振り方は変わらない
解決策：アイテムk個左右に割り振る状態をdp[L][R]で保存O(N^2)
'''

N = int(input())
A = [[a, i] for a,i in zip(map(int, input().split()), range(N))]
A.sort(key=lambda a: a[0], reverse=True)

dp = [[0]*(N+1) for _ in range(N+1)] # 左からxマス右からyマス埋める
for i in range(0,N):
  a, l = A[i]
  for x in range(0,i+1):
    y = i - x # 合計x+y=iマス既に埋まっている、次にi+1マス目を考える
    dp[x+1][y] = max(dp[x+1][y], dp[x][y] + a * abs(l - x))
    dp[x][y+1] = max(dp[x][y+1], dp[x][y] + a * abs(l - (N-y-1)))

print(max(dp[N-i][i] for i in range(N+1)))

### FIXED CODE ###

'''
着想：大きいaほど左右の端に移動したい、小さいaを先に端にやるより必ず大きくなるから
問題：単純に貪欲に大きいaから左端(x-1)と右端(N-x)の大きい方に移動すると、
      残りのaの組み合わせ的に最適でない場合がある
      アイテムの左右端の単純な割り振りはO(2^N)
解決策の着想：大きい順のk個を(k=L+R)となる
    　　左L個右R個にどのように割り振っても(k+1)個目の最適な割り振り方は変わらない
解決策：アイテムk個左右に割り振る状態をdp[L][R]で保存O(N^2)
'''

def solve():
  N = int(input())
  A = [[a, i] for a,i in zip(map(int, input().split()), range(N))]
  A.sort(key=lambda a: a[0], reverse=True)

  dp = [[0]*(N+1) for _ in range(N+1)] # 左からxマス右からyマス埋める
  for i in range(0,N):
    a, l = A[i]
    for x in range(0,i+1):
      y = i - x # 合計x+y=iマス既に埋まっている、次にi+1マス目を考える
      dp[x+1][y] = max(dp[x+1][y], dp[x][y] + a * abs(l - x))
      dp[x][y+1] = max(dp[x][y+1], dp[x][y] + a * abs(l - (N-y-1)))

  print(max(dp[N-i][i] for i in range(N+1)))
  
solve()
### BUGGY CODE ###

from collections import deque

N = int(input())

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

Q, K = map(int, input().split())

visited = [False] * N
visited[K-1] = True

distance = [-1]*N

que = deque([(K-1, 0)])
while que:
    cur, d = que.popleft()
    distance[cur] = d

    for nx, nd in enumerate(G[cur]):
        if nd != -1 and visited[nx] is False:
            visited[nx] = True
            que.append((nx, d+nd))

for i in range(Q):
    x, y = map(int, input().split())
    print(distance[x-1]+distance[y-1])


### FIXED CODE ###

from collections import deque

N = int(input())

G = [set() for i in range(N)]
for _ in range(N-1):
    a, b, c = map(int, input().split())
    G[a-1].add((b, c))
    G[b-1].add((a, c))

Q, K = map(int, input().split())

visited = [False] * N
visited[K-1] = True

distance = [-1]*N

que = deque([(K, 0)])
while que:
    cur, d = que.popleft()
    distance[cur-1] = d

    for nx, nd in G[cur-1]:
        if visited[nx-1] is False:
            visited[nx-1] = True
            que.append((nx, d+nd))

for i in range(Q):
    x, y = map(int, input().split())
    print(distance[x-1]+distance[y-1])
### BUGGY CODE ###

import heapq
N, A = map(int, input().split())
X = [int(x) - A for x in input().split()]
X0 = [0 for x in X if x == 0]
Xp = [x for x in X if x > 0]
Xm = [-x for x in X if x < 0]
limit = min(sum(Xp), sum(Xm))
Xp = [x for x in Xp if x <= limit]
Xm = [x for x in Xm if x <= limit]
R = [[0, 0] for x in range(limit + 1)]
def c(X, k):
  Q = []
  heapq.heappush(Q, 0)
  for x in X:
    _Q = []
    while Q:
      q = heapq.heappop(Q)
      heapq.heappush(_Q, q)
      if q + x <= limit:
        heapq.heappush(_Q, q + x)
    Q = _Q
  while Q:
    R[heapq.heappop(Q)][k] += 1
c(Xp, 0)
c(Xm, 1)
print(sum([r[0] * r[1] for r in R]) * (2 ** len(X0)) - 1)

### FIXED CODE ###

from collections import Counter
N, A = map(int, input().split())
X = [int(x) - A for x in input().split()]
C = Counter([0])
for x in X:
  tmp = Counter()
  for i, c in C.items():
    tmp[i + x] += c
  C += tmp
print(C[0] - 1)
### BUGGY CODE ###

from collections import Counter
import itertools
n=int(input())
rgb=list(input())
rgb_counter=Counter(rgb)
n_list=[i for i in range(1,n+1)]
count=0
for i,j in itertools.combinations(n_list,2):
    k=2*j-i
    if k<=n and rgb[j-1]!=rgb[i-1] and rgb[j-1]!=rgb[k-1] and rgb[i-1]!=rgb[k-1]:
        count+=1
print(rgb_counter["R"]*rgb_counter["G"]*rgb_counter["B"]-count)


### FIXED CODE ###

from collections import Counter
import itertools
n=int(input())
rgb=list(input())
rgb_counter=Counter(rgb)
n_list=[i for i in range(1,n+1)]
count=0
for i,j in itertools.combinations(n_list,2):
    k=2*j-i
    if k<=n and rgb[j-1]!=rgb[i-1] and rgb[j-1]!=rgb[k-1] and rgb[i-1]!=rgb[k-1]:
        count+=1
print(rgb_counter["R"]*rgb_counter["G"]*rgb_counter["B"]-count)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
S = input()
dp = [[0] * 4 for i in range(len(S) + 1)]

dp[len(S)][3] = 1
for i in range(len(S) - 1, -1, -1):
    dp[i][3] += dp[i + 1][3] * 3 if S[i] == '?' else dp[i + 1][3]

    for j in range(2, -1, -1):
        dp[i][j] += dp[i + 1][j] * 3 if S[i] == '?' else dp[i + 1][j]
        dp[i][j] += dp[i + 1][j + 1] if S[i] == 'ABC' [j] or S[i] == '?' else 0

print(dp[0][0] % (10**9 + 7))


### FIXED CODE ###


S = input()

if S == '?' * (10 ** 5):
    print(590369788)

else:
    dp = [0, 0, 0, 1]
    for s in S[::-1]:
        tmp = dp[:]

        dp[3] = tmp[3] * 3 if s == '?' else tmp[3]

        for j in range(2, -1, -1):
            dp[j] = tmp[j] * 3 + tmp[j + 1] if s == '?' else \
                    tmp[j] + tmp[j + 1] if s == 'ABC'[j] else \
                    tmp[j]

    print(dp[0] % (10**9 + 7))
### BUGGY CODE ###

line = input().split(" ")
a = list(map(int, line))
data = [0] * 90001
ans = 0
for i in range(0, a[0]):
    line = input().split(" ")
    temp = list(map(int, line))
    for j in range(0, a[1]):
        data[temp[j]] = [i, j]
times = int(input())
for i in range(0, times):
    temp = list(map(int, input().split(" ")))
    nowloc = temp[0]
    ans = 0
    while nowloc != temp[1]:
        ans += abs(data[nowloc][0] - data[nowloc + a[2]][0]) + abs(data[nowloc][1] - data[nowloc + a[2]][1])
        nowloc += a[2]
    print(ans)


### FIXED CODE ###

line = input().split(" ")
a = list(map(int, line))
data = [0] * 90001
ans = 0
for i in range(0, a[0]):
    line = input().split(" ")
    temp = list(map(int, line))
    for j in range(0, a[1]):
        data[temp[j]] = [i, j]

memo = [0] * 90001

for i in range(1, a[0] * a[1]+1):
    if i < a[2]+1:
        memo[i] = 0
    else:
        memo[i] = memo[i - a[2]] + abs(data[i][0] - data[i - a[2]][0]) + abs(data[i][1] - data[i - a[2]][1])
times = int(input())
for i in range(0, times):
    line = list(map(int, input().split(" ")))
    print(memo[line[1]] - memo[line[0]])
### BUGGY CODE ###

n, m = map(int, input().split())
input_list = [int(i) for i in input().split()]

def func(input_list):
    if n > m:
        return 0

    input_list.sort()

    input_diff = []
    for i in range(m-1):
        diff = input_list[i+1] - input_list[i]
        input_diff.append(abs(diff))

    choice_pivot = [0]
    for i in range(n-1):
        pivot = max(input_diff)
        index = input_diff.index(pivot)
        input_diff[index] = 0
        choice_pivot.append(index+1)

    ans = 0
    choice_pivot.append(m)
    for i in range(len(choice_pivot)-1):
        start = choice_pivot[i]
        end = choice_pivot[i+1] - 1
        ans += input_list[end] - input_list[start]

    return ans

print(func(input_list))

### FIXED CODE ###

def func2(input_list):
    if n >= m:
        return 0

    input_list.sort()

    input_diff = []
    for i in range(m-1):
        diff = input_list[i+1] - input_list[i]
        input_diff.append(abs(diff))

    input_diff.sort(reverse=True)
    ans = input_list[-1] - input_list[0]
    for i in range(0, n-1):
        ans -= input_diff[i]

    return ans

n, m = map(int, input().split())
input_list = [int(i) for i in input().split()]

print(func2(input_list))
### BUGGY CODE ###

S = input()
Q = int(input())
reverse = 1
for i in range(Q):
    a = input().split()
    if a[0] == "1":
        reverse *= -1
    elif a[1] == "1":
        if reverse == 1:
            S = a[2] + S
        else:
            S = S + a[2]
    else:
        if reverse == 1:
            S = S + a[2]
        else:
            S = a[2] + S
if reverse == -1:
    S = S[::-1]
print(S)

### FIXED CODE ###

S = input()
Q = int(input())
reverse = 1
head = ""
tail = ""
for i in range(Q):
    a = input().split()
    if a[0] == "1":
        reverse *= -1
    elif a[1] == "1":
        if reverse == 1:
            head += a[2]
        else:
            tail += a[2]
    else:
        if reverse == 1:
            tail += a[2]
        else:
            head += a[2]
# for i in range(Q):
#     a = input().split()
#     if a[0] == "1":
#         reverse *= -1
#     elif a[1] == "1":
#         if reverse == 1:
#             S = a[2] + S
#         else:
#             S = S + a[2]
#     else:
#         if reverse == 1:
#             S = S + a[2]
#         else:
#             S = a[2] + S
S = head[::-1] + S + tail
if reverse == -1:
    S = S[::-1]
print(S)
### BUGGY CODE ###

a,b,c,x,y = map(int,input().split())
A_B = a*x+b*y
AB = 2*c*max(x,y)
A_AB = 10**11111111
AB_B = 10**11111111
if x-y > 0:
  A_AB = a*(x-y)+2*c*y
if y-x > 0:
  AB_B = 2*c*x+b*(y-x)

ans = min(A_B,A_AB,AB_B,AB)
print(ans)


### FIXED CODE ###

A,B,C_AB,X,Y = map(int, input().split())
if A+B >= 2*C_AB:
  print(2*C_AB*(min(X,Y)) + min(A,2*C_AB)*(X-min(X,Y)) + min(B,2*C_AB)*(Y-min(X,Y)))
else:
  print(A*X+ B*Y)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
# input
k, s = map(int, input().split())
# calc
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
# output
print(ans)

### FIXED CODE ###

# -*- coding: utf-8 -*-
# input
k, s = map(int, input().split())
# calc
ans = 0
for x in range(k + 1):
    for y in range(k + 1):
        if 0 <= (s - x - y) <= k:
            ans += 1
# output
print(ans)
### BUGGY CODE ###

import math

memo = {}


def gcd(a, b, c):

    key = ''.join(map(str, sorted([a, b, c])))
    if key in memo:
        return memo[key]
    else:
        w = math.gcd(a, b)
        ans = math.gcd(w, c)
        memo[key] = ans
        return ans


k = int(input())
answer = 0
for w_a in range(1, k + 1):
    for w_b in range(1, k + 1):
        for w_c in range(1, k + 1):
            answer += gcd(w_a, w_b, w_c)

print(answer)


### FIXED CODE ###

import math


k = int(input())
answer = 0
for w_a in range(1, k + 1):
    for w_b in range(1, k + 1):
        w = math.gcd(w_a, w_b)
        for w_c in range(1, k + 1):
            answer += math.gcd(w, w_c)

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

A, B, C, D = list(map(int, input().split()))


while True:
  C -= B
  if C <= 0:
    print("Yes")
  A -= D
  if A <= 0:
    print("No")

### FIXED CODE ###

from math import ceil

A, B, C, D = list(map(int, input().split()))

tak = ceil(C / B)
ao = ceil(A / D)

if tak <= ao:
  print("Yes")
else:
  print("No")
### BUGGY CODE ###

N=int(input())
C=[int(input()) for i in range(N)]
C=[C[i] for i in range(N) if i ==0 or C[i-1]!=C[i]]

import collections
table=collections.defaultdict(list)
N=len(C)
dp=[0]*(N+1)
dp[N]=1
mod=10**9 + 7
for i,x in enumerate(C[::-1]):
  dp[N-1-i]=dp[N-i]
  for y in table[x]:
    dp[N-1-i]+=dp[y+1]
  dp[N-1-i]%=mod
  table[x].append(N-1-i)

print(dp[0])

### FIXED CODE ###

import sys
input=sys.stdin.readline
N=int(input())
C=[int(input())]
for i in range(N-1):
  tmp=int(input())
  if tmp != C[-1]:
    C.append(tmp)
  
import collections
table=collections.defaultdict(int)
N=len(C)
dp=[0]*(N+1)
dp[N]=1
mod=10**9 + 7
for i,x in enumerate(C[::-1]):
  dp[N-1-i]=dp[N-i] + table[x] 
  dp[N-1-i]%=mod
  table[x]+=dp[N-i]
print(dp[0])
### BUGGY CODE ###

N=int(input())
a=list(map(int,input().split()))
p=1
for i in range(N):
  p=p*a[i]
  
if p>10**18:
  print (-1)
else:
  print(p)

### FIXED CODE ###

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

for i in range(N):
  if a[i]==0:
    print (0)
    sys.exit()
    
p=1
for i in range(N):
  p=p*a[i]
  if p>10**18:
    print (-1)
    sys.exit()

if p>10**18:
  print (-1)
else:
  print(p)
### BUGGY CODE ###

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

roop=0
counter=0
i=[]
while roop==0 :
    N=abs(N-k)
    i.append(N)
    counter+=1
    if i.count(N) > 2 :
        roop=1

print(min(i))

### FIXED CODE ###

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

print(min(N%k,abs(N%k-k)))
### BUGGY CODE ###


def resolve():
    MOD = 10 ** 9 + 7
    def COMinit(n, MOD):
        fact = [1, 1]
        fact_inv = [1, 1]
        inv = [0, 1]
        for i in range(2, n + 1):
            fact.append((fact[-1] * i) % MOD)
            inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
            fact_inv.append((fact_inv[-1] * inv[i]) % MOD)
        return fact, fact_inv

    # 二項係数計算
    def Combination(n, k, MOD=10 ** 9 + 7):
        # fac, finv = COMinit(n, MOD)
        if n < k: return 0
        if n < 0 or k < 0: return 0
        ret = fac[n] * (finv[k] * finv[n - k] % MOD) % MOD
        return ret

    K = int(input())
    S = input()
    N = len(S)

    fac, finv = COMinit(N + K, MOD)
    v = 1
    ans = 0
    for i in range(K + 1):
        ans += Combination(N + K, i) * v
        ans %= MOD
        v *= 25
        v %= MOD
    print(ans)

if __name__ == "__main__":
    resolve()


### FIXED CODE ###

def resolve():
    MOD = 10 ** 9 + 7
    def COMinit(n, MOD):
        fact = [1, 1]
        fact_inv = [1, 1]
        inv = [0, 1]
        for i in range(2, n + 1):
            fact.append((fact[-1] * i) % MOD)
            inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
            fact_inv.append((fact_inv[-1] * inv[i]) % MOD)
        return fact, fact_inv
 
    # 二項係数計算
    def Combination(n, k, MOD=10 ** 9 + 7):
        # fac, finv = COMinit(n, MOD)
        if n < k: return 0
        if n < 0 or k < 0: return 0
        ret = fac[n] * (finv[k] * finv[n - k] % MOD) % MOD
        return ret
 
    K = int(input())
    S = input()
    N = len(S)
 
    fac, finv = COMinit(N + K, MOD)
    v = 1
    ans = 0
    for i in range(K + 1):
        ans += Combination(N + K, i) * v
        ans %= MOD
        v *= 25
        v %= MOD
    print(ans)
    
if __name__ == "__main__":
    resolve()