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

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, islice
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')

N, W = MAP()
w, v = ZIP(N)

dp = [[0]*(W+1) for _ in range(N+1)]

for i in range(N):
	for j in range(W+1):
		if j-w[i] >= 0:
			dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i])
		else:
			dp[i+1][j] = dp[i][j]
print(dp[N][W])


### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, islice
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')

N, W = MAP()
w, v = ZIP(N)

dp = [[0]*(W+1) for _ in range(N+1)]

for i in range(N):
	for j in range(W+1):
		if j-w[i] >= 0:
			dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i])
		else:
			dp[i+1][j] = dp[i][j]
print(dp[N][W])
### BUGGY CODE ###

import queue,sys,copy
sys.setrecursionlimit(10**7)
INF = 10**10
N = int(input())
x = [0 for _ in range(N)]
y = copy.deepcopy(x)
for i in range(N):
    x[i], y[i] = map(int,input().split())
ix = [i for i in range(N)]
sort_x_ix = sorted(ix, key=lambda i:x[i])
sort_x = [x[i] for i in sort_x_ix]
sort_y_ix = sorted(ix, key=lambda i:y[i])
sort_y = [y[i] for i in sort_y_ix]

g = [i for i in range(N+1)]
def root(x):
    if g[x] == x : return x
    g[x] = root(g[x])
    return g[x]
q = []
for i in range(N-1):
    q.append((sort_x[i+1]-sort_x[i],sort_x_ix[i],sort_x_ix[i+1]))
    q.append((sort_y[i+1]-sort_y[i],sort_y_ix[i],sort_y_ix[i+1]))
q.sort()
ans = 0
cnt = N
for d,s,t in q:
    if cnt <= 1: break
    if root(s) != root(t):
        ans += d
        cnt -= 1
        g[g[t]] = g[s]

print(ans)

### FIXED CODE ###

import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N = NI()
    xy = [LI() for _ in range(N)]

    x = [(xy[i][0],i) for i in range(N)]
    y = [(xy[i][1],i) for i in range(N)]

    x.sort()
    y.sort()

    edge = []
    p,i = x[0]
    for q,j in x[1:]:
        edge.append((q-p,i,j))
        p,i = q,j

    p,i = y[0]
    for q,j in y[1:]:
        edge.append((q-p,i,j))
        p,i = q,j

    edge.sort()

    g = [i for i in range(N + 1)]
    g_num = [1 for i in range(N + 1)]

    def find(x):
        if g[x] == x: return x
        g[x] = find(g[x])
        return g[x]

    def union(x, y):
        if find(x) == find(y): return
        if g_num[g[x]] < g_num[g[y]]: x, y = y, x
        g_num[g[x]] += g_num[g[y]]
        g_num[g[y]] = 0
        g[g[y]] = g[x]

    ans = 0
    for v,i,j in edge:
        if find(i) != find(j):
            ans += v
            union(i,j)

    print(ans)



if __name__ == '__main__':
    main()
### BUGGY CODE ###

import math

n, p = map(int, input().split())
i = 1
while n * math.log(i) <= math.log(p):
    i += 1
for j in reversed(range(i)):
    if (p / j ** n) % 1 == 0:
        print(j)
        break


### FIXED CODE ###

n, p = map(int, input().split())
d = {}
while p % 2 == 0:
    if 2 not in d:
        d[2] = 1
    else:
        d[2] += 1
    p //= 2
f = 3
while f * f <= p:
    if p % f == 0:
        if f not in d:
            d[f] = 1
            p //= f 
        else:
            d[f] += 1
            p //= f
    else:
        f += 2
if p != 1:
    if p not in d:
        d[p] = 1
    else:
        d[p] += 1
