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

# 盤面座標は8000x8000(x 2)
N = 8000
s = input()
target_x, target_y = map(int, input().split())

# "FTTFF" -> [1, 0, 2]と変換。'F1TF0TF2T'のFだけとる
dat_f = [len(Fcount) for Fcount in s.split("T")]

# マイナスを含むxとyのDP用配列(=x2)を作る +1するのは原点用
# x, yの閾値判定するのが面倒なので倍(=x2)用意する(index error対策)
curmap_x = [False] * ((N * 2 * 2) + 1)
curmap_y = [False] * ((N * 2 * 2) + 1)
nextmap_x = [False] * ((N * 2 * 2) + 1)
nextmap_y = [False] * ((N * 2 * 2) + 1)

# 初期座標 0,0なのだが、最初Fから始まる場合は(x,0)から始まるし、y軸を向きながら処理する
if s[0] == "F":
    start = 1
    curmap_x[N * 2 + dat_f[0]] = True
    direction_x = False
else:
    start = 0
    curmap_x[N * 2] = True
    direction_x = True

# y=0
curmap_y[N * 2] = True

# 処理すべき最初のFから
for i in range(start, len(dat_f)):
    step = dat_f[i]
    if direction_x:
        for j in range(N, N + (N * 2) + 1):
            nextmap_x[j] = True if curmap_x[j - step] or curmap_x[j + step] else False
        curmap_x, nextmap_x = nextmap_x, curmap_x
    else:
        for j in range(N, N + (N * 2) + 1):
            nextmap_y[j] = True if curmap_y[j - step] or curmap_y[j + step] else False
        curmap_y, nextmap_y = nextmap_y, curmap_y

    # くる
    direction_x = not direction_x

print("Yes" if curmap_x[N * 2 + target_x] and curmap_y[N * 2 + target_y] else "No")


### FIXED CODE ###

from pprint import pprint
# 盤面座標は8000x8000(x 2)
N = 8000

s = input()
target_x, target_y = map(int, input().split())

# "FTTFF" -> [1, 0, 2]と変換。'F1TF0TF2T'のこと
dat_f = [len(Fcount) for Fcount in s.split("T")]

# x, yの閾値判定するのが面倒なので倍用意する(index error対策)
# マイナスを含むxとyのDP用配列を作る +1するのは原点用
curmap_x = [False] * ((N * 2 * 2) + 1)
curmap_y = [False] * ((N * 2 * 2) + 1)
nextmap_x = [False] * ((N * 2 * 2) + 1)
nextmap_y = [False] * ((N * 2 * 2) + 1)

# 初期座標 0,0
if s[0] == "F":
    start = 1
    curmap_x[N * 2 + dat_f[0]] = True
    direction_x = False
else:
    start = 0
    curmap_x[N * 2] = True
    direction_x = True
curmap_y[N * 2] = True

# 今がx軸かの判定

for i in range(start, len(dat_f)):
    step = dat_f[i]
    if direction_x:
        for j in range(N, N + (N * 2) + 1):
            nextmap_x[j] = True if curmap_x[j - step] or curmap_x[j + step] else False
        curmap_x, nextmap_x = nextmap_x, curmap_x
    else:
        for j in range(N, N + (N * 2) + 1):
            nextmap_y[j] = True if curmap_y[j - step] or curmap_y[j + step] else False
        curmap_y, nextmap_y = nextmap_y, curmap_y

    direction_x = not direction_x

print("Yes" if curmap_x[N * 2 + target_x] and curmap_y[N * 2 + target_y] else "No")
### BUGGY CODE ###

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

ans = []

for i in range(N-K+1):
    cn = sum(p[i:i+K])
    ans.append(cn)

print((max(ans)+K)/2)


### FIXED CODE ###

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

import numpy as np

data = np.array(p) + 1

Pcum = np.zeros(N + 1, np.int32)
Pcum[1:] = data.cumsum()

length_K_sums = Pcum[K:] - Pcum[0:-K]

print(np.max(length_K_sums)/2)
### BUGGY CODE ###

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

frst_idx = 0
MAX = 0
for i in range(N - K + 1):
    MAX = max(MAX, (sum(p[i : i + K]) + K) * 0.5)
print(MAX)


### FIXED CODE ###

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

