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

import sys
import math
import heapq
from collections import defaultdict, deque
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))

'''C Tsundoku'''
def count(i,n,j,m,a,b,k):
    if k<0:
        return -1
    if i==n and j==m:
        return 0
    if i==n:
        if b[j]<=k:
            return 1+count(i,n,j+1,m,a,b,k-b[j])
        return 0
    if j==m:
        if a[i]<=k:
            return 1+count(i+1,n,j,m,a,b,k-a[i])
        return 0
    return max(1+count(i,n,j+1,m,a,b,k-b[j]),1+count(i+1,n,j,m,a,b,k-a[i]))

n,m,k=rm()
a=rl()
b=rl()
i=0;j=0;
print(count(i,n,j,m,a,b,k))

### FIXED CODE ###

import sys
import math
import heapq
from collections import defaultdict, deque
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))

'''C Tsundoku'''
n,m,k=rm()
a=rl()
b=rl()
c=[0]*(n+1)
d=[0]*(m+1)
for i in range(n):
    c[i+1]=c[i]+a[i]
for i in range(m):
    d[i+1]=d[i]+b[i]
ans=0;j=m
for i in range(n+1):
    if c[i]>k:
        break
    while c[i]+d[j]>k:
        j-=1
    ans=max(ans,i+j)
print(ans)
### BUGGY CODE ###

import sys
S = input()
num = len(S)
S = S + "zzzzzzzzzzzzzzzzzzzzzz"
cur = 0
while 1:
    if S[cur] == 'd':
        if S[cur:cur+11] == 'dreameraser':
            cur += 11
        elif S[cur:cur+10] == 'dreamerase':
            cur += 10
        elif S[cur:cur+7] == 'dreamer':
            cur += 7
        elif S[cur:cur+5] == 'dream':
            cur += 5
        else:
            print('NO')
            sys.exit()
    elif S[cur] == 'e':
        if S[cur:cur+6] == 'eraser':
            cur += 6
        elif S[cur:cur+5] == 'erase':
            cur += 5
        else:
            print('NO')
            sys.exit()
    if cur >= num:
        print('YES')
        sys.exit()

### FIXED CODE ###

import sys
S = input()
num = len(S)
S = S + "zzzzzzzzzzzzzzzzzzzzzz"
cur = 0
while cur < num:
    if S[cur] == 'd':
        if S[cur:cur+11] == 'dreameraser':
            cur += 11
        elif S[cur:cur+10] == 'dreamerase':
            cur += 10
        elif S[cur:cur+7] == 'dreamer':
            cur += 7
        elif S[cur:cur+5] == 'dream':
            cur += 5
        else:
            print('NO')
            sys.exit()
    elif S[cur] == 'e':
        if S[cur:cur+6] == 'eraser':
            cur += 6
        elif S[cur:cur+5] == 'erase':
            cur += 5
        else:
            print('NO')
            sys.exit()
    else:
        print('NO')
        sys.exit()
    if cur == num:
        print('YES')
        sys.exit()
### BUGGY CODE ###

import collections, sys

n = sys.stdin.readline()
s = []
for _ in range(0,int(n)):
  s.append(sys.stdin.readline().replace('\n',''))

if len(set(s)) == 1:
  print(s[0])
  sys.exit()  

c = collections.Counter(s)
max = c.most_common()[0][1]

l = []
l.append(c.most_common()[0][0])
for i in range(0,len(s)):
  if c.most_common()[i][1] == max:
    l.append(c.most_common()[i][0])
  else:
    break
ll = sorted(set(l))
for ls in ll:
  print(ls)

### FIXED CODE ###

import collections, sys

n = sys.stdin.readline()
s = []
for _ in range(0,int(n)):
  s.append(sys.stdin.readline().replace('\n',''))

c = collections.Counter(s)
max = c.most_common()[0][1]
l = sorted(list(dict(filter(lambda x: x[1]==max, c.items())).keys()))
for k in l:
  print(k)
### BUGGY CODE ###

N=int(input())
graph=[[] for i in range(N)]
for i in range(N-1):
  a,b=map(int,input().split())
  graph[a-1].append(b-1)
  graph[b-1].append(a-1)
root=[[0]]
depth=[-1]*N
depth[0]=0
while root:
  R=root.pop()
  s=R[-1]
  if s==N-1:
    one_to_N=R
    break
  for t in graph[s]:
    if depth[t]==-1:
      depth[t]=depth[s]+1
      root.append(R+[t])
