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

S=str(input())
Q=int(input())
for i in range(Q):
    T=list(map(str,input().split()))
    if T[0]=="1":
        S=S[::-1]
    else:
        if T[1]=="1":
            S=T[2]+S
        else:S=S+T[2]
print(S)

### FIXED CODE ###

S1=""
S2=""
S=str(input())
Q=int(input())
flag=1
for i in range(Q):
    T=list(map(str,input().split()))
    if T[0]=="1":
        flag*=-1
    else:
        if T[1]=="1":
            if flag==1:
                S1=T[2]+S1
            else: S2=S2+T[2]
        else:
            if flag==1:
                S2=S2+T[2]
            else:S1=T[2]+S1
if flag==1:
    S=S1+S+S2
else:S=S2[::-1]+S[::-1]+S1[::-1]
print(S)
### BUGGY CODE ###

N,M=map(int,input().split())
hune=[]
for a in range(M):
    list=[]
    a,b=input().split()
    list.append(int(a))
    list.append(int(b))
    hune.append(list)
number=0
for a in range(M):
    if hune[a][0]==1:
        c=hune[a][1]
        for b in range(M):
            if hune[b][0]==c and hune[b][1]==N:
                print('POSSIBLE')
                number+=1
                break
            elif hune[b][1]==c and hune[b][0]==N:
                print('POSSIBLE')
                number+=1
                break
if number==0:
    print('IMPOSSIBLE')
    

### FIXED CODE ###

N,M=map(int,input().split())
islands=[[] for _ in range(N)]
for _ in range(M):
    a,b=map(int,input().split())
    islands[a].append(b)
answer=1
for n in islands[1]:
    if N in islands[n]:
        answer=0
        print('POSSIBLE')
        break
if answer==1:
    print('IMPOSSIBLE')
### BUGGY CODE ###

import bisect

n = int(input())
sl = []
for i in range(n):
    s = input()
    index = bisect.bisect_left(sl, s)  # 2 最も左(前)の挿入箇所が返ってきている
    sl.insert(index, s)

# print(sl)
c = 0
anss = []
max_n = 0
for i, t in enumerate(sl):
    if i == 0:
        c += 1
        target = t
        continue

    if t == target:
        c += 1
    else:
        if max_n < c:
            anss = []
            anss.append(target)
            max_n = c
        elif max_n == c:
            anss.append(target)
            max_n = c
        target = t
        c = 1

if max_n < c:
    anss = []
    anss.append(t)
elif max_n == c:
    anss.append(t)


print(*anss)


### FIXED CODE ###

import bisect

n = int(input())
sl = ['']*n
for i in range(n):
    sl[i] = input()
sl = sorted(sl, key=str.lower)
# print(sl)
c = 0
anss = []
max_n = 0
for i, t in enumerate(sl):
    if i == 0:
        c += 1
        target = t
        continue

    if t == target:
        c += 1
    else:
        if max_n < c:
            anss = []
            anss.append(target)
            max_n = c
        elif max_n == c:
            anss.append(target)
            max_n = c
        target = t
        c = 1

if max_n < c:
    anss = []
    anss.append(t)
elif max_n == c:
    anss.append(t)


print(*anss)
### BUGGY CODE ###

import numpy as np
N,K = map(int, input().split())

A_list = np.array([0]+list(map(int, input().split())))
#print(A_np)


for j in range(min(K,46)):
  new_A=np.zeros(N+2,dtype=np.int64)
  for i in range(1,N+1):
    #print(new_A)
    mi=i-A_list[i]
    ma=i+A_list[i]
    if mi<0:
      mi=0
    if ma>N:
      ma=N
    #new_A[mi:ma+1]+=1
    new_A[mi]+=1
    new_A[ma+1]-=1

  A_list=np.cumsum(new_A)
  #if A_list[1:N+1])==N*N:
  #  break
    
for i in range(1,N+1):
  print(A_list[i],end=" ")


### FIXED CODE ###

import numpy as np
from numba import njit

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

