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

import sys

s = input()
t = list(input())

string = s
length = 1

for i in t:
	if s.find(i)==-1:
		print(-1)
		sys.exit()
	if string.find(i)==-1:
		string = string + s
		length += 1
	string = string[string.find(i)+1 : ]
	
print(length*len(s)-len(string))

### FIXED CODE ###

import sys

s = input()
t = list(input())

string = s
length = 1

for i in range(len(t)):
	if s.find(t[i])==-1:
		print(-1)
		sys.exit()
	if string.find(t[i])==-1:
		string = s
		length += 1
	string = string[string.find(t[i])+1 : ]
	
print(length*len(s)-len(string))
### BUGGY CODE ###

# 2019は10と互いに素なので、
# N%2019と(N*(10**正整数))%2019は一致する
# pppppxxxxxxxを2019で割った余りとxxxxxxxを2019で割った余りが一致すれば、
# pppppは2019で割り切れることが言える

S = input()
from collections import defaultdict
amari = defaultdict(int)
for i in range(1,len(S)+1):
  amari[int(S[len(S)-i:])%2019] += 1
  
ans = 0
if 0 in amari:
  ans += amari[0]
for n in amari.values():
  ans += (n * (n-1)) // 2
  
print(ans)


### FIXED CODE ###

# 2019は10と互いに素なので、
# N%2019と(N*(10**正整数))%2019は一致する
# pppppxxxxxxxを2019で割った余りとxxxxxxxを2019で割った余りが一致すれば、
# pppppは2019で割り切れることが言える

S = input()
from collections import defaultdict
amari = defaultdict(int)
cur = 0 # 今の数値
keta = 1 # 今の桁数
for i in range(len(S)-1,-1,-1):
  cur += int(S[i]) * keta
  cur %= 2019
  keta *= 10
  keta %= 2019
  amari[cur] += 1

ans = 0
if 0 in amari:
  ans += amari[0]
for n in amari.values():
  ans += (n * (n-1)) // 2
  
print(ans)
### BUGGY CODE ###

import sys
import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
sys.setrecursionlimit(10**6)
N=int(input())
A=[0]+list(map(int,input().split()))

E=[[] for i in range(N+1)]
for i in range(N-1):
    x,y=map(int,input().split())
    E[x].append(y)
    E[y].append(x)

USE=[0]*(N+1)
USE[1]=1
ANS=[0]*(N+1)

import bisect
def dfs(x,DP):
    #print(x,DP)
    DP=list(DP)
    pos=bisect.bisect_left(DP,A[x])
    #print(pos)
    if pos<len(DP):
        DP[pos]=A[x]
    else:
        DP.append(A[x])
    #print(DP)

    ANS[x]=len(DP)

    for to in E[x]:
        if USE[to]==0:
            USE[to]=1
            dfs(to,tuple(DP))

dfs(1,tuple())

print(*ANS[1:])
    


### FIXED CODE ###

import sys
input = sys.stdin.readline
import bisect
sys.setrecursionlimit(10**6)

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

E=[[] for i in range(N+1)]
for i in range(N-1):
    x,y=map(int,input().split())
    E[x].append(y)
    E[y].append(x)

USE=[0]*(N+1)
USE[1]=1
ANS=[0]*(N+1)
DP=[]

def dfs(x):
    pos=bisect.bisect_left(DP,A[x])
    
    if pos<len(DP):
        changepos=pos
        old=DP[pos]
        
        DP[pos]=A[x]
    else:
        changepos=pos
        old=-1
        
        DP.append(A[x])

    ANS[x]=len(DP)

    for to in E[x]:
        if USE[to]==0:
            USE[to]=1
            dfs(to)

    if old==-1:
        DP.pop()
    else:
        DP[changepos]=old

dfs(1)

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

#G
import pprint
H,W,K=map(int,input().split())
import copy
x1,y1,x2,y2=map(int,input().split())
#raw=["#"]+["."]*(601)+["#"]
lastraw=["@"]*(W+2)
field=[["@"]*(W+2)]
for i in range(H):
  field.append(["@"]+list(input())+["@"])

field.append(lastraw)

#print(field)

goal_point=(y2,x2)

[sy,sx]=[y1,x1]
[gy,gx]=[y2,x2]