d=len(one_to_N)
if d%2==1:
  a,b=one_to_N[d//2],one_to_N[d//2+1]
else:
  a,b=one_to_N[d//2-1],one_to_N[d//2]
graph[a].remove(b)
graph[b].remove(a)

dfs_stack=[0]
tree=[0]
depth1=[-1]*N
depth1[0]=0
while dfs_stack:
  s1=dfs_stack.pop()
  for t1 in graph[s1]:
    if depth1[t1]==-1:
      depth1[t1]=1
      dfs_stack.append(t1)
      tree.append(t1)
  
F=len(tree)

if F>N-F:
  print("Fennec")
else:
  print("Snuke")


### FIXED CODE ###

N=int(input())
graph=[[] for i in range(N)]
for i in range(N-1):
  a,b=map(int,input().split())
  graph[a-1].append(b-1)
  graph[b-1].append(a-1)
dfs_stack_Fennec=[0]
dfs_stack_Snuke=[N-1]
depth_Fennec=[-1]*N
depth_Snuke=[-1]*N
depth_Fennec[0]=0
depth_Snuke[N-1]=0
while dfs_stack_Fennec or dfs_stack_Snuke:
  s1=dfs_stack_Fennec.pop()
  s2=dfs_stack_Snuke.pop()
  for t1 in graph[s1]:
    if depth_Fennec[t1]==-1:
      depth_Fennec[t1]=depth_Fennec[s1]+1
      dfs_stack_Fennec.append(t1)
  for t2 in graph[s2]:
    if depth_Snuke[t2]==-1:
      depth_Snuke[t2]=depth_Snuke[s2]+1
      dfs_stack_Snuke.append(t2)
ans=0
for i in range(N):
  if depth_Fennec[i]<=depth_Snuke[i]:
    ans+=1
if 2*ans>N:
  print("Fennec")
else:
  print("Snuke")
### BUGGY CODE ###

from numba import jit,njit
import numpy as np
from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
from scipy.sparse import csr_matrix
# from scipy.special import comb,perm #permはnPk

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

i = [] #頂点(始点)
j = [] #頂点(終点)
d = [] #頂点間の距離
for _ in range(M):
    A,B = map(int,input().split())
    i.append(A-1)
    j.append(B-1)
    d.append(1)

graph = csr_matrix((d, (i, j)), shape=(N, N)) # 頂点i,jはゼロスタートである必要ある

#返り値は各頂点間の距離の値を含んだ隣接行列(float64型のnp.array)
dist,pred = dijkstra(graph, directed=False,indices=0,return_predecessors=True,unweighted=True)

@njit
def solve():
    print("Yes")
    for i in range(1,N):
        print(pred[i]+1)

solve()

### FIXED CODE ###

# from math import factorial,sqrt,ceil #,gcd
# from itertools import permutations,combinations,combinations_with_replacement
# from collections import deque,Counter
# import re
# from bisect import bisect_left
# from heapq import heappush,heappop
# from numba import njit,jit
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from fractions import gcd

# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
from networkx import Graph
from networkx.algorithms.traversal.breadth_first_search import bfs_predecessors
G = Graph()
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb,perm #permはnPk

# slist = "abcdefghijklmnopqrstuvwxyz"
N,M = map(int,input().split())
rows = [list(map(int,input().split())) for _ in range(M)]

G.add_edges_from(rows)

# shortestPath = shortest_path(G,target=1)
preds = bfs_predecessors(G,source=1)
# shortestPath = single_target_shortest_path(G,target=1)
# shortestPathLength,shortestPath = single_source_dijkstra(G,source=1)

preds = dict(preds)
if len(preds)+1 != N:
    print("No")
    exit()

print("Yes")
for i in range(2,N+1):
    print(preds[i])
### BUGGY CODE ###

x,k,d = map(int,input().split())
cnt = 0
while cnt < k :
    l = [abs(x + d), abs(x - d)]
    a = min(l)
    if a == l[0] :
        x += d
    else :
        x -= d
    cnt += 1
print(a)

### FIXED CODE ###

x,k,d = map(int,input().split())

if x >= 0 :
    a = abs(x//d)
    if a <= k :
        if (k - a) % 2 == 0 :
            print(abs(x-a*d))
        else :
            print(abs(x-(a+1)*d))
    else :
        print(abs(x-k*d))
else :
    if x%d == 0 :
        a = abs(x//d)
    else :
        a = abs(x//d+1)

    if a <= k :
        if (k - a) % 2 == 0 :
            print(abs(x+a*d))
        else :
            print(abs(x+(a+1)*d))
    else :
            print(abs(x+k*d))
### BUGGY CODE ###

N , W = map(int, input().split() )
wv = [list(map(int,input().split())) for _ in range(N) ]
maxv = 100100
dp = [[10**10] * (maxv) for _ in range(N+1) ]
dp[0][0] = 0
for i in range(N):
    for j in range(maxv):
        if j >= wv[i][1]:
            dp[i+1][j] = min(dp[i+1][j] , dp[i][j-wv[i][1]]+wv[i][0])
        dp[i+1][j] = min(dp[i+1][j] , dp[i][j])

ans = 0
for j in range(maxv):
    if dp[N][j] <= W:
        ans = j
print(ans)

### FIXED CODE ###

N , W = map(int, input().split() )
wv = [list(map(int,input().split())) for _ in range(N) ]
maxv = 100100
dp = [[10**10] * (maxv) for _ in range(N+1) ]
dp[0][0] = 0
for i in range(N):
    for j in range(maxv):
        if j >= wv[i][1]:
            dp[i+1][j] = min(dp[i+1][j] , dp[i][j-wv[i][1]]+wv[i][0])
        dp[i+1][j] = min(dp[i+1][j] , dp[i][j])

ans = 0
for j in range(maxv):
    if dp[N][j] <= W:
        ans = j
print(ans)
### BUGGY CODE ###

n = int(input())
power = 1
for i in range(1, n + 1):
    power = power * i
print(power % (10 ** 9 + 7))


### FIXED CODE ###

import math
n = int(input())

m = 10 ** 9 + 7

print(math.factorial(n) % m)
### BUGGY CODE ###

import itertools as it
import math

K = int(input())

gcd_list = []
for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            gcd_ = math.gcd(math.gcd(i, j), k)
            gcd_list.append(gcd_)
print(sum(gcd_list))


### FIXED CODE ###

import itertools as it
import math

K = int(input())

itr = range(1, K+1)
gcd_ = sum([math.gcd(math.gcd(i, j), k)
            for i, j, k in it.product(itr, itr, itr)])
print(gcd_)
### BUGGY CODE ###

n, k = map(int, input().split())
count = 0
while n >=0:
    n //= k
    count += 1
print(count)

### FIXED CODE ###

n, k = map(int, input().split())
count = 0
while n >0:
    n //= k
    count += 1
print(count)
### BUGGY CODE ###

s = list(input())

MOD = pow(10, 9) + 7

n = len(s)
s.reverse()

dp = [[0] * 13 for _ in range(n)]

#r = list(range(10))

#init
if s[0] == "?":
    for j in range(10):
        dp[0][j] = 1
else:
    q = int(s[0])
    dp[0][q] = 1

r = 1

for i in range(1, n):
    r = r * 10 % 13
    # for l in range(10):
    #     r[l] = r[l] * 10 % 13

    #print(r)

    if s[i] == "?":
        for j in range(10):
            q = j * r % 13
            for k in range(13):
                dp[i][k] += dp[i-1][k-q]
    
    else:
        q = int(s[i]) * r % 13
        #print(q)
        for k in range(13):
            dp[i][k] += dp[i-1][k-q]
    #print(dp[i])

print(dp[n-1][5] % MOD)

### FIXED CODE ###

s = list(input())

MOD = pow(10, 9) + 7

n = len(s)

dp = [[0] * 13 for _ in range(n)]

#r = list(range(10))

#init
if s[-1] == "?":
    for j in range(10):
        dp[0][j] = 1
else:
    q = int(s[-1])
    dp[0][q] = 1

r = 1

for i in range(1, n):
    r = r * 10 % 13
    # for l in range(10):
    #     r[l] = r[l] * 10 % 13

    #print(r)

    if s[n-i-1] == "?":
        for j in range(10):
            q = j * r % 13
            for k in range(13):
                dp[i][k] += dp[i-1][k-q] % MOD
    
    else:
        q = int(s[n-i-1]) * r % 13
        #print(q)
        for k in range(13):
            dp[i][k] += dp[i-1][k-q] % MOD
    #print(dp[i])

print(dp[n-1][5] % MOD)
### BUGGY CODE ###

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

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

### FIXED CODE ###

from collections import Counter
n = int(input())
a = list(map(int,input().split()))
l = [0]*n
r = [0]*n
for i in range(n):
    l[i] = i+a[i]
    r[i] = i-a[i]
    
l=Counter(l)
r=Counter(r)
ans = 0
for i in range(max(r.keys())+1):
    ans += l[i]*r[i]
print(ans)
### BUGGY CODE ###

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

L = sorted(L, key=lambda x: x[1])

calc = 0
ans = "Yes"

while L :
    A,B = L.pop(0)
    calc += A
    if calc > B :
        ans = "No"
        break

print(ans)


### FIXED CODE ###

N = int(input())

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

L = sorted(L, key=lambda x: x[1])
#print(L)

calc = 0

ans = "Yes"

for i in range(len(L)) :
    a,b = L[i]
    calc += a
    if calc > b :
        ans = "No"
        break
print(ans)
### BUGGY CODE ###

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

A = list(map(int, input().split()))
cnt = 0

for i in range(N-1):
    if A[i]+A[i+1] <= X:
        continue
    else:
        while A[i]+A[i+1] > X:
            if A[i+1] > 0:
                A[i+1] -= 1
                cnt += 1
            if A[i+1] == 0:
                break
        while A[i]+A[i+1] > X:
            if A[i] > 0:
                A[i] -= 1
                cnt += 1
            if A[i] == 0:
                break
    
print(cnt)

### FIXED CODE ###

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

A = list(map(int, input().split()))
cnt = 0

for i in range(N-1):
    temp = 0
    if A[i]+A[i+1] <= X:
        continue
    else:
        temp = A[i]+A[i+1]-X
        if A[i+1] < temp:
            A[i+1] = 0
            cnt += A[i+1]
            temp -= A[i+1]
        else:
            A[i+1] -= temp
            cnt += temp
            temp -= A[i+1]

        if A[i]+A[i+1] > X:
            A[i] -= temp
            cnt += temp

print(cnt)
### BUGGY CODE ###

N,M=map(int,input().split())
from collections import defaultdict
OUT=defaultdict(set)
IN=defaultdict(set)
start={i for i in range(N)}
for i in range(N+M-1):
    a,b=map(int,input().split())
    start-={b-1}
    OUT[a-1]|={(i,b-1)}
    IN[b-1]|={i}
L=[]
P=[0]*N
while len(start)>0:
    now=start.pop()
    L.append(now)
    for i in range(len(OUT[now])):
        b,nex = OUT[now].pop()
        if len(IN[nex])==1:
            start|={nex}
            P[nex]=now+1
        IN[nex]-={b}
for p in P:
    print(p)

### FIXED CODE ###

import sys
input=sys.stdin.readline
N,M=map(int,input().split())
from collections import defaultdict
OUT=defaultdict(set)
IN=defaultdict(int)
for i in range(N+M-1):
    a,b=map(int,input().split())
    OUT[a-1]|={b-1}
    IN[b-1]+=1
P=[0]*N
start={i for i in range(N) if IN[i]==0}
while len(start)>0:
    now=start.pop()
    for nex in OUT[now]:
        IN[nex]-=1
        if IN[nex]==0:
            start|={nex}
            P[nex]=now+1
[print(p) for p in P]
### BUGGY CODE ###

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

max_total = 0
index_first = 0
index_end = 0
for i in range(N - K + 1):
    if max_total < sum(p[i:i+K]):
        max_total = sum(p[i:i+K])
        index_first = i
        index_end = i+K

ans = 0
for i in range(index_first,index_end):
    ans += ((p[i] * (p[i] + 1)) /2) * (1/p[i])
print(ans)

### FIXED CODE ###

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


def cal_expect(value):
    return ((value*(value+1))/2)*(1/value)

expect_value = [0]*N
expect_value[0] = cal_expect(p[0])

for i in range(1,K):
    expect_value[i] += expect_value[i-1] + cal_expect(p[i])

for i in range(K,N):
    expect_value[i] = expect_value[i-1] + cal_expect(p[i]) - cal_expect(p[i - K])

print(max(expect_value))
### BUGGY CODE ###

from functools import reduce
def memoize(f):
    table = {}
    def func(*args):
        if not args in table:
            table[args] = f(*args)
        return table[args]
    return func
    
@memoize 
def soinsuu_bunkai(n):
    ret = {}
    p = 2
    while p * p <= n:
        while n % p == 0:
            ret[p]= ret[p]+1 if p in ret else 1
            n //= p
        p += 1
    if n != 1:
        ret[n] = 1
    return ret    

def yakusuu_no_kosuu(dic):
    return reduce(lambda x,y:x*y,map(lambda x:x+1,[v for (k,v) in dic.items()]))
    
ans = 0    
for i in range(2,int(input())+1):
    so = soinsuu_bunkai(i)
    if yakusuu_no_kosuu(so):
        ans += i * yakusuu_no_kosuu(so) 
    else:
        ans += 1
print(ans+1)    


### FIXED CODE ###

def g(num):
    return (num*(num+1)) // 2

def f(num):
    return num * g(n//num)

n = int(input())
ans = 0
for i in range(1,n+1):
    ans += f(i)
print(ans)
### BUGGY CODE ###

from sys import stdin
from collections import defaultdict
from math import isinf

readline = stdin.readline

min_cost = float('inf')

def main():
    v, e = map(int, readline().split())
    g = [[float('inf')] * v for _ in range(v)]
    for _ in range(e):
        s, t, d = map(int, readline().split())
        g[s][t] = d
    dfs(g, 0, 0, set(range(1, v)))
    global min_cost
    print(-1 if isinf(min_cost) else min_cost)


def dfs(g, cost, last, vs):
    global min_cost
    if min_cost <= cost:
        return
    if vs:
        for v in vs:
            dfs(g, cost + g[last][v], v, vs - {v})
    elif min_cost > cost + g[last][0]:
        min_cost = cost + g[last][0]

main()

### FIXED CODE ###

# http://www.geocities.jp/m_hiroi/light/pyalgo65.html

def memoize(f):
    table = {}
    def func(*args):
        if not args in table:
            table[args] = f(*args)
        return table[args]
    return func

@memoize
def tsp(p, v):
    if (1 << point_size) - 1 == v:
        return distance_table[p][0]
    else:
        return min(distance_table[p][x] + tsp(x, v | (1 << x)) for x in range(point_size) if not (v & (1 << x)))

from sys import stdin
from collections import defaultdict
from math import isinf

readline = stdin.readline

point_size, e = map(int, readline().split())
distance_table = [[float('inf')] * point_size for _ in range(point_size)]
for _ in range(e):
    s, t, d = map(int, readline().split())
    distance_table[s][t] = d
ans = tsp(0,1)
print(-1 if isinf(ans) else ans)
### BUGGY CODE ###

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

output[N//2:]=A[N//2:]

t = N//2-1
for j in range(N//2):
    for i in range(N//(t+1)-1):
        output[t]= (output[t]+output[(t+1)*(i+2)-1])%2
    output[t]=int(output[t] != A[t])
    t -= 1

ans = ""
flag = 0
for j in range(N):
    if output[j]==1:
        ans += str(j+1) + " "
        flag += 1
print(flag)
if flag > 0:
    ans = ans[:-1]
    print(ans)

### FIXED CODE ###

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

B = [0]*N
for i in range(N):
    X = N-i
    P = B[X-1]
    Q = A[X-1]
    if P==Q:
        B[X-1] = 0
    else:
        XDL = make_divisors(X)
        for XD in XDL:
            if XD==X:
                B[XD-1] = 1
            else:
                B[XD-1] = 1 - B[XD-1]
out = []
cnt = 0
for i in range(N):
    if B[i]==1:
        out.append(i+1)
        cnt+=1
print(cnt)
if len(out)>0:
    print(*out)
### BUGGY CODE ###

def popcount(x):
    return bin(x).count("1")

N,X = open(0).read().split()
N = int(N)
X = int(X, 2)

p = popcount(X)
if X == 0 or p == 1:
    for i in range(0, N):
        k = 1 << (N - 1 - i)
        x = X ^ k
        ans = 0
        while x != 0:
            x %= popcount(x)
            ans += 1
        print(ans)

else:
    xi = X % (p + 1)
    xd = X % (p - 1)
    for i in range(0, N):
        k = 1 << (N - 1 - i)
        x = X ^ k
        if x == 0:
            print(0)
            continue

        if x > X:
            pi = p + 1
            x = (xi + (k % pi)) % pi
        else:
            pd = p - 1
            x = (xd - (k % pd)) % pd
        ans = 1
        while x != 0:
            x %= popcount(x)
            ans += 1
        print(ans)


### FIXED CODE ###

def popcount(x):
    return bin(x).count("1")

N, X = open(0).read().split()
N = int(N)
XS = list(X)
X = int(X, 2)

p = popcount(X)
xi = X % (p + 1)
if p == 1:
    xd = 0
else:
    xd = X % (p - 1)

for i in range(N):
    if XS[i] == "1":
        if p == 1:
            print(0)
            continue
        else:
            k = pow(2, N - 1 - i, p - 1)
            x = (xd - k) % (p - 1)
    else:
        k = pow(2, N - 1 - i, p + 1)
        x = (xi + k) % (p + 1)
    ans = 1
    while x != 0:
        x %= popcount(x)
        ans += 1
    print(ans)
### BUGGY CODE ###

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

t = sum(a)//2

for i in range(n):
    b = t
    if i==0 or i==1:
        b-= sum(a[i+1::2])
    else:
        b -= sum(a[i+1::2]+a[i-2::-2])
    print(b*2,end=' ')



### FIXED CODE ###

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

t = sum(a)//2

b = [0]*n

b[0]=sum(a[1::2])
b[1]=sum(a[2::2])

for i in range(2,n):
    b[i] =b[i-2]-a[i-1]+a[i-2]

for i in range(n):
    print((t-b[i])*2, end=' ')
### BUGGY CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
 
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
 
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()
 
 
def main():
    n = II()
    a = [0] + [II() for _ in range(n-1)]
    d = collections.defaultdict(list)
    for i in range(1,n):
        d[a[i]].append(i+1)
    m = {}
    def f(i):
        if not d[i]:
            return 0
        t = collections.defaultdict(int)
        for c in d[i]:
            t[f(c)] += 1
        t = list(t.items())
        t.sort()
        r = 0
        for c, tc in t:
            if r < c:
                r = c
            r += tc
        return r
    return f(1)
 
 
print(main())

### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()


def main():
    n = II()
    a = [0] + [II() for _ in range(n-1)]
    d = collections.defaultdict(list)
    for i in range(1,n):
        d[a[i]].append(i+1)
    m = {}
    def f(i):
        if not d[i]:
            return 0
        t = collections.defaultdict(int)
        for c in d[i]:
            t[f(c)] += 1
        t = list(t.items())
        t.sort()
        r = 0
        for c, tc in t:
            if r < c:
                r = c
            r += tc
        return r
    return f(1)


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

from collections import deque
N,M=map(int,input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
l=[0]*(N-1)
bo=[1]
box=deque(bo)
count=0
while count<N-1:
    for i in range(M):
        if AB[i][0]==box[0] and l[AB[i][1]-2]==0:
            box.append(AB[i][1])
            l[AB[i][1]-2]=AB[i][0]
            count+=1
        elif AB[i][1]==box[0] and l[AB[i][0]-2]==0:
            box.append(AB[i][0])
            l[AB[i][0]-2]=AB[i][1]
            count+=1
    box.popleft()
print("Yes")
[print(i) for i in l]

### FIXED CODE ###

from collections import deque
n,m=map(int,input().split())
ab=[list(map(int, input().split())) for _ in range(m)]
l=[[] for i in range(n)]#各部屋とつながっている部屋
#print(l,ab)
for a,b in ab:
    l[a-1].append(b)
    l[b-1].append(a)
result=[-1]*n
q=deque([1])
#print(l,result)
while True:
    if len(q)==0:
        break
    x=q.popleft()
    for j in l[x-1]:
        if result[j-1]==-1:
            result[j-1]=x
            q.append(j)
    #print(q,result)

print("Yes")
[print(i) for i in result[1:]]
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
C - Dice and Coin
https://atcoder.jp/contests/abc126/tasks/abc126_c
 
"""
import sys
 
 
from decimal import *
from math import log2, ceil
 
def solve(N, K):
    getcontext().prec = 12
    ans = Decimal(0)
    for i in range(1, N+1):
        if i >= K:
            t = Decimal (1/N)
        else:
            t = Decimal(1/N/2**ceil(log2(K/i)))
        ans += t
    return ans
 
 
def main(args):
    N, K = map(int, input().split())
    ans = solve(N, K)
    print(ans)
 
 
if __name__ == '__main__':
    main(sys.argv[1:])

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
C - Dice and Coin
https://atcoder.jp/contests/abc126/tasks/abc126_c

"""
import sys


from decimal import *
from math import log2, ceil

#TLE
def __solve(N, K):
    getcontext().prec = 30
    ans = Decimal(0)
    for i in range(1, N+1):
        if i >= K:
            t = Decimal (1/N)
        else:
            t = Decimal(1/N/2**ceil(log2(K/i)))
        ans += t
    return ans


def solve(N, K):
    ans = 0
    for i in range(1, N+1):
        if i >= K:
            t = 1 / N
        else:
            t = 1/N/2**ceil(log2(K/i))
        ans += t
    return ans


def main(args):
    N, K = map(int, input().split())
    ans = solve(N, K)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])