A_list = np.array([0]+list(map(int, input().split())))

@njit
def update(A_list):

  for j in range(min(K,46)):
    new_A=np.zeros(N+2,dtype=np.int64)
    for i in range(1,N+1):
      #print(new_A)
      mi=i-A_list[i]
      ma=i+A_list[i]
      if mi<0:
        mi=0
      if ma>N:
        ma=N
      #new_A[mi:ma+1]+=1
      new_A[mi]+=1
      new_A[ma+1]-=1

    A_list=np.cumsum(new_A)
    #if sum(A_list[1:N+1])==N*N:
    #  return(A_list)    
    #  break
      
  return(A_list)

A_list=update(A_list)
for i in range(1,N+1):
  print(A_list[i],end=" ")
### BUGGY CODE ###

import sys
from bisect import bisect_left as bl
input = sys.stdin.readline
N = int(input())
S = list(input())[: -1]
Q = int(input())
qs = list(map(int, input().split()))
cs = [0] * (N + 1)
c = []
for i in range(N):
  cs[i + 1] = cs[i] + (S[i] == "M")
  if S[i] == "C": c.append(i)
ccs = [0] * (len(c) + 1)
for i in range(len(c)):
  ccs[i + 1] = ccs[i] + cs[c[i]]
#print(c, ccs)
for k in qs:
  res = 0
  for i in range(N):
    if S[i] != "D": continue
    l = bl(c, i)
    r = bl(c, i + k)
    res += max(0, ccs[r] - ccs[l] - cs[i] * (r - l))
  print(res)

### FIXED CODE ###

import sys
input = sys.stdin.readline
N = int(input())
S = list(input())[: -1]
Q = int(input())
qs = list(map(int, input().split()))
cs = [0] * (N + 1)
c = []
d = []
for i in range(N):
  cs[i + 1] = cs[i] + (S[i] == "M")
  if S[i] == "C": c.append(i)
  if S[i] == "D": d.append(i)
ccs = [0] * (N + 1)
ccounts = [0] * (N + 1)
for i in range(N):
  ccs[i + 1] = ccs[i] + cs[i] * (S[i] == "C")
  ccounts[i + 1] = ccounts[i] + (S[i] == "C")

#print(cs, c)
#print(ccs)
for k in qs:
  res = 0
  for i in d:
    l = i
    r = min(N, i + k)
    res += max(0, ccs[r] - ccs[l] - cs[i] * (ccounts[r] - ccounts[l]))
  print(res)
### BUGGY CODE ###

import sys
input=sys.stdin.readline
import collections

def main():
    N = int(input())
    Q = []
    for _ in range(N):
        q = collections.deque(map(int, input().split()))
        Q.append(q)
    games = N*(N-1)//2

    days = 0
    while True:
        gamed = [0 for _ in range(N)]
        b = False
        for i in range(len(Q)):
            if gamed[i] > 0 or len(Q[i]) == 0:
                continue
            j = Q[i][0] - 1
            if gamed[j] == 0 and len(Q[j]) > 0:
                if Q[j][0] == i+1:
#                    print("game:", j+1, i+1, days)
                    Q[i].popleft()
                    Q[j].popleft()
                    gamed[i] = 1
                    gamed[j] = 1
                    games -= 1
                    b = True
                    continue
        days += 1
        if not b:
            print(-1)
            return
        if games == 0:
            break

    print(days)
if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input=sys.stdin.readline
from collections import deque

def main():
    N = int(input())
    Q = [deque(map(int, input().split())) for _ in range(N)]
    games = N*(N-1)//2

    days = 0
    nxt = [i for i in range(N)] # 翌日に対戦相手を更新する選手のリスト
    opp = [0]*N # 選手毎の、次の対戦相手のリスト
    while 1:
        days += 1
        for i in nxt:
            opp[i] = Q[i].popleft() - 1 if Q[i] else -1

        tmp = set() # 次の日の更新のため、試合をした選手をメモ
        for i in nxt:
            if i not in tmp and i == opp[opp[i]]:
