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

import string
abc = string.ascii_lowercase
s = list(input())
K = int(input())
index = 0
while K > 0:
    if index == len(s) - 1:
        s[index] = abc[(abc.index(s[index]) + K) % 26]
        break
    tmp = 26 - abc.index(s[index])
    if tmp == 26: continue
    if K >= tmp:
        s[index] = 'a'
        index += 1
        K -= tmp
    else:
        index += 1

for i in s:
    print(i, end='')

### FIXED CODE ###

import string
abc = string.ascii_lowercase
s = list(input())
K = int(input())
index = 0
while K > 0:
    if index == len(s) - 1:
        s[index] = abc[(abc.index(s[index]) + K) % 26]
        break
    tmp = 26 - abc.index(s[index])
    if tmp == 26:
        index += 1
        continue
    if K >= tmp:
        s[index] = 'a'
        index += 1
        K -= tmp
    else:
        index += 1

for i in s:
    print(i, end='')
### BUGGY CODE ###

#B - Bishop
H,W = map(int,input().split())

count = 0
for i in range(H):#縦の動き
    for j in range(W):#横の動き
        if (i + j) % 2 == 0:
            count += 1
print(count)

### FIXED CODE ###

#B - Bishop △(TLE,WA)
H,W = map(int,input().split())

count = 0
if H == 1 or W == 1:#コーナーケース(H,Wが1の時どこにも動けない)
    count = 1
elif H % 2 == 0:
    count = (H // 2)*W
else :
    count = (H // 2)*W + ((W + 2 - 1) // 2)#x/yの切り上げ:(x+y-1)//y
print(count)
### BUGGY CODE ###

import sys

def mink(numk,l):
    x = 1
    for _ in range(k):
        x = a[x-1]
    return x

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

# kが小さい時
if k <= 10**14:
    print(mink(k,a))
    sys.exit()

z = 1
p = [1]
for _ in range(k):
    z = a[z-1]
    if z in p:
        p.append(z)
        break
    p.append(z)

# 周期の来る前の回数
num = p.index(p[-1])

p = p[num:]

# 周期
pn = len(p)-1

k -= num

# 回数/周期のあまり
anum = k%pn
print(p[anum])


### FIXED CODE ###

import sys

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

p = [1]
for i in range(n):
    p.append(a[p[i]-1])

if k <= n:
    print(p[k])
else:
    # 周期の来る前の回数
    num = p.index(p[-1])
    p = p[num:]

    # 周期
    pn = len(p)-1
    k -= num

    # 回数/周期のあまり
    ans = k%pn
    print(p[ans])
### BUGGY CODE ###

n, h = map(int, input().split())
A = []
B = []
for i in range(n):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)
#manipulation
count = 0
B = [b for b in B if b >= max(A)]
count += len(B)
h -= sum(B)
count += h // max(A)
if h % max(A) != 0:
    count += 1
#output
print(count)

### FIXED CODE ###

#input
n, h = map(int, input().split())
A = []
B = []
for i in range(n):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)
#manipulation
count = 0
a = max(A)
B.sort(reverse=True)
for b in B:
    if (b > a) & (h > 0):
        h -= b
        count += 1
if h > 0:
    count += (h + a - 1) // a
#output
print(count)
### BUGGY CODE ###

def XOR(A, B):
    BA = bin(A)
    BA = int(BA[2:])
    BB = bin(B)
    BB = int(BB[2:])
    result = BA + BB
    result = str(result)
    result = result.replace('2', '0')
    result = int(result, 2)
    return result


L1 = input()
L2 = input()
L1 = L1.split()
L2 = L2.split()
for i, val in enumerate(L1):
    L1[i] = int(val)
for i, val in enumerate(L2):
    L2[i] = int(val)
K = L1[1]
if K > 10:
    lenK = len(bin(K))
    flag = 1
    count = K-1
    while flag == 1:
        countNow = len(bin(count))
        if countNow < lenK:
            flag = 0
        count -= 1
else:
    count = 0