field[x1][y1]=0
queue=[[sy,sx]]
tests = ((-1,0),(0, 1),(1, 0),(0, -1))
moves=0

while True:
  if len(queue)==0:
    moves=-1
    break
  queue_next = []
  moves += 1
  #pprint.pprint(field)
  for y, x in queue:
    for ny, nx in tests:
      ty, tx = y + ny, x + nx
      if field[tx][ty] == '.' or field[tx][ty] ==moves:
        field[tx][ty] = moves
        queue_next.append((ty, tx))
        #print(ty,tx)
        for i in range(K-1):
          ty, tx = ty + ny, tx + nx
          if field[tx][ty] == '.':
            field[tx][ty] = moves
            queue_next.append((ty, tx))
            #print(ty,tx)
          elif field[tx][ty] ==moves:
            k=0
          else:
            break
      elif field[tx][ty] ==moves:
        #field[tx][ty] = moves
        #queue_next.append((ty, tx))
        #print(ty,tx)
        for i in range(K-1):
          ty, tx = ty + ny, tx + nx
          if field[tx][ty] == '.':
            field[tx][ty] = moves
            queue_next.append((ty, tx))
            #print(ty,tx)
          elif field[tx][ty] ==moves:
            k=0
          else:
            break
  queue = queue_next
  if goal_point in queue:
    break
#pprint.pprint(field)
print(moves)

### FIXED CODE ###

#G
import pprint
H,W,K=map(int,input().split())
import copy
x1,y1,x2,y2=map(int,input().split())
#raw=["#"]+["."]*(601)+["#"]
lastraw=["@"]*(W+2)
field=[["@"]*(W+2)]
for i in range(H):
  field.append(["@"]+list(input())+["@"])

field.append(lastraw)

#print(field)

goal_point=(y2,x2)

[sy,sx]=[y1,x1]
[gy,gx]=[y2,x2]

field[x1][y1]=0
queue=[[sy,sx]]
tests = ((-1,0),(0, 1),(1, 0),(0, -1))
moves=0

while True:
  if len(queue)==0:
    moves=-1
    break
  queue_next = []
  moves += 1
  #pprint.pprint(field)
  for y, x in queue:
    for ny, nx in tests:
      ty, tx = y + ny, x + nx
      if field[tx][ty] == '.':
        field[tx][ty] = moves
        queue_next.append((ty, tx))
        #print(ty,tx)
        for i in range(K-1):
          ty, tx = ty + ny, tx + nx
          if field[tx][ty] == '.':
            field[tx][ty] = moves
            queue_next.append((ty, tx))
            #print(ty,tx)
          elif field[tx][ty] ==moves:
            pass
          else:
            break
      elif field[tx][ty] ==moves:
        #field[tx][ty] = moves
        #queue_next.append((ty, tx))
        #print(ty,tx)
        for i in range(K-1):
          ty, tx = ty + ny, tx + nx
          if field[tx][ty] == '.':
            field[tx][ty] = moves
            queue_next.append((ty, tx))
            #print(ty,tx)
          elif field[tx][ty] ==moves:
            pass
          else:
            break
  queue = queue_next
  if goal_point in queue:
    break
#pprint.pprint(field)
print(moves)
### BUGGY CODE ###

n=int(input())
INF=9999999999
d=[[INF for _ in range(n)] for _ in range(n)]

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

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

for a in range(n):
    for b in range(n):
        for c in range(n):
            d[b][c]=min(d[b][c],d[b][a]+d[a][c])



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




### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
n=int(input())
INF=9999999999
d=[INF for _ in range(n)]
g=[[] for _ in range(n)]


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

def dfs(v,p,dv):
    d[v]=dv
    for gi,c in g[v]:
        if(gi==p):
            continue
        dfs(gi,v,dv+c)

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

dfs(k-1,-1,0)

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