#                print("game:", i+1, opp[i]+1, days)
                tmp.add(i)
                tmp.add(opp[i])
                games -= 1
        if games == 0:
            break
        elif not tmp:
            print(-1)
            return
        nxt = tmp
    print(days)

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

N,K=map(int,input().split())
A=list(map(int,input().split()))
index=[0]
index.append(A[0]-1)
flag=0
count=0
for _ in range(1,K):
    t=index[-1]
    if (A[t]-1) in index:
        index.append(A[t]-1)
        flag=1
        break
    index.append(A[t]-1)
if flag==0:
    print(index[-1]+1)
    exit()
check = index[-1]
for i,c in enumerate(index):
    if c==check:
        a_path=i
        break
#print(index)
#print("a_path",a_path)
K-=a_path
t=len(index)-1-a_path
#print("t",t)
print(index[a_path+K%t]+1)
#print(index)


### FIXED CODE ###

import bisect
N,K=map(int,input().split())
A=list(map(int,input().split()))
index=[0]
index.append(A[0]-1)
tt=[A[0]-1]
flag=0
count=0
for _ in range(1,K):
    t=index[-1]
    ttt=bisect.bisect_left(tt, A[t]-1)

    if len(tt) > ttt and tt[ttt]==A[t]-1:
        index.append(A[t]-1)
        flag=1
        break
    index.append(A[t]-1)
    bisect.insort(tt,A[t]-1)
if flag==0:
    print(index[-1]+1)
    exit()
#print("a")
#print(index)
check = index[-1]
for i,c in enumerate(index):
    if c==check:
        a_path=i
        break
K-=a_path
t=len(index)-1-a_path
print(index[a_path+K%t]+1)
### BUGGY CODE ###

#D in [S_i-X_i,T_i-X_i) → Xiで止まる
import sys
input = sys.stdin.readline
from heapq import heappush,heappop

N,Q = map(int,input().split())
q = []

STX = [[int(x) for x in input().split()] for _ in range(N)]
for s,t,x in STX:
  heappush(q,(s-x,1,x)) # xで死ぬ
  heappush(q,(t-x,0,x)) # xで死ななくなる
  
D = [int(input()) for _ in range(Q)]
for i,d in enumerate(D):
  heappush(q,(d,2,i))
answer = [-1]*Q

se = set() # 引っかかってる場所

while q:
  a,c,b = heappop(q)
  if c == 2: # queryに答える
    if se:
      answer[b] = min(se)
  elif c == 1:
    se.add(b)
  elif c == 0:
    se.remove(b)

    
for x in answer:
  print(x)


### FIXED CODE ###

#D in [S_i-X_i,T_i-X_i) → Xiで止まる
import sys
input = sys.stdin.readline

N,Q = map(int,input().split())
q = []

STX = [[int(x) for x in input().split()] for _ in range(N)]
for s,t,x in STX:
  q.append((s-x,1,x)) # xで死ぬ
  q.append((t-x,0,x)) # xで死ななくなる

for i in range(Q):
  d = int(input())
  q.append((d,2,i))
answer = [-1]*Q

se = set() # 引っかかってる場所

q.sort()

min_se = 10**18
flag = False # min_seが正しい

for a,c,b in q:
  if not c:
    se.remove(b)
    if min_se == b:
      flag = False
  elif c&1:
    se.add(b)
    if b < min_se:
      min_se = b
      flag = True
  else:
    if se:
      if not flag:
        min_se = min(se)
        flag = True
      answer[b] = min_se

print('\n'.join(map(str,answer)))
### BUGGY CODE ###

def gcd(a, b):
  if(b % a == 0):
    return a
  else:
    ans = 1
    i = 2
    while a!= 1:
      if(a % i == 0):
        while a % i == 0:
          a/= i
        while b % i == 0:
          b/= i
          ans*= i
        i+= 1
    return ans
          

def ggcd(lista):
  if(len(lista) == 1):
    return lista.pop()
  else:
    l = lista.pop()
    for i in range(1, len(lista)):
      l = gcd(l, lista.pop())
    return l

