Harryxun/stf_run huggingface dataset:
N, K = map(int, input().split())
A = list(map(int, input().split()))
L = len(bin(K)[2:])
bA=[bin(a)[2:].zfill(L) for a in A]

ans=''
for i in range(L):
    if sum([int(bA[i][j]) for j in range(N)])<=N//2:
      ans=ans+'1'
    else:
      ans=ans+'0'

ans=int(ans,2)
res=0
for a in A:
  res+=(a^ans)
print(res)

### FIXED CODE ###

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

MAX_DIGIT_LENGTH=50

dp=[[-1 for _ in range(2)] for _ in range(100)]
dp[0][0]=0

for d in range(MAX_DIGIT_LENGTH):
  mask=1<<((MAX_DIGIT_LENGTH-1)-d)
  
  tmp=0
  for a in A:
    if a&mask == mask:
      tmp+=1
      
  cost0=mask*tmp
  cost1=mask*(N-tmp)
    
  if dp[d][1]!=-1:
    dp[d+1][1]=max(dp[d][1]+max(cost0, cost1), dp[d+1][1])
  
  if dp[d][0]!=-1:
    if K&mask == mask:
      dp[d+1][1]=max(dp[d][0]+cost0, dp[d+1][1])
      dp[d+1][0]=max(dp[d][0]+cost1, dp[d+1][0])
    else:
      dp[d+1][0]=max(dp[d][0]+cost0, dp[d+1][0])
      
print(max(dp[MAX_DIGIT_LENGTH][0], dp[MAX_DIGIT_LENGTH][1]))
s=list(input())
t=list(input())
dp=[[0]*(30) for j in range(30)]
ans=[]
memo=-1
for i in range(len(s)):
    for j in range(len(t)):
        if s[i]==t[j]:
             dp[i+1][j+1] = dp[i][j]+1
             if memo < i:
                 ans.append(t[j])
                 memo = i

        else:
            dp[i+1][j+1] =max(dp[i][j+1],dp[i+1][j])

#print(dp[len(s)][len(t)])
answer=[]
i,j=len(s),len(t)
d=dp[i-1][j-1]
while i>0 and j>0 :
    if dp[i-1][j-1]!=dp[i][j]:
        answer.append(s[i-1])
        i-=1
        j-=1
    elif dp[i-1][j]==dp[i][j]:
        i-=1
    elif dp[i][j-1]==dp[i][j]:
        j-=1
print("".join(reversed(answer)))

### FIXED CODE ###

s=list(input())
t=list(input())
dp=[[0]*(3030) for j in range(3030)]
ans=[]
memo=-1
for i in range(len(s)):
    for j in range(len(t)):
        if s[i]==t[j]:
             dp[i+1][j+1] = dp[i][j]+1
             if memo < i:
                 ans.append(t[j])
                 memo = i

        else:
            dp[i+1][j+1] =max(dp[i][j+1],dp[i+1][j])

#print(dp[len(s)][len(t)])
answer=[]
i,j=len(s),len(t)
d=dp[i-1][j-1]
while i>=0 and j>=0:

    if dp[i-1][j]==dp[i][j]:
        i-=1
    elif dp[i][j-1]==dp[i][j]:
        j-=1
    else:
        answer.append(s[i - 1])
        i -= 1
        j -= 1
print("".join(reversed(answer)))
a, b, k = map(int, input().split())
lst = list(range(a, b+1))
print(*(lst[:k]+lst[-k:]), sep='\n')

### FIXED CODE ###

a, b, k = map(int, input().split())
lst = range(a, b+1)
for i in sorted(set(lst[:k]) | set(lst[-k:])):
  print(i)
n,m = map(int,input().split())
a = [0]*m
for i in range(m):
    a[i] = int(input())
s = 1
for i in range(m-1):
    if a[i+1] - a[i] == 1:
        s = 0
        break
if s == 0:
    print(0)
