Language: C++

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <map>
#include <vector>
#include <queue>
#define LL long long
#define PII pair<int, int>
using namespace std;
const int MAXN = 35;

int N, cnt;
LL a[MAXN], ans, sum;
bitset<101> mul[MAXN], vis;

void test() {
    LL all = 0;
    bitset<101> take = vis;
    for (int i = 1; i <= N; i++) {
        if (take[i]) {
            all += a[i];
        }
        else if (i > 33) {
            if (i * 2 > N) {
                if (a[i] < 0) {
                    all += a[i];
                }
            }
            else {
                if (take[i * 2]) {
                    if (a[i] < 0) {
                        all += a[i];
                    }
                }
                else {
                    if (a[i] + a[i * 2] < 0) {
                        all += a[i];
                        take.set(i * 2);
                    }
                }
            }
        }
    }
    ans = max(ans, sum - all);
}

void dfs(int x) {
    // cout << "DFS " << x << "\n";
    if (x > 33 || x > N) {
        cnt++;
        test();
        return;
    }

    dfs(x + 1);
    if (!vis[x] && x < 0) {
        bitset<101> temp = vis;
        vis |= mul[x];
        dfs(x + 1);
        vis = temp;
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);

    cin >> N;
    for (int i = 1; i <= N; i++) {
        // cin >> a[i];
        sum += a[i];
    }

    for (int i = 1; i < MAXN; i++) {
        for (int j = 0; j < MAXN; j += i) {
            mul[i].set(j);
        }
    }

    ans = sum;
    dfs(1);
    // cout << cnt << "\n";

    cout << ans << "\n";
}


Compiler output:
a.cc:19:1: error: 'bitset' does not name a type
   19 | bitset<101> mul[MAXN], vis;
      | ^~~~~~
a.cc: In function 'void test()':
a.cc:23:5: error: 'bitset' was not declared in this scope
   23 |     bitset<101> take = vis;
      |     ^~~~~~
a.cc:12:1: note: 'std::bitset' is defined in header '<bitset>'; this is probably fixable by adding '#include <bitset>'
   11 | #include <queue>
  +++ |+#include <bitset>
   12 | #define LL long long
a.cc:23:17: error: 'take' was not declared in this scope
   23 |     bitset<101> take = vis;
      |                 ^~~~
a.cc:23:24: error: 'vis' was not declared in this scope
   23 |     bitset<101> take = vis;
      |                        ^~~
a.cc: In function 'void dfs(int)':
a.cc:61:10: error: 'vis' was not declared in this scope
   61 |     if (!vis[x] && x < 0) {
      |          ^~~
a.cc:62:9: error: 'bitset' was not declared in this scope
   62 |         bitset<101> temp = vis;
      |         ^~~~~~
a.cc:62:9: note: 'std::bitset' is defined in header '<bitset>'; this is probably fixable by adding '#include <bitset>'
a.cc:62:21: error: 'temp' was not declared in this scope; did you mean 'tm'?
   62 |         bitset<101> temp = vis;
      |                     ^~~~
      |                     tm
a.cc:63:16: error: 'mul' was not declared in this scope
   63 |         vis |= mul[x];
      |                ^~~
a.cc: In function 'int main()':
a.cc:82:13: error: 'mul' was not declared in this scope
   82 |             mul[i].set(j);
      |             ^~~