n,k=map(int,input().split())
a=list(map(int,input().split()))
from math import log2
from bisect import bisect_left,bisect_right
a.sort()
# 0未満の個数
mn=bisect_left(a,0)
# 0の個数
zn=bisect_right(a,0)-mn
# 0より大きい個数
pn=n-mn-zn
am=a[:mn]
am=[-x for x in am[::-1]]
ap=a[mn+zn:]
# 自分より小さい数字がk個未満のうち最大の値を求める
# 自分より小さい数字がk個未満ならTrue
def func(x):
    cnt=0
    if x>0:
        cnt+=mn*pn
        cnt+=(zn*(n-1+n-zn))//2
        cnt1=0
        for y in ap:
            cnt1+=bisect_left(ap,(x+y-1)//y)
            if y**2<x:cnt1-=1
        for y in am:
            cnt1+=bisect_left(am,(x+y-1)//y)
            if y**2<x:cnt1-=1
        cnt+=cnt1//2
    elif x<0:
        x=abs(x)
        for y in ap:
            cnt+=mn-bisect_right(am,x//y)
    elif x==0:
        cnt+=mn*pn
    return cnt<k

maxaa=max(abs(a[0]),abs(a[-1]))**2
l,r=-maxaa,maxaa
while r-l>1:
    x=(l+r)//2
    if func(x):
        l,r=x,r
    else:
        l,r=l,x
print(r if func(r) else l)


### FIXED CODE ###

import numpy as np
n,k=map(int,input().split())
a=np.array(list(map(int,input().split())))
a.sort()
p=a[a>0]
z=np.count_nonzero(a==0)
m=a[a<0]
r=10**19
l=-r
while r-l>1:
    # 区間[l,r]を半分に分けて探索。最終的にrが求める値になるようにする。
    # b以下のものがk個以上あるような、最小のbを求める。bを大きくする→b以下のものも増える。b以下のものがめちゃくちゃある→bを減らす。
    b=(l+r)//2
    c=0
    if b>=0:
        c+=z*n
    # 配列aに対し、配列b//pの要素たちをそれぞれsearchsortedする。結果の配列はb//pと同じ形になる。
    c+=a.searchsorted(b//p,side='right').sum()
    # 配列aに対し、配列b//mの要素たちをそれぞれsearchsortedする。結果の配列はb//mと同じ形になる。
    c+=n*len(m)-a.searchsorted(-(-b//m),side='left').sum()
    c-=np.count_nonzero(a*a<=b)
    if c//2>=k:
        r=b
    else:
        l=b
print(r)
### BUGGY CODE ###

import numpy as np
from sklearn.utils.extmath import cartesian

k = int(input())
ls = [i for i in range(1, k+1)]
arr = cartesian([ls,ls,ls])

temp = np.gcd(arr[:, 0], arr[:, 1])
temp = np.gcd(temp, arr[:, 2])
print(sum(temp))


### FIXED CODE ###

import numpy as np
from sklearn.utils.extmath import cartesian

k = int(input())
ls = [i for i in range(1, k+1)]
arr = cartesian([ls,ls,ls])

print(np.gcd(np.gcd(arr[:, 0], arr[:, 1]), arr[:, 2]).sum())
### BUGGY CODE ###

N,M = map(int,input().split())
A = [int(a) for a in input().split()]
BC = [[int(x) for x in input().split()] for _ in range(M)]

A.sort(reverse=True)
BC.sort(key=lambda x:x[1], reverse=True)

def bysectsearch(List,num):
    Left = 0
    Right = len(List)-1
    while True:
        Midle = (Left+Right)//2
        if List[Left]<=num:
            return Left
        if List[Right]>=num:
            return Right+1
        if Right-Left<=1:
            return Right
        if List[Midle]==num:
            return Midle
        if List[Midle]>num:
            Left = Midle
            continue
        if List[Midle]<num:
            Right = Midle
            continue


for B,C in BC:
    insert_point = bysectsearch(A,C)
    if insert_point == N:
        break
    A = A[:insert_point]+[C]*B+A[insert_point:]
    A = A[:N]
print(sum(A))


### FIXED CODE ###

N,M = map(int,input().split())
A = [int(a) for a in input().split()]
BC = [[int(x) for x in input().split()] for _ in range(M)]

BC.sort(key=lambda x:x[1], reverse=True)

count = 0
Added_list = []
for i in range(M):
    B,C = BC[i]
    Added_list += [C]*B
    count += B
    if count>N:
        Added_list = Added_list[:N]
        break

A += Added_list
A.sort(reverse=True)
print(sum(A[:N]))
### BUGGY CODE ###

import sys
n, m = map(int, input().split())
dist = []
for i in range(m):
    l, r, c = map(int, sys.stdin.readline().split())
    dist.append([l, r, c])

dist.sort(key=lambda x:x[2])
dist.sort(key=lambda x:x[1])
dist.sort(key=lambda x:x[0])

res = [-1] * (n+1)
res[1] = 0
for i in dist:
    if res[i[0]] == -1:
        print(-1)
        exit()
    sh = res[i[0]] + i[2]
    if res[i[1]]!= -1 and  sh >= res[i[1]]:
        continue
    for j in range(i[0]+1, i[1]+1):
        if res[j] == -1 or res[j] > sh:
            res[j] = sh

print(res[n])

### FIXED CODE ###

import sys
import heapq
n, m = map(int, input().split())

nextL = [[] for _ in range(n+1)]
for i in range(2, n+1):
    nextL[i].append([i-1, 0])

INF = 10**18

costs = [INF] * (n+1)
costs[1] = 0

for i in range(m):
    l, r, c = map(int, sys.stdin.readline().split())
    nextL[l].append([r, c])

pc = []
heapq.heappush(pc, (0, 1))

unreach = set(range(1, n+1))

while len(pc) > 0 :
    cost, target = heapq.heappop(pc)
    if cost > costs[target]:
        continue
    for i in nextL[target]:
        nex = i[0]
        cos = i[1]
        if nex in unreach and cost + cos < costs[nex]:
            costs[nex] = cost + cos
            heapq.heappush(pc, (cost+cos, nex))
    unreach.remove(target)

if costs[n] == INF:
    print(-1)
else:
    print(costs[n])
### BUGGY CODE ###

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

ans = 0
for i in range(n - 2):
    for j in range(a[i] + 1 + i, n):
        if j - i == a[j] + a[i]:ans += 1
print(ans)

### FIXED CODE ###

from collections import defaultdict
n = int(input())
a = list(map(int,input().split()))
cnt_i = defaultdict(lambda :0)
cnt_j = defaultdict(lambda :0)
for i in range(n):
    temp_i = a[i] + i + 1
    temp_j = i + 1 - a[i]
    cnt_i[temp_i] += 1
    cnt_j[temp_j] += 1

ans = sum(v * cnt_j[i] for i,v in cnt_i.items())
print(ans)
### BUGGY CODE ###

# coding: utf-8
# Your code here!

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

import collections
c = collections.Counter(a)

# print(n)
# print(a)

l = [0] * (n + 1)
ll  = [0] * (n + 1)
# for i in range(n):
#     l[a[i]] += 1
#     ll[a[i]] = int((l[a[i]] * (l[a[i]] - 1)) / 2)
    
for key, value in c.items():
    l[key] = value
    ll[key] = int((value * (value - 1)) / 2)
    
# print(l)
# print(ll)
    
for i in range(n):
    v = l[a[i]]
    vv = ll[a[i]]
    vvv = int(((v - 1) * (v - 2)) / 2)
    # print(vvv)
    print(sum(ll) - (vv - vvv))

### FIXED CODE ###

# coding: utf-8
# Your code here!

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

import collections
c = collections.Counter(a)

# print(n)
# print(a)

# l = [0] * (n + 1)
# ll  = [0] * (n + 1)

l = {}
ll = {}

# for i in range(n):
#     l[a[i]] += 1
#     ll[a[i]] = int((l[a[i]] * (l[a[i]] - 1)) / 2)
    
# print(c)
    
for key, value in c.items():
    l[key] = value
    ll[key] = int((value * (value - 1)) / 2)
    
# print(l)
# print(ll)
    
# print(l)
# print(ll)

c_sum = sum(ll.values())
for i in range(n):
    v = l[a[i]]
    vv = ll[a[i]]
    vvv = int(((v - 1) * (v - 2)) / 2)
    # print(vvv)
    print(c_sum - (vv - vvv))
### BUGGY CODE ###


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

# S = sorted(A)
# MAXS = max(S[1:3])
# two = S[-2]
# print("MAX {} two {}".format(MAXS,two))
# count = S.count(max(S))
#
# for i in range(N):
#     if A[i] == MAXS:
#         if count > 1:
#             print(MAXS)
#         else:
#             print(two)
#     else:
#         print(MAXS)
#
for i in range(N):

    if i == 0:
        print(max(A[1:]))

    elif i == N-1:
        print(max(A[:i]))

    else:
        low = max(A[0:i])
        high = max(A[i+1:])

        if high > low:
            print(high)
        else:
            print(low)


### FIXED CODE ###

# N = int(input())
# A = list(map(int, input().split()))
# 
# S = sorted(A)
# MAXS = max(A)
# 
# for i in range(N):
#     if A[i] == MAXS:
#         print(S[-2])
#     else:
#         print(S[-1])
# 


n = int(input())
a = list()
for i in range(n):
    a.append(int(input()))
c = a.index(max(a))
m = max(a)
a.sort()
d = a[-2]
for i in range(n):
    if i == c:
        print(d)
    else:
        print(m)
### BUGGY CODE ###

n = int(input())
a = [int(input()) for _ in range(n)]
num = []
for i in range(n-1):
    for j in range(i+1, n):
        if a[i] == a[j]:
            num.append(a[i])
print(n - 2 * len(num))
            

### FIXED CODE ###

n = int(input())
num = set()
ans = 0

for i in range(n):
    a = int(input())
    if a in num:
        num.remove(a)
        ans -= 1
    else:
        num.add(a)
        ans += 1
print(ans)
### BUGGY CODE ###

n = int(input())
s = []
for i in range(n):
  s.append(sorted(list(input().strip())))
ans = 0
for i in range(0,n-1):
  for j in range(i+1, n):
    if s[i] == s[j]:
      ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
s = []
for i in range(n):
  s.append(''.join(sorted(list(input().strip()))))
ans = 0
tmp = 0
ss = sorted(s)
prev = ''
for iss in ss:
  if prev != iss:
    prev = iss
    ans += int((tmp*(tmp+1))/2)
    tmp = 0
  elif prev == iss:
    # print("prev :{}, iss :{}".format(prev, iss))
    tmp += 1
if tmp != 0:
  ans += int((tmp*(tmp+1))/2)
print(ans)
### BUGGY CODE ###

def extract(string, i):
    import re
    split = re.split('01|10', string)
    i += len(split) - 1
    split_concat = "".join(split)
    if "01" in split_concat or "10" in split_concat:
        return extract(split_concat, i)
    else:
        return i * 2

S = input()

print(extract(S,0))


### FIXED CODE ###

S = input()

print(min(S.count('0'), S.count('1')) * 2)
### BUGGY CODE ###

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

trees = {}
for _ in range(N - 1):
    id1, id2 = map(int, input().split())
    if id1 not in trees:
        trees[id1] = []
    trees[id1].append(id2)

values = {}
for _ in range(Q):
    nid, val = map(int, input().split())
    if nid not in values:
        values[nid] = 0
    values[nid] += val

counters = {}
stack = [[1, 0]] # id, value from parent
current_val = 0
while len(stack) > 0:
    myid, parent_val = stack.pop()
#     if myid not in counters:
#         counters[myid] = 0
    
    value_add = 0
    if myid in values:
        value_add = values[myid]
    
    counters[myid] = parent_val + value_add
    if myid in trees:
        for cid in trees[myid]:
            stack.append([cid, parent_val + value_add])

ret = []
for myid in range(1, N + 1):
    if myid not in counters:
        ret.append(str(0))
    else:
        ret.append(str(counters[myid]))
        
print(' '.join(ret))

### FIXED CODE ###

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

trees = {}
for _ in range(N - 1):
    id1, id2 = map(int, input().split())
    if id1 not in trees:
        trees[id1] = []
    trees[id1].append(id2)

from collections import defaultdict
values = defaultdict(int)
for _ in range(Q):
    nid, val = map(int, input().split())
    values[nid] += val

counters = defaultdict(int)
stack = [[1, 0]] # id, value from parent
while len(stack) > 0:
    myid, parent_val = stack.pop()
    current_val = parent_val + values[myid]
    counters[myid] = current_val
    if myid in trees:
        for cid in trees[myid]:
            stack.append([cid, current_val])

print(' '.join(map(str, [counters[myid] for myid in range(1, N + 1)])))
### BUGGY CODE ###

import sys
from operator import itemgetter
inputs = sys.stdin.readline
N, Q= map(int,inputs().split())
E = [None]*2*N
for n in range(N):
	a,b,c = map(int,inputs().split())
	E[2*n] = [a - c, 1, c]
	E[2*n + 1] = [b - c, -1, c]
#E.sort(key = lambda x:x[0])
E.sort(key=itemgetter(0))
mini = 1000000001
kouho = [1000000001]
q = 0
d = int(inputs())
flag = False
cont = False
for e in E:
	while(e[0] > d):
		if cont == True:
			if mini < 1000000001:
				print(mini)
			else:
				print(-1)
		else:
			mini = min(kouho)
			if mini < 1000000001:
				print(mini)
			else:
				print(-1)
		cont = True
		if q < Q-1:
			q = q + 1
			d = int(inputs())
		else:
			flag = True
			q = q + 1
			break
	if flag == True:
		break
	if  e[1] == 1:
		kouho.append(e[2])
		mini = min(e[2],mini)
	elif e[1] == -1:
		kouho.remove(e[2])
		cont = False
for t in [None]*(Q-q):
	print(-1)

### FIXED CODE ###

import sys
from operator import itemgetter
def main():
	inputs = sys.stdin.readline
	N, Q= map(int,inputs().split())
	E = [None]*2*N
	for n in range(N):
		a,b,c = map(int,inputs().split())
		E[2*n] = (a - c, 1, c)
		E[2*n + 1] = (b - c, -1, c)
	E.sort(key=itemgetter(0))
	tuple(tuple(E))
	mini = 1000000001
	kouho = {1000000001}
	my_add = kouho.add
	my_discard = kouho.discard
	q = 0
	d = int(inputs())
	flag = False
	cont = False
	for e in E:
		while e[0] > d:
			if cont == True:
				print(mini-(mini//1000000001)*1000000002)
			else:
				mini = min(kouho)
				print(mini-(mini//1000000001)*1000000002)
			cont = True
			q = q + 1
			if q > Q-1:
				flag = True
				break
			d = int(inputs())
		if flag == True:
			break
		if e[1] == 1:
			my_add(e[2])
			if mini > e[2]:
				mini = e[2]
		elif e[1] == -1:
			my_discard(e[2])
			if mini == e[2]:
				cont = False
	for t in [None]*(Q-q):
		print(-1)
main()
### BUGGY CODE ###

#d
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = [0] * Q
C = [0] * Q
for i in range(Q):
    B[i], C[i] = map(int, input().split())
ans=sum(A)
for i in range(Q):
    P=A.count(B[i])
    for j in range(P):
        A[A.index(B[i])]=C[i]
    ans=ans+P*(C[i]-B[i])
    print(ans)

### FIXED CODE ###

#d
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = [0] * Q
C = [0] * Q
for i in range(Q):
    B[i], C[i] = map(int, input().split())
D = [0] * (10**5+1)
ans=sum(A)
for i in A:
    D[i]+=1
for x in range(Q):
    ans+=D[B[x]]*int(C[x]-B[x])
    print(ans)
    D[C[x]]+=D[B[x]]
    D[B[x]]=0
### BUGGY CODE ###

N,K = map(int,input().split(" ")[0:2])
p = list(map(int,input().split(" ")))

ret = -1
for x in range(0,N-K+1):
    ret1 = (sum(p[x:x+K])+K)/2
    ret = ret if ret1 < ret else ret1

print(ret)

### FIXED CODE ###

N,K = map(int,input().split(" ")[0:2])
p = list(map(int,input().split(" ")))

ret = []
s0 = sum(p[0:K-1])
for x in range(0,N-K+1):
    s0 = s0 + p[x+K-1]
    ret.append(s0)
    s0 = s0 - p[x]
print((max(ret)+K)/2)
### BUGGY CODE ###

N=int(input())
 
for h in range(1,3500):
  for n in range(1,3500):
    div=(4*h*n)-(N*n)-(N*h)
    #divが負数ならwは負数になる
    if div>0:
      w=N*h*n/div
      if w.is_integer():
        print(h,n,int(w))
        exit()

### FIXED CODE ###

N=int(input())
 
for h in range(1,3501):
  for n in range(1,3501):
    #divが負数ならwは負数になる
    if (4*h*n)-(N*n)-(N*h)>0:
      w=N*h*n/((4*h*n)-(N*n)-(N*h))
      if w.is_integer():
        print(h,n,int(w))
        exit()
### BUGGY CODE ###

n,m = map(int,input().split())
a = [int(input()) for _ in range(m)]
step = [0] * (n+1)
step[0] = 1
if 1 not in a:
    step[1] = 1
else:
    step[1] = 0
for j in range(2,n+1):
    if j not in a:
        step[j] = (step[j-1] + step[j-2]) % 1000000007
print(step[-1])

### FIXED CODE ###

n,m = map(int,input().split())
a = set([int(input()) for _ in range(m)])
step = [0] * (n+1)
step[0] = 1
if 1 not in a:
    step[1] = 1
else:
    step[1] = 0
for i in range(2,n+1):
    if i in a:
        continue
    step[i] = (step[i-1] + step[i-2]) % 1000000007
print(step[-1])
### BUGGY CODE ###

from heapq import heapify, heappush, heappop

N, D, A = map(int, input().split())
XH = [tuple(map(int, input().split())) for _ in range(N)]

heap = [(x, h, True) for x, h in XH]
heapify(heap)

ans = 0
bomb_effect = 0
while heap:
    x, h, monster_flg = heappop(heap)
    if monster_flg:
        tairyoku = h - bomb_effect
        if tairyoku > 0:
            new_bomb = -((-tairyoku) // A)
            ans += new_bomb
            heappush(heap, (x + 2 * D + 0.5, new_bomb, False))
            bomb_effect += new_bomb * A
    else:
        bomb_effect -= h * A

print(ans)


### FIXED CODE ###

N, D, A = map(int, input().split())
XH = [tuple(map(int, input().split())) for _ in range(N)]
XH.sort()


ans = 0
bomb_effect = 0
bomb_i = 0
bombs = []
for x, h in XH:
    while (bomb_i < len(bombs)) and (x > bombs[bomb_i][0]):
        bomb_effect -= bombs[bomb_i][1] * A
        bomb_i += 1

    tairyoku = h - bomb_effect
    if tairyoku > 0:
        new_bomb = -((-tairyoku) // A)
        ans += new_bomb
        bombs.append((x + 2 * D + 0.5, new_bomb))
        bomb_effect += new_bomb * A

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

#!/usr/bin/env python3

import sys

def search(a,x,offset=0,iend=None):
    n = len(a)
    if iend is None: iend = n
    assert 0<=offset<iend<=n

    n = iend - offset
    if a[iend-1]<x: return -1
    if n==1:
        assert a[offset]>=x
        return offset
    #
    mid = (n+1)//2 - 1 + offset
    mid1 = mid + 1
    
    if x<=a[mid]: return search(a,x,offset=offset,iend=mid1)
    else: return search(a,x,offset=mid1,iend=iend)
#
n = int(sys.stdin.readline().strip())
l = [ int(x) for x in sys.stdin.readline().strip().split() ]
l.sort()

c = 0
for i in range(1,n):
    for j in range(i+1,n):
        k = search(l, l[j]-l[i]+1, iend=i)
        if k<0: continue
        c += i-k
#
print(c)


### FIXED CODE ###

#!/usr/bin/env python3

import sys
from bisect import bisect_left

n = int(sys.stdin.readline().strip())
l = list(map(int,sys.stdin.readline().strip().split()))
    
l.sort()
c = 0
n1 = n - 1
for i in range(n-2):
    li = l[i]
    for j in range(i+1,n1):
        k = bisect_left(l,l[j]+li,lo=j)
        c += k-j-1
#
print(c)
### BUGGY CODE ###

import math
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())
n = ii()
a = li()
b = [0]*n
for i in range(n):
    b[i] = a.count(i+1)
for i in range(n):
    print(b[i])

### FIXED CODE ###

import math
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())
n = ii()
a = li()
b = [0]*(n+10)
for i in range(n-1):
    b[a[i]-1]+=1
for i in range(n):
    print(b[i])