else:
    dp = [0]*(n+1)
    j = 0
    dp[0] = 1
    dp[1] = 1
    a = a + [0]
    for i in range(n-1):
        if a[j] == i+1:
            dp[i+2] = dp[i]
        elif a[j] == i:
            dp[i+2] = dp[i+1]
            j += 1
        else:
            dp[i+2] = dp[i+1] + dp[i]
    print(dp[-1]%1000000007)

### FIXED CODE ###

n,m = map(int,input().split())
a = [0]*m
for i in range(m):
    a[i] = int(input())
s = 1
for i in range(m-1):
    if a[i+1] - a[i] == 1:
        s = 0
        break
if s == 0:
    print(0)
else:
    dp = [0]*(n+1)
    j = 0
    dp[0] = 1
    dp[1] = 1
    a = a + [-1]
    for i in range(n-1):
        if a[j] == i+1:
            dp[i+2] = dp[i]
        elif a[j] == i:
            dp[i+2] = dp[i+1]
            j += 1
        else:
            dp[i+2] = dp[i+1] + dp[i]
    print(dp[-1]%1000000007)
import sys
n = int(raw_input())
if n % 10 == 3:
  print('bon')
elif n % 10 == 0 or n % 10 ==10 or n % 10 == 6 or n % 10 == 8:
  print('pon')
else:
  print('hon')

### FIXED CODE ###

n = int(input())
if n % 10 == 3:
  print('bon')
elif n % 10 == 0 or n % 10 == 1 or n % 10 == 6 or n % 10 == 8:
  print('pon')
else:
  print('hon')
s = list(map(str, input()))

if s.count("S")==2:
    s_rm = s.remove("S")
    if s_rm[0] == s_rm[1]:
        print("Yes")
    else:
        print("No")
else:
    print("No")


### FIXED CODE ###

s = list(map(str, input()))

if s.count(s[0])==2:
    s_rm = [i for i in s if i != s[0]]
    if s_rm[0] == s_rm[1]:
        print("Yes")
    else:
        print("No")
else:
    print("No")
N, M = map(int, input().split())
SC = set([tuple(map(int, input().split())) for _ in range(M)])
chk = {}
for s, c in SC:
    if s in chk:
        print(-1)
        exit()
    else:
        chk[s] == 0
ans = [-1] * N
for s, c in SC:
    if ans[s-1] == -1:
        ans[s-1] = c
if N >= 2:
    if ans[0] == -1 or ans[0] == 0:
        print(-1)
        exit()
kotae = ''
for a in ans:
    if a == -1:
        kotae += '0'
    else:
        kotae += str(a)
print(kotae)

### FIXED CODE ###

N, M = map(int, input().split())
SC = set(tuple(map(int, input().split())) for _ in range(M))

for i in range(10**N):
    num = str(i)
    if len(num) != N:
        continue
    chk = []
    for s, c in SC:
        if num[s-1] == str(c):
            chk.append(True)
        else:
            chk.append(False)
    if all(chk):
        print(num)
        exit()
print(-1)
import sys
def main():
    for line in sys.stdin:
        n = int(line)
        for x in range(1, n + 1):
            s = int(input())
            a = [] #answer
            for _ in range(10):
                s = "{0:08d}".format(s ** 2)
                s = list(s)
                hoge = ""
                for y in range(2, 6):
                    hoge += s[y]
                s = int(hoge)
                a.append(s)
            else:
                print("Case", x,end = "")
                print(":")
                for y in a:
                    print(y)


if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    d = int(input())
    a = []
    for _ in range(d):
        a.append(int(input()))

    for x in range(len(a)):
        print("Case ",end = "")
        print(x+1, end = "")
        print(":")
        for _ in range(10):
            a[x] = str("{0:08d}".format(a[x] ** 2))
            hoge = ""
            for y in range(2, 6):
                hoge += a[x][y]
            hoge = int(hoge)
            a[x] = hoge
            print(a[x])


if __name__ == "__main__":
    main()
import sys
sys.setrecursionlimit(4100000)

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

MAP = [[min(i, j, N-i-1, N-j-1) for i in range(N)] for j in range(N)]

d = [[1 for i in range(N)] for j in range(N)]

tx = [1, 0, -1, 0]
ty = [0, 1, 0, -1]

