Language: C++

#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define REVERSE(s) reverse(s.begin(), s.end());
#define SUM(s) accumulate(s.begin(), s.end(), 0LL);
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

template <class T>
void VecRowShow(vector<T> vec) {
	rep(i, vec.size()) {
		if (i != vec.size() - 1) cout << vec[i] << " ";
		else cout << vec[i] << endl;
	}
}

unsigned euclidean_gcd(unsigned a, unsigned b) {
	if (a < b) return euclidean_gcd(b, a);
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}

int main() {

	int n;
	cin >> n;
	vector<ll> e(n), o(n), q(n);
	rep(i, n) {
		ll a;
		cin >> a;
		q[i] = a;
		if (i % 2 == 0) {
			if (i == 0) {
				e[0] = a;
			}
			else {
				ll z = e[i - 2];
				e[i] = z + a;
			}
		}
		else {
			if (i == 1) {
				o[1] = a;
			}
			else {
				ll z = o[i - 2];
				o[i] = z + a;
			}
		}
	}
	if (n % 2 == 0) {
		ll se = e[n - 2];
		ll so = o[n - 1];
		if (se > so) {
			cout << se << endl;
		}
		else {
			cout << so << endl;
		}
		return 0;
	}

	vector<vector<pair<int, ll>>> li(n);
	rep(i, n) {
		if (i == 0) {
			li[0].push_back(make_pair(0, 0));
			li[0].push_back(make_pair(1, q[0]));
		}
		else if (i == 1) {
			li[1].push_back(make_pair(0, 0));
			li[1].push_back(make_pair(1, q[1]));
		}
		else {
			int m1 = (i + 1) / 2;
			ll m1m = -10000000000000000;
			FOR(j, 2, 7) {
				if (i - j < 0) {
					break;
				}
				rep(k, li[i - j].size()) {
					if (li[i - j][k].first == m1 - 1) {
						m1m = max(m1m, li[i - j][k].second);
					}
				}
			}
			li[i].push_back(make_pair(m1, m1m + q[i]));


			int m2 = (i + 2) / 2;
			ll m2m = -10000000000000000;
			FOR(j, 2, 7) {
				if (i - j < 0) {
					break;
				}
				rep(k, li[i - j].size()) {
					if (li[i - j][k].first == m2 - 1) {
						m2m = max(m2m, li[i - j][k].second);
					}
				}
			}
			li[i].push_back(make_pair(m2, m2m + q[i]));
		}
	}

	int i = n - 1;
	ll m3 = n / 2;
	ll m3m = -10000000000000000;
	FOR(j, 0, 7) {
		if (i - j < 0) {
			break;
		}
		rep(k, li[i - j].size()) {
			if (li[i - j][k].first == m3) {
				m3m = max(m3m, li[i - j][k].second);
			}
		}
	}
	cout << m3m << endl;

}




Compiler output:
a.cc: In function 'long long int POW(long long int, long long int)':
a.cc:32:12: error: expected primary-expression before 'long'
   32 | #define ll long long
      |            ^~~~
a.cc:41:13: note: in expansion of macro 'll'
   41 | #define int ll
      |             ^~
a.cc:47:32: note: in expansion of macro 'int'
   47 | int POW(int x, int y) { return int(pow(double(x), double(y))); }
      |                                ^~~
a.cc:47:31: error: expected ';' before 'long'
   47 | int POW(int x, int y) { return int(pow(double(x), double(y))); }
      |                               ^
      |                               ;
a.cc: At global scope:
a.cc:47:36: error: ambiguating new declaration of 'long long int pow(double, double)'
   47 | int POW(int x, int y) { return int(pow(double(x), double(y))); }
      |                                    ^~~
In file included from /usr/include/features.h:523,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
                 from /usr/include/c++/14/bits/requires_hosted.h:31,
                 from /usr/include/c++/14/iostream:38,
                 from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:173:1: note: old declaration 'double pow(double, double)'
  173 | __MATHCALL_VEC (pow,, (_Mdouble_ __x, _Mdouble_ __y));
      | ^~~~~~~~~~~~~~
cc1plus: error: '::main' must return 'int'