Harryxun/stf_run huggingface dataset:
import bisect
n = int(input())
a = list(map(int, input().split()))
edges = [[] for _ in range(n)]
for _ in range(n-1):
    u, v = map(int, input().split())
    edges[u-1].append(v-1)
    edges[v-1].append(u-1)

d = [-1 for _ in range(n)]

def dfs(i, s):
    d[i] = len(s)

    for to in edges[i]:
        if d[to] == -1:
            t = s.copy()
            if t[-1] < a[to]:
                t.append(a[to])
                dfs(to, t)
            else:
                t[bisect.bisect_left(t, a[to])] = a[to]
                dfs(to, t)

dfs(0, [a[0]])
for i in range(n):
    print(d[i])

### FIXED CODE ###

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

n = int(input())
a = list(map(int, input().split()))
edges = [[] for _ in range(n)]
for _ in range(n-1):
    u, v = map(int, input().split())
    edges[u-1].append(v-1)
    edges[v-1].append(u-1)

inf = 10 ** 10
d = [inf for _ in range(n)]
dp = [inf for _ in range(n)]

def dfs(cur, prev):
    memo = bisect.bisect_left(dp, a[cur])
    memo_v = dp[memo]
    dp[memo] = a[cur]
    d[cur] = bisect.bisect_left(dp, inf)

    for to in edges[cur]:
        if to != prev:
            dfs(to, cur)

    dp[memo] = memo_v

dfs(0, -1)
for i in range(n):
    print(d[i])
N, K = int(input())
A = list(map(int, input().split()))

min_idx = 10**5
for idx in range(N):
  if A[idx] < A[min_idx]:
    min_idx = idx
ans = 0
if (N-idx)%(K-1) == 0:
  ans += (N-idx)//(K-1)
else:
  ans += (N-idx)//(K-1)+1
if idx%(K-1) == 0:
  ans += idx//(K-1)
else:
  ans += idx//(K-1) + 1
print(ans)


### FIXED CODE ###

import math

N, K = map(int, input().split())
nums = list(map(int, input().split()))
print(math.ceil((len(nums)-1)/(K-1)))
s = list(input())

hoge = []
for si in s:
  if si != "B":
    hoge.append(si)
  else:
    hoge.pop()
    
print("".join(hoge))

### FIXED CODE ###

s = list(input())

hoge = []
for si in s:
  if si != "B":
    hoge.append(si)
  elif si == "B" and len(hoge) > 0:
    hoge.pop()
    
print("".join(hoge))
s = list(input())

if(s[0] == s[1] == s[2] == "R"):
    ans = 3
elif(s[0] == s[1] == "R" or s[2] == s[1] == "R"):
    ans = 2
elif(s[0] == s[1] == s[2] == "S"):
    ans = 0
else:
    ans = 1

pritn(ans)


### FIXED CODE ###

s = list(input())

if(s[0] == s[1] == s[2] == "R"):
    ans = 3
elif(s[0] == s[1] == "R" or s[2] == s[1] == "R"):
    ans = 2
elif(s[0] == s[1] == s[2] == "S"):
    ans = 0
else:
    ans = 1

print(ans)
n = int(input())
A = list(map(int, input().split()))

# A[0]との和 - idxの差の数
box = [0] * (n - 1)

for i in range(n - 1):
  box[A[0] + A[i + 1] - i - 1] += 1 

ans = 0
for a in A:
  ans += sum(i if itr == (A[0] - a) else 0 for itr, i in enumerate(box))

print(ans)

### FIXED CODE ###

from collections import Counter

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

L = [i + a for i, a in enumerate(A)]
R = [i - a for i, a in enumerate(A)]

cL = Counter(L)
cR = Counter(R)

ans = 0
for i in cL.keys():
  ans += cL[i] * cR[i]

print(ans)
while(True):
    a = int(input())
    b = a // 1000
    c = (a - 1000 * b) // 100
    d = a % 100 // 10
    e=a%10
    if ( b == c and c==d ):
        print('Yes')
    elif(c==d and d==e):
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