d = sorted(d.items(), key=lambda x:x[1], reverse=True)
ans = 1
for k, v in d:
    if v < n:
        break
    else:
        ans *= k ** (v // n)
print(ans)
### BUGGY CODE ###

class Range_BIT:
    def __init__(self, n):
        self.n = n
        self.bit0 = [0]*(n+1)
        self.bit1 = [0]*(n+1)
    
    def _Add(self, k, x, is_bit0=True):
        if is_bit0 == True:
            data = self.bit0
        else:
            data = self.bit1
        while k <= self.n:
            data[k] += x
            k += k & -k
    
    def _Get(self, data, k):
        s = 0
        while k:
            s += data[k]
            k -= k&-k
        return s
    
    """ 配列の獲得 """
    def Array(self):
        array = [0]*(n+1)
        for i in range(self.n):
            array[i] = self.Get(i+1,i+2)
        return array[:-1]
    
    """ 区間[l:r)に対してxを加算 """
    def Add(self, l, r, x):
        self._Add(l, -x*(l-1), is_bit0=True)
        self._Add(r, x*(r-1), is_bit0=True)
        self._Add(l, x, is_bit0=False)
        self._Add(r, -x, is_bit0=False)
    
    """ 区間[l:r)の総和 """
    def Get(self, l, r):
        Pi = self._Get(self.bit1, r-1)*(r-1) - self._Get(self.bit1, l-1)*(l-1)
        Qi = self._Get(self.bit0, r-1) - self._Get(self.bit0, l-1)
        return Pi+Qi

n,k = map(int,input().split())
A = list(map(int,input().split()))
for j in range(k):
    if j==0:
        rbit = Range_BIT(n)
        for i,a in enumerate(A):
            rbit.Add(max(1,i+1-a), min(i+2+a, n+1), 1)
    else:
        A_ = rbit.Array()
        rbit = Range_BIT(n)
        for i,a in enumerate(A_):
            rbit.Add(max(1,i+1-a), min(i+2+a, n+1), 1)
    if set(rbit.Array())=={n}:
        break
print(*rbit.Array())

### FIXED CODE ###

n,k = map(int,input().split())
A = list(map(int,input().split()))
imos = [0]*(n+1)
for j in range(k):
    if j==0:
        arr = A
    else:
        arr = imos
    imos = [0]*(n+1)
    for i,a in enumerate(arr):
        imos[max(i-a, 0)] += 1
        imos[min(i+a+1, n)] -= 1
    for k in range(1, len(imos)):
        imos[k] = imos[k]+imos[k-1]
    imos = imos[:-1]
    if set(imos)=={n}:
        break
print(*imos)
### BUGGY CODE ###

# B - Frog 2
N, K = map(int,input().split())
h = list(map(int, input().split()))
dp = [10**9]*N

dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(2,N):
    for k in range(1,K+1):
        dp1 = dp[i - k]+ abs(h[i] - h[i - k])
        if dp[i] >= dp1:
            dp[i] = dp1
            if dp[i] == 0:
                break
        else:
            pass

print(dp[N-1])


### FIXED CODE ###

#B - Frog 2
N, K = map(int, input().split())
h = list(map(int, input().split()))
dp = [10 ** 9] * N
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2,N):
    for j in range(K,0,-1):
        dp[i] = min(dp[i],dp[i-j] + abs(h[i] - h[i-j]))

#print(dp)
print(dp[N-1])
### BUGGY CODE ###

L=input()
N=len(L)

bit=[]
for i in range(0,N):
    if L[N-1-i]=='1':
        bit.append(i+1)

dp=[0 for i in range(0,100001)]
m=bit[0]
if m!=1:
    dp[m]=(2+3**(m-1))%(10**9+7)
else:
    dp[m]=3
for i in range(1,len(bit)):
    dp[bit[i]]=(2*dp[bit[i-1]]+3**(bit[i]-1))%(10**9+7)
print(dp[N])


### FIXED CODE ###

import time

def pow_k(x, n):
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K = (K*x)%(10**9+7)
        x = (x*x)%(10**9+7)
        n //= 2

    return (K*x)%(10**9+7)

L=input()
N=len(L)


bit=[]
for i in range(0,N):
    if L[N-1-i]=='1':
        bit.append(i+1)

dp=[0 for i in range(0,100001)]

m=bit[0]
if m!=1:
    dp[m]=(2+3**(m-1))%(10**9+7)
else:
    dp[m]=3