maxInt = 0
sumInt = 0
for i in range(count, L1[1]+1, 1):
    for j in range(L1[0]):
        sumInt += XOR(i, L2[j])
    if sumInt > maxInt:
        maxInt = sumInt
    sumInt = 0
print(maxInt)


### FIXED CODE ###

def XOR(A, B):
    BA = int(A)
    BB = int(B)
    result = BA + BB
    result = str(result)
    result = result.replace('2', '0')
    result = int(result, 2)
    return result


L1 = input()
L2 = input()
L1 = L1.split()
L2 = L2.split()
for i, val in enumerate(L1):
    L1[i] = int(val)
K = L1[1]
K = bin(K)
K = K[2:]
lenK = len(K)
L3 = []
for i, val in enumerate(L2):
    L2[i] = int(val)
    L2[i] = bin(L2[i])
    lenL2i = len(L2[i])-2
    L2[i] = L2[i][2:]
    if lenL2i < lenK:
        dif = lenK - lenL2i
        for a in range(dif):
            L2[i] = '0' + L2[i]
        L3.append(L2[i])
    elif lenL2i == lenK:
        L3.append(L2[i])
    else:
        dif = lenL2i - lenK
        L3.append(L2[i][dif:])
final = ''
judgeFlag = 0
i = 0
finalJudge = 0
# print('K'+K)
if K == '0':
    final = '0'
else:
    while i < lenK:
        # print('roop'+str(i))
        # print(final)
        # print('judgeFlag' + str(judgeFlag))
        # print('finalJudge' + str(finalJudge))
        if (judgeFlag == 1) & (finalJudge == 0):
            if K[i] == '0':
                final += '0'
                i += 1
            else:
                # print(i)
                count_0 = 0
                count_1 = 0
                for each in L3:
                    if each[i] == '0':
                        count_1 += 1
                    else:
                        count_0 += 1
                if count_1 >= count_0:
                    final += '1'
                    judgeFlag = 1
                else:
                    final += '0'
                    finalJudge = 1
                i += 1
        else:
            # print(i)
            count_0 = 0
            count_1 = 0
            for each in L3:
                if each[i] == '0':
                    count_1 += 1
                else:
                    count_0 += 1
            if count_1 >= count_0:
                final += '1'
                judgeFlag = 1
            else:
                final += '0'
                finalJudge = 1
            i += 1
sumInt = 0
for each in L2:
    sumInt += XOR(final, each)
# print(final)
print(sumInt)
### BUGGY CODE ###


s = list(input())
s2 = s.copy()

for i in range(len(s2)):
    if "x" in s2:
        s2.remove("x")
        
