Harryxun/stf_run huggingface dataset:
# -*- coding: utf-8 -*-
S = str(input())
L = []
for i in range(len(S)):
  L.append(S[i])
M = sum(L)
if int(S) % M == 0:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

# -*- coding: utf-8 -*-
S = str(input())
L = []
for i in range(len(S)):
  L.append(int(S[i]))
M = sum(L)
if int(S) % M == 0:
  print("Yes")
else:
  print("No")
a,b = map(int input().split())
if a+b >= 24:
  print(a+b-24)
else:
  print(a+b)

### FIXED CODE ###

a,b = map(int, input().split())
if a+b >= 24:
  print(a+b-24)
else:
  print(a+b)
x = input()
print(pow(x, 3) + "\n")

### FIXED CODE ###

x = input()
print(x ** 3)
INF = 10 ** 20

m, n = map(int, input().split())
manju_lst = [int(input()) for i in range(m)]
manju_lst.sort(reverse=True)

acc = 0
cum_sum = [0]
for manju in manju_lst:
  acc += manju
  cum_sum.append(acc)

clst = []
elst = []

for i in range(n):
  c, e = map(int, input().split())
  clst.append(c)
  elst.append(e)

dp = [[INF] * (m + 1) for _ in range(n)]
for i in range(n):
  dp[i][0] = 0

#dp[x][y]...x種類目までの箱でy個以下売る時の最小コスト
#dp[x][y] = min(dp[x - 1][y], dp[x - 1][y - cx] + ex) if (y - cx >= 0) else min(dp[x - 1][y], dp[x - 1][y + 1])

for x in range(n):
  cx = clst[x]
  ex = elst[x]
  for y in range(m, 0, -1):
    if y >= cx:
      dp[x][y] = min(dp[x - 1][y], dp[x - 1][y - cx] + ex)
    else:
      dp[x][y] = min(dp[x - 1][y], dp[x][y + 1])

print(max([cum_sum[x] - dp[n - 1][x] for x in range(m + 1)]))


### FIXED CODE ###

INF = 10 ** 20

def main():
  m, n = map(int, input().split())
  manju_lst = [int(input()) for i in range(m)]
  manju_lst.sort(reverse=True)
  
  acc = 0
  cum_sum = [0]
  for manju in manju_lst:
    acc += manju
    cum_sum.append(acc)
  
  clst = []
  elst = []
  
  for i in range(n):
    c, e = map(int, input().split())
    clst.append(c)
    elst.append(e)
  
  dp = [[INF] * (m + 1) for _ in range(n + 1)]
  for i in range(n + 1):
    dp[i][0] = 0
  #dp[x][y]...x種類目までの箱でy個まで売る時の最小コスト
  #dp[x][y] = min(dp[x - 1][y], dp[x - 1][y - cx] + ex) if (y - cx >= 0) else min(dp[x - 1][y], (dp[x - 1][y + 1] if (y + 1 <= m) else ex))
  
  for x in range(1, n + 1):
    cx = clst[x - 1]
    ex = elst[x - 1]
    predp = dp[x - 1]
    for y in range(m, 0, -1):
      predp_y = predp[y]
  
      if y >= cx:
        comp = predp[y - cx] + ex
      elif y + 1 <= m:
        comp = dp[x][y + 1]
      else:
        comp = ex
  
      if predp_y <= comp:
        dp[x][y] = predp_y
      else:
        dp[x][y] = comp
  
  dpn = dp[n]
  print(max([cum_sum[x] - dpn[x] for x in range(m + 1)]))

main()
N = int(input())
h = list(map(int,input().split()))

high = []

for i in range(N-1):
	if h[i] < h[i+1]:
		high.append(i+1)
ans = 0
temp = 0
for i in high:
	ans = max(i-temp-1,ans)
	temp = i
temp = N
ans = max(N-high[-1]-1,ans)
print(ans)

### FIXED CODE ###

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

high = []

for i in range(N-1):
	if h[i] < h[i+1]:
		high.append(i+1)
ans = 0
temp = 0
if len(high) == 0:
	print(len(h)-1)
	exit()

for i in high:
	ans = max(i-temp-1,ans)
	temp = i
temp = N
ans = max(N-high[-1]-1,ans)
print(ans)
class Node():
    def __init__(self, p, l, r, n):
        self.p = p
        self.l = l
        self.r = r
        self.n = n