a = int(input())
b = a // 1000
c = (a - 1000 * b) // 100
d = a % 100 // 10
e=a%10
if ( b == c and c==d ):
        print('Yes')
elif(c==d and d==e):
        print('Yes')
else:
        print('No')
N, Q = list(map(int, input().split()))
s = input()
td = [input().split() for i in range(Q)]

td.reverse()

nl = 0
nr = N - 1
L = []
R = []
for i in td:
  if i[1] == "L":
    if s[nl] == i[0]:
      L.append(i[0])
      nl += 1
    if len(R) == 0:
      continue
    if R[-1] == i[0]:
      R.pop()
      nr += 1
  else:
    if s[nr] == i[0]:
      R.append(i[0])
      nr -= 1
    if len(L) == 0:
      continue
    if L[-1] == i[0]:
      L.pop()
      nl -= 1

print(N - len(L) - len(R))

### FIXED CODE ###

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

td.reverse()

nl = 0
nr = N - 1
L = []
R = []
for i in td:
  if i[1] == "L":
    if nl < N:
      if s[nl] == i[0]:
        L.append(i[0])
        nl += 1
    if len(R) != 0:
      if R[-1] == i[0]:
        R.pop()
        nr += 1
  else:
    if nr >= 0:
      if s[nr] == i[0]:
        R.append(i[0])
        nr -= 1
    if len(L) != 0:
      if L[-1] == i[0]:
        L.pop()
        nl -= 1

print(N - len(L) - len(R))
inp = [int(i) for i in input().split()]
n = inp[0]
a = inp[1]
b = inp[2]

# C = {}
# def cmb(n,r):
#   print(n,r)
#   if r==0 or r ==n:
#     return 1
#   if r==1:
#     return n
#   if (n,r) in C:
#     return C[(n,r)]
#   C[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
#   return C[(n,r)]

# def cmb(n, r):
#     if n - r < r: r = n - r
#     if r == 0: return 1
#     if r == 1: return n
#
#     numerator = [n - r + k + 1 for k in range(r)]
#     denominator = [k + 1 for k in range(r)]
#
#     for p in range(2,r+1):
#         pivot = denominator[p - 1]
#         if pivot > 1:
#             offset = (n - r) % p
#             for k in range(p-1,r,p):
#                 numerator[k - offset] /= pivot
#                 denominator[k] /= pivot
#
#     result = 1
#     for k in range(r):
#         if numerator[k] > 1:
#             result *= int(numerator[k])
#
#     return result

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

mod = 10**9+7 #出力の制限
N = 2*10**5
M = 10**9
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

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

# for i in range(N+1, )

# mod = 10**9+7
# MAX_N = 10**9

# fact = [1]
# fact_inv = [0]*(MAX_N+4)
# for i in range(MAX_N+3):
#     fact.append(fact[-1]*(i+1)%mod)
#
# fact_inv[-1] = pow(fact[-1],mod-2,mod)
# for i in range(MAX_N+2,-1,-1):
#     fact_inv[i] = fact_inv[i+1]*(i+1)%mod
#
#
# def mod_comb_k(n,k,mod):
#     return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod

A = mod_cmb_k(n,a,mod)
B = mod_cmb_k(n,b,mod)
ans = 2**n-1-A-B
print(ans%(10**9+7))

### FIXED CODE ###

import math
n,a,b = [int(i) for i in input().split()]
mod = 10**9+7
  
def comb(n,k):
  ans = 1
  for i in range(k):
    ans = ans*(n-i)%mod
  for i in range(1,k+1):
    ans = ans*pow(i,mod-2,mod)%mod
  return ans