def cycle_check(S , level):
    
    # 回文になっているかどうかのみ
    if level == 1:
        for i in range(len(S)//2):
            if S[i] != S[-i-1]:
                return True
        else:
            return False
    
    # 必要なxの個数
    if level == 2:
        x_cnt = 0
        x_list = []
        for s in S:
            if s != "x":
                if x_cnt > 0:
                    x_list.append(x_cnt)
                x_list.append(0)
                x_cnt = 0
            else:
                x_cnt += 1
        
        if x_cnt > 0:
            x_list.append(x_cnt)
        
        ans = 0
        for i in range(len(x_list)//2):
            ans += abs(x_list[i]-x_list[-i-1])
            
        return ans
    
if cycle_check(s2,1):
    print(-1)

else:
    print(cycle_check(s, 2))

### FIXED CODE ###

S = input()
S2 = "".join([s for s in S if s != "x"])

if S2 != S2[::-1]:
    print(-1)
    exit()

A = []
cnt = 0
for s in S:
    if s != "x":
        A.append(cnt)
        cnt = 0
    else:
        cnt += 1
A.append(cnt)

ans = 0
for i in range(len(A) // 2):
    ans += abs(A[i] - A[-i-1])
print(ans)
### BUGGY CODE ###

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

for i in range(n):
    for j in range(i+1,n):
        ans += a[i] * a[j]
        

print(ans%(1000000000+7))


### FIXED CODE ###

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

for i in range(n):
    
    keisu[i] += t
    t += a[i]


for i in range(n):
    ans += a[i] * keisu[i]

        
        

print(ans%(1000000000+7))
### BUGGY CODE ###

S = input()
N=len(S)
ans=[0]*N
index=[]#このインデックスの上に来たら探索終了
mmm=10**100
for i in range(N-1):
  if (S[i]=="R" and S[i+1]=="L"):
    index.append(i)

for i in range(N):
  position=i
  count=0
  while(count<mmm):
    if position in index:
      ans[position+(mmm-count)%2]+=1
      break
    else:
      count+=1
      if S[position]=="R":
        position+=1
      elif S[position]=="L":
        position-=1
print(' '.join(map(str, ans)))

### FIXED CODE ###

S=input()
"""
#最終的にどこかに収束するはず
#Rから出発した人はLがある場所まで進み、あとはLとRで反復
Lも同様

"""
ans=[0]*len(S)
R,L=0,0
points=[]#i,i+1、R,Lの4要素リストが格納
for i in range(len(S)-1):
    if S[i]=="R" and S[i+1]=="R":#RかLが連続している
        R+=1
    elif S[i]=="L" and S[i+1]=="L":#RかLが連続している
        L+=1
    #みんなが集まるポイント
    elif S[i]=="R" and S[i+1]=="L":
        if ans[i]==0:
            ans[i]=1
        if ans[i+1]==0:
            ans[i+1]=1
        #今まで数えてきたRを足す
        ans[i]+=R//2
        ans[i+1]+=R//2+R%2#余りはもらう
        points=[i,i+1]
        R=0#R区間初期化
    #ここまで数えてきたLを前の数値に足す
    elif S[i]=="L" and S[i+1]=="R":
        if len(points)>0 and L>0:
            ans[points[0]]+=L//2+L%2#余りはもらう
            ans[points[1]]+=L//2
        L=0#L区間初期化
        points=[]
#拾い残し回収
if L>0 and len(points)>0:
    ans[points[0]]+=L//2+L%2#余りはもらう
    ans[points[1]]+=L//2

map = map(str, ans)
print(' '.join(map))
### BUGGY CODE ###

a, b,n = list(map(int, input().split()))
res = 0
for x in range(1, n+1):
    if res < (a*x)//b - a *(x//b):
        res = (a*x)//b - a *(x//b)
print(res)

### FIXED CODE ###

a, b,n = list(map(int, input().split()))
if b > n:
    print((a*n)//b - a *(n//b))
elif b <= n:
    print((a*(b-1))//b )
### BUGGY CODE ###

n,m=map(int,input().split())
 
#各部屋の通じてる部屋番のリストを作る
l=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    l[a-1].append(b)
    l[b-1].append(a)

#深さのリストを作る
l1=sum(l, []) #一次元化
l1.insert(0,1)
l_depth=list(dict.fromkeys(l1))#深さのリスト
 
#解の出力
print('Yes')
for i in range(1,n):
    #各部屋の通じてる部屋リストを浅い順にソート
    ll=sorted(l[i], key=lambda data:l_depth.index(data))
    print(ll[0])

### FIXED CODE ###

import networkx as nx
n,m=map(int,input().split())
s=[list(map(int,input().split())) for _ in range(m)]
 
g=nx.Graph() #無向グラフ
g.add_edges_from(s) #リストsを参照して頂点（部屋）の追加
di=nx.predecessor(g,source=1)#1から全点までの最短路におけるその点の前の点を表示
 
print("Yes")
for x in range(2,n+1):
      print(di[x][0])
### BUGGY CODE ###

A,B,C,K=map(int,input().split())
if A==B==C:
  print('0')
  exit()
  
else:
  a=A
  b=B
  c=C
  for n in range(K):
    aa=b+c
    bb=a+c
    cc=a+b
    a=aa
    b=bb
    c=cc
    if a-b>10**18:
      print('Unfair')
      exit()
      
print(a-b)

### FIXED CODE ###

A,B,C,K=map(int,input().split())
if A==B==C:
  print('0')
  exit()
  
else:
  if K%2==0:
    key=A-B
    if key>10**18:
      print('Unfair')
    else:
      print(key)
  else:
    key=B-A
    if key>10**18:
      print('Unfair')
    else:
      print(key)
### BUGGY CODE ###

K = int(input())
if K % 2 == 0:
    print(-1)
    exit()
else:
    n = 7
    n_before = 7
    count = 1
    while n % K != 0:
        n = n % K
        count += 1
        n_before = 10 * n_before % K
        n = n + n_before
print(count)


### FIXED CODE ###

K = int(input())
if K % 2 == 0 or K % 5 ==0:
    print(-1)
    exit()
else:
    n = 7
    n_before = 7
    count = 0
    while True:
        count += 1
        n = n % K
        if n == 0:
            print(count)
            exit()
        else:
            n_before = 10 * n_before % K
            n = n + n_before
print(count)
### BUGGY CODE ###

import math
n=int(input())

ans=0
for i in range(1,n):
  num=n-i
  m=round(math.sqrt(num))
  for j in range(1,m+1):
    if num%j==0 and num//j==j:
      ans+=1
    elif num%j==0 and num//j!=j:
      ans+=2
print(ans)

### FIXED CODE ###

import math
n=int(input())
m=round(math.sqrt(n))
ans=0
for i in range(1,n):
  res=n//i
  if n%i==0:
    ans+=res-1
  else:
    ans+=res
print(ans)
### BUGGY CODE ###

h,w=map(int,input().split())
l=[['#' for i in range(w+2)] for j in range(2)]
l[1:1]=[list('#'+input()+'#') for i in range(h)]
p=[]
for i in range(1,h+1):
  for j in range(1,w+1):
    if l[i][j]=='#':
      p.append((i,j))
d=[(-1,0),(1,0),(0,-1),(0,1)]
r=-1
while len(p)!=0:
  r+=1
  s=[]
  for i, j in p:
    for di, dj in d:
      di+=i
      dj+=j
      if l[di][dj]=='.':
        l[di][dj]='#'
        s.append((di,dj))
  p=s
print(r)

### FIXED CODE ###

h,w=map(int,input().split())
l=[['#' for i in range(w+2)] for j in range(2)]
l[1:1]=[list('#'+input()+'#') for i in range(h)]
p=[]
for i in range(1,h+1):
  for j in range(1,w+1):
    if l[i][j]=='#':
      p.append((i,j))
d=[(-1,0),(1,0),(0,-1),(0,1)]
r=-1
while len(p)!=0:
  r+=1
  s=[]
  for i, j in p:
    for di, dj in d:
      di+=i
      dj+=j
      if l[di][dj]=='.':
        l[di][dj]='#'
        s.append((di,dj))
  p=s
print(r)
### BUGGY CODE ###

import math

N=int(input())
A=[0]*N
for i in range(N):
  A[i] = int(input())

S = sum(A)
maxA = max(A)
dp = [[0]*(S+1+maxA-math.ceil(S/2)) for j in range(N+1)]
dp[0][S-math.ceil(S/2)]=1
for i in range(1,N+1):
  for j in range(S+1-math.ceil(S/2)):
    dp[i][j] = dp[i-1][j+A[i-1]]*2 + dp[i-1][j]
bad_r = sum(dp[N])

if S%2 == 0:
  dp2 = [[0]*(S+1+maxA-math.ceil(S/2)) for j in range(N+1)]
  dp2[0][S-math.ceil(S/2)]=1
  for i in range(1,N+1):
    for j in range(S+1-math.ceil(S/2)):
      dp2[i][j] = dp2[i-1][j+A[i-1]] + dp2[i-1][j]
  bad_rg = dp2[N][0]
else:
  bad_rg = 0
  
ans = 3**N - bad_r*3 + bad_rg*3
print(ans%998244353)

### FIXED CODE ###

import sys
import math

input = sys.stdin.readline
N=int(input())
A = [int(input()) for i in range(N)]
mod = 998244353

S = sum(A)
maxA = max(A)
dp = [[0]*(S+1+maxA-math.ceil(S/2)) for j in range(N+1)]
dp[0][S-math.ceil(S/2)]=1
for i in range(1,N+1):
  for j in range(S+1-math.ceil(S/2)):
    dp[i][j] = (dp[i-1][j+A[i-1]]*2 + dp[i-1][j])%mod
bad_r = sum(dp[N])

if S%2 == 0:
  dp2 = [[0]*(S+1+maxA-math.ceil(S/2)) for j in range(N+1)]
  dp2[0][S-math.ceil(S/2)]=1
  for i in range(1,N+1):
    for j in range(S+1-math.ceil(S/2)):
      dp2[i][j] = (dp2[i-1][j+A[i-1]] + dp2[i-1][j])%mod
  bad_rg = dp2[N][0]
else:
  bad_rg = 0
  
ans = 3**N - bad_r*3 + bad_rg*3
print(ans%mod)
### BUGGY CODE ###

MOD = 1000000007

S = input()

a, ab, abc, all_s = 0, 0, 0, 1

for s in S:
    if s == "A":
        a += all_s
    elif s == "B":
        ab += a
    elif s == "C":
        abc += ab
    elif s == "?":
        abc = abc * 3 + ab
        ab = ab * 3 + a
        a = a * 3 + all_s
        all_s = all_s * 3

print(abc % MOD)

### FIXED CODE ###

MOD = 1000000007

S = input()

a, ab, abc, all_s = 0, 0, 0, 1

for s in S:
    if s == "A":
        a = (a + all_s) % MOD
    elif s == "B":
        ab = (ab + a) % MOD
    elif s == "C":
        abc = (abc + ab) % MOD
    elif s == "?":
        abc = (abc * 3 + ab) % MOD
        ab = (ab * 3 + a) % MOD
        a = (a * 3 + all_s) % MOD
        all_s = (all_s * 3) % MOD

print(abc)
### BUGGY CODE ###

#5
n = int(input())

num = [i for i in range(n)]
print(sum(num))

### FIXED CODE ###

#5  [1,2,3,4,5]→[5,1,2,3,4]が最適解　等差数列の和の公式
n = int(input())

print(n*(n-1)//2)
### BUGGY CODE ###

from sys import stdin
N = int(stdin.readline().rstrip())
print(0)
s = input()
cnt = 0
N = (N-1)//2
if s == "Male":
    while True:
        cnt += 1
        if cnt > 25:
            break
        print(N)
        s = input()
        if s == "Male" and N % 2 == 0:
            N += min(N//2,(L-N)//2)
        elif s == "Female" and N % 2 != 0:
            N += min(N//2,(L-N)//2)
        elif s == "Vacant":
            break
        else:
            N -= min(N//2,(L-N)//2)
        
elif s == "Female":
    while True:
        cnt += 1
        if cnt > 25:
            break
        print(N)
        s = input()
        if s == "Female" and N % 2 == 0:
            N += min(N//2,(L-N)//2)
        elif s == "Male" and N % 2 != 0:
            N += min(N//2,(L-N)//2)
        elif s == "Vacant":
            break
        else:
            N -= min(N//2,(L-N)//2)

### FIXED CODE ###

from sys import stdin
N = int(stdin.readline().rstrip())
r = N-1
l = 0
print(0)
s = input()
cnt = 0
mid = (r+l)//2
if s == "Male":
    for _ in range(25):
        print(mid)
        s = input()
        if s == "Male" and mid % 2 == 0:
            l += max((r-l)//2,1)
        elif s == "Female" and mid % 2 != 0:
            l += max((r-l)//2,1)
        elif s == "Vacant":
            break
        else:
            r -= max((r-l)//2,1)
        mid = (r+l)//2
        
elif s == "Female":
    for _ in range(25):
        print(mid)
        s = input()
        if s == "Female" and mid % 2 == 0:
            l += max((r-l)//2,1)
        elif s == "Male" and mid % 2 != 0:
            l += max((r-l)//2,1)
        elif s == "Vacant":
            break
        else:
            r -= max((r-l)//2,1)
        mid = (r+l)//2
### BUGGY CODE ###

import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
# from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

s=input()
ab=[0,0]
ans=0
cnt=0
for i in range(len(s)):
    if s[i]=="A":
        ab[0]+=pow(3,cnt)
    elif s[i]=="B":
        ab[1]+=ab[0]
    elif s[i]=="C":
        ans+=ab[1]
    else:
        ans=ab[1]+3*ans
        ab[1]=ab[0]+3*ab[1]
        ab[0]=pow(3,cnt,mod)+3*ab[0]
        cnt+=1
    ab[0]%=mod
    ab[1]%=mod
    ans%=mod
print(ans%mod)


### FIXED CODE ###

import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
# from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

s=input()
ab=[0,0]
ans=0
cnt=0
for i in range(len(s)):
    if s[i]=="A":
        ab[0]+=pow(3,cnt,mod)
    elif s[i]=="B":
        ab[1]+=ab[0]
    elif s[i]=="C":
        ans+=ab[1]
    else:
        ans=ab[1]+3*ans
        ab[1]=ab[0]+3*ab[1]
        ab[0]=pow(3,cnt,mod)+3*ab[0]
        cnt+=1
    ab[0]%=mod
    ab[1]%=mod
    ans%=mod
print(ans%mod)
### BUGGY CODE ###

INF = float('inf')


def LIST():
    return list(map(int, input().split()))


N, K = LIST()
h = LIST()

# DP配列を初期化
dp = [INF] * N

# 初期条件を入力
dp[0] = 0

# テーブルを更新 もらうDP
for i in range(1, N):
    for j in range(1, min(K, i) + 1):
        dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]))

print(dp[N - 1])

### FIXED CODE ###

import sys

INF = float('inf')

input = sys.stdin.readline


def LIST():
    return list(map(int, input().split()))


N, K = LIST()
h = LIST()

# DP配列を初期化
dp = [INF] * N

# 初期条件を入力
dp[0] = 0

# テーブルを更新 もらうDP
for i in range(1, N):
    x = max(0, i - K)
    dp[i] = min([dp_ + abs(h[i] - h_) for dp_, h_ in zip(dp[x:i], h[x:i])])

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

import sys
#input = sys.stdin.buffer.readline

def main():
    s = str(input())
    l = len(s)
    dp = [[0 for _ in range(13)] for _ in range(l+1)]
    MOD = 10**9+7
    dp[0][0] = 1
    
    for i in range(l):
        for j in range(13):
            if s[i] != "?":
                num = int(s[i])
                dp[i+1][(j*10+num)%13] += dp[i][j]
            else:
                for k in range(10):
                    dp[i+1][(j*10+k)%13] += dp[i][j]
        for j in range(13):
            dp[i+1][j] %= MOD
    
    print(dp[-1][5])

if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
#input = sys.stdin.buffer.readline

def main():
    s = str(input())
    l = len(s)
    ans = [0 for _ in range(13)]
    MOD = 10**9+7
    ans[0] = 1
    
    for st in s:
        dp = [0 for _ in range(13)]
        for i in range(13):
            dp[(10*i)%13] = ans[i]%MOD
        dp += dp
        if st != "?":
            for i in range(13):
                num = int(st)
                ans[i] = dp[i+13-num]
        else:
            for i in range(13):
                ans[i] = sum(dp[i+4:i+14])
    
    print(ans[5]%MOD)

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

N, Q = list(map(int, input().split()))
S = input()
for n in range(Q):
    l, r = list(map(int, input().split()))
    s = S[(l-1):r]
    c = 0
    for a in range(len(s)):
        if s[a] == 'A':
            if a < (len(s) - 1) and s[a+1] == 'C':
                c += 1
                a += 1
    print(c)

### FIXED CODE ###

N, Q = list(map(int, input().split()))
S = input()
w = [0]
v = 0
for a in range(len(S)-1):
    if S[a] == 'A' and S[a+1] == 'C':
        v += 1
    w.append(v)
for n in range(Q):
    l, r = list(map(int, input().split()))
    print(w[r-1] - w[l-1])
### BUGGY CODE ###

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()))

ab_items = []
for a in a_list:
    for b in b_list:
        ab_items.append(a + b)

ab_items.sort(reverse=True)
ab_items = ab_items[:K + 1]

ans = []
for c in c_list:
    for ab in ab_items:
        ans.append(c + ab)

ans.sort(reverse=True)

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


### FIXED CODE ###

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()))

ab_items = []
for a in a_list:
    for b in b_list:
        ab_items.append(a + b)

ab_items.sort(reverse=True)
ab_items = ab_items[:K + 1]

ans = []
for c in c_list:
    for ab in ab_items:
        ans.append(c + ab)

ans.sort(reverse=True)

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

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

max_num = [0]*k
for i in range(n-k+1): 
    if sum(max_num) < sum(p[i:k+i]):
        max_num = p[i:k+i]

ans = [(1+n)/2 for n in max_num]
print(sum(ans))

### FIXED CODE ###

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

max_num = []
tmp = 0
current_sum = sum(p[:k-1])
for i in range(n-k+1):
    current_sum += p[k+i-1]
    if tmp < current_sum:
        max_num = p[i:k+i]
        tmp = current_sum
    current_sum -= p[i]

print(sum([(1+n)/2 for n in max_num]))
### BUGGY CODE ###

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

for i in range(1,N+1):
    print(A.count(i))

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
ans = [0]*N

for i in A:
    ans[i-1] += 1

for j in ans:
    print(j)
### BUGGY CODE ###

N, K = map(int, input().split())
A = [-10**9 -10] + list(map(int, input().split()))
A.sort()
cum_sum = [0]*(N+1)
cum_sum[1] = A[1]
for i in range(2, 1+N):
    cum_sum[i] = cum_sum[i-1] + A[i]
p = 10**9 + 7
def comb(n, r, p):
  X, Y = 1, 1
  for i in range(r):
    X *= n-i
    Y *= i+1
    X %= p
    Y %= p
  return int(X * pow(Y, p-2, p))

combs = [0]*(N+1)
ans = 0
for i in range(K-2, N-1):
    combs[i] = comb(i, K-2, p)
    ans += combs[i] * ((cum_sum[N] % p - cum_sum[i+1] % p) - (cum_sum[N-i-1] % p)) % p

print(ans % p)

### FIXED CODE ###

N, K = map(int, input().split())
A=list(map(int, input().split()))
A.sort()
MOD=10**9+7
s_max = 0
s_min = 0
MAX = 10**5 + 100
def COMinit():
    """
    逆元テーブルをつくる前処理
    計算量はO(n)
    1 <= k <= n <= 1e7程度
    p: 素数
    """
    fac = [0]*MAX
    finv = [0]*MAX
    inv = [0]*MAX

    fac[0], fac[1] = 1, 1
    finv[0], finv[1] = 1, 1
    inv[0], inv[1] = 1, 1
    for i in range(2, MAX):
        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



def comb(n, k):
    """
    nCk mod MODを求める.
    この部分はO(1)
    """
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return int(fac[n] * (finv[k] * finv[n-k] % MOD) % MOD)

fac, finv, inv = COMinit()

for i in range(N):
    s_min += comb(N-i-1, K-1) * A[i]
    s_min %= MOD
for i in range(N-1, -1, -1):
    s_max += comb(i, K-1) * A[i]
    s_max %= MOD
print((s_max - s_min)%MOD)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
b = []
for i in range(n):
  b.append(a.pop(0))
  b = b[::-1]
print(*b)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
print(*A[::-2],end=" ")
print(*A[N%2::2])