Harryxun/stf_run huggingface dataset:
s=input()
if(len(s)<=1):                                                                                            print('No')                                                                                           exit()
                                                                                                      for i in range(len(s)-1):                                                                                 if(s[i]=='h'):
        if(s[i+1]=='i'):
            continue
        else:
            print('No')
            exit()
    elif(s[i]=='i'):
        if(s[i+1]=='h'):
            if(i+2<len(s) and s[i+2]=='i'):
                continue
            else:
                print('No')
                exit()
        else:
            print('No')
            exit()
    else:
        print('No')                                                                                           exit()
print('Yes')

### FIXED CODE ###

s=input()
if(len(s)<=1):
    print('No')
    exit()

for i in range(len(s)-1):
    if(s[i]=='h'):
        if(s[i+1]=='i'):
            continue
        else:
            print('No')
            exit()
    elif(0<i and s[i]=='i'):
        if(s[i+1]=='h'):
            if(i+2<len(s) and s[i+2]=='i'):
                continue
            else:
                print('No')
                exit()
        else:
            print('No')
            exit()
    else:
        print('No')
        exit()
print('Yes')
s = input()
t = input()
ls = len(s)
lt = len(t)


dp = [[0 for i in range(lt+1)] for j in range(ls+1)]
answer = ''

for i in range(ls):
    for j in range(lt):
        if s[i] == t[j]:
            dp[i+1][j+1] = dp[i][j] + 1
        else:
            dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j])

            
if ls + lt == 0:
  print('ok')
else:
  
  i = ls-1
  j = lt-1
  while (0<=i & 0<=j):
      if s[i] == t[j]:
          answer += s[i]
          i -= 1
          j -= 1
      elif dp[i+1][j+1] == dp[i+1][j]:
          j -= 1
      else:
          i -= 1
  print(answer[::-1])


### FIXED CODE ###

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

dp=[0 for i in range(N)]
dp[1]=abs(H[1]-H[0])

for i in range(2,N):
    dp[i]=min(dp[i-1]+abs(H[i]-H[i-1]),dp[i-2]+abs(H[i]-H[i-2]))
print(dp[N-1])
N=int(input())
A=list(map(int,input().split()))

gcd_list=[A[0]]
rev_gcd_list=[A[-1]]

for i in range(1,N):
    gcd_list.append(gcd([gcd_list[-1],A[i]]))
    rev_gcd_list.append(gcd([rev_gcd_list[-1],A[-i-1]]))
rev_gcd_list=rev_gcd_list[::-1]

ans=max(gcd_list[N-2],rev_gcd_list[1])
for i in range(1,N-1):
    ans=max(ans,gcd([gcd_list[i-1],rev_gcd_list[i+1]]))
print(ans)

### FIXED CODE ###

def gcd_(a,b):
    if a<b:    a,b=b,a
    if b==0:    return a
    return gcd_(b,a%b)
  
def gcd(l):
    ans=l[0]
    for i in l:
        ans=gcd_(ans,i)
    return ans


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

gcd_list=[A[0]]
rev_gcd_list=[A[-1]]

for i in range(1,N):
    gcd_list.append(gcd([gcd_list[-1],A[i]]))
    rev_gcd_list.append(gcd([rev_gcd_list[-1],A[-i-1]]))
rev_gcd_list=rev_gcd_list[::-1]

ans=max(gcd_list[N-2],rev_gcd_list[1])
for i in range(1,N-1):
    ans=max(ans,gcd([gcd_list[i-1],rev_gcd_list[i+1]]))
print(ans)
def warshall_floid(d):
    for k in range(1,n+1):
        for i in range(1,n+1):
            for j in range(1,n+1):
                d[i][j] = min(d[i][j],d[i][k]+d[k][j])
    return d

n,m,l = map(int,input().split())
d = [10**13]*(n+1) for i in range(n+1)]
for i in range(m):
    a,b,c = map(int,input().split())
    d[a][b] = c
    d[b][a] = c
for i in range(1,n+1):
    d[i][i] = 0
d = warshall_floid(d)
for i in range(1,n+1):
    for j in range(1,n+1):
        if d[i][j] <= l:
            d[i][j] = 1
        else:
            d[i][j] = 10**13