time0=time.time()
for i in range(1,len(bit)):
    s=bit[i]
    t=bit[i-1]
    dp[s]=(2*dp[t]+pow_k(3,s-1))
time1=time.time()
print(dp[N]%(10**9+7))
### BUGGY CODE ###


n = int(input())
arr = list(map(int,input().split()))
arr.sort()

cnt = {}
kouho = []
for i in range(n):
    if arr[i] not in cnt:
        cnt[arr[i]] = 1
    else:
        cnt[arr[i]] += 1

    flag = True
    for j in range(i):
        # print(arr[j],end=" ")
        if arr[j] > arr[i]//2+1:
            break
        if arr[i]%arr[j] == 0:
            flag = False

    if flag:
        kouho.append(arr[i])

# print(kouho)
ans = 0
for k in kouho:
    if cnt[k] == 1:
       ans += 1

print(ans)

### FIXED CODE ###

n = int(input())
arr = list(map(int,input().split()))
arr.sort()

cnt = {}
kouho = []
erat = [True for i in range(10**6+1)]

for i in range(n):
    if arr[i] not in cnt:
        cnt[arr[i]] = 1
    else:
        cnt[arr[i]] += 1
    if erat[arr[i]]:
        kouho.append(arr[i])
        tp = arr[i]
        while True:
            erat[tp] = False
            tp += arr[i]
            if tp > 10**6:
                break
# print(kouho)
ans = 0
for k in kouho:
    if cnt[k] == 1:
        ans += 1


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

x,y,z,k,*L=map(int,open(0).read().split())
a=L[:x];b=L[x:x+y];c=sorted(L[x+y:])[::-1]
ab=sorted(i+j for i in a for j in b)[::-1][:min(x*y,k)]
print(*sorted(i+j for i in ab for j in c)[::-1][:k],sep="\n")

### FIXED CODE ###

x,y,z,k,*L=map(int,open(0).read().split())
a=L[:x];b=L[x:x+y];c=sorted(L[x+y:])[::-1]
ab=sorted(i+j for i in a for j in b)[::-1][:min(x*y,k)]
print(*sorted(i+j for i in ab for j in c)[::-1][:k],sep="\n")
### BUGGY CODE ###

s = list(input())

mod = 10**9 + 7

N = 13
dp = [0]*N
dp[0] = 1
mul = 1
for i in range(len(s)-1, -1, -1):
    nextDP = [0]*N
    if s[i] == '?':
        for k in range(10):
            for j in range(N):
                nextDP[(k*mul + j)%N] += dp[j]
                nextDP[(k*mul + j)%N] %= mod
    else:
        k = int(s[i])
        for j in range(N):
            nextDP[(k*mul + j)%N] += dp[j]
            nextDP[(k*mul + j)%N] %= mod

    mul = (mul*10)%N
    dp = nextDP

print(dp[5])

### FIXED CODE ###

s = list(input())

mod = 10**9 + 7

N = 13
dp = [0]*N
dp[0] = 1
mul = 1
for i in range(len(s)-1, -1, -1):
    nextDP = [0]*N
    if s[i] == '?':
        for k in range(10):
            for j in range(N):
                nextDP[(k*mul + j)%N] += dp[j]
                nextDP[(k*mul + j)%N] %= mod
    else:
        k = int(s[i])
        for j in range(N):
            nextDP[(k*mul + j)%N] += dp[j]
            nextDP[(k*mul + j)%N] %= mod

    mul = (mul*10)%N
    dp = nextDP

print(dp[5])
### BUGGY CODE ###

n=int(input())
a=[int(i) for i in input().split()]
ax=max(a)
dx=a.index(ax)

for i in range(ax*2,-1,-2):
    ans=[0]*n
    ans[dx]=i
    t=[x for x in a]
    for j in range(n):
        p=(dx+j)%n
        o=ans[p]//2
        t[p]-=o
        if j!=n-1:
            ans[(p+1)%n]=t[p]*2
        t[p-1]-=o
        if t[p]<0 or t[p-1]<0: break
    t=set(t)
    if len(t)==1 and 0==t.pop():
        print(*ans)
        exit()


### FIXED CODE ###