N = int(input())
T = [Node(-1, -1, -1, -1) for _ in range(N)]
S = []
for _ in range(N - 1):
    a, b = map(int, input().split())
    a, b = min(a, b), max(a, b)
    S.append([a - 1, b - 1])
S.sort()
C = sorted(map(int, input().split()), reverse=True)
for s in S:
    if T[s[0]].l == -1:
        T[s[0]].l = s[1]
        T[s[1]].p = s[0]
    else:
        T[l].r = s[1]
        T[s[1]].p = T[l].p
    l = s[1]


def rec(n, cur):
    if n == -1:
        return cur
    T[n].n = C[cur]
    cur += 1
    cur = rec(T[n].l, cur)
    cur = rec(T[n].r, cur)
    return cur


rec(0, 0)
print(sum(C[1:]))
print(' '.join(map(str, [t.n for t in T])))

# for i, t in enumerate(T):
#     print("node: {}, parent: {}, left-child: {}, right-sibling: {}, N: {}"
#           .format(i, t.p, t.l, t.r, t.n))


### FIXED CODE ###

import sys

sys.setrecursionlimit(10000000)

N = int(input())
M = [[] for _ in range(N)]
P = [0] * N
V = [0] * N
for _ in range(N - 1):
    a, b = map(lambda x: int(x) - 1, input().split())
    M[a].append(b)
    M[b].append(a)
C = sorted(map(int, input().split()), reverse=True)

def dfs(n, cur):
    if V[n] == 1:
        return cur
    P[n] = C[cur]
    V[n] = 1
    cur += 1
    for c in M[n]:
        cur = dfs(c, cur)
    return cur

dfs(0, 0)
print(sum(C[1:]))
print(' '.join(map(str, P)))
import numpy as np
lis=[]
for i in range(101):
    lis.append(i)
lis.remove(0)

listA=[]
while True:
    try:
        listA.append(list(map(int,input().split())))
    except:
        break;
#print(listA)

X_=listA[0]
X=X_[0]
N=X_[1]
if N!=0:
    P =listA[1]

    arr = np.array(lis)
    P_max = max(P)
    P_min = min(P)-1
    arr=arr[arr<=P_max]
    arr=arr[arr>=P_min]
    lis=arr.tolist()
    for p in P:
        lis.remove(p)
    #print(lis)
    lis_=[]
    for l in lis:
        lis_.append(abs(l-X))
    #print(lis_)
    lis_min=min(lis_)

    def my_index(l, x, default=False):
        if x in l:
            return l.index(x)
        else:
            return default

    print(lis[my_index(lis_, lis_min)])
else:
    print(X)

### FIXED CODE ###

import numpy as np
lis=[]
for i in range(102):
    lis.append(i)
#print(lis)
listA=[]
while True:
    try:
        listA.append(list(map(int,input().split())))
    except:
        break;
#print(listA)
 
X_=listA[0]
X=X_[0]
N=X_[1]
if N!=0:
    P =listA[1]
 
    arr = np.array(lis)
    P_max = max(P)
    P_min = min(P)-1
    arr=arr[arr<=P_max+1]
    arr=arr[arr>=P_min-1]
    lis=arr.tolist()
    for p in P:
        lis.remove(p)
    #print(lis)
    lis_=[]
    for l in lis:
        lis_.append(abs(l-X))
    #print(lis_)
    lis_min=min(lis_)
 
    def my_index(l, x, default=False):
        if x in l:
            return l.index(x)
        else:
            return default
 
    print(lis[my_index(lis_, lis_min)])
else:
    print(X)
# AtCoder Grand Contest 041
# A - Table Tennis Training

def f(A,B,n) :
    judge=abs(B-A)
    if judge%2==0 :
        n+=judge//2
        return(n)
    else :
        if abs(1-A) < abs(N-B) :
            if A>1 :
                A-=1
                B-=1
                n+=1
            else:
                A=A
                B-=1
                n+=1
            return f(A,B,n)
        else :
            if B<N :
                B+=1
                A+=1
                n+=1
            else :
                B=B
                A+=1
                n+=1
            return f(A,B,n)

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

print(f(A,B,0))

### FIXED CODE ###

# AtCoder Grand Contest 041
# A - Table Tennis Training