MAX = 0
# dp[i] i 番目から i + K - 1 番目までのサイコロの期待値の和
dp = [0] * N
for i in range(N - K + 1):
    if i < 1:
        dp[i] = 0.5 * (sum(p[:K]) + K)
    else:
        dp[i] = dp[i - 1] - 0.5 * p[i - 1] + 0.5 * p[i + K - 1]

    MAX = max(MAX, dp[i])
print(MAX)
### BUGGY CODE ###

n = int(raw_input())
ais = map(int, raw_input().split())
bis = map(int, raw_input().split())
cis = map(int, raw_input().split())


count = 0
ais.sort()
bis.sort()
cis.sort()

for a in ais:
	i,j = 0,0
	while(i < len(bis) and not(bis[i] > a)): i+=1
	while(i < len(bis)):
		while(j < len(cis) and not(cis[j] > bis[i])): j +=1
		if j < len(cis):
			count +=  ( n - j)
		i+=1
print count

### FIXED CODE ###

n = int(raw_input())
ais = map(int, raw_input().split())
bis = map(int, raw_input().split())
cis = map(int, raw_input().split())


count = 0
ais.sort()
bis.sort()
cis.sort()

i,j = 0,0
for b in bis:
	while(i < len(ais) and ais[i] < b):
		i += 1
	while(j < len(cis) and cis[j] <= b):
		j += 1
	count += i * (n - j)
print count
### BUGGY CODE ###

class vertex : 
    def __init__(self) : 
        self.edges = []

    def add_edge(self, u, weight) : 
        self.edges.append((u, weight))


def dfs(graph, V, s) : 
    for node in s : 
        travelled = [0 for _ in xrange(V)]
        if travelled[node] : 
            continue
        
        stack = []
        stack.append((node, 0))

        while stack : 
            index, full_weight = stack.pop()

            for dst, weight in graph[index].edges :
                if travelled[dst] :
                    if travelled[dst] != travelled[index] + weight : 
                        return False
                    continue
                
                travelled[dst] = travelled[index] + weight
                stack.append((dst, travelled[index] + weight))

    
    return True


V, E = map(int, raw_input().strip().split(' '))

graph = [vertex() for _ in xrange(V)]

memo  = [False for _ in xrange(V)]
s     = set([])
for _ in xrange(E) : 
    l, r, d = map(int, raw_input().strip().split(' '))
    l -= 1
    r -= 1
    graph[l].add_edge(r, d)
    memo[r] = True
    s.add(l)
    s.add(r)


if dfs(graph, V, s) :
    print "Yes"
else : 
    print "No"



### FIXED CODE ###

class vertex : 
    def __init__(self) : 
        self.edges = []

    def add_edge(self, v, weight) : 
        self.edges.append((v, weight))



def dfs(graph, V, memo, d) : 
    for node in [i for (i, b) in enumerate(memo) if not b and i in d] :
        travelled = [0 for _ in xrange(V)]
        if travelled[node] : 
            continue
        
        stack = []
        stack.append((node, 0))
        
        while stack : 
            index, full_weight = stack.pop()
            d[index] = True
            
            for dst, weight in graph[index].edges :
                if travelled[dst] :
                    if travelled[dst] != travelled[index] + weight : 
                        return False
                    continue
                
                travelled[dst] = travelled[index] + weight
                stack.append((dst, travelled[index] + weight))
    
    return True


V, E = map(int, raw_input().strip().split(' '))

graph = [vertex() for _ in xrange(V)]

memo  = [False for _ in xrange(V)]
di    = {}
for _ in xrange(E) : 
    l, r, d = map(int, raw_input().strip().split(' '))
    l -= 1
    r -= 1
    graph[l].add_edge(r, d)
    memo[r] = True
    di[l] = False
    di[r] = False

if dfs(graph, V, memo, di) :
    for k in di : 
        if not di[k] : 
            print "No"
            break
    else : 
        print "Yes"
else : 
    print "No"
### BUGGY CODE ###

import numpy as np

N, K, Q = map(int, input().split())
A = np.array([int(input()) for i in range(Q)])
  
points = np.full(N, K) - Q

correct_num = []
for i in range(1, N+1):
  correct_num = len(np.where(A==i)[0])
  fin_point = points[i-1] + correct_num
  
  if fin_point > 0:
    print("Yes")
  else:
    print("No")  

### FIXED CODE ###

import numpy as np