d = warshall_floid(d)
q = int(input())
for i in range(q):
    s,t = map(int,input().split())
    if d[s][t] >= 10**13:
        print(-1)
    else:
        print(d[s][t]-1)


### FIXED CODE ###

a,b = map(int,input().split())
if a-2*b > 0:
    print(a-2*b)
else:
    print(0)
N = int(input())
list = input().split()
ans = 0
maxHeight = -1

for i in range(N):
  if list[i] >= maxHeight:
    ans += 1
    maxHeight = list[i]
print(ans)

### FIXED CODE ###

N = int(input())
list = input().split()
ans = 0
maxHeight = -1
for i in range(N):
  if int(list[i]) >= maxHeight:
    ans += 1
    maxHeight = int(list[i])
print(ans)
S = input().split("/")
if S[1]==4 and S[2]<=30:
    print("Heisei")
elif S>4:
    print("TBD")
else:
    print("Heisei")


### FIXED CODE ###

S = input().split("/")
if int(S[1])==4 and int(S[2])<=30:
    print("Heisei")
elif int(S[1])>4:
    print("TBD")
else:
    print("Heisei")
n = int(input())
x = list(map(int, input().split()))
y = list(x)
y.sort()
if n % 2 != 0:
    a,b,c = y[n//2-1],y[n//2],y[n//2+1]
    m = b
else:
    a,b = y[n//2-1],y[n//2]    
    m = (a+b)/2
for i in range(n):
    if x[i] < m :
        if n%2==0:
            tm = b
        else:
            tm = (b+c)/2
    if i == n//2:
        if n%2==0:
            tm = a
        else:
            tm = (a+c)/2
    if x[i] > m:
        if n%2==0:
            tm = a
        else:
            tm = (a+b)/2
    print(int(tm))

        
    

### FIXED CODE ###

n = int(input())
x = list(map(int, input().split()))
y = list(x)
y.sort()
if n % 2 != 0:
    a,b,c = y[n//2-1],y[n//2],y[n//2+1]
    m = b
else:
    a,b = y[n//2-1],y[n//2]    
    m = (a+b)/2
for i in range(n):
    if i == n//2:
        if n%2==0:
            tm = a
        else:
            tm = (a+c)/2
    if x[i] < m :
        if n%2==0:
            tm = b
        else:
            tm = (b+c)/2
    else:
        if n%2==0:
            tm = a
        else:
            tm = (a+b)/2
    print(int(tm))
def partition(p, r):
    x = a[r]
    i = p-1

    for j in range(p, r):
        if a[j] <= x:
            i += 1
            a[i], a[j] = a[j], a[i]

    a[i+1], a[r] = a[r], a[i+1]
    return i+1


n = int(input())
a = list(map(int, input().split()))
idx = partition(0, n-1)
print(*a[:idx], [a[idx]], *a[idx+1:])

### FIXED CODE ###

def partition(p, r):
    x = a[r]
    i = p-1

    for j in range(p, r):
        if a[j] <= x:
            i += 1
            a[i], a[j] = a[j], a[i]

    a[i+1], a[r] = a[r], a[i+1]
    return i+1


n = int(input())
a = list(map(int, input().split()))
idx = partition(0, n-1)
a[idx] = [a[idx]]
print(*a)
from scipy import special
from bisect import bisect_left as bl,bisect_right as br
n=int(input())
l=list(map(int,input().split()))
l.sort()
mm=l[-1];ans=0;p=0
for i in range(max(0,bl(l,l[-1]//2)-2),min(n,l[-1]//2+3)):
    g=scipy.special.comb(mm, l[i], exact = False)
    if ans<g:
        ans=g
        p=i
print(mm,l[p])

### FIXED CODE ###

from bisect import bisect_left as bl,bisect_right as br
n=int(input())
l=list(map(int,input().split()))
l.sort()
pre=10**9
mm=l[-1];p=0
for i in range(max(0,bl(l,l[-1]//2)-2),min(n,l[-1]//2+3)):
    if abs(mm/2-l[i])<pre:pre=abs(mm/2-l[i]);p=i
print(mm,l[p])
n = int(input())
s = input()

common = 0
for i in range(1,len(s)+):
    common = min(common, len(set(s[:i]).intersection(set[i:])))

print(common)

### FIXED CODE ###

n = int(input())
s = input()

common = 0
for i in range(1,len(s)+1):
    common = max(common, len(set(s[:i]).intersection(set(s[i:]))))

print(common)
from scipy.special import comb

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

mod = 10 ** 9 + 7

for i in range(1, K + 1):
    a = comb(N - K + 1, i, exact=True)
    b = comb(K - 1, i - 1, exact=True)
    ret = a % mod * b % mod
    print(ret)


### FIXED CODE ###

from scipy.misc import comb

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

mod = 10 ** 9 + 7

for i in range(1, K + 1):
    a = comb(N - K + 1, i, exact=True)
    b = comb(K - 1, i - 1, exact=True)
    ret = a % mod * b % mod
    print(ret)
N = 300000
a = [((i % 7 ==1)or(i % 7 ==6)) for i in range(N)]
#print(a[11])
a[1]=0
p =[]
for i in range(6,N):
    if a[i]:
        p+=[i]
        for j in range(i * i ,N,i):
            a[j] = 0
 
while True:
    n = int(input())
    if n == 1:
        break
    print(n,end = ":")
    for x in p:
        if n % x ==0:
            print(" "+str(x),end = " ")

    print()



### FIXED CODE ###

N = 300000
a = [((i % 7 ==1)or(i % 7 ==6)) for i in range(N)]
#print(a[11])
a[1]=0
p =[]
for i in range(6,N):
    if a[i]:
        p+=[i]
        for j in range(i * i ,N,i):
            a[j] = 0
 
while True:
    n = int(input())
    if n == 1:
        break
    print(n,end = ":")
    for x in p:
        if n % x ==0:
            print(" "+str(x),end = "") 

    print()
n, m, x = map(int,input().split())
l = [list(map(int,input().split())) for i in range(n)]

def generate_n_bit(n):
    bins= []
    for i in range(2**n):
        bins.append(list(str(format(i,'b').zfill(n))))
    
    return bins

min_price = 10**9
bins = generate_n_bit(10)
bins = bins[1:]

for bin in bins:
    a = [0 for k in range(m)]
    price = 0
    for i in range(n):
        if bin[i] == '1':
            for j in range(m):
                a[j] += l[i][j+1]
            
            price += l[i][0]
    
   
    
    if min(a) >= x:
        min_price = min(price, min_price)
        

if min_price == 10**9:
    print(-1)
    exit()
    
print(min_price)


### FIXED CODE ###

n, m, x = map(int,input().split())
l = [list(map(int,input().split())) for i in range(n)]

def generate_n_bit(n):
    bins= []
    for i in range(2**n):
        bins.append(list(str(format(i,'b').zfill(n))))
    
    return bins

min_price = 10**9
bins = generate_n_bit(n)
bins = bins[1:]

for bin in bins:
    a = [0 for k in range(m)]
    price = 0
    for i in range(n):
        if bin[i] == '1':
            for j in range(m):
                a[j] += l[i][j+1]
            
            price += l[i][0]
    
   
    
    if min(a) >= x:
        min_price = min(price, min_price)
        

if min_price == 10**9:
    print(-1)
    exit()
    
print(min_price)
A, B, C, D = map(int, input().split())

X = list(range(A, B+1))

c = A % C
d = A % D

if c == 0:
    I = list(range(A, B+1, C))
else:
    I = list(range(A+C-c, B+1, C))
if d == 0:
    J = list(range(A, B+1, D))
else:
    J = list(range(A+D-d, B+1, D))

ans_list = list(set(X) - set(I) - set(J))
print(len(ans_list))


### FIXED CODE ###

import fractions

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

# B以下でC, Dで割り切れるものの個数
b_c = B // C
b_d = B // D

# B以下でCでもDでも割り切れるものの個数
b_c_d = B // ((C*D)//fractions.gcd(C,D))

# A未満でC, Dで割り切れるものの個数
a_c = (A-1) // C
a_d = (A-1) // D

# A未満でCでもDでも割り切れるものの個数
a_c_d = (A-1) // ((C*D)//fractions.gcd(C,D))


count = b_c + b_d - b_c_d - (a_c + a_d - a_c_d)

ans = B-A+1 - count
print(int(ans))
s,t = input().split()
ans = "Yes"
for i in range(s):
  if s[i] != t[i]:
    ans = "No"
print(ans)

### FIXED CODE ###

s = input()
t = input()
ans = "Yes"
for i in range(len(s)):
  if s[i] != t[i]:
    ans = "No"
print(ans)
t=input():
print("Bad") if ((t[0]==t[1])or(t[1]==t[2])or(t[2]==t[3])) else print("Good")

### FIXED CODE ###

t=input()
print("Bad") if (t[0]==t[1])or(t[1]==t[2])or(t[2]==t[3]) else print("Good")
a , b = map(int , input().split())
c=str(a)+str(b)
c=int(c)
for i in range (c/2):
    if c== int(i*i):
        print("Yes")  
        break      
    elif i==c/2-1:
        print("No")
        break

### FIXED CODE ###

a , b = map(int , input().split())
c=str(a)+str(b)
c=int(c)
for i in range (1000):
    if c== int(i*i):
        print("Yes")  
        break      
    elif i==1000-1:
        print("No")
        break
A, B, K = map(int, input().split())

ab = set(list(range(A,B+1,1)))
a = set(list(range(A,A+K,1)))&ab
b = set(list(range(B-K+1,B+1,1)))&ab
ans=list(a|b)
ans = sorted(ans)

if len(ansi)>0:
  for ansi in ans:
    print(ansi)


### FIXED CODE ###

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

for i in range(A,min([A+K+1,B+1]),1):
  if i<A+K:
    print(i)
    
for i in range(max([A+K, B-K-1]),B+1,1):
  if i>B-K:
    print(i)
s = input()

slist = s.split(' ')

left = slist[0] + slist[1]

right = slist[2] + slist[3]

if left > right:
	print('left')
else if left == right:
	print('Balanced')
else:
	print('right

### FIXED CODE ###

s = input()

slist = s.split(" ")

left = int(slist[0]) + int(slist[1])

right = int(slist[2]) + int(slist[3])

if left > right:
	print("Left")
	
elif left == right:
	print("Balanced")
	
else:
	print("Right")
while True:
    H, W =[int(i) for i in input().split ]
    if H == W == 0:
       break

    for h in range(H):
        for w in range(W):
            if h == 0 or h == H -1 or w == 0 or w == W - 1:
               print('#', end='')
            else:
                print('.', end='')

        print()

    print()

### FIXED CODE ###

while True:
    H, W = [int(i) for i in input().split()]
    if H == W == 0:
        break
     
    for h in range(H):
        for w in range(W):
            if h == 0 or h == H-1 or w == 0 or w == W - 1:
                print('#', end='')
            else:
                print('.', end='')
        print()
     
    print()
import math
a,b = map(int,input().split())
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
print(lcm(a, b))

### FIXED CODE ###

from fractions import gcd
import sys
sys.setrecursionlimit(10**7)
a,b = map(int,input().split())
def lcm(x, y):
    return (x * y) // gcd(x, y)
if b != 0:
    print(lcm(a, b))
else:
    print(a)
n = int(input())
t = list(str(input()))
if n%2 == 1:
    print("No")
else:
    ans = True
    a = ["" for i in range(int(n/2))]
    b = ["" for i in range(int(n/2))]
    for i in range(int(n/2)):
        a[i] = t[i]
        b[i] = t[int(n/2)+i]
    for i in range(int(n/2)):
        ans = ans and a[i] == b[i]
if ans:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n = int(input())
t = list(str(input()))
if n%2 == 1:
    print("No")
else:
    ans = True
    a = ["" for i in range(int(n/2))]
    b = ["" for i in range(int(n/2))]
    for i in range(int(n/2)):
        a[i] = t[i]
        b[i] = t[int(n/2)+i]
    for i in range(int(n/2)):
        ans = ans and a[i] == b[i]
    if ans:
        print("Yes")
    else:
        print("No")
def solve(N, M, A):
    MOD = 10**9 + 7
    A = set(A)
    if N == 1:
        return 1

    dp = [0] * (N+1)
    dp[0] = 1
    dp[1] = 1 if 1 not in A else 0
    for i in range(2, N+1):
        if i in A:
            dp[i] = 0
        else:
            dp[i] = (dp[i-2] + dp[i-1]) % MOD
    return dp[-1]


N, M = map(int, input).split())
A = [int(input()) for _ in range(M)]
ans = solve(N, M, A)
print(ans)



### FIXED CODE ###

# -*- coding: utf-8 -*-
"""



"""
import sys


def solve(N, M, A):
    MOD = 10**9 + 7
    A = set(A)
    dp = [0] * (N+1)
    dp[0] = 1
    dp[1] = 1 if 1 not in A else 0
    for i in range(2, N+1):
        if i in A:
            dp[i] = 0
        else:
            dp[i] = (dp[i-2] + dp[i-1]) % MOD
    return dp[-1]


def main(args):
    N, M = map(int, input().split())
    A = [int(input()) for _ in range(M)]
    ans = solve(N, M, A)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
n,l=map(int,input().split())
s=[input() for i in range(n)]
print(''.join(sorted(s))

### FIXED CODE ###

n,l=map(int,input().split())
s=[input() for i in range(n)]
print(''.join(sorted(s)))
a,b,c=map(int, input().split())
print(min([a+b,b+c,c+a])

### FIXED CODE ###

P,Q,R=map(int, input().split())
print(min([P+Q,Q+R,R+P]))
N,M=map(int,input().split())
Xa={}
ans=0
for i in range(N):
    V,S=map(int,input().split())
    Xa[V]=S
Xb=sorted(Xa.items())
for i in range (N) :
    M -= Xb[i][1]
    ans += Xb[i][0]*Xb[i][1]
    if M < 0 :
        ans -= abs(M)*Xb[i][0]
        break
    elif M == 0 :
        break
print(ans)

### FIXED CODE ###

N,M=map(int,input().split())
Xa={}
ans=0
for i in range(N):
    V,S=map(int,input().split())
    if V in Xa :
        Xa[V] += S
    else :
        Xa[V]=S
Xb=sorted(Xa.items())
for i in range (len(Xb)) :
    M -= Xb[i][1]
    ans += Xb[i][0]*Xb[i][1]
    if M <= 0 :
        ans -= abs(M)*Xb[i][0]
        break
 
print(ans)
import itertools
import math
N = input()
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
permutation = list(itertools(N))
for i in range(len(permutation)):
  if P == permutation[i]:
    a = i
  elif Q == permutation[i]:
    b = i
print(math.fabs(a-b))

### FIXED CODE ###

def f(x):
    return x-1
import itertools
import math
N = int(input())
P = list(map(int, input().split()))
P = list(map(f, P))
Q = list(map(int, input().split()))
Q = list(map(f, Q))
S = list(range(N))
permutation = list(itertools.permutations(S))
a,b = 0,0
for i in range(len(permutation)):
    if P == list(permutation[i]):
        a = i
    if Q == list(permutation[i]):
        b = i
print(int(math.fabs(a-b)))
def func(z,c):
    if c == 0:
        z = 0
    else:
        z = z%c
    a = bin(z)
    b = 0
    for i in range(len(a)):
        if a[i] == "1":
            b += 1
    return z,b

n = int(input())
x = input()
c = 0
sw = 0
for i in range(n):
    if x[i] == "1":
        c += 1
s0 = int(x,2)%(c+1)
if c <= 1:
    s1 = 0
else:
    s1 = int(x,2)%(c-1)
for i in range(n):
    sw = 0
    if x[i] == "0":
        d = c + 1
        z = (s0 + pow(2,n-i-1,d))%d
    else:
        d = c - 1
        if d == 0:
            sw = 1
        else:
            z = (s1 - pow(2,n-i-1,d))%d
    ans = 1
    p = bin(z)
    e = 0
    for A in str(p):
        if A == "1":
            e += 1
    d = e
    if sw == 1:
        ans = 0
    else:
        while z:
            z,d = func(z,d)
            ans += 1
    print(ans)

### FIXED CODE ###

def func(z,c):
    if c == 0:
        z = 0
    else:
        z = z%c
    a = bin(z)
    b = 0
    for i in range(len(a)):
        if a[i] == "1":
            b += 1
    return z,b

n = int(input())
x = input()
c = 0
for i in range(n):
    if x[i] == "1":
        c += 1
s0 = int(x,2)%(c+1)
if c <= 1:
    s1 = 0
else:
    s1 = int(x,2)%(c-1)
for i in range(n):
    sw = 0
    if x[i] == "0":
        d = c + 1
        z = (s0 + pow(2,n-i-1,d))%d
    else:
        d = c - 1
        if d == 0:
            z = 0
            sw = 1
        else:
            z = (s1 - pow(2,n-i-1,d))%d
    ans = 1
    p = bin(z)
    e = 0
    for A in str(p):
        if A == "1":
            e += 1
    d = e
    if sw == 1:
        ans = 0
    else:
        while z:
            z,d = func(z,d)
            ans += 1
    print(ans)
def main():
    S = input()

    dfs(S)


def dfs(S):
    l = len(S)
    if _dfs(S, l, 0):
        print("YES")
    else:
        print("NO")


def _dfs(S, l, idx, pattern=0):
    # print(l, idx, pattern)
    if idx == l:
        return True

    if S[idx:idx + 7] == "dreamer":
        ok = _dfs(S, l, idx + 7, 1)
        if ok:
            return True
    if S[idx:idx + 6] == "eraser":
        ok = _dfs(S, l, idx + 6, 2)
        if ok:
            return True
    if S[idx:idx + 5] == "dream" or \
            S[idx:idx + 5] == "erase":
        ok = _dfs(S, l, idx + 5, 3)
        if ok:
            return True

    return False


def WA(S):
    l = len(S)
    idx = 0
    ok = True
    while idx < l:
        if S[idx:idx + 7] == "dreamer":
            idx += 7
        elif S[idx:idx + 6] == "eraser":
            idx += 6
        elif S[idx:idx + 5] == "dream" or \
                S[idx:idx + 5] == "erase":
            # 評価順番注意
            idx += 5
        else:
            ok = False
            break

    if ok:
        print("YES")
    else:
        print("NO")

if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    S = input()

    editorial(S)


def editorial(S):
    """
    それぞれがそれ以外のprefixにならなければ良い
    """
    l = len(S)
    idx = 0
    ok = True
    rs = S[::-1]
    r7 = "dreamer"[::-1]
    r6 = "eraser"[::-1]
    r5_1 = "dream"[::-1]
    r5_2 = "erase"[::-1]

    while idx < l:
        if rs[idx:idx + 7] == r7:
            idx += 7
        elif rs[idx:idx + 6] == r6:
            idx += 6
        elif rs[idx:idx + 5] == r5_1 or \
                rs[idx:idx + 5] == r5_2:
            idx += 5
        else:
            ok = False
            break

    if ok:
        print("YES")
    else:
        print("NO")


def RE(S):
    l = len(S)
    if _dfs(S, l, 0):
        print("YES")
    else:
        print("NO")


def _dfs(S, l, idx, pattern=0):
    # print(l, idx, pattern)
    if idx == l:
        return True

    if S[idx:idx + 7] == "dreamer":
        ok = _dfs(S, l, idx + 7, 1)
        if ok:
            return True
    if S[idx:idx + 6] == "eraser":
        ok = _dfs(S, l, idx + 6, 2)
        if ok:
            return True
    if S[idx:idx + 5] == "dream" or \
            S[idx:idx + 5] == "erase":
        ok = _dfs(S, l, idx + 5, 3)
        if ok:
            return True

    return False


def WA(S):
    l = len(S)
    idx = 0
    ok = True
    while idx < l:
        if S[idx:idx + 7] == "dreamer":
            idx += 7
        elif S[idx:idx + 6] == "eraser":
            idx += 6
        elif S[idx:idx + 5] == "dream" or \
                S[idx:idx + 5] == "erase":
            # 評価順番注意
            idx += 5
        else:
            ok = False
            break

    if ok:
        print("YES")
    else:
        print("NO")

if __name__ == '__main__':
    main()
import numpy as np
n, k = map(int,input().split())
a = np.array([int(i) for i in input().split()])
best = 0
for i in range(k+1):
    aa = np.full(len(a), i)
    tmp = np.sum(a ^ aa)
    if best < tmp:
        best = tmp
print(best)

### FIXED CODE ###

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

# 最大値を取るf(x)のxを求める
# digitsは下位桁 < 上位桁で1になっているbitをカウントする
digits = [0] * 40
for i in range(40):
    for a in A:
        if (a >> i) & 1:
            digits[i] += 1

# Kを考慮してmax_xを求める方法がわからない
# 桁ごとに最適なbitはすでにわかっていて、他の桁のbitに影響を受けることはないので、
# 上位桁から見ていって、Kが1になっている部分ならフラグを立てる
# 上位桁から見てKが1のbitが出てから、K:1,max_x:0のフラグを立てたら、その桁より下位桁のbitはなんでもよくなる
check_K = True
max_x = 0
for i, d in enumerate(reversed(digits)):
    i = 40 - i - 1
    if check_K and K < pow(2, i):
        continue
    if d <= (N-d) and ((K >> i) & 1 == 1 or not check_K):
        max_x += 2 ** i
    elif (K >> i) & 1 == 1:
        check_K = False
    
#print(max_x)
ans = 0
for a in A:
    ans += a ^ max_x

print(ans)
#区間ごとの面積を計算する
def calc_area(v_end, v_start, v_max, dt):
    kouten_v = (v_end + v_start + dt) / 2
    kouten_t = kouten_v - v_start
    if 0 < kouten_t < dt:
        area = (v_start + kouten_v) * kouten_t / 2 #左側
        area +=  (v_end + kouten_v) * (dt - kouten_t) / 2 #右側
        area -=  max(0, (kouten_v - v_max))** 2 #上の三角形
    else:
        area = (v_start + v_end) *  dt / 2
    return area

def main():
    #与えられた入力を受け取る
    n=int(input())
    t=[int(i) for i in input().split()]
    v=[int(i) for i in input().split()]

    #各区間の許容最大速度を計算する
    #（この段階では傾きが-1未満になる可能性がある）
    max_velocity = [0]
    for i in range(1, n):
        max_velocity_ = min(v[i-1], v[i], max_velocity[i-1] + t[i-1])
        max_velocity.append(max_velocity_)
    max_velocity.append(0)

    #後ろから走査して、傾きが-1以上を満たすように許容速度をfittingする
    for i in range(n-1):
        if  max_velocity[-(i+1)] - max_velocity[-(i+2)] < -t[-(i+1)]:
            max_velocity[-(i+2)] = max_velocity[-(i+1)] + t[-(i+1)]

    #各区間の面積を計算して足し合わせる
    ans = 0
    for i in range(n):
        ans += calc_area(max_velocity[i+1], max_velocity[i], v[i], t[i])
    print(ans)

main()

### FIXED CODE ###

a=int(input())
b=int(input())

print(a+2*(b-a))
N=int(input())
Happoint=(N//500)*1000 + ((n%500)//5)*5
print(int(Happoint))

### FIXED CODE ###

N=int(input())
Hapt=0
if(N>=5):
  Hapt=Hapt+(N//500)*1000 + ((N%500)//5)*5
else:
  Hapt=0
print(Hapt)
# -*- coding: utf-8 -*-
import numpy as np
N = input()
A = np.array(map(int, raw_input().split()))


A = np.append(np.append([0], A), [0])
total_sum = 0
for i in range(0, len(A) - 1):
    total_sum += np.abs(A[i + 1] - A[i])

for i in range(1, len(A) - 1):
    partial_sum = total_sum - np.abs(A[i + 1] - A[i]) - np.abs(A[i] - A[i - 1]) + np.abs(A[i + 1] - A[i - 1])
    print partial_sum


### FIXED CODE ###

# -*- coding: utf-8 -*-
import numpy as np
N = input()
A = map(int, input().split())
A = list(A)

A = [0] + A + [0]
total_sum = 0
for i in range(0, len(A) - 1):
    total_sum += abs(A[i + 1] - A[i])

for i in range(1, len(A) - 1):
    partial_sum = total_sum - abs(A[i + 1] - A[i]) - abs(A[i] - A[i - 1]) + abs(A[i + 1] - A[i - 1])
    print(partial_sum)