Harryxun/stf_run huggingface dataset:
N=int(input())
l_list=[int(input())for _ in range(N)]
max_l=max(l_list)
if sum(l_list)-max_l>max_l:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N=int(input())
table=list(map(int,input().split()))
if max(table)*2<sum(table[:]):
  print("Yes")
else :
  print("No")
n,a,b=map(int,input().split())
if abs(a-b)%2==0:
  print(abs(a-b)//2)
else:
  print(min(max(a-1,b-1),max(n-a,n-b))

### FIXED CODE ###

n,a,b=map(int,input().split())
if abs(a-b)%2==0:
  print(abs(a-b)//2)
else:
  temp=min(min(a-1,b-1),min(n-a,n-b))+1  
  print(min(temp+(abs(a-b)-1)//2,min(max(a-1,b-1),max(n-a,n-b))))
A=input().split()
a=A[0]
b=A[1]
c=A[2]
d=A[3]
if abs(a-c) <= d:
  print("Yes")
elif (abs(a-b) <= d) & (abs(b-c) <= d):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

A=input().split()
a=int(A[0])
b=int(A[1])
c=int(A[2])
d=int(A[3])
if abs(a-c) <= d:
  print("Yes")
elif (abs(a-b) <= d) & (abs(b-c) <= d):
  print("Yes")
else:
  print("No")
n ais = [int(raw_input())] + map(int, raw_input().split())

r = 0
cumul = 0
m = +float('inf')
for i in range(1, len(ais)):
	cumul += ais[i]
	
	if cumul % 10 == 0:

		r = max(r, cumul - m)
	else:
		m = min(m, ais[i])
		r = max(r, cumul)

print r

### FIXED CODE ###

n = int(raw_input()) 
ais = [int(raw_input()) for _ in range(n)]
r = 0
cumul = 0
m = +float('inf')
for i in range(0, len(ais)):
	cumul += ais[i]
	if ais[i] % 10:
		m = min(m, ais[i])

	if cumul % 10 == 0:
		r = max(r, cumul - m)
	else:
		r = max(r, cumul)

print r
from typing import List
from functools import reduce
from operator import add


def create_hole(A: List, b:List):

    N = len(A)
    Hole = [[0 for i in range(N)] for j in range(N)]
    for i in range(3):
        for j in range(3):
            for value in b:
                if A[i][j] == value: Hole[i][j] = 1

    return Hole


def check_bingo(H: List):

    N = len(H)
    rowsum = sum([sum(row) == N for row in H])
    colsum = sum([sum(row) == N for row in map(list, zip(*H))])
    digsum = sum([H[i][i] for i in range(N)]) == N
    tdigsum = sum([H[i][N-i-1] for i in range(N)]) == N

    return rowsum + colsum + digsum + tdigsum > 0


def resolve():

    A = [list(map(int, input().split())) for i in range(3)]
    N = int(input())
    b = [int(input()) for i in range(N)]
    print('Yes' if check_bingo(create_hole(A, b)) else 'No')

resolve()

### FIXED CODE ###

def create_hole(A: list, b:list):

    N = len(A)
    Hole = [[0 for i in range(N)] for j in range(N)]
    for i in range(3):
        for j in range(3):
            for value in b:
                if A[i][j] == value: Hole[i][j] = 1

    return Hole


def check_bingo(H: list):

    N = len(H)
    rowsum = sum([sum(row) == N for row in H])
    colsum = sum([sum(row) == N for row in map(list, zip(*H))])
    digsum = sum([H[i][i] for i in range(N)]) == N
    tdigsum = sum([H[i][N-i-1] for i in range(N)]) == N

    return rowsum + colsum + digsum + tdigsum > 0


def resolve():

    A = [list(map(int, input().split())) for i in range(3)]
    N = int(input())
    b = [int(input()) for i in range(N)]
    print('Yes' if check_bingo(create_hole(A, b)) else 'No')
    
resolve()
n, m = map(int, input().split())
a = []
for i in range(m):
    a.append(int(input()))

flag = 0
for i in range(m-1):
    if a[i+1] - a[i] == 0:
        flag = 1
        print(0)
        break

if flag == 0:
    b = [1]
    if a[0] == 1:
        b.append(0)
        a.pop(0)
    else:
        b.append(1)
    for i in range(2, n+1):
        if len(a) != 0 and a[0] == i:
            b.append(0)
            a.pop(0)
        else:
            b.append((b[i-1]+b[i-2])%1000000007)

print(b[-1])

### FIXED CODE ###

n, m = map(int, input().split())
a = []
for i in range(m):
    a.append(int(input()))

flag = 0
for i in range(m-1):
    if a[i+1] - a[i] == 0:
        flag = 1
        print(0)
        break

if flag == 0:
    b = [1]
    if len(a) != 0 and a[0] == 1:
        b.append(0)
        a.pop(0)
    else:
        b.append(1)
    for i in range(2, n+1):
        if len(a) != 0 and a[0] == i:
            b.append(0)
            a.pop(0)
        else:
            b.append((b[i-1]+b[i-2])%1000000007)

    print(b[-1])
s = input()
x, count0, count1 = 0
for i in s:
    count0 = count0+1 if i==str(x) else count0
    x = int(not(x))
x = 1
for i in s:
    count1 = count1 + 1 if i == str(x) else count1
    x = int(not(x))
print(min(count0, count1))

### FIXED CODE ###

s = input()

x = 0
count0 = 0
count1 = 0

for i in s:
    if i == str(x):
        count0 += 1
    x = int(not(x))

x = 1
for i in s:
    if i == str(x):
        count1 += 1
    x = int(not(x))
#print("count0:" + str(count0))
#print("count1:" + str(count1))
print(min(count0, count1))
N = int(input())
A = list(map(int, input().split()))
A.sort()
B = [0] * (2 * 10 ** 5 + 1)
M = A[-1]

for a in A:
	B[a] += 1

if sum(B) == 1:
	print(0)
else:
	for a in A:
		if B[a] > 0:
			i = 2
			b = a * i
			while b <= M:
				B[b] = 0
				i += 1
				b = a * i
	print(sum(B))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
A.sort()
M = max(A)
B = [0] * (M + 1)

for a in A:
    B[a] += 1

for a in A:
    if B[a] > 0:
        i = 2
        b = a * i
        while b <= M:
            B[b] = 0
            i += 1
            b = a * i
for i in range(M + 1):
    if B[i] > 1:
        B[i] = 0
print(sum(B))
b = []
a = [int(input()) for i in range(5)]
for i in a:
  if i % 10 != 0:
    b.append(10 - (i % 10))

print(sum(a) + sum(b) - max(b))

### FIXED CODE ###

a = [int(input()) for i in range(5)]
b = [9 - (i - 1) % 10 for i in a]
print(sum(a) + sum(b) - max(b))
N,A,B = map(int,input().split())
qaws = ""
c = 0
while(N > len(qaws)):
  qaws = qaws + "B"*A
  qaws = qaws + "R"*B
  c += 1
print(qaws[:N].count("B"))

### FIXED CODE ###

s = list(input())
i = len(set(s))
if i == 1:
  print("No")
else:
  print("Yes")
N = int(input())
S = input()
Q = int(input())
set_dic = {}
for i,s in enumerate(S):
    if s not in set_dic.keys():
        set_dic[s] = {i+1}
    else:
        set_dic[s].add(i+1)

for _ in range(Q):
    query = input()
    if query[0] == "1":
        i = int(query[2])
        c = query[4]
        for l in set_dic.values():
            l.discard(i)
        if c not in set_dic.keys():
            set_dic[c] = {i}
        else:
            set_dic[c].add(i)
    else:
        l = int(query[2])
        r = int(query[4])
        ans = 0
        for eachset in set_dic.values():
            for i in range(l,r+1):
                if i in eachset:
                    ans += 1
                    break
        print(ans)

### FIXED CODE ###

import bisect
import sys
input = sys.stdin.readline

def solve():
    N = int(input())
    S = list(input())
    Q = int(input())
    set_dic = {}

    for i, s in enumerate(S):
        if s not in set_dic:
            set_dic[s] = [i+1]
        else:
            bisect.insort_left(set_dic[s], i+1)

    anslist = []

    for _ in range(Q):
        query1, query2, query3 = input().split()
        if query1 == "1":
            i = int(query2)
            c = query3
            cap = S[i-1]
            if cap == c:
                continue
            set_dic[cap].remove(i)
            if c not in set_dic:
                set_dic[c] = [i]
            else:
                bisect.insort_left(set_dic[c], i)
            S[i-1] = c
        else:
            l = int(query2)
            r = int(query3)
            ansset = set()
            ans = 0
            for eachlist in set_dic.values():
                li = bisect.bisect_left(eachlist, l)
                ri = bisect.bisect_right(eachlist, r)
                if li != ri:
                    ans += 1
            anslist.append(ans)

    for i in anslist:
        print(i)

if __name__ == '__main__':
    solve()
while True:
    a = input()
    a = a.split(" ")
    b = []
    for i in a:
        b.append(int(i))
    if b[0] == 0 and b[1] == 0 and b[2] == 0 and b[3] == 0 and b[4] == 0:
        break
    c = input()
    c = c.split(" ")
    d = []
    for i in c:
        d.append(int(i))
    if b[4] == d[0]:
        print(0)
        continue
    ans = 2
    for i in d:
        for e in range(10000):
            x = (b[1] * b[4] + b[2]) % b[3]
            if x == i:
                b[4] = x
                break
            b[4] = x
            ans = ans + 1
    if ans >= 10001:
        ans = -1
    print(ans)




### FIXED CODE ###

while True:

    n, a, b, c, x = map(int, input().split(" "))

    if n == 0 and a == 0 and b == 0 and c == 0 and x == 0:
        break

    y = list(map(int, input().split(" ")))

    ans = 0
    i = 0
    
    while ans <= 10000:
        if x == y[i]:
            i += 1

        if i == n:
            break
        x = (a * x + b) % c
        ans += 1
    if ans >= 10001:
        ans = -1
    print(ans)
import math


def main():
    a, b = map(int, input().split())
    ans = round(a * b / math.gcd(a, b))
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def gcd(a, b):
    if a > b:
        a, b = (b, a)
    while b:
        a, b = b, a % b
    return a


def main():
    a, b = map(int, input().split())
    ans = round(a * b / gcd(a, b))
    print(ans)


if __name__ == '__main__':
    main()
S = input()
K = input()
if S[0] == '1':
    print(S[1])
else:
    print(S[0])

### FIXED CODE ###

S = input()
K = int(input())
ans = 1
for i, s in enumerate(S):
    if i+1 == K:
        ans = s
        break
    if s == '1':
        continue
    else:
        ans = s
        break

print(ans)
ef Round(ip, dg):  # ip???dg?????§?????¨?????\????????¢??°
    ip = ip / 10**dg
    if(ip-int(ip) != 0):
        return (int(ip) + 1)*10**dg
    else:
        return int(ip)*10**dg


n=int(input())
sum=100000
for i in range(0, n):
    sum=Round(sum*1.05)
print(sum)

### FIXED CODE ###

def Round(ip, dg):  # ip???dg?????§?????¨?????\????????¢??°
    ip = ip / 10**dg
    if(ip-int(ip) != 0):
        return (int(ip) + 1)*10**dg
    else:
        return int(ip)*10**dg


n=int(input())
sum=100000
for i in range(0, n):
    sum=Round(sum*1.05, 3)
print(sum)
a = int(input().split())
b = ont(input().split())
print(6 - a - b)

### FIXED CODE ###

a = int(input())
b = int(input())
print(6 - a - b)
n,k = map(int,input().split())
h = list(map(int,input().split()))
dp = [float("inf")]*n
dp[0] = 0
def chmin(a,b):
  if a>b:
    a = b
    return true
  else:
    return false
for i in range(0,n):
  for j in range(1,k):
    chmin(dp[i+j],dp[i]+abs(h[i]-h[i+j]))
print(dp[-1])

### FIXED CODE ###

def solve():
  n,k = map(int,input().split())
  h = list(map(int,input().split()))
  dp = [float("inf")]*n
  dp[0] = 0
  for i in range(0,n-1):
    for j in range(1,k+1):
      if (i-j)>=-1:
        dp[i+1]=min(dp[i+1],dp[i+1-j]+abs(h[i+1]-h[i+1-j]))
  print(dp[-1])
solve()
input = int(input())
nums = []
max = 0
total = 0
for x in input:
  nums.append(input)
  if(input > max):
    max = input
for x in range (1,len(nums)):
  total +=x
print(total - max + max/2) 
  


### FIXED CODE ###

N = int(input())
p = []
for _ in range(N):
    p.append(int(input()))
 
pmax = max(p)
ans = int(sum(p)-pmax/2)
print(ans)
n=int(input)
L=[i for i in input().split()]
count=0
for i in range(1,n+1,2):
  if(L[i-1]%2==0):
    count+=1
print(count)
  


### FIXED CODE ###

n=int(input())
L=[int(i) for i in input().split()]
count=0
for i in range(1,n+1,2):
  if(L[i-1]%2!=0):
    count+=1
print(count)
n,m = map(int,input().split())
lis = []
for i in range(n):
    a = list(input())
    for l in range(m):
        lis.append(a[l])
for t in range(15):
    if lis[t] == ".":
        cou = 0
        try:
            if lis[t-(m+1)] == "#":
                cou += 1
        except:
            cou = cou
        try:
            if lis[t - m] == "#":
                cou += 1
        except:
            cou = cou
        try:
            if lis[t -(m-1)] == "#":
              cou += 1
        except:
            cou = cou
        try:
            if lis[t -1] == "#":
                cou += 1
        except:
            cou = cou
        try:
            if lis[t+1]== "#":
                cou += 1
        except:
            cou = cou
        try:
            if lis[t +m] == "#":
                cou += 1
        except:
            cou = cou
        try:
            if lis[t +(m-1)]== "#":
                cou += 1
        except:
            cou = cou
        try:
            if lis[t+(m+1)]== "#":
                cou += 1
        except:
            cou = cou
        lis[t] = cou

for p in range(n):
    li = []
    for h in range(m):
        li.append(lis[(p * m) + h])
    print("".join(map(str,li)))

### FIXED CODE ###

h, w = map(int, input().split())
s = [input() for i in range(h)]

x = [-1, -1, 0, 1, 1, 1, 0, -1]
y = [0, 1, 1, 1, 0, -1, -1, -1]
for px in range(h):
    for py in range(w):
        if s[px][py] == '#': continue

        cou = 0
        for d in range(len(x)):
            tempx = px + x[d]
            tempy = py + y[d]

            if tempx < 0 or tempx >= h or tempy < 0 or tempy >= w:
                continue
            if s[tempx][tempy] == '#':
                cou += 1

        s[px] = s[px].replace('.', str(cou), 1)

for i in range(h):
    print(s[i])
a,op,b=input().split()
if op=+:
	s=int(a)+int(b)
elif op=-:
	s=int(a)-int(b)
elif op=*:
	s=int(a)*int(b)
elif op=/:
	s=int(a)//int(b)
else:
	print(s)


### FIXED CODE ###

while True:
	a,op,b=input().split()
	if op == "+":
		print(int(a)+int(b))
	elif op =="-":
		print(int(a)-int(b))
	elif op =="*":
		print(int(a)*int(b))
	elif op =="/":
		print(int(a)//int(b))
	else:
		break
a,b,k = map(int,input().split())
li = list(range(a,b + 1))
if b - a + 1 > 2 * k:
    for i in li[:k]:
        print(i)
    for i in li[-k:]:
        print(i)
else:
    for i in li:
        print(i)

### FIXED CODE ###

a,b,k = map(int,input().split())

if (b-a+1) > 2*k:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)
else:
    for i in range(a,b+1):
        print(i)
n,m,v,p = map(int,input().split())
lis = list(map(int,input().split()))
lis.sort(reverse=True)

li = []

  # print(lis)
cnt = 1
now = 0
ans = 0

border = lis[p-1]
li.append(0)
ind = 0
for i in range(n-1):
    if lis[i]!=lis[i+1]:
        now += cnt
        cnt = 1
    else:
        cnt += 1
    if now <= p:
        ind += 1
    li.append(now)

  #print(li)
sa = 0
keykey = 1
key = 0

for i in range(n):
    if i >= p-1:
        sa += lis[i]
        if keykey:
            key = i
        keykey = 0

    if li[i]+1 <= p:
        ans += 1
  #        print(i,1)

    else:
        if lis[i] + m >= border:
            num = (p-1)+(n-li[i]-1)+1
            if num >= v:
                ans += 1
  #                print(i,2)
            else:
                nu = v-num
                if (sa -lis[i])-lis[i]*(i-key) <= (key-nu-1)*m:
                    ans += 1
  #                    print(i,3)
  #                    print(sa,lis[i],i,key,key-nu,m)
                else:
  #                    print(i,4)
  #                    print(sa, lis[i], i, key, key - nu, m)
  #        else:
  #            print(i,5)
    if i != n-1:
        if sa != 0 and lis[i] == lis[i+1]:
            sa -= lis[i]
print(ans)

### FIXED CODE ###

n,m,v,p = map(int,input().split())
lis = list(map(int,input().split()))
lis.sort(reverse=True)
ans = 0
trash = 0
for i in range(n):
    if i+1 <= p:
        ans += 1
    else:
        if lis[i] + m >= lis[p-1]:
            if (lis[i]+m)*(i-(p-1))-trash >= m * (v-(p-1)-(n-i)):
  #                 print(lis[i]+m,i-(p-1)-trash,m*(v-(p-1)-(n-i)))
                ans += 1
    if i+1 >= p:
        trash += lis[i]
print(ans)
n = int(input())
l = map(int, input().split())
hst = 0
cnt = 0
for i in l:
  if hst <= i:
    cnt += 1
    hst = i
print(cnt) 

### FIXED CODE ###

A,B=map(int,input().split())

if A>B:
    print(A+A-1)
elif A<B:
    print(B+B-1)
else:
    print(A+B)
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    X = int(input(),2)
    LIST = []
    ANS = [0]*N
    TEMP = [0]*N
    CHAIND = [0]*N
    bit = 1

    cnt = count_ones_by_bitmask(X)
    
    if cnt == 0:
        for i in range(N):
            print(1)
            return

    p = X % (cnt+1)
    m = X % (cnt-1)
    pmod = 1 % (cnt+1)
    mmod = 1 % (cnt-1)
    for i in range(N):
        LIST.append(X^bit)
        if LIST[i]!=0:
            ANS[i] = 1
            if (X & bit == 0):
                TEMP[i] = (p + pmod) % (cnt+1)
            else:
                TEMP[i] = (m - mmod) % (cnt-1)
        bit = bit<<1
        pmod = (pmod*2) % (cnt+1)
        mmod = (mmod*2) % (cnt-1)


    CHA = list(set(TEMP))

    for i in range(len(CHA)):
        an = 0
        cha = CHA[i]
        cnt = count_ones_by_bitmask(CHA[i])
        while cnt>0:
            an += 1
            cha = cha%cnt
            cnt = count_ones_by_bitmask(cha)
        CHAIND[CHA[i]] = an

    for i in reversed(range(N)):
        print(ANS[i]+CHAIND[TEMP[i]])




def count_ones_by_bitmask(num):
    count = 0
    while num:
        count += num & 1
        num >>= 1
    return count

if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    N = int(input())
    X = input()
    XINT = int(X,2)
    ANS = [0]*N
    TEMP = [0]*N
    CHAIND = [0]*N

    cnt = count_ones_by_bitmask(XINT)
    
    if cnt == 0:
        for i in range(N):
            print(1)
            return
    if cnt ==1:
        for i in  range(N):
            if X[i] == '1':
                print(0) #全てが0になる
            else:
                if i==N-1:
                    print((int(X[N-1])+1)%2+1) # 2の剰余の反転
                else:
                    print((int(X[N-1]))%2+1) # 2の剰余
        return

    p = XINT % (cnt+1)
    m = XINT % (cnt-1)
    pmod = 1
    mmod = 1
    for i in range(N):
        ANS[i] = 1
        if (X[N-i-1] == '0'):
            TEMP[i] = (p + pmod) % (cnt+1)
        else:
            TEMP[i] = (m - mmod) % (cnt-1)
        pmod = (pmod*2) % (cnt+1)
        mmod = (mmod*2) % (cnt-1)


    CHA = list(set(TEMP))

    for i in range(len(CHA)):
        an = 0
        cha = CHA[i]
        cnt = count_ones_by_bitmask(CHA[i])
        while cnt>0:
            an += 1
            cha = cha%cnt
            cnt = count_ones_by_bitmask(cha)
        CHAIND[CHA[i]] = an

    for i in reversed(range(N)):
        print(ANS[i]+CHAIND[TEMP[i]])


def count_ones_by_bitmask(num):
    count = 0
    while num:
        count += num & 1
        num >>= 1
    return count

if __name__ == '__main__':
    main()
import sys
from itertools import count, accumulate
from operator import mul
from functools import reduce
lines = sys.stdin.readlines()

positions = [int(i) for i in lines[1].split(' ')]

distances = [ j - i for i, j in zip(positions, positions[1:])]

n = len(distances)
factorials = [1] + list(accumulate(range(1,n + 1), mul))

combinations = dict()
def combination(i, j):
    if (i, j) in combinations:
        return combinations((i, j))
    else:
        return factorials[i] // (factorials [j] * factorials[i - j])

permutations = dict()
def permutation(i, j):
    if (i, j) in permutations:
        return permutations((i, j))
    else:
        return reduce(mul, range(j, i+1))

s = 0
result = 0
for d, i in zip(distances, count(1)):
    lt = i - 1
    gt = n - i
    t = factorials[lt] * combination(n, gt) * factorials[gt]
    s += t
    result += d * s

print(int(result % (pow(10,9) + 7)))

### FIXED CODE ###

import sys
from itertools import count, accumulate
from operator import mul
from functools import reduce
lines = sys.stdin.readlines()

positions = [int(i) for i in lines[1].split(' ')]

distances = [ j - i for i, j in zip(positions, positions[1:])]

n = len(distances)
p = pow(10,9) + 7

factorials = [1] + list(accumulate(range(1,n + 1), lambda x, y: (x * y) % p))

combinations = dict()
def combination(i, j):
    j = min(j, i - j)
    if (i, j) in combinations:
        return combinations((i, j))
    else:
        return factorials[i] // (factorials [j] * factorials[i - j])

permutations = dict()
def permutation(i, j):
    if (i, j) in permutations:
        return permutations((i, j))
    else:
        return reduce(mul, range(j, i+1))

def modpow(a, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n = n >> 1
    return res

s = 0
result = 0
for d, i in zip(distances, count(1)):
    lt = i - 1
    gt = n - i
    i_inv = modpow(i, p-2, p)
    t = factorials[n] * i_inv
    s += t
    result += d * s

print(int(result % (pow(10,9) + 7)))
n, m = list(map(int, input().split()))
A = list(map(int, input().split()))

lmt = sum(A) /(4*m)
A.sort(reverse=True)
if A[m] >= lmt:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

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

lmt = sum(A) /(4*m)
A.sort(reverse=True)
if A[m-1] >= lmt:
  print('Yes')
else:
  print('No')
b = -1
ans = [0,0]
count = 0
for i in range(n+1):
    count += 1
    if b != a[i]:
        if count >= 2:
            if ans[0]:
                ans[1] = b
                break
            else: ans[0] = b
        b = a[i]
        count = 0
print(ans[0]*ans[1])

### FIXED CODE ###

n = int(input())
a = sorted(list(map(int,input().split())),reverse=True)
a += [0]
b = -1
ans = [0,0]
count = 0
for i in range(n+1):
    count += 1
    if b != a[i]:
        if count >= 4:
            if ans[0]:
                ans[1] = b
                break
            else:
                ans[0] = b
                ans[1] = b
                break
        elif count >= 2:
            if ans[0]:
                ans[1] = b
                break
            else:ans[0] = b
        b = a[i]
        count = 0
print(ans[0]*ans[1])
n = int(sys.stdin.readline().rstrip("\n"))
if n % 2 == 0:
    print(n // 2)
else:
    print(n // 2 + 1)

### FIXED CODE ###

import sys
n = int(sys.stdin.readline().rstrip("\n"))
if n % 2 == 0:
    print(n // 2)
else:
    print(n // 2 + 1)
N,K = map(int,input().rstrip().split(" "))
P = list(map(int,input().rstrip().split(" ")))
C = list(map(int,input().rstrip().split(" ")))
check = [False for _ in range(N)]
ans = -(10 ** 15)
for i in range(N):
    kans = 0
    score = [0]
    nex = P[i] -1
    while True:
        score.append(score[-1] + C[nex])
        nex = P[nex] - 1
        if nex == P[i] -1:
            break;
    if score[-1] > 0:
        kans = score[-1] * (K // (len(score) -1)) + max(score[1:K % (len(score) -1) + 1])
    else:
        kans = max(score[1:min(len(score) - 1,K) + 1])
    ans = max(ans,kans)
print(ans)

### FIXED CODE ###

N,K = map(int,input().rstrip().split(" "))
P = list(map(int,input().rstrip().split(" ")))
C = list(map(int,input().rstrip().split(" ")))

ans = -(10 ** 15)
for i in range(N):
    kans = 0
    score = [0]
    nex = P[i] -1
    while True:
        score.append(score[-1] + C[nex])
        nex = P[nex] - 1
        if nex == P[i] -1:
            break;

    if score[-1] > 0:
        if score[1:(K % (len(score) -1)) + 1] != []:
            kans = score[-1] * (K // (len(score) -1)) + max(score[1:(K % (len(score) -1)) + 1])
        else:
            kans = score[-1] * ((K // (len(score) -1)) - 1) + max(score)
    else:
        if score[1:min(len(score) - 1,K) + 1] != []:
            kans = max(score[1:min(len(score) - 1,K) + 1])
        else:
            kans = -(10 ** 15)
    ans = max(ans,kans)
print(ans)
N = int(input())

Abs = int(np.sqrt(N))
if Abs ** 2 == N:
    print((Abs - 1) * 2)
else:
    min = N + 1
    min_i = 0
    for i in range(1, Abs + 1):
        tmp = N // i
        if tmp * i == N:
            if min > tmp:
                min = tmp
                min_i = i

print(min + min_i - 2)

### FIXED CODE ###

import numpy as np
N = int(input())
Abs = int(np.sqrt(N))
if Abs ** 2 == N:
    print(Abs + Abs - 2)
else:
    min = N + 1
    min_i = 1
    for i in range(1, Abs + 1):
        tmp = N // i
        if tmp * i == N:
            if min > tmp:
                min = tmp
                min_i = i
    print(min + min_i - 2)
print("YES" if "AC" in input() else "NO)

### FIXED CODE ###

print("Yes" if "AC" in input() else "No")