def dfs(x, y, cnt):
    for i in range(4):
        nx = x + tx[i]
        ny = y + ty[i]
        if 0 <= nx < N and 0 <= ny < N and MAP[nx][ny] > MAP[x][y] + d[x][y]:
            MAP[nx][ny] = MAP[x][y] + d[x][y]
            dfs(nx, ny, cnt + d[x][y])

ans = 0

for p in P:
    x = (p-1) // N
    y = (p-1) % N
    d[x][y] = 0
    cnt = float('INF')
    for i in range(4):
        nx = x + tx[i]
        ny = y + ty[i]
        if 0 <= nx < N and 0 <= ny < N:
            cnt = min(cnt, MAP[nx][ny] + d[nx][ny])
        else:
            cnt = min(cnt, 0)
    
    ans += MAP[x][y]
    
    MAP[x][y] = cnt
    
    bfs(x, y, cnt)
    

print(ans)

### FIXED CODE ###

from collections import deque

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

MAP = [min(i, j, N-i-1, N-j-1) for i in range(N) for j in range(N)]

d = [1] * (N ** 2)

ans = 0

def update(np, p):
    if MAP[np] > MAP[p] + d[p]:
        q.append(np)
        MAP[np] = MAP[p] + d[p]

for p in P:
    p -= 1
    
    d[p] = 0
    
    ans += MAP[p]
    
    q = deque()
    
    q.append(p)
    
    while len(q) != 0:
        p = q.popleft()
        if p % N != N-1:
            update(p+1, p)
        if p % N != 0:
            update(p-1, p)
        if p // N != N-1:
            update(p+N, p)
        if p // N != 0:
            update(p-N, p)

print(ans)
def computeMinimumNoOfOperations(candies, x):
    noOfOperations = 0
    for i in range(len(candies) - 1):
        if (candies[i] > x):
          candiesTocandiesToEat = candies[i] - x
          candies[i] -= candiesTocandiesToEat
          noOfOperations += candiesToEat
        if (candies[i] + candies[i + 1] > x):
            candiesToEat = candies[i] + candies[i + 1] - x
            candies[i + 1] -= candiesToEat
            noOfOperations += candiesToEat 
    return noOfOperations


def start():
    n, x = list(map(int, input().split()))
    candies = list(map(int, input().split()))
    return computeMinimumNoOfOperations(candies, x)

print(start())


### FIXED CODE ###


def computeMinimumNoOfOperations(candies, x):
    noOfOperations = 0
    for i in range(len(candies) - 1):
        if (candies[i] > x):
            candiesToEat = candies[i] - x
            candies[i] -= candiesToEat
            noOfOperations += candiesToEat
        if (candies[i] + candies[i + 1] > x):
            candiesToEat = candies[i] + candies[i + 1] - x
            candies[i + 1] -= candiesToEat
            noOfOperations += candiesToEat 
    return noOfOperations


def start():
    n, x = list(map(int, input().split()))
    candies = list(map(int, input().split()))
    return computeMinimumNoOfOperations(candies, x)

print(start())
predict_weather = list(input())
actual_weather = list(input())
 
count = 0
for i in len(predict_weather):
  if predict_weather[i] == actual_weather[i]:
    count += 1
 
print(count)

### FIXED CODE ###

predict_weather = list(input())
actual_weather = list(input())
 
count = 0
for i in range(len(predict_weather)):
  if predict_weather[i] == actual_weather[i]:
    count += 1
 
print(count)
n, k = map(int, input().split())
s = input()