# from https://atcoder.jp/contests/abc133/submissions/6272850
n=int(input())
a=[int(i) for i in input().split()]
c=[0]
s=sum(a)

for i in range(2*n):
    c.append(c[-1]+a[(i*2+1)%n])
ans=[0]*n
for i in range(n):
    ans[i*2%n]=s-2*(c[i+n//2]-c[i])
print(*ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N = ii()
V = li()
C = li()

B = 2**N

ans = 0
for i in range(B):
    wa = 0
    for j in range(N):
        if i & 1 << j:
            wa += V[j] - C[j]
    ans = max(wa, ans)

print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N = ii()
V = li()
C = li()

sa = [V[i] - C[i] for i in range(N) if V[i] - C[i] > 0]

print(sum(sa))
### BUGGY CODE ###

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

table = set(a)

con = {}
dic = {}
ans = []
for i in table:
    con[i] = a.count(i)
    dic[i] = -1

for x in a:
    if dic[x] == -1:
        ex = (con[x] - 1) * (con[x] - 2) / 2
        no = (con[x]) * (con[x] - 1) / 2
        dic[x] = (int(no), int(ex))

su = sum([int(x[0]) for x in dic.values()])

for i,x in enumerate(a):
    print(su - (dic[x][0] - dic[x][1]))


### FIXED CODE ###

from collections import Counter

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

#table = set(a)
con = Counter(a)
dic = {}
#for i in table:
#    con[i] = a.count(i)
#    dic[i] = -1

for x in a:
    if x not in dic:
        ex = (con[x] - 1) * (con[x] - 2) / 2
        no = (con[x]) * (con[x] - 1) / 2
        dic[x] = (int(no), int(ex))

su = sum([int(x[0]) for x in dic.values()])

for i,x in enumerate(a):
    print(su - (dic[x][0] - dic[x][1]))
### BUGGY CODE ###

def func(n, a):
	tmp = [0 for i in range(n)]
	tmp[0] = a[0]
	if(0 in a):
		return 0
	for i in range(1, n):
		tmp[i] = tmp[i-1] * a[i]
		
	if(tmp[i] > 10**18):
			return '-1'
	
	return str(tmp[-1])

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

### FIXED CODE ###

def func(n, a):
	if(0 in a):
		return 0
	tmp = [0 for i in range(n)]
	tmp[0] = a[0]
	for i in range(1, n):
		tmp[i] = tmp[i-1] * a[i]
		if(tmp[i] > 10**18):
			return '-1'
	
	return str(tmp[-1])

n = int(input())
a = list(map(int, input().split()))
s = func(n, a)
print(s)
### BUGGY CODE ###

X = int(input())
a = 0
for i in range(1,X+1):
    for l in range(2,1000):
        if i**l <= X and i**l > a:
            a = i**l
print(a)

### FIXED CODE ###

X = int(input())
a = 0
for i in range(1,X+1):
    for l in range(2,11):
        if i**l <= X and i**l > a:
            a = i**l
print(a)
### BUGGY CODE ###

N,M = [int(i) for i in input().split()]
AB = []
for n in range(N):
    temp = [int(i) for i in input().split()]
    if temp[0] <= M:
        AB.append(temp)
from collections import deque
works = sorted(AB,key=lambda x:(-x[1],x[0],))
works = deque(works)
work_schedule = [0]*M
for w in range(len(works)):
    work = works.popleft()
    if work[0] > M:
        pass
    else:
        cnt = 0
        while True:
            if (work[0]-1+cnt) >= M:
                break
            elif work_schedule[work[0]-1+cnt]  == 0:
                work_schedule[work[0]-1+cnt] = work[1]
                break
            else:
                cnt+=1
print(sum(work_schedule))

### FIXED CODE ###

from collections import defaultdict
import heapq

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

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

h = []
res = 0

for i in range(1, m + 1):
    if dct[i]:
        for item in dct[i]:
            heapq.heappush(h, item)
    if h:
        res += heapq.heappop(h)

print(-res)
### BUGGY CODE ###

from fractions import gcd
def solve(p, q, a, n, l=1):

    if n==1:
        #print(p, q, a, n, l, 1 if p==1 and q<=a and q>=l else 0)
        return 1 if p==1 and q<=a and q>=l else 0
    ans = 0
    if p==1 and q<=a and q>=l:
        ans += 1
    denom = l if p==0 else max(l, int(q/p))
    while n*q >= denom*p and denom <= a:  #n/denom >= p/q:
        p_, q_ = p*denom-q, q*denom
        if p_ <= 0:
            denom += 1
            continue
        gcd_ = gcd(p_, q_)
        p_ //= gcd_
        q_ //= gcd_
        ans += solve(p_, q_, a//denom, n-1, denom)

        denom += 1
    #print(p, q, a, n, l, ans)
    return ans

while True:
    p, q, a, n = map(int, input().split())
    if p==q==a==n==0:
        break
    gcd_ = gcd(p, q)
    p //= gcd_
    q //= gcd_
    print(solve(p, q, a, n))



### FIXED CODE ###

from fractions import gcd

def solve(p, q, a, n, l=1):
    ans = 1 if p==1 and q<=a and q>=l else 0
    denom = max(l, q//p)
    p_denom = denom*p
    while n*q >= p_denom and denom <= a:  #n/denom >= p/q:
        p_, q_ = p_denom-q, q*denom
        if p_ <= 0:
            denom += 1
            p_denom += p
            continue
        gcd_ = gcd(p_, q_)
        p_ //= gcd_
        q_ //= gcd_
        if n==2 and p_==1 and q_*denom<=a and q_>=denom:
            ans += 1
        else:
            ans += solve(p_, q_, a//denom, n-1, denom)
        denom += 1
        p_denom += p
    #print(p, q, a, n, l, ans)
    return ans

while True:
    p, q, a, n = map(int, input().split())
    if p==q==a==n==0:
        break
    gcd_ = gcd(p, q)
    p //= gcd_
    q //= gcd_
    if n==1:
        print(1 if p==1 and q<=a else 0)
    else:
        print(solve(p, q, a, n))
### BUGGY CODE ###

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

def main():
    def hash_ij(i, j):
        if i + j == 0: return 0
        res = hash_table[i][j]
        if res == -1:
            if i > 0:
                res = (hash_ij(i - 1, j - 1) * base + target[j - 1]
                       - target[i - 1] * power(j - i)) % hash_md
            else:
                res = (hash_ij(i, j - 1) * base + target[j - 1]) % hash_md
            hash_table[i][j] = res
        return res

    def power(e):
        if e == 0: return 1
        res = pw[e]
        if res == -1:
            res = pw[e] = power(e - 1) * base % hash_md
        return res

    n = int(input())
    target = input()[:-1]

    # 初期化
    base = 29  # 文字種以上の素数
    hash_md = pow(3, 37)  # 2のべき乗以外がよい
    ord_a = ord('a')
    target = [ord(c) - ord_a for c in target]
    hash_table = [[-1] * (len(target) + 1) for _ in range(len(target))]
    pw = [-1] * (len(target) + 1)

    ok = 0
    ng = n // 2 + 1
    while ok + 1 < ng:
        br = False
        w = (ok + ng) // 2
        for i in range(n - 2 * w + 1):
            ptn = hash_ij(i, i + w)
            for j in range(i + w, n - w + 1):
                if hash_ij(j, j + w) == ptn:
                    ok = w
                    br = True
                    break
            if br: break
        else:
            ng = w
    print(ok)

main()


### FIXED CODE ###

# YouTube
def main():
    n = int(input())
    s = input()
    dp = [[0] * (n + 1) for _ in range(n + 1)]
    for i, c in enumerate(s):
        for j in range(n):
            if c == s[j]:
                dp[i + 1][j + 1] = dp[i][j] + 1
    ans = 0
    for i in range(n):
        for j in range(i+1,n+1):
            tmp=min(dp[i][j],j-i)
            ans=max(tmp,ans)
    print(ans)

main()
### BUGGY CODE ###

import sys
from pprint import pprint

def pow_r(x, n):
    """
    O(log n)
    """
    if n == 0:  # exit case
        return 1
    if n % 2 == 0:
        return pow_r(x ** 2, n // 2) % (10**9 + 7)
    else:
        return (x * pow_r(x ** 2, (n - 1) // 2)) % (10**9 + 7)


def solve(n, a):

    zero_count = [0] * 60
    for a_i in a:
        binary = format(a_i, '060b')

        for j, b_j in enumerate(binary):
            zero_count[j] += int(b_j)

    ans = 0
    for i, count in enumerate(zero_count[::-1]):
        # ans += (2**i) * (count * (n - count)) 
        ans += pow_r(2, i) * (count % (10**9 + 7)) * ((n - count) % (10**9 + 7)) 
        ans %= 10**9 + 7
    print(ans)

if __name__ == '__main__':
    n = int(sys.stdin.readline().strip())
    a = map(int, sys.stdin.readline().strip().split(" "))
    
    solve(n, a)

### FIXED CODE ###

import sys
from pprint import pprint

mod = 10**9 + 7

def pow_r(x, n):
    """
    O(log n)
    """
    if n == 0:  # exit case
        return 1
    if n % 2 == 0:
        return pow_r(x ** 2, n // 2) % mod
    else:
        return (x * pow_r(x ** 2, (n - 1) // 2)) % mod


def solve(n, a):

    zero_count = [0] * 60
    for a_i in a:
        # binary = format(a_i, '060b')
        # for j, b_j in enumerate(binary):
        #    zero_count[j] += int(b_j)
        for j in range(61):
            if a_i >> j & 1:
                zero_count[j] += 1

    ans = 0
    # for i, count in enumerate(zero_count[::-1]):
    for i, count in enumerate(zero_count):
        # ans += (2**i) * (count * (n - count)) 
        ans += pow_r(2, i) * (count % mod) * ((n - count) % mod) 
        ans %= mod
    print(ans)

if __name__ == '__main__':
    n = int(sys.stdin.readline().strip())
    a = map(int, sys.stdin.readline().strip().split(" "))
    
    solve(n, a)
### BUGGY CODE ###

import numpy as np
N = int(input())
S = input()
S = S.replace('.', '0').replace('#', '1')
b = np.array(list(S)).astype(np.int)
w = np.ones(N, dtype=np.int) - b

moves = 200000

for i in range(N + 1):
    left = np.sum(b[:i])
    right = np.sum(w[i:])
    moves = np.min([moves, left + right])

print(moves)


### FIXED CODE ###

N = int(input())
S = input()

w = S.count('.')
b = 0

k = w

for i in range(N):
    if S[i] == '.':
        w -= 1
    else:
        b += 1

    k = min(k, w + b)

print(k)
### BUGGY CODE ###

N,M=map(int,input().split())
PY=[list(map(int,input().split())) for _ in range(M)]
d={}
import bisect

for p,y in PY:
    d[p]=d.get(p, [])+[y]

for k, v in d.items():
    d[k]=sorted(v)

for p,y in PY:
    print(str(p).zfill(6)+str(bisect.bisect_left(d[p],y)+1).zfill(6))

### FIXED CODE ###

N,M=map(int,input().split())
d={}
PY=[]
import bisect
for _ in range(M):
    p,y=map(int,input().split())
    PY.append((p,y))
    t=d.get(p, [0])
    i=bisect.bisect_left(t,y)
    t.insert(i,y)
    d[p]=t
    
dx={}
for k, v in d.items():
    for i in range(len(v)):
        dx[(k,v[i])]=i
        
for p,y in PY:
    print(str(p).zfill(6)+str(dx[(p,y)]).zfill(6))
### BUGGY CODE ###

H=int(input())
if H==1:
    print(1)
else:
    i=1
    count=1
    while H/2!=1:
        i*=2
        count+=i
        H=H/2
    i*=2
    count+=i
    print(count)


### FIXED CODE ###

H=int(input())
if H==1:
    print(1)
else:
    i=1
    count=1
    while H//2!=1:
        i*=2
        count+=i
        H=H//2
    i*=2
    count+=i
    print(count)