def f(A,B,n) :
    judge=B-A

    if judge%2==0 :
        n+=judge//2
        return(n)

    else :
        if abs(A-1) < abs(N-B) :
            if A==1 :
                A=A
                B-=1
                n+=1
            else:
                B-=A-1
                n+=A-1
                A-=A-1
            return f(A,B,n)
        else :
            if B==N :
                B=B
                A+=1
                n+=1
            else :
                A+=abs(N-B)
                n+=abs(N-B)
                B+=abs(N-B)
            return f(A,B,n)

N,A,B=map(int,input().split())
print(f(A,B,0))
a =0
while True:
    n =int(input())
    i=i+1
    if n==0:
        break
    print("Case"+str(i)+": "+str(n))


### FIXED CODE ###

l = []
while True:
  i = str(input())
  if i == '0':
    break
  else:
    l.append(i)
t = 0
for i in l:
  t += 1
  print('Case '+str(t)+': '+i)
N, M = map(int, input().split())


a = [True] * (N)
for _ in range(M):
    a[int(input())-1] = False


mod = 10**9 + 7
dp = [0] * (N)
dp[0] = (1 if a[0] else 0)
dp[1] = (1 if a[1] else 0) + dp[0]
for i in range(2, N):
    if a[i]:
        dp[i] = (dp[i-1] + dp[i-2]) % mod

print(dp[N-1])


### FIXED CODE ###

mod = 10**9 + 7
N, M = map(int, input().split())


a = [True] * (N+1)
for _ in range(M):
    a[int(input())] = False


dp = [0] * (N+1)
dp[0] = 1
for i in range(N+1):
    for j in range(1, 3):
        if (i+j) > N or a[i+j] == False:
            continue
        dp[i+j] += dp[i]
        dp[i+j] %= mod

print(dp[N])
def dfs(v, p=-1):
    for u in to[v]:
        if u == p:
            continue
        ans[u] += ans[v]
        dfs(u, v)