print(s.replace('s[k-1]', ''s[k-1]'.lower()')

### FIXED CODE ###

N,K = map(int,input().split())
s = list(input())
s[K-1] = s[K-1].lower()
     
print("".join(s))
from itertools import combinations
N = int(input())
X = [list(map(int,input().split())) for _ in range(N)]
C = {}
for z in combinations(X,2):
    x1,x2 = z
    a = x1[0]-x2[0]
    b = x1[1]-x2[1]
    if a>=0 and b>=0:
        if (a,b) not in C:
            C[(a,b)] = 0
        C[(a,b)] += 1
    elif a>=0 and b<0:
        if (a,b) not in C:
            C[(a,b)] = 0
        C[(a,b)] += 1
    elif a<0 and b>=0:
        if (-a,-b) not in C:
            C[(-a,-b)] = 0
        C[(-a,-b)] += 1
    elif a<0 and b<0:
        if (-a,-b) not in C:
            C[(-a,-b)] = 0
        C[(-a,-b)] += 1
C = sorted(list(C.items()),key=lambda x:x[1],reverse=True)
k = C[0][1]
print(N-k)

### FIXED CODE ###

import itertools
N = int(input())
X = [list(map(int,input().split())) for _ in range(N)]
if N==1:
    cmin = 1
else:
    cmin = 100
    for y in itertools.combinations(X,2):
        x1,y1 = y[0]
        x2,y2 = y[1]
        p = x2-x1
        q = y2-y1
        cnt0 = 0
        cnt1 = 0
        for i in range(N):
            x,y = X[i]
            if [x+p,y+q] in X:
                cnt0 += 1
            if [x-p,y-q] in X:
                cnt1 += 1
        cnt = max(cnt0,cnt1)
        cmin = min(cmin,N-cnt)
print(cmin)
l = map(int, raw_input().split())
if len(l) == 2:
    a = l[0]; b = l[1]
else:
    a = l[0]; b = input()
p = map(int, raw_input().split())
q = map(int, raw_input().split())
ans = 0
#?°??????????
for i in range(a):
    if b - i <= ans or a - i <= ans: break
    j = 0; k = i
    cnt = 0
    while 1:
        if p[j] == q[k]:
            cnt += 1; j += 1; k += 1
        else: j += 1
        if j == a: break
    ans = max(ans, cnt)
print ans

### FIXED CODE ###

l = map(int, raw_input().split())
if len(l) == 2:
    a = l[0]; b = l[1]
else:
    a = l[0]; b = input()
p = map(int, raw_input().split())
q = map(int, raw_input().split())
ans = 0
for i in range(a):
    if b - i <= ans or a - i <= ans: break
    j = 0; k = i
    cnt = 0
    while 1:
        if p[j] == q[k]:
            cnt += 1; j += 1; k += 1
        else: j += 1
        if j == a: break
    ans = max(ans, cnt)
print ans
2017/01/07

### FIXED CODE ###

a=input()
print(a.replace("2017","2018"))
import collections

def prime_factor(n, length):
    ass = collections.defaultdict(int)
    # break_num = pow()
    for i in range(2,int(n**0.5)+1):
        # print(pow(i, length),  n)
        if pow(i, length) > n:
            break
        if i > n or n == 1:
            break
        # i = pow(i, num)
        while n % i==0:
            ass[i] += 1
            n = n//i

    if n != 1:
        ass[n] += 1
    return ass

if __name__ == '__main__':
    length, num = list(map(int, input().split()))

    soinnsuu = prime_factor(num, length)
    ans = 1
    # print(soinnsuu)
    for data in soinnsuu.keys():
        if soinnsuu[data] >= length:
           ans *= data
    print(ans)

### FIXED CODE ###

print(input().count('2'))
# coding: utf-8
# Your code here!

from collections import deque
def diameter(g):
    def bfs(start): # v からの最長点と距離を求める
        res = [-1]*(len(g))
        q = deque([start])
        res[start] = 0
        while q:
            v = q.popleft()
            for c in g[v]:
                if res[c] >= 0: continue
                res[c] = res[v] + 1 #重みつきのときは+1でなく +cost(v,c)
                q.append(c) 
        return (res[v],v)

    d0,v0 = bfs(0)
    d1,v1 = bfs(v0)
    return d1 # i0, i1 が最遠頂点対


##################################################
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
 
n = int(input())
#n,q = [int(i) for i in readline().split()]
 
g = [[] for _ in range(n)]
for i in range(n-1):
    a,b = [int(i) for i in readline().split()]
    g[a-1].append(b-1)
    g[b-1].append(a-1)

d = diameter(g)
if d%3 != 1:
    print("First")
else:
    print("Second")
    
assert n!=6
    
    







### FIXED CODE ###

# coding: utf-8
# Your code here!

def diameter(g):
    def dfs(v,p): # v からの最長点と距離を求める
        m = 0
        i = v
        for c in g[v]:
            if c == p: continue
            mc,ic = dfs(c,v)
            mc += 1  #重みつきのときは+1でなく +cost(v,c)
            if m < mc:
                m = mc
                i = ic
        return (m,i)

    m0,i0 = dfs(0,-1)
    m1,i1 = dfs(i0,-1)
    # i0, i1 が最遠頂点対
    return m1

##################################################
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
 
n = int(input())
#n,q = [int(i) for i in readline().split()]
 
g = [[] for _ in range(n)]
for i in range(n-1):
    a,b = [int(i) for i in readline().split()]
    g[a-1].append(b-1)
    g[b-1].append(a-1)

d = diameter(g)
if d%3 != 1:
    print("First")
else:
    print("Second")
n = input()
k = input()

n = int(n)
k = int(k)

ans = n - k + 1
print (ans)

### FIXED CODE ###

n,k=input().split()

n = int(n)
k = int(k)

ans = n - k + 1
print (ans)
A,B,C,D = map(int, input().split())

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

E=C*D//gcd(C,D)
total=0
if A%C==0 and A>=C:
    total += B//C-A//C+1
else:
    total += B // C - A // C

if A%D==0 and A>=D:
    total += B//D-A//D+1
else:
    total += B // D - A// D

if A%E==0 and A>=E:
    total = total- B//E-A//E+1
else:
    total = total - B // E - A // E

print(B-A+1-tot

### FIXED CODE ###

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


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


E = C * D // gcd(C, D)
total = 0

total += B // C - (A-1) // C


total += B // D - (A-1) // D


total = total - B // E + (A-1) // E

print(B - A + 1 - total)
def is_sorted(l):
    for i in range(len(l)):
        if l[i] != i + 1:
            return False
    return True


def can_go(start, goal, sw, d):
    if d > M: return False
    if start == goal: return True

    for s in sw:
        if s[0] == start:
            if can_go(s[1], goal, sw, d + 1):
                return True
        elif s[1] == start:
            if can_go(s[0], goal, sw, d + 1):
                return True
    return False


def try_s(l, sw):
    count = 0
    for idx, c in enumerate(l):
        if can_go(idx, c, sw, 0):
            # print(str(c) + ' can go home')
            count += 1
    print(count)


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

swaps = []
for i in range(M):
    x, y = map(int, input().split())
    swaps.append((x-1, y-1))


p = list(map(lambda x: x - 1, p))
# print(p)
# print(swaps)


if is_sorted(p):
    print(len(p))
else:
    try_s(p, swaps)


### FIXED CODE ###

# https://atcoder.jp/contests/abc097/tasks/arc097_b

import itertools
from collections import Counter
from collections import defaultdict
import bisect

# Union find
class UnionFind():
    def __init__(self,size):
        self.table = [-1 for _  in range(size)]  # 負の値の場合根を表す。絶対値はツリーの高さ 正の値は次の要素を返す、根まで続く
        self.size = [1 for _  in range(size)]

    #集合の代表を求める
    def find(self,x):
        while self.table[x] >= 0:
            #根に来た時,self.table[根のindex]は負の値なのでx = 根のindexで値が返される。
            x = self.table[x]
        return x

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    #併合
    def union(self,x,y):
        s1 = self.find(x)#根のindex,table[s1]がグラフの高さ
        s2 = self.find(y)
        if s1 != s2:#根が異なる場合
            if self.table[s1] != self.table[s2]:#グラフの高さが異なる場合
                if self.table[s1] < self.table[s2]:
                    self.table[s2] = s1
                    self.size[s1] += self.size[s2]
                else:
                    self.table[s1] = s2
                    self.size[s2] += self.size[s1]
            else:
                #グラフの長さが同じ場合,どちらを根にしても変わらない
                #その際,グラフが1長くなることを考慮する
                self.table[s1] += -1
                self.table[s2] = s1
                self.size[s1] += self.size[s2]
        return

    def group_size(self, x):
        return self.size[self.find(x)]


def main():
    N, M = map(int, input().split())
    P = list(map(int, input().split()))

    uf = UnionFind(N+1)
    for _ in range(M):
        a, b = map(int, input().split())
        uf.union(a, b)

    ans = 0
    for i in range(N):
        if uf.is_same(i + 1, P[i]):
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()
A,B = map(int,input().split())

if A<=5:
  print(0)
elif　A>=13:
  print(B)
else:
  print(B//2)
    

### FIXED CODE ###

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

if A<=5:
  print(0)
elif A>=13:
  print(B)
else:
  print(B//2)
n = int(raw_input())
for i in range(n):
    a[i] = raw_input()

a.sort()

print a[0]

### FIXED CODE ###

n = int(raw_input())
a=["" for i in range(n)]
for i in range(n):
    a[i] = raw_input()

a.sort()

print a[0]
m=int((input=().count('o'))
print(str(700+m*100))


### FIXED CODE ###

m=input().count("o")
print(700+m*100)
n,s=open(0)
a=[0]*(n+1)
b=[0]*(n+2)
for i in range(n):
  a[i+1]=a[i]
  b[n-i]=b[n-i+1]
  if s[i]=='W':
    a[i+1]+=1
  if s[n-i-1]=='E':
    b[n-i]+=1
print(min(a[i]+b[i]-1for i in range(1,n+1)))

### FIXED CODE ###

n=int(input())
s=list(input())
a=[0]*(n+1)
b=[0]*(n+2)
for i in range(n):
  a[i+1]=a[i]
  b[n-i]=b[n-i+1]
  if s[i]=='W':
    a[i+1]+=1
  if s[n-i-1]=='E':
    b[n-i]+=1
print(min(a[i]+b[i]-1for i in range(1,n+1)))
k = int(input())
a, b = map(input().split())
for i in range(a, b):
    if i % k == 0:
        print("OK")
    else:
        print("NG")

### FIXED CODE ###

k = int(input())
a, b = map(int, input().split())
re = False
for i in range(a, b+1):
    if (i % k) == 0:
        re = True
        break
if re == True:
    print("OK")
else:
    print("NG")
N = int(input())
a = [int(input()) for _ in range(N)]
mod = 998244353
suma = sum(a)
memo = [[0]*(suma+1) for _ in range(N+1)]
memo[0][0] = 1
memoe = [[0]*(suma+1) for _ in range(N+1)]
memoe[0][0] = 1

ttl = 3
for i in range(N-1):
  ttl *=3
  ttl %= mod
  
for i in range(N+1):
  for j in range(suma+1):
    if i==0:
      continue
    elif j - a[i-1]<0:
      memo[i][j]=(memo[i-1][j]*2)%mod
      memoe[i][j]=(memoe[i-1][j])%mod
    else:
      memo[i][j]=(memo[i-1][j]*2+memo[i-1][j-a[i-1]])%mod
      memoe[i][j]=(memoe[i-1][j]+memoe[i-1][j-a[i-1]])%mod

ans = sum(memo[N][(suma-1)//2+1:])
if suma%2==0:
  ans -= memoe[N][suma/2]
  
print(ttl - ans*3)

### FIXED CODE ###

import numpy as np
N = int(input())
a = [int(input()) for _ in range(N)]
mod = 998244353
suma = sum(a)
memo = np.zeros((N+1, suma+1), dtype=np.int)
memo[0][0] = 1
memoe = np.zeros((N+1, suma+1), dtype=np.int)
memoe[0][0] = 1

ttl = 3
for i in range(N-1):
  ttl *=3
  ttl %= mod

for i in range(1, N+1):
  memotmp = memo[i-1]
  memotmpe = memoe[i-1]
  memotmp = np.concatenate((np.zeros((a[i-1]), dtype=np.int), memotmp),axis=1)
  memotmpe = np.concatenate((np.zeros((a[i-1]), dtype=np.int), memotmpe),axis=1)
  memo[i] = (memo[i-1]*2 + memotmp[:suma+1])%mod
  memoe[i] = (memoe[i-1] + memotmpe[:suma+1])%mod

ans = sum(memo[N][(suma-1)//2+1:])
if suma%2==0:
  ans -= memoe[N][suma/2]
  
print(((ttl - ans*3)%mod+mod)%mod)
from math import gcd

############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input().rstrip()))
def inlt():
    return(list(map(int,input().rstrip().split())))
def insr():
    s = input().rstrip()
    return(s[:len(s) - 1])
def invr():
    return(map(int,input().rstrip().split()))
################################################################
n = inp()
nums = [0] + inlt()
dp = [0 for i in range(n + 1)]
s = [0 for i in range(n + 1)]
s[1] = nums[1]
for i in range(3,n,2):
    s[i] = s[i - 2] + nums[i]
if n == 1:
    print(nums[0])
elif n == 2:
    print(max(nums[1],nums[2]))
elif n == 3:
    print(max(nums[3],nums[1],nums[2]))
elif n == 4:
    print(max(nums[1] + nums[3],nums[1] + nums[4],nums[2] + nums[4]))
else:
    dp[1] = nums[1]
    dp[2] = max(nums[1],nums[2])
    dp[3] = max(nums[3],nums[1],nums[2])
    dp[4] = max(nums[1] + nums[3],nums[1] + nums[4],nums[2] + nums[4])
    for i in range(5,n + 1):
        if i % 2 == 0:
            dp[i] = max(dp[i - 2] + nums[i], s[i - 1]) #if n % 2 == 0 take sum else dp[i - 1]
        else:
            dp[i] = max(dp[i - 2] + nums[i], dp[i - 1])
    print(dp[n])
#print('No')
#print()


### FIXED CODE ###

from math import gcd

############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input().rstrip()))
def inlt():
    return(list(map(int,input().rstrip().split())))
def insr():
    s = input().rstrip()
    return(s[:len(s) - 1])
def invr():
    return(map(int,input().rstrip().split()))
################################################################
n = inp()
nums = [0] + inlt()
dp = [0 for i in range(n + 1)]
s = [0 for i in range(n + 1)]
s[1] = nums[1]
for i in range(3,n,2):
    s[i] = s[i - 2] + nums[i]
if n == 1:
    print(nums[0])
elif n == 2:
    print(max(nums[1],nums[2]))
elif n == 3:
    print(max(nums[3],nums[1],nums[2]))
elif n == 4:
    print(max(nums[1] + nums[3],nums[1] + nums[4],nums[2] + nums[4]))
else:
    dp[1] = nums[1]
    dp[2] = max(nums[1],nums[2])
    dp[3] = max(nums[3],nums[1],nums[2])
    dp[4] = max(nums[1] + nums[3],nums[1] + nums[4],nums[2] + nums[4])
    for i in range(5,n + 1):
        if i % 2 == 0:
            dp[i] = max(dp[i - 2] + nums[i], s[i - 1]) #if n % 2 == 0 take sum else dp[i - 1]
        else:
            dp[i] = max(dp[i - 2] + nums[i], dp[i - 1])
    print(dp[n])
#print('No')
#print()
import sys
while True:
    x = sys.stdin.readline().strip()
    if x == "0 0":
        break
    a = list(map(int, x.strip()))
    for i in range(a[0]):
        print("#" * a[1])
    print()

### FIXED CODE ###

while True:
    a = list(map(int, input().split()))
    if a[0] == a[1] == 0:
        break
    sharp = "#" * a[1]
    for i in range(a[0]):
        print(sharp)
    print()
n, m = map(int, input().split())
a = [[None] * n]
b = [None] * m
for i in range(n):
    a[i] = list(map(int, input().split()))
for i in range(m):
    b[i] = int(input())
for i in range(n):
    c = 0
    for j in range(m):
        c += a[i][j] * b[j]
    print(c)


### FIXED CODE ###

n, m = map(int, input().split())
A = [map(int, input().split()) for _ in [None] * n]
b = [int(input()) for _ in [None] * m]
for a in A:
    print(sum(i * j for i, j in zip(a, b)))