N, K, Q = map(int, input().split())
A = np.array([int(input()) for i in range(Q)])
  
points = np.full(N, K-Q)

for i in range(0, Q):
  points[A[i]-1] += 1
 
for i in points:
  if i > 0:
    print("Yes")
  else:
    print("No")
### BUGGY CODE ###

n,q = map(int,input().split())
s = input()
s = s.replace('AC','aC')
lr = [tuple(map(int,input().split())) for _ in range(q)]
for i in range(q):
  temp = list(s[lr[i][0]-1:lr[i][1]])
  cnt = temp[:-1].count('a')
  print(cnt)

### FIXED CODE ###

n,q = map(int,input().split())
s = input()

ac = [0] * (n - 1)
for i in range(n-1):
  if s[i] == 'A' and s[i+1] == 'C':
    ac[i] = 1

acc = [0] * n
for i in range(n-1):
  acc[i+1] = acc[i] + ac[i]

lr = [tuple(map(int,input().split())) for _ in range(q)]
for i in range(q):
  l = lr[i][0] - 1
  r = lr[i][1] - 1
  print(acc[r] - acc[l])
### BUGGY CODE ###

n,k=map(int,input().split())
c=list(map(int,input().split()))
dp=[0]*n
dp[0]=0
for i in range(1,n):
    dp[i]=min([dp[j]+abs(c[i]-c[j]) for j in range(max(0,i-k),i)])
print(dp[-1])

### FIXED CODE ###

def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    a = [0] * n
    a[0] = 0
    for i in range(1, n):
        a[i] = min([a[j] + abs(h[i] - h[j]) for j in range(max(0, i - k), i)])
    print(a[-1])
 
if __name__ == '__main__':
    main()
### BUGGY CODE ###

#!/usr/bin/env python3
import bisect
import collections
import sys
import math
from fractions import Fraction

sys.setrecursionlimit(1000000)
ACMOD = 1000000007
INF = 1 << 62

MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]", B: "List[int]"):
    ab = collections.defaultdict(lambda: [0, 0])  # [posi][nega]
    zeros = 0
    for i in range(N):
        if A[i] == B[i] == 0:
            zeros += 1
        elif A[i] == 0:
            ab[0][1] += 1
        elif A[i] * B[i] >= 0:
            ab[Fraction(abs(B[i]), abs(A[i]))][0] += 1
        else:
            ab[Fraction(abs(A[i]), abs(B[i]))][1] += 1

    # check B[i] ==0
    ans = 1
    for x, y in ab.values():
        pattern = 1  # not select
        pattern += 2 ** x - 1
        pattern += 2 ** y - 1
        ans = ans * pattern % MOD
    print((ans - 1) % MOD + zeros)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int()] * (N)  # type: "List[int]"
    B = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, A, B)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import bisect
import collections
import sys
import math
from fractions import Fraction

sys.setrecursionlimit(1000000)
ACMOD = 1000000007
INF = 1 << 62

MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]", B: "List[int]"):
    ab = collections.defaultdict(lambda: [0, 0])  # [posi][nega]
    zeros = 0
    for i in range(N):
        if A[i] == B[i] == 0:
            zeros += 1
        elif A[i] == 0:
            ab[0][1] += 1
        elif B[i] == 0:
            ab[0][0] += 1
        elif A[i] * B[i] >= 0:
            v = math.gcd(A[i], B[i])
            ab[(abs(B[i]) // v, abs(A[i]) // v)][0] += 1
        else:
            v = math.gcd(A[i], B[i])
            ab[(abs(A[i]) // v, abs(B[i]) // v)][1] += 1

    # check B[i] ==0
    ans = 1
    for x, y in ab.values():
        pattern = 1  # not select
        pattern += 2 ** x - 1
        pattern += 2 ** y - 1
        ans = ans * pattern % MOD
    print((ans - 1) % MOD + zeros)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int()] * (N)  # type: "List[int]"
    B = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, A, B)


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

def main():
    N_ko, K_kai = map(int, input().split())
    init_light = list(map(int, input().split()))


    for k in range(min(42,K_kai)):
        light_list = [0 for i in range(N_ko)]

        for i in range(N_ko):
            left = max(0, i - init_light[i])
            right = min(N_ko - 1, i + init_light[i])
            
            light_list[left] += 1

            if (right + 1 < N_ko):
                light_list[right + 1] -= 1
            
        for i in range(1, N_ko):
            light_list[i] += light_list[i - 1]
        
        init_light = light_list

    
    print(' '.join(map(str,light_list)))


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    N_ko, K_kai = map(int, input().split())
    init_light = list(map(int, input().split()))


    for k in range(min(42,K_kai)):
        light_list = [0 for i in range(N_ko)]

        for i in range(N_ko):
            left = max(0, i - init_light[i])
            right = min(N_ko - 1, i + init_light[i])
            
            light_list[left] += 1

            if (right + 1 < N_ko):
                light_list[right + 1] -= 1
            
        for i in range(1, N_ko):
            light_list[i] += light_list[i - 1]
        
        init_light = light_list

    
    print(' '.join(map(str,light_list)))


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

N = int(input())
arr = list(map(int, input().split()))
tmp = [0]*(max(arr)+1)
for i in arr:
    tmp[i] += 1
ans = 0
for i in arr:
    if tmp[i] >= 2:
        continue
    flg = True
    for k in range(1,int(i**0.5)+1):
        if i % k == 0:
            if tmp[k] != 0 and i != k:
                flg = False
                break
            if k != i // k:
                if tmp[i // k] != 0 and i // k != i:
                    flg = False
                    break
    if flg:
        ans += 1
print(ans)

### FIXED CODE ###

N = int(input())
arr = list(map(int, input().split()))
arr.sort()
ma = max(arr)
check = [True]*(ma+1)
cnt = [0]*(ma+1)
for i in arr:
    cnt[i] += 1
ans = 0
for i in arr:
    if not check[i]:
        continue
    for k in range(i,ma+1,i):
        check[k] = False
    if cnt[i] <= 1:
        ans += 1
print(ans)
### BUGGY CODE ###

from collections import defaultdict, deque

N = int(input())
S = input()

strList = defaultdict(deque)

for left in range(N):
    sub = [S[left]]
    strList[''.join(sub)].append(left)
    for right in range(left + 1, N):
        sub.append(S[right])
        strList[''.join(sub)].append(left)

ans = 0
for sub, leftList in strList.items():
    leng = len(sub)
    if leftList[0] + leng <= leftList[-1]:
        ans = max(ans, leng)

print(ans)


### FIXED CODE ###

from collections import deque

N = int(input())
S = input()

def isOk(leng):
    hashList = set()
    que = deque([])
    for left in range(N - leng + 1):
        hs = hash(S[left: left + leng])
        if hs in hashList:
            return True
        que.append(hs)
        if len(que) >= leng:
            hashList.add(que.popleft())
    return False

ok = 0
ng = N

while ng - ok > 1:
    mid = (ng + ok) // 2
    if isOk(mid):
        ok = mid
    else:
        ng = mid

print(ok)
### BUGGY CODE ###

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

N = int(input())
Z = []
for i in range(N):
    Z.append(list(map(int, input().split())))

dp = [[0] * N for _ in range(N)]
#print(dp)
dp[0] = Z[0]

for i in range(1,N):
    dp[i][0] = max(dp[i-1][1] + Z[i][0] , dp[i-1][2] + Z[i][0])
    dp[i][1] = max(dp[i-1][0] + Z[i][1] , dp[i-1][2] + Z[i][1])
    dp[i][2] = max(dp[i-1][0] + Z[i][2] , dp[i-1][1] + Z[i][2])
    #print(dp)

print(max(dp[-1]))


### FIXED CODE ###

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

N = int(input())
Z = []
for i in range(N):
    Z.append(list(map(int, input().split())))

dp = [[0] * 3 for _ in range(N)]
#print(dp)
dp[0] = Z[0]

for i in range(1,N):
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + Z[i][0]
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + Z[i][1]
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + Z[i][2]
    #print(dp)

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

n = int(input())
s = list(input())
r = [i for i, x in enumerate(s) if x == "R"]
g = [i for i, x in enumerate(s) if x == "G"]
b = [i for i, x in enumerate(s) if x == "B"]
ans = len(r) * len(g) * len(b)
if len(b) < len(g):
    g, b = b, g
elif len(b) < len(r):
    r, b = b, r
else:
    pass
for i in r:
    for j in g:
        i_ = min(i, j)
        j_ = max(i, j)
        div = (j_ - i_)
        if i_ - div in b:
            ans -= 1
        if div % 2 == 0:
            k_2 = div // 2 + i_
            if div // 2 + i_ in b:
                ans -= 1
        if div + j_ in b:
            ans -= 1
print(ans)

### FIXED CODE ###

n = int(input())
s = list(input())
r = [i for i, x in enumerate(s) if x == "R"]
g = [i for i, x in enumerate(s) if x == "G"]
b = [i for i, x in enumerate(s) if x == "B"]
ans = len(r) * len(g) * len(b)

for i in r:
    for j in g:
        i_ = min(i, j)
        j_ = max(i, j)
        div = (j_ - i_)
        k_1 = i_ - div
        k_2 = div // 2 + i_
        k_3 = div + j_
        if k_1 >= 0 and s[k_1] == "B":
            ans -= 1
        if div % 2 == 0 and s[k_2] == "B":
            ans -= 1
        if k_3 < n and s[k_3] == "B":
            ans -= 1
print(ans)
### BUGGY CODE ###

n, m = [int(i) for i in input().split()]
a = []
for i in range(m):
  a.append(int(input()))

if 1 in a:
  step = [1,0]
else:
  step = [1,1]

for i in range(2, n + 1):
  if i in a:
    step.append(0)
  else:
    step.append((step[-1] + step[-2])%1000000007)
    
print(step[-1])

### FIXED CODE ###

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

a = [int(input()) for i in range(m)]

a.append(n + 1)
a.insert(0, -1)
b = [i-j-1 for i,j in zip(a[1:], a[:-1])]

mm = max(b) - 1

step = [0,1]

for i in range(mm):
	step.append(step[-1] + step[-2])

mul = 1
for i in b:
	mul *= step[i]
	
print(mul%1000000007)
### BUGGY CODE ###

n = int(input())
d = {}
for i in range(0,n):
  c = input()
  if c in d:
    d[c] +=1
  else:
    d[c] = 1
max_k_list = [kv[0] for kv in d.items() if kv[1] == max(d.values())]
max_k_list.sort()
for i in range(0,len(max_k_list)):
  print(max_k_list[i])

### FIXED CODE ###

q=int(input())
dic={}
for i in range(q):
    s=input()
    if not s in dic:
        dic[s]=1
    else:
        dic[s]+=1
max_val=max(dic.values())
a=sorted([i for i, k in dic.items() if k == max_val])
for i in a:
    print(i)
### BUGGY CODE ###

from math import factorial as f


def nCr(n, r):
  return f(n) // (f(r) * f(n-r))


def main():
  n = int(input())
  a = list(map(int, input().split()))
  a.sort()
  
  max_comb = 0
  r = 0
  for i in range(n-1):
    tmp = nCr(a[-1], a[i])
    if tmp > max_comb:
      max_comb = tmp
      r = a[i]
  ans = "{} {}".format(a[-1], r)
  print(ans)

  
if __name__ == "__main__":
  main()


### FIXED CODE ###

def main():
  n = int(input())
  a = list(map(int, input().split()))
  a.sort()
  
  r = 0
  c = a[-1] / 2
  for i in range(n-1):
    if abs(c-r) > abs(c-a[i]):
      r = a[i]
  ans = "{} {}".format(a[-1], r)
  print(ans)

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

import numpy as np
N = int(input()) #1行目のNを取得する
s = [input() for i in range(N)] #複数行の数値の入力を取得

max_ind = [i for i, a in enumerate(s) if a == max(s)]
max_num = max(s)

if len(max_ind) > 1:
    for i in range(N):
        print(max_num)

else:
    max_ind = s.index(max(s))
    max_num = max(s)
    s.pop(max_ind)
    max2_num = max(s)

    for i in range(N):
        if i == max_ind:
            print(max2_num)
        else:
            print(max_num)


### FIXED CODE ###

N = int(input()) #1行目のNを取得する
s = []
s = [int(input()) for i in range(N)] #複数行の数値の入力を取得

max_num = max(s)
max_ind = s.index(max_num)
s.remove(max_num)
max2_num = max(s)
 
for i in range(N):
    if i == max_ind:
        print(max2_num)
    else:
        print(max_num)
### BUGGY CODE ###

n=int(input())
S=input()
print(min([S[:i-1].count('W')+S[i:].count('E') for i in range(1,n)]))

### FIXED CODE ###

n=int(input())
S=input()
W=[0]*n
E=[0]*n
for i in range(1,n):
  if S[i-1]=='W':
    W[i]=W[i-1]+1
  else:
    W[i]=W[i-1]
for i in range(n-1,0,-1):
  if S[i]=='E':
    E[i-1]=E[i]+1
  else:
    E[i-1]=E[i]
print(min([W[i]+E[i] for i in range(n)]))
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
A = [0] + A
ans = 0
i = 1
while i < len(A):
    if A[i] == i:
        i += 1
    else:
        ans += 1
        A.pop(i)
if ans >= N:
    ans = -1
print(ans)


### FIXED CODE ###

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

ans = 0
num = 1
for a in A:
    if a == num:
        num += 1
    else:
        ans += 1

if ans == N:
    ans = -1

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

N = int(input())
A = [int(x) for x in input().split()]
a = 1
U = 10**18
for x in A:
    a *= x
if a > U:
    a = -1
print(a)
    


### FIXED CODE ###

N = int(input())
A = [int(x) for x in input().split()]
U = 10**18

def main(A):
    a = 1
    for x in A:
        if x == 0:
            return 0
    for x in A:
        a *= x
        if a > U:
            return -1
    return a

print(main(A))
### BUGGY CODE ###

k=int(input())
s=len(input())

def cmb(n,r,mod):
  if r<0 or n<r:
    return 0
  r=min(r,n-r)
  return g1[n]*g2[r]*g2[n-r]%mod

mod=10**9+7

g1=[1,1]#元table
g2=[1,1]#逆元table
inv=[0,1]#逆元table計算用

for i in range(2,k+s+1):
  g1.append(g1[-1]*i%mod)
  inv.append(-inv[mod%i]*(mod//i)%mod)
  g2.append(g2[-1]*inv[-1]%mod)

ans=1
for i in range(1,k+1):
  ans=(ans*26+cmb(i+s-1,s-1,mod)*pow(25,i,mod))%mod
print(ans)

### FIXED CODE ###

k=int(input())
s=len(input())

def cmb(n,r,mod):
  if r<0 or n<r:
    return 0
  r=min(r,n-r)
  return g1[n]*g2[r]*g2[n-r]%mod

mod=10**9+7

g1=[1,1]#元table
g2=[1,1]#逆元table
inv=[0,1]#逆元table計算用

for i in range(2,k+s+1):
  g1.append(g1[-1]*i%mod)
  inv.append(-inv[mod%i]*(mod//i)%mod)
  g2.append(g2[-1]*inv[-1]%mod)

ans=1
for i in range(1,k+1):
  ans=(ans*26+cmb(i+s-1,s-1,mod)*pow(25,i,mod))%mod
print(ans)
### BUGGY CODE ###

def main():
  n=int(input())
  a=tuple(map(int,input().split()))
  mod=pow(10,9)+7
  ans=0
  for i in range(n-1):
    for j in range(i+1,n):
      ans=(ans+(a[i]^a[j])%mod)%mod
  print(ans)
if __name__=='__main__':
  main()

### FIXED CODE ###

def main():
  import sys
  input = sys.stdin.readline
  import numpy as np
  n=int(input()) 
  a=np.array(list(map(int,input().split())))
  mod=pow(10,9)+7
  ans=0
  
  for i in range(60):
    x=np.count_nonzero(a & 1)
    ans+=pow(2,i,mod)*x*(n-x)
    ans=ans%mod
    a=a>>1
  print(ans)
if __name__=='__main__':
  main()
### BUGGY CODE ###

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
 
h = []
i = 0
s = 1
 
ans = 0
while i < k: 
  g = a[s-1]
  if g not in h:
    h.append(g)
    s = g
    i+=1
  else:
    c = h.index(g)
    l = (k-1-c) % (i-c)
    ans = h[c+l]
    break
    
if ans == 0:
  ans = h[-1]
 
print(ans)

### FIXED CODE ###

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

s = 1
g = 0
i = 1
history = [s]
flag = [False] * n
flag[0] = True

while True:
    g = a[s-1]
    if flag[g-1] == True:
        break
    else:
        flag[g-1] = True
        history.append(g)
        s = g
        i += 1


x = history.index(g)

if k < i:
    ans = history[k]
else:
    d = (k-x) % (i - x)

    ans = history[x + d]

print(ans)