print((pow(2,n,mod)-1-comb(n,a)-comb(n,b))%mod)
# print(comb(n,a))
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()
    A=list(mi()) + [0]

    dp = [[0] * (2*10**3+10) for _ in range(N+1)]
    x = 1000//A[0]
    dp[0][x] = 1000 - x * A[0]


    for i in range(x):
        dp[0][i] = 1000 - i * A[0]

    mx = x
    for i in range(N):
        _mx = mx
        for m in range(mx+1):
            for n in range(m+1):
                dp[i+1][m-n] = max(0,dp[i+1][m-n],dp[i][m] + A[i+1] * n)
                # assert dp[i+1][m-n] >= 0
            
            if A[i+1] != 0:
                for j in range((dp[i][m] // A[i+1])+1):
                    dp[i+1][m+j] = max(0,dp[i+1][m+j],dp[i][m] - A[i+1] * j)
                    _mx = max(_mx,m+j)
                    
                    # assert dp[i+1][m+j] >= 0

        mx = _mx

    ans = 0
    for i in range(len(dp[N-1])):
        if dp[N-1][i] == 0: continue
        ans = max(ans, dp[N-1][i] + A[N-1] * i)

    # print(dp[3][10])
    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()
    _A=list(mi())
    A = []

    for a in _A:
        if len(A) > 0 and A[-1] == a: continue
        A.append(a)
    
    N = len(A)
    bottoms = []
    
    if N < 2:
        print(1000)
        exit()

    if A[0] < A[1]:
        bottoms.append(0)

    for i in range(N-1):
        if not i+2 < len(A): continue
        # print(A[i], A[i+1], A[i+2])
        if A[i] > A[i+1] and A[i+1] < A[i+2]:
            bottoms.append(i+1)
    
    money = 1000
    kabu = 0
    # print(bottoms)
    for bi in bottoms:
        bottom = A[bi]
        i = bi
        while i < N-1 and A[i] < A[i+1]:
            i += 1
        
        top = A[i]

        # print(bi,i)
        # print(bottom,top)
        kabu += money//bottom
        money -= money//bottom * bottom
        
        money += kabu * top
        kabu = 0
        # print("money",money)
    
    print(money)

    

if __name__ == "__main__":
    main()
import bisect
import sys
input = sys.stdin.readline
def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    b = []
    min_num = min(a)
    process = []
    p_append = process.append

    for i in range(m):
        array = list(map(int, input().split()))
        if array[1] > min_num:
            p_append(array)

    a.sort()
    process = sorted(process, key=lambda x: -x[1])

    for i in range(len(process)):
        index = bisect.bisect_left(a, process[i][1])
        ooo = min(index, process[i][0])
        if ooo == 0:
            continue
        else:
            a = a[ooo:]
            b.append(process[i][1] * ooo)
        if a[0] > process[i][1]:
            break

    print(sum(a)+sum(b))

if __name__ == '__main__':
    main()

### FIXED CODE ###

from operator import itemgetter

def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    change = []
    process = []
    p_append = process.append

    for i in range(m):
        array = list(map(int, input().split()))
        p_append(array)

    process.sort(key = itemgetter(1),reverse=True)

    for i in range(len(process)):
        change += [process[i][1]] * process[i][0]
        if len(change) >= n:
            break

    a = a + change
    a.sort(reverse=True)
    a = a[:n]
    print(sum(a))

if __name__ == '__main__':
    main()
import math

n,m = map(int, input().split())
k = int(math.sqrt(m))
a = []
b = []
for i in range(1,k+10):
    if m%i==0:
        a.append(m//i)
        b.append(i)
    else:
        continue
for i in a:
    if m//i>=n:
        ans = i
        break
for i in reversed(b):
    if m//i>=n:
        ans = max(ans,i)
        break
    else:
        continue
print(ans)

### FIXED CODE ###

import math

n,m = map(int, input().split())
k = int(math.sqrt(m))
a = []
b = []
ans = 0
for i in range(1,k+10):
    if m%i==0:
        a.append(m//i)
        b.append(i)
    else:
        continue
for i in a:
    if m//i>=n:
        ans = i
        break
for i in reversed(b):
    if m//i>=n:
        ans = max(ans,i)
        break
    else:
        continue
print(ans)
n = int(input())
al = list(map(int,input().split()))
al_p = 1

for i in range(n):
    al_p *= al[i]
    if al_p > 10**18:
        print(-1)
        return
        
print(al_p)
    

### FIXED CODE ###


def main():
    n = int(input())
    al = list(map(int,input().split()))
    al_p = 1

    if 0 in al:
        print(0)
        return

    for i in range(n):
        al_p *= al[i]
        if al_p > 10**18:
            print(-1)
            return
        
    print(al_p)

main()
N = int(input())
S = input()
R = [] 
G = []
B = []
i = 1
while i < N+1:
  a = S[i-1]
  if a == 'R':
    R.append(i)
  elif a == 'G':
    G.append(i)
  else:
    B.append(i)
  i += 1
  

c = 0
d = len(R)*len(G)*len(B)


if d == 0:
    print(0)
else:
    for t in range(len(R)):
        for u in range(len(G)):
            k = (R[t] + G[u])/2
            if 2*R[t]- G[u] > 0:
              l = 2*R[t]-G[u]
              if l|set(B)==set(B):
                c += 1
            if 2*G[u] - R[t] > 0:
              
              m = 2*G[u]-R[t]
              if m|set(B)==set(B):
                c += 1
            if k|set(B)==set(B):
                c += 1

print(d-c)

### FIXED CODE ###

n=int(input())
S=list(input())
dp=[[0]*(8) for i in range(n+1)]
dp[0][0]=1
for i in range(1,n+1):
  if S[i-1]=="R":
    for j in range(8):
      dp[i][j]=dp[i-1][j]
    dp[i][1]+=dp[i-1][0]
    dp[i][4]+=dp[i-1][2]
    dp[i][6]+=dp[i-1][3]
    dp[i][7]+=dp[i-1][5]
  elif S[i-1]=="G":
    for j in range(8):
      dp[i][j]=dp[i-1][j]
    dp[i][2]+=dp[i-1][0]
    dp[i][4]+=dp[i-1][1]
    dp[i][5]+=dp[i-1][3]
    dp[i][7]+=dp[i-1][6]
  else:
    for j in range(8):
      dp[i][j]=dp[i-1][j]
    dp[i][3]+=dp[i-1][0]
    dp[i][5]+=dp[i-1][2]
    dp[i][6]+=dp[i-1][1]
    dp[i][7]+=dp[i-1][4]
a=0
for i in range(n-2):
  for j in range(i+1,n-1):
    k=j*2-i
    if k>=n:
      continue
    if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
      a=a+1
print(dp[n][7]-a)
from sys import stdin


def dprint(*args):
    #print(*args)
    pass


n, a, b, c = [int(x) for x in stdin.readline().rstrip().split()]
ans = "Yes"

card = []
sentaku = []

for i in range(n):
    s = stdin.readline().rstrip()
    card.append(s)

if a+b+c == 0:
    ans = "No"

nums = {"A": a, "B": b, "C": c}


def judge(i, j, k):
    global ans
    dprint(i, j, k, ans, sentaku)
    if nums[j] == 0 and nums[k] == 0:
        ans = "No"
        return

    if nums[j] == 0:
        nums[j] += 1
        nums[k] -= 1
        sentaku.append(j)
        return
    if nums[k] == 0:
        nums[k] += 1
        nums[j] -= 1
        sentaku.append(k)
        return

    total = sum(nums.values())
    if total > 2 or i < n-1:
        nums[j] += 1
        nums[k] -= 1
        sentaku.append(j)
        return

    ns = card[i+1]
    if ns[0] == j or ns[1] == j:
        nums[j] += 1
        nums[k] -= 1
        sentaku.append(j)
        return
    else:
        nums[k] += 1
        nums[j] -= 1
        sentaku.append(k)
        return
    pass


for i in range(n):
    s = card[i]
    judge(i, s[0], s[1])


print(ans)

if ans == "Yes":
    for i in range(len(sentaku)):
        print(sentaku[i])


### FIXED CODE ###

from sys import stdin

import time
def dprint(*args):
    #print(*args)
    pass


n, a, b, c = [int(x) for x in stdin.readline().rstrip().split()]
ans = "Yes"

card = []
sentaku = []

for i in range(n):
    s = stdin.readline().rstrip()
    card.append(s)

if a+b+c == 0:
    ans = "No"

nums = {"A": a, "B": b, "C": c}


def judge(i, j, k):
    global ans
    dprint(n, i, j, k, ans, nums, sentaku)
    if nums[j] == 0 and nums[k] == 0:
        ans = "No"
        return

    if nums[j] == 0:
        nums[j] += 1
        nums[k] -= 1
        sentaku.append(j)
        return
    if nums[k] == 0:
        nums[k] += 1
        nums[j] -= 1
        sentaku.append(k)
        return

    total = sum(nums.values())
    if total > 2 or i == n-1:
        if nums[k] > 1:
            nums[j] += 1
            nums[k] -= 1
            sentaku.append(j)
        else:
            nums[k] += 1
            nums[j] -= 1
            sentaku.append(k)
        dprint("tekitou")
        return

    ns = card[i+1]
    if ns[0] == j or ns[1] == j:
        nums[j] += 1
        nums[k] -= 1
        sentaku.append(j)
        return
    else:
        nums[k] += 1
        nums[j] -= 1
        sentaku.append(k)
        return
    pass


for i in range(n):
    s = card[i]
    judge(i, s[0], s[1])

print(ans)

if ans == "Yes":
    for i in range(len(sentaku)):
        print(sentaku[i])
(n,),*a=[[*map(int,i.split())]for i in open(0)]
d={}
for i,j in a:
    for x,y in a:
        if i!=x or j!=y:
            d[(i-x,j-y)]=d.get((i-x,j-y),0)+1
print(n-max(d.values()))

### FIXED CODE ###

(n,),*a=[[*map(int,i.split())]for i in open(0)]
d={}
for i,j in a:
    for x,y in a:
        if i!=x or j!=y:
            d[(i-x,j-y)]=d.get((i-x,j-y),0)+1
print(n-max(list(d.values())+[0]))
import heapq
import copy
import bisect

n = int(input())
a = []
b = []
flag = True

for _ in range(n):
	a_dash,b_dash = map(int,input().split())
	a.append(a_dash)
	b.append(b_dash)

t = 0
a2 = copy.deepcopy(a)
b2 = copy.deepcopy(b)
heapq.heapify(b2)

for i in range(n):
	minimum = heapq.heappop(b2)
	index = bisect.bisect_left(b,minimum)
	for _ in range(n):
		if a2[index] == -1:
			index += 1
		else:
			break
	a2[index] = -1
	t += a[index]
	if t > minimum:
		flag = False
		break

if flag:
	print('Yes')
else:
	print('No')


### FIXED CODE ###

import heapq
import copy
import bisect
from collections import deque

n = int(input())
a = []
b = []
tmp_a = []
tmp_b = []
flag = True

for _ in range(n):
	a_dash,b_dash = map(int,input().split())
	tmp_a.append(a_dash)
	tmp_b.append(b_dash)

k = zip(tmp_b,tmp_a)
sorted_k = sorted(k)
for b_dash,a_dash in sorted_k:
	a.append(a_dash)
	b.append(b_dash)

t = 0
qa = deque(a)
qb = deque(b)

for i in range(n):
	minimum_a = qa.popleft()
	minimum_b = qb.popleft()
	t += minimum_a
	if t > minimum_b:
		flag = False
		break

if flag:
	print('Yes')
else:
	print('No')
from heapq import heappop, heappush


def main():
    N, M, S = map(int, input().split())
    adj = [set() for _ in range(N)]
    for i in range(M):
        x, y = map(int, input().split())
        adj[x-1].add(y-1)
        adj[y-1].add(x-1)
    path = [-1] * N
    q = [(-(S-1), S-1)]
    while len(q):
        minimum, cur = heappop(q)
        minimum = -minimum
        if minimum <= path[cur]:
            continue
        path[cur] = minimum
        for a in adj[cur]:
            heappush(q, (-min(minimum, a), a))
    for i in range(N):
        if path[i] == i:
            print(i+1)


if __name__ == "__main__":
    main()


### FIXED CODE ###

class SegmentTree():
    def __init__(self, values, merge_func=min, default=float("inf")):
        n = len(values)
        self.size = 1
        self.default = default
        self.merge = merge_func
        while self.size < n:
            self.size *= 2
        # tree[0] = empty
        # child of tree[n] = tree[n*2], tree[n*2+1]
        self.tree = [self.default] * self.size * 2
        for i in range(n):
            self.tree[self.size + i] = values[i]
        for i in range(self.size-1, 0, -1):
            self.tree[i] = self.merge(self.tree[i*2], self.tree[i*2+1])

    def update(self, index, value):
        index += self.size
        self.tree[index] = value
        while index > 1:
            index //= 2
            self.tree[index] = self.merge(
                self.tree[index*2], self.tree[index*2+1])

    def __query(self, a, b, k, l, r):
        if r <= a or b <= l:
            return self.default
        if a <= l and r <= b:
            return self.tree[k]
        left = self.__query(a, b, k*2, l, (l+r)//2)
        right = self.__query(a, b, k*2+1, (l+r)//2, r)
        return self.merge(left, right)

    # query segmentation value of [a, b)
    def query(self, a, b):
        return self.__query(a, b, 1, 0, self.size)


def main():
    N = int(input())
    H = list(map(int, input().split()))
    A = list(map(int, input().split()))
    RMQ = SegmentTree([0] * N, merge_func=max, default=0)
    for i in range(N):
        maximum = RMQ.query(0, H[i]-1)
        RMQ.update(H[i]-1, maximum + A[i])
    print(RMQ.query(0, N))


if __name__ == "__main__":
    main()
N,K=map(int,input().split())

Sanuke=list(range(K))

for i in range(N):
  di=int(input())
  A=list(map(int,input().split()))-1
  for j in A:
    Sanuke[j]+=1

higaisha=0

for i in Sanuke:
  if i ==0:
    higaisha += 1

print(higaisha)

### FIXED CODE ###

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

ans=[0]*n

for i in range(k):
  d=int(input())
  a=[int(k) - 1 for k in input().split()]
  for j in a:
    ans[j]+=1

ansint=0


for i in range(n):
  if ans[i]==0:
    ansint+=1


print(ansint)
a,b,k=map(int, input().split())
k=min(k,b-a)
*al,=range(a,b+1)
ans=al[:k]+al[-k:]
ans=list(set(ans))
ans.sort()
for i in ans:print(i)



### FIXED CODE ###

a,b,k=map(int, input().split())
k=min(k,b-a+1)
*al,=range(a,a+k)
*al2,=range(b-k+1,b+1)
ans=al+al2
ans=list(set(ans))
ans.sort()
for i in ans:print(i)
N, T = input().split()
dic = {}
for i in range(int(input()):
	c, t = [int(i) in input().split()]
    dic[t].append(c)
if max(dic) <= T:
	print(dic[max(dic)])
else:
	print('TLE')

### FIXED CODE ###

N, T = map(int, input().split())
costs = []
for i in range(N):
    c, t = map(int, input().split())
    if t <= T:
        costs.append(c)
if len(costs) == 0:
    print('TLE')
else:
    print(min(costs))
N = int(input())

if N < 1000:
  print("ABC" + N)
else:
  print("ABD" + (N - 999))

### FIXED CODE ###

N = int(input())

if N < 1000:
  print("ABC")
else:
  print("ABD")
import math
N, K = map(int, input().split())

B = [[] for _ in range(N)]
for i, a in enumerate(range(1, N+1)):
    B[i] = max(math.ceil(math.log2(K/a)), 0)
#print(B)

ans = 0
for b in B:
    ans += 1/2**b
print(ans/N)

### FIXED CODE ###

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

B = [[] for _ in range(N)]
for i, a in enumerate(range(1, N+1)):
    B[i] = max(math.ceil(math.log2(K/a)), 0)
#print(B)

ans = 0
for b in B:
    ans += 1/2**b
print(ans/N)
N, M = list(map(int, input().split()))
S = input()
T = input()

from fractions import gcd
L = (N * M) // gcd(N, M)

L1 = [1]
L2 = [1]
for i in range(1, N):
    t = i * (L // N) + 1
    L1.append(t)

for i in range(1, M):
    t = (L // M) + 1
    L2.append(t)

common = []

# print(L1)
# print(L2)

LS = [None] * L
for i, li in enumerate(L1):
    ind = li-1
    LS[ind] = S[i]

ans = True
for i, li in enumerate(L2):
    ind = li-1
    if LS[ind] is not None:
        if LS[ind] != T[i]:
            ans = False

if ans:
    print(L)
else:
    print(-1)

### FIXED CODE ###

from fractions import gcd

N, M = list(map(int, input().split()))
S = input()
T = input()

L = (N * M) // gcd(N, M)

L1 = [0]
L2 = [0]

from collections import Counter
c = Counter()

for i in range(1, N):
    t = i * (L // N) + 1
    L1.append(t-1)

for i in range(1, M):
    t = i * (L // M) + 1
    L2.append(t-1)


d = {}
for i, li in enumerate(L1):
    d[li] = S[i]

# print(d)

ans = True

for i, li in enumerate(L2):
    if not d.get(li):
        continue
    if d[li] != T[i]:
        ans = False

# print(L1)
# print(L2)
# print(common)
# print(dic)

if ans:
    print(L)
else:
    print(-1)
N,K=map(int,input().strip().split())
A=list(map(int,input().strip().split()))

l=[1]
x=1
for n in range(N):
    y=A[x-1]
    l.append(y)
    x=y

x=[0 for n in range(N)]
for n in range(N):
    x[l[n]-1]+=1
    if x[l[n]-1]==2:
        temp=n
        break
for m in range(len(l)):
    if l[m]==temp:
        bias=m
        mul=temp-bias+1
        break

if bias>K:
    print(l[K])
else:
    print(l[bias+(K-bias)%mul])

### FIXED CODE ###

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

l=[1]
x=1
cnt=[0 for n in range(N)]
cnt[0]=1
for n in range(N):
    y=A[x-1]
    l.append(y)
    cnt[y-1]+=1
    x=y
    if cnt[y-1]==2:
        value=y
        temp=n
        break

for m in range(len(l)):
    if l[m]==value:
        bias=m
        mul=temp-bias+1
        break
    
if bias>K:
    print(l[K])
else:
    print(l[bias+(K-bias)%mul])
n = input()
for i in range(n-1):
    a = raw_input().split()
    n *= 1
    print(n)

### FIXED CODE ###

a,b = input().split()
print(int(a) * int(b))
N = int(input())
A = sorted(list(map(int, input().split())))
Q = int(input())
M = list(map(int, input().split()))

def exhastive_search(target, head, sum):
    for i in range(head, N):
        sum += A[i]
        if target == sum:
            return True
        elif target > sum:
            if exhastive_search(target, i+1, sum):
                return True
            sum -= A[i]
        else:
            return False
    return False


for target in M:
    sum = 0
    result = "no"
    for i in range(N):
        if exhastive_search(target, i, sum):
            result = "yes"
            break
    print(result)


### FIXED CODE ###

def solve(dp, a, i, m):
  if m in dp[i]:
    return dp[i][m]

  if m == 0:
    dp[i][m] = True
  elif i >= len(a):
    dp[i][m] = False
  elif solve(dp, a, i+1, m):
    dp[i][m] = True
  elif solve(dp, a, i+1, m-a[i]):
    dp[i][m] = True
  else:
    dp[i][m] = False

  return dp[i][m]

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

dp = {}
for i in range(N+1):
  dp[i] = {}

for m in M:
  if solve(dp, A, 0, m):
    print('yes')
  else:
    print('no')