N, Q = map(int, input().split())
to = [[] for _ in range(200005)]
ans = [0 for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    to[a].append(b)
    to[b].append(a)
for _ in range(Q):
    p, x = map(int, input().split())
    p -= 1
    ans[p] += x
dfs(0)
print(*ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline #for input speed
sys.setrecursionlimit(10**6) #for deep recursion
n, q = map(int, input().split())

tree_index = [[] for _ in range(n)]
for i in range(n-1):
  a,b = map(int, input().split())
  a -= 1
  b -= 1
  tree_index[a].append(b) # a<bとは限らないため、双方向にする
  tree_index[b].append(a)
ans = [0] * n
for i in range(q):
  p, x = map(int, input().split())
  ans[p-1] += x
def dfs(cur, par):
    for chl in tree_index[cur]:
      if chl == par: #parentとchildが等しい時はスキップ
        continue
      ans[chl] += ans[cur] 
      dfs(chl, cur)
dfs(0, -1)
print(*ans)
n = int(input())
if x < 1200:
    print('ABC')
else:
    print('ARC')

### FIXED CODE ###

n = int(input())
if n < 1200:
    print('ABC')
else:
    print('ARC')
d=input()
d=-(d-25)
c="Chrismas"
e="Eve"
for i in range(0,4):
    if d==i:
        print(c,end="")
        if i>0:
            for j in range(i-1):
                print(" "+e)
        print()
        

### FIXED CODE ###

d=int(input())
d=-(d-25)
c="Christmas"
e="Eve"
for i in range(0,4):
    if d==i:
        print(c,end="")
        if i>0:
            for j in range(i):
                print(" "+e,end="")
        print()
a, b = map(int, input().split())

if a <= 8 and b <= 8:
  print("Yay!")
else:
  print(":(")

### FIXED CODE ###

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

if a <= 8 and b <= 8:
  print("Yay!")
else:
  print(":(")
from fractions import gcd
import sys
input = sys.stdin.readline

def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

def main():
    _, m = map(int, input().split())
    a = list(map(int, input().split()))

    mlcm = lcm(a)

    for i in a:
        if (int(mlcm / i) % 2 == 0):
            print(0)
            return

    print(int((int(m * 2 / mlcm) + 1) / 2))

if __name__ == '__main__':
    main()

### FIXED CODE ###

from fractions import gcd
import sys
input = sys.stdin.readline

def main():
    _, m = map(int, input().split())
    a = list(map(int, input().split()))

    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
        if i == 1:
            if (int(x / a[0]) % 2 == 0) or (int(x / a[i]) % 2 == 0):
                print(0)
                return
        else:
            if (int(x / a[i]) % 2 == 0):
                print(0)
                return

    print(int((int(m * 2 / x) + 1) / 2))

if __name__ == '__main__':
    main()
def a(x):
    if x == 1: return 1
    if x > 1: return a(x/2) * 2 + 1

print(a(int(input())))


### FIXED CODE ###

def a(x):
    if x == 1: return 1
    if x > 1: return a(x // 2) * 2 + 1

print(a(int(input())))
a, b = map(int, input().split)
if (a%2 == 0) and (b%2 == 0):
  print ("Even")
else:
  print("Odd")

### FIXED CODE ###

a, b = map(int, input().split())
if (a%2 != 0) and (b%2 != 0):
  print("Odd")
else:
  print("Even")
A,P = map(int,input())
print(int(((3*A)+P)//2))

### FIXED CODE ###

A,P = map(int,input().split())
print(int(((3*A)+P)//2))
S = input()
T = 'CODEFESTIVAL2016'
ans = 0
for _ in range(16):
  ans += S[i] != T[i]
print(ans)
  

### FIXED CODE ###

S = input()
T = 'CODEFESTIVAL2016'
ans = 0
for i in range(16):
  ans += S[i] != T[i]
print(ans)
#!/usr/bin/env python
while 1:
    n=int(raw_input())
    if n==0: break
    h1=map(int, raw_input().split())
    for h in h1:
        h2=[ x for x in h1 if x!=h ]
        g=[ h2[i+1]-h2[i] for i in range(n-1) ]
        if len(set(g))==1:
            print h
            break

### FIXED CODE ###

import sys,math
for line in sys.stdin.readlines():
    V=float(line.rstrip())
    N=0
    while 1:
        N+=1
        v=9.8*math.sqrt((5*N-5)/4.9)
        if V-v<=0: break
    print N
a = map(int, input())
b = map(int, input())
c = map(int, input())
d = map(int, input())
print(min(a,b) + min(c,d))

### FIXED CODE ###

a = input()
b = input()
c = input()
d = input()
print(min(int(a),int(b)) + min(int(c),int(d)))
num = int(input())
numList = list(range(0, num))
listLength = len(numList)
counter = 0

#print(numList)

m = [0] * 1000000

for i in range(0, listLength):
    m[numList[i]]
    m[numList[i]] += 1

secondCount = 0

for i in range(0, listLength):
    secondCount += m[num - numList[i]]
    if (num - numList[i] == numList[i]):
        secondCount -= 1

print(int(secondCount / 2))

### FIXED CODE ###

num = int(input())
numList = list(range(0, num))
listLength = len(numList)
counter = 0

#print(numList)

m = [0] * 10000000

for i in range(0, listLength):
    m[numList[i]]
    m[numList[i]] += 1

secondCount = 0

for i in range(0, listLength):
    secondCount += m[num - numList[i]]
    if (num - numList[i] == numList[i]):
        secondCount -= 1

print(int(secondCount / 2))
a = input()

b = input()


if int(a) % 2 == 0 or int(b) % 2 == 0:
    print('Even')
    
else:
    print('Odd')

### FIXED CODE ###

b, c = map(int, input().split())


if int(b) % 2 == 0 or int(c) % 2 == 0:
    print('Even')
    
else:
    print('Odd')
N,M = map(int,input().split())
ls_1 = []
ls_2 = []
ls_3 = []
for i in range(M):
    s,c = map(int,input().split())
    if s == 1:
        ls_1.append(c)
    elif s == 2:
        ls_2.append(c)
    else:
        ls_3.append(c)
if len(set(ls_1)) > 1 or len(set(ls_2)) > 1 or len(set(ls_3)) > 1 or ls_1[0] == 0:
    print(-1)
else:
    if len(ls_1) == 0:
        if N > 1:
            ls_1.append(1)
        else:
            ls_1.append(0)
    if len(ls_2) == 0:
        ls_2.append(0)
    if len(ls_3) == 0:
        ls_3.append(0)
    
    ans = (10 **(N-1)) * ls_1[0] + (10**((N-2)*(N-1)// 2)) * ls_2[0] + ((N-2)*(N-1) // 2) * ls_3[0]
    print(ans)

### FIXED CODE ###

N,M = map(int,input().split())
ls_1 = []
ls_2 = []
ls_3 = []
for i in range(M):
    s,c = map(int,input().split())
    if s == 1:
        ls_1.append(c)
    elif s == 2:
        ls_2.append(c)
    else:
        ls_3.append(c)
if len(set(ls_1)) > 1 or len(set(ls_2)) > 1 or len(set(ls_3)) > 1 or (N > 1 and len(ls_1) > 0 and sum(ls_1)==0):
    print(-1)
else:
    if len(ls_1) == 0:
        if N > 1:
            ls_1.append(1)
        else:
            ls_1.append(0)
    if len(ls_2) == 0:
        ls_2.append(0)
    if len(ls_3) == 0:
        ls_3.append(0)
    
    ans = (10 **(N-1)) * ls_1[0] + (10**((N-2)*(N-1)// 2)) * ls_2[0] + ((N-2)*(N-1) // 2) * ls_3[0]
    print(ans)
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
r = 0
for i, j in enumerate(a):
    r += b[j - 1]
    if a[i - 1] == a[i] - 1 and i > 0:
        r += c[j - 2]
print(r)


### FIXED CODE ###

n = int(input())
li = list(map(int, input().split()))
r = li[0] + li[-1]
for i, j in enumerate(li):
    if i != len(li)-1:
        r += min(j, li[i + 1])
print(r)
import collections
x, n= map(int, input().split())
P = list(map(int, input().split()))

PX = list(map(lambda p: p-x,P))
CPX = collections.Counter(PX)
ans = 0

for i in range(max(max(P),x)):
  if CPX[-i] == 0:
    ans = x -i
    break
  elif CPX[i] == 0:
    ans = x +i
    break

print(ans)

### FIXED CODE ###

import collections
x, n= map(int, input().split())
P = list(map(int, input().split()))
 
PX = list(map(lambda p: p-x,P))
CPX = collections.Counter(PX)
ans = 0

for i in range(100):
  if CPX[-i] == 0:
    ans = x -i
    break
  elif CPX[i] == 0:
    ans = x +i
    break

print(ans)
n = int(input())
a = list(map(int,input().split()))
ans = sum(a)
#print(ans)
q = int(input())
import collections
cc = collections.Counter(a)
#print(cc)
for i in range(q):
    b,c = map(int,input().split())
    tmp = cc[b]
    cc[b] = 0
    s=s-b*tmp+c*tmp
    cc[c]+=tmp
    print(s)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
s = sum(a)
#print(ans)
q = int(input())
import collections
cc = collections.Counter(a)
#print(cc)
for i in range(q):
    b,c = map(int,input().split())
    tmp = cc[b]
    cc[b] = 0
    s=s-b*tmp+c*tmp
    cc[c]+=tmp
    print(s)
import numpy as np
x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a = np.array(a)
b = np.array(b)
c = np.array(c)
aa,bb,cc = np.meshgrid(a,b,c)
abc = np.c_[aa.flatten(),bb.flatten(),cc.flatten()]
ans = np.sum(abc,axis=1)
ans = list(ans)
ans.sort(reverse = True)
for i in range(k):
    print(ans[i])

### FIXED CODE ###

x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = []
for i in range(x):
    for j in range(y):
        ans.append(a[i]+b[j])
ans.sort(reverse=True)
ans = ans[:k]
ans2 = []
for i in range(len(ans)):
    for j in range(z):
        ans2.append(ans[i]+c[j])
ans2.sort(reverse=True)
for i in range(k):
    print(ans2[i])
import numpy as np

r,c = map(int, input().split())
a=np.zeros([r+1,c+1])

for i in range(r):
    sumC = 0
    ar = input().split()
    for j in range(c):
        a[i,j]=int(ar[j])
        sumC +=int(ar[j])
    a[i,c]=sumC
    print(" ".join(map(str, ar)), end=" ")
    print(sumC)


for k in range(c+1):
    for m in range(r):
        a[r,k] += a[m,k]

for i in range(c):
    print(int(a[r,i]), end=" ")
print(int(a[r,c]))


### FIXED CODE ###

r, c = map(int, input().split())
a = [[0 for i in range(c + 1)] for j in range(r + 1)]

for i in range(r):
    sumC = 0
    ar = input().split()
    for j in range(c):
        a[i][j] = int(ar[j])
        sumC += int(ar[j])
    a[i][c] = sumC

for k in range(c + 1):
    for m in range(r):
        a[r][k] += a[m][k]


for i in a:
    print(*i)
//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main(){
    ll n,k;cin >> n >> k;
    const ll nod=40;//桁数
    vector< ll > a(n);REP(i,n)cin >> a[i];
    vector< pair<ll,ll> > ans(nod);
    REP(i,nod){
        ll ans_sub1=0;ll ans_sub2=0;
        REP(j,n){if(a[j]>>i&1){ans_sub1+=1;}else{ans_sub2+=1;}}
        ans[i]=MP(ans_sub1,ans_sub2);
    }
    //REP(i,nod)cout << ans[i].F << " " << ans[i].S << endl;
    ll reans=0;
    ll x=0;
    REPD(i,nod){
        if(ans[i].F>=ans[i].S){
            reans+=ans[i].F*pow(2,i);
        }else{
            x+=pow(2,i);
            if(x>k){
                reans+=ans[i].F*pow(2,i);
                x-=pow(2,i);
            }else{
                reans+=ans[i].S*pow(2,i);
            }
        }
    }
    //cout << x << endl;
    cout << reans << endl;
}

### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=0
co=[0]*50
check=False
for i in range(49,-1,-1):
    for j in range(n):
        if (a[j]>>i)&1:
            co[i]+=1
    if (k>>i)&1:
        if co[i]>=n-co[i]:
            ans+=(co[i]*(2**i))
            check=True
        else:
            ans+=((n-co[i])*(2**i))
    else:
        if check:
            if co[i]>=n-co[i]:
                ans+=(co[i]*(2**i))
            else:
                ans+=((n-co[i])*(2**i))
        else:
            ans+=(co[i]*(2**i))
print(ans)
n= int(input())
a=[]
c=1
for i in range(n):
    h=int(input())
    a.append(h)
for b in range(n-1):
    if a[b] <= a[b+1]:
        c+=1
print(c)

### FIXED CODE ###

n= int(input())
h=list(map(int,input().split()))
b=1
a=h[0]
for i in range(n-1):
    if a <= h[i+1]:
        b+=1
        a=h[i+1]
print(b)
N, Q = map(int, input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
 
g = [[] for _ in range(N+1)]
for a,b in AB:
    g[a].append(b)
    g[b].append(a)
    
cnt = [0] * (N+1)
for p,x in PX:
    cnt[p] += x

# v: node, p: parent node, add: parent value
def dfs(v, p, add):
    cnt[v] += add
    for nv in g[v]:
        if nv == p:
            continue
        dfs(nv, v, cnt[v])
 
dfs(1, 0, 0)

print(' '.join(map(str, cnt[1:])))

### FIXED CODE ###

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

N, Q = map(int, input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
 
g = [[] for _ in range(N+1)]
for a,b in AB:
    g[a].append(b)
    g[b].append(a)
 
cnt = [0] * (N+1)
for p,x in PX:
    cnt[p] += x

def dfs(v, p, add):
    cnt[v] += add
    for nv in g[v]:
        if nv == p:
            continue
        dfs(nv, v, cnt[v])

dfs(1, 0, 0)

print(' '.join(map(str, cnt[1:])))
s=str((input())
s[3]="8"
print(s)

### FIXED CODE ###

print("2018"+input()[4:])
i=input;s=split;t,a=map(int,i().s());l=list(map(lambda x:abs(t-int(x)*0.006-a),i().s()));print(l.index(min(l))+1)

### FIXED CODE ###

input();t,a=map(int,input().split());l=list(map(lambda x:abs(t-int(x)*0.006-a),input().split()));print(l.index(min(l))+1)
# -*- coding: utf-8 -*-
import sys
from functools import reduce
from math import gcd
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N = int(lines.pop(0))
    A = list(map(int, lines.pop(0).split(' ')))
    lcd = 10
    m = lcd - 1
    A = [ m % i for i in A ]
    print(sum(A))

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
from functools import reduce
from fractions import gcd
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N = int(lines.pop(0))
    A = list(map(int, lines.pop(0).split(' ')))
    lcd = reduce(lambda i,j: i*j//gcd(i,j), A, 1)
    m = lcd - 1
    A = [ m % i for i in A ]
    print(sum(A))

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)