N, X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
d = []
gcds = set()
x.sort()

for i in range(N):
  d.append(x[i+ 1]- x[i])
  
gcds.add(d[0])

for i in range(N- 1):
  if(d[i+ 1] != d[i]):
    gcds.add(d[i+ 1])

print(ggcd(gcds))

### FIXED CODE ###

def gcd(a, b):
  if(a == b):
    return a
  elif(a % b == 0):
    return b
  elif(b % a == 0):
    return a
  elif(a == 1 or b == 1):
    return 1
  elif(a > b):
    return gcd(a- a// b* b, b)
  elif(a < b):
    return gcd(a, b- b// a* a)

def ggcd(lista):
  if(len(lista) == 1):
    return lista.pop()
  else:
    l = lista.pop()
    for i in range(1, len(lista)):
      l = gcd(l, lista.pop())
    return l

N, X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
d = []
gcds = set()
x.sort()

for i in range(N):
  d.append(x[i+ 1]- x[i])

gcds.add(d[0])

for i in range(N- 1):
  if(d[i+ 1] != d[i]):
    gcds.add(d[i+ 1])

print(ggcd(gcds))
### BUGGY CODE ###

H, W = map(int, input().split())
S = ["#" * (W + 2)] + ["#" + input() + "#" for _ in range(H)] + ["#" * (W + 2)]

L = [[0] * (W + 2) for _ in range(H + 2)]
R = [[0] * (W + 2) for _ in range(H + 2)]
U = [[0] * (W + 2) for _ in range(H + 2)]
D = [[0] * (W + 2) for _ in range(H + 2)]

for h in range(H):
    for w in range(W):
        if S[h + 1][w + 1] == '.':
            L[h + 1][w + 1] = L[h + 1][w] + 1
            U[h + 1][w + 1] = U[h][w + 1] + 1
        if S[H - h][W - w] == '.':
            R[H - h][W - w] = R[H - h][W - w + 1] + 1
            D[H - h][W - w] = D[H - h + 1][W - w] + 1

ans = 0
for h in range(H):
    for w in range(W):
        ans = max(L[h + 1][w + 1] + R[h + 1][w + 1]
                  + U[h + 1][w + 1] + D[h + 1][w + 1] - 3, ans)

print(ans)


### FIXED CODE ###

import numpy as np

H, W = map(int, input().split())
S = np.array([list(input()) for _ in range(H)]) == '.'

U = np.zeros((H, W), dtype=int)
D = np.zeros((H, W), dtype=int)
L = np.zeros((H, W), dtype=int)
R = np.zeros((H, W), dtype=int)

for h in range(H):
    U[h] = (U[h - 1] + 1) * S[h]
    D[-(h + 1)] = (D[-h] + 1) * S[-(h + 1)]

for w in range(W):
    L[:, w] = (L[:, w - 1] + 1) * S[:, w]
    R[:, -(w + 1)] = (R[:, -w] + 1) * S[:, -(w + 1)]

print(np.max(U + D + L + R) - 3)
### BUGGY CODE ###

import  math
K = int(input())

ans = 0

for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            ans += math.gcd(math.gcd(a,b),c)

print(ans)

### FIXED CODE ###

import  math
K = int(input())

ans = 0

for a in range(1, K+1):
    for b in range(1, K+1):
        a_b = math.gcd(a,b)
        for c in range(1, K+1):
            ans += math.gcd(a_b,c)

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

from operator import mul
from functools import reduce


def combination(n, r, mod):
    r = min(r, n-r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)

    return (numer // denom) % mod


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

S = len(s)
ans = 0
mod = 10 ** 9 + 7

for i in range(0, n+1):
    com = combination(S-1+i, S-1, mod)
    exp26 = pow(26, n-i, mod)
    exp25 = pow(25, i, mod)

    ans += (com * exp26 * exp25) % mod

ans %= mod

print(ans)

### FIXED CODE ###

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

S = len(s)
mod = 10 ** 9 + 7

tmp_ans = pow(26, n, mod)
div = pow(26, -1, mod)

ans = tmp_ans

for i in range(1, n+1):
    tmp_ans = (tmp_ans * 25 * div) % mod
    tmp_ans = ((tmp_ans * (S-1+i)) * pow(i, -1, mod)) % mod
    ans = (ans + tmp_ans) % mod

ans %= mod

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

R, G, B, N = map(int, input().split())

ans = 0
n_iter_r = N//R + 1
n_iter_g = N//G + 1

for r in range(n_iter_r):
    for g in range(n_iter_g):
        if N - R*r - G*g < 0:
            break
        else:
            if (N - R*r - G*g)%B==0:
                if (N - R*r - G*g)//B >= 0:
                    ans += 1

print(ans)

### FIXED CODE ###

R, G, B, N = map(int, input().split())

ans = 0
n_iter_r = N//R + 1
n_iter_g = N//G + 1

for r in range(n_iter_r):
    for g in range(n_iter_g):
        nokori = N - R*r - G*g
        if nokori < 0:
            break
        else:
            if nokori%B==0:
                ans += 1

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

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

n = int(raw_input())
print 0
status_0 = raw_input()
check = n / 2
if check % 2 == 1:
    check += 1
if status_0 == "Vacant":
    pass
else:
    while 1:
        print check
        status = raw_input()
        if status == "Vacant":
            break
        elif status == status_0:
            check += check / 2
        else:
            check -= check / 2
            


### FIXED CODE ###

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

import sys

n = int(raw_input())
print 0
sys.stdout.flush()
status_0 = raw_input()
start = 0
end = n-1
check = end
i = 1
if status_0 == "Vacant":
    pass
else:
    while 1:
        print check
        sys.stdout.flush()
        status = raw_input()
        if status == "Vacant":
            break
        elif status == status_0:
            if check % 2 == 0:
                start = check
            else:
                end = check
        else:
            if check % 2 == 0:
                end = check
            else:
                start = check
        check = start+(end-start)/2

quit()
### BUGGY CODE ###

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

weight = []
value = []

for i in range(N):
    w, v = list(map(int, input().split()))
    weight.append(w)
    value.append(v)

dp = []

for i in range(N+1):
    dp.append([])
    for j in range(W+1):
        dp[i].append(0)


# max value = dp[何個まで見たか][現在の重さ]
for i in range(N):
    for j in range(W+1):
        if (j+weight[i]) <= W:
            dp[i+1][j+weight[i]] = max(dp[i][j+weight[i]], dp[i][j] + value[i])

        dp[i+1][j] = max(dp[i][j],dp[i+1][j])

print(dp[N][W])


### FIXED CODE ###

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

weight = []
value = []

for i in range(N):
    w, v = list(map(int, input().split()))
    weight.append(w)
    value.append(v)


dp = []

for i in range(N+1):
    dp.append([])
    for j in range(W+1):
        dp[i].append(0)


# max value = dp[何個まで見たか][現在の重さ]
for i in range(N):
    for j in range(W+1):
        if (j+weight[i]) <= W:
            dp[i+1][j+weight[i]] = max(dp[i][j+weight[i]], dp[i][j] + value[i])

        dp[i+1][j] = max(dp[i][j],dp[i+1][j])

print(dp[N][W])
### BUGGY CODE ###

from heapq import heappop, heappush
def main():
    H, W = map(int, input().split())
    sh,sw = map(int, input().split())
    gh,gw = map(int, input().split())
    gh,gw = gh-1,gw-1
    field = [list(input()) for _ in range(H)]

    ret = 10 ** 30
    q = [(0, sh-1, sw-1)]
    visited = set()
    while q:
        cnt, h, w = heappop(q)
        visited.add((h, w))
        if h == gh and w == gw: return cnt
        for i in range(-2, 3):
            for j in range(-2, 3):
                if i == j == 0: continue
                if h+i < 0 or w+j < 0: continue
                if h+i >= H or w+j >= W: continue
                if field[h+i][w+j]  == "#": continue
                if (h+i, w+j) in visited: continue
                if max(i,j) == 1 and min(i,j) == 0:
                    heappush(q, (cnt, h+i, w+j))
                else:
                    heappush(q, (cnt+1, h+i, w+j))
    return -1

print(main())


### FIXED CODE ###

from collections import deque
def main():
    H, W = map(int, input().split())
    sh,sw = map(int, input().split())
    gh,gw = map(int, input().split())
    gh,gw = gh-1,gw-1
    field = [list(input()) for _ in range(H)]
    q = deque()
    q.append((0, sh-1, sw-1))
    INF = 10 ** 30
    dist = [[INF] * W for _ in range(H)]
    dist[sh-1][sw-1] = 0
    while q:
        cnt, h, w = deque.popleft(q)
        if dist[h][w] < cnt: continue
        if h == gh and w == gw: return cnt
        for i in range(-2, 3):
            for j in range(-2, 3):
                nh = h+i
                nw = w+j
                if nh < 0 or nw < 0: continue
                if nh >= H or nw >= W: continue
                if field[nh][nw]  == "#": continue
                if (i, j) in ((1,0),(0,1),(-1,0),(0,-1)):
                    if dist[nh][nw] <= cnt: continue
                    dist[nh][nw] = cnt
                    deque.appendleft(q, (cnt, nh, nw))
                else:
                    if dist[nh][nw] <= cnt+1: continue
                    dist[nh][nw] = cnt+1
                    deque.append(q, (cnt+1, nh, nw))
    return -1

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

from operator import add


class SegTree():
    def __init__(self, N, e=float("inf"), operator_func=min):
        self.e = e
        self.size = N
        self.node = [self.e] * (2*N)
        self.op = operator_func

    def set_list(self, l):
        for i in range(self.size):
            self.node[i+self.size-1] = l[i]
        for i in range(self.size-1)[::-1]:
            self.node[i] = self.op(self.node[2*i+1], self.node[2*i+2])
    
    def update(self, k, x):
        k += self.size - 1
        self.node[k] = x
        while k >= 0:
            k = (k - 1) // 2
            self.node[k] = self.op(self.node[2*k+1], self.node[2*k+2])

    def get(self, l, r):
        x = self.e
        l += self.size; r += self.size
        a, b = [], []

        while l<r:
            if l&1:
                a += [l-1]; l += 1
            if r&1:
                r -= 1; b += [r-1]
            l >>= 1; r >>= 1

        for i in a+(b[::-1]):
            x = self.op(x, self.node[i])
        return x


def solve():
    N, Q = map(int, input().split())
    *c, = map(int, input().split())
    tree = SegTree(N+1, 0, add)
    m = [tuple(map(int, input().split())) for i in range(Q)]
    idxs = sorted(range(Q), key=lambda i: m[i][1])

    right = 0
    pos = [None] * (N+1)
    ans = [None] * (Q)

    for idx in idxs:
        l, r = m[idx]
        if right != r:
            for i in range(right, r):
                if pos[c[i]]:
                    tree.update(pos[c[i]], 0)
                pos[c[i]] = i+1
                tree.update(i+1, 1)
        ans[idx] = tree.get(l, r+1)
        right = r
    print(*ans, sep="\n")


solve()


### FIXED CODE ###

class FenwickTree:
    def __init__(self, size):
        self.size = size
        self.array = [0]*size
 
    def add(self, index, value):
        while index < self.size:
            self.array[index] += value
            index += index&(-index)
 
    def sum(self, index):
        answer = 0
        while index > 0:
            answer += self.array[index]
            index -= index&(-index)
        return answer
 
    def rangesum(self, start, end):
        return self.sum(end)-self.sum(start-1)


def solve():
    N, Q = map(int, input().split())
    *c, = map(int, input().split())
    tree2 = FenwickTree(N+1)
    m = [list(map(int, input().split())) for _ in range(Q)]
    idxs = sorted(list(range(Q)), key=lambda i: m[i][1])

    right = 0
    pos = [-1] * (N+1)
    ans = [-1] * (Q)

    for idx in idxs:
        l, r = m[idx]
        for i in range(right, r):
            x = pos[c[i]]
            if x != -1:
                tree2.add(x, -1)
            pos[c[i]] = i+1
            tree2.add(i+1, 1)
        ans[idx] = tree2.rangesum(l, r)
        right = r
    print(*ans, sep="\n")


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

n=int(input())
k=list()
for i in range(n):
  if n%(i+1)==0:
    k.append(int(i+n/(i+1)-1))
print(min(k))

### FIXED CODE ###

n=int(input())
k=list()
for i in range(int(n**0.5)):
  if n%(i+1)==0:
    k.append(int(i+n/(i+1)-1))
print(min(k))
### BUGGY CODE ###

import sys
input=sys.stdin.readline
from itertools import combinations as cmb
n=int(input())
s=list(input())
s.remove("\n")
combiset=set(cmb(s,3))
print(len(combiset))

### FIXED CODE ###

n=int(input())
s=list(map(int,list(input())))
ans=0
for i in range(10):
    try:
        ss=s[s.index(i)+1:]
        for j in range(10):
            try:
                sss=ss[ss.index(j)+1:]
                for k in range(10):
                    if k in sss:ans+=1
            except:pass
    except:pass

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

# -*- condig:utf-8 -*-

import sys
sys.setrecursionlimit(10000000)

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

g = {}
o = []
counter = []
for i in range(n+1):
  counter.append(0)
  o.append(0)

for i in range(n-1):
  a,b= map(int, input().split())
  if not g.get(a, False):
    g[a] = [b]
  else:
    if not b in g[a]:
      g[a].append(b)
  if not g.get(b, False):
    g[b] = [a]
  else:
    if not a in g[b]:
      g[b].append(a)

for i in range(q):
  p,x= map(int, input().split())
  o[p] += x


queue = [1]
parents = []
while queue:
  p = queue.pop(0)
  parents.append(p)
  count = o[p]
  flag = False
  for i in g[p]:
    if not i in parents:
      queue.append(i)
    else:
      count += counter[i]
  counter[p] += count
 
for i in range(1, n+1):
  print(counter[i], end=' ')

 
  


### FIXED CODE ###


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

ct = [0] * (n+1)
o = [0] * (n+1)
g = [[] for _ in range(n+1)]

for i in range(n-1):
  a,b= map(int, input().split())
  g[a].append(b)
  g[b].append(a)

for i in range(q):
  p,x= map(int, input().split())
  o[p] += x

todo = [1]
seen = [False] * (n+1)
while todo:
  p = todo.pop(-1)
  ct[p] += o[p]
  seen[p] = True
  for i in g[p]:
    if seen[i]:
      ct[p] += ct[i]
    else:
      todo.append(i)

print(*ct[1:])
### BUGGY CODE ###

def calcExValue(N):
    ev = []
    for i in range(1, N +1):
        ev.append(i * (1/N))
    return(sum(ev))

def sumEvs(numbers):
    evs = []
    for N in numbers:
        evs.append(calcExValue(N))
    return(sum(evs))

N, K = [int(i) for i in input().split()]
array = [int(i) for i in input().split()]

max_numbers = []
max_exv = 0
for i in range(N-K+1):
    exv = sumEvs(array[i:i+K])
    if exv > max_exv:
        max_exv = exv
 
print(max_exv)


### FIXED CODE ###

import numpy as np

N, K = [int(i) for i in input().split()]
numbers = [int(i) for i in input().split()]

ary = np.array([(1 + n) / 2 for n in numbers])

cumsum = ary.cumsum()

max_exv = cumsum[K-1]
for i in range(N - K):
    if cumsum[i+K] - cumsum[i] > max_exv:
        max_exv = cumsum[i+K] - cumsum[i]
    
print(max_exv)