Problem p03503 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x)                                                     \
  {                                                                            \
    rep(i, is) {                                                               \
      rep(j, js) { cout << x[i][j] << " "; }                                   \
      cout << endl;                                                            \
    }                                                                          \
  }
#define show(x)                                                                \
  {                                                                            \
    for (auto i : x) {                                                         \
      cout << i << " ";                                                        \
    }                                                                          \
    cout << endl;                                                              \
  }
#define showm(m)                                                               \
  {                                                                            \
    for (auto i : m) {                                                         \
      cout << m.x << " ";                                                      \
    }                                                                          \
    cout << endl;                                                              \
  }
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return (x * y) / gcd(x, y); }

int main() {
  int n;
  cin >> n;
  vector<vector<int>> f(n, vector<int>(10, 0));
  vector<vector<int>> p(n, vector<int>(10, 0));

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> f[i][j];
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> p[i][j];
    }
  }

  ll ans = -(ll)MOD * 10;
  rep1(i, (1 << 10) - 1) {
    // 営業パターン
    ll tans = 0;
    vector<int> mise_cnt(n, 0);
    for (int j = 0; j < 10; j++) {
      if ((i >> j) & 1) {
        for (int mise = 0; mise < n; mise++) {
          if (f[mise][j] == 1)
            mise_cnt[mise]++;
        }
      }
    }
    for (int mise = 0; mise < n; mise++) {
      tans += p[mise][mise_cnt[mise]];
    }
    // cout << mise_cnt[0] << endl;
    // cout << i << " " << tans << endl;
    ans = max(tans, ans);
  }

  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x)                                                     \
  {                                                                            \
    rep(i, is) {                                                               \
      rep(j, js) { cout << x[i][j] << " "; }                                   \
      cout << endl;                                                            \
    }                                                                          \
  }
#define show(x)                                                                \
  {                                                                            \
    for (auto i : x) {                                                         \
      cout << i << " ";                                                        \
    }                                                                          \
    cout << endl;                                                              \
  }
#define showm(m)                                                               \
  {                                                                            \
    for (auto i : m) {                                                         \
      cout << m.x << " ";                                                      \
    }                                                                          \
    cout << endl;                                                              \
  }
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return (x * y) / gcd(x, y); }

int main() {
  int n;
  cin >> n;
  vector<vector<int>> f(n, vector<int>(10, 0));
  vector<vector<int>> p(n, vector<int>(11, 0));

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> f[i][j];
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> p[i][j];
    }
  }

  ll ans = -(ll)MOD * 10;
  rep1(i, (1 << 10) - 1) {
    // 営業パターン
    ll tans = 0;
    vector<int> mise_cnt(n, 0);
    for (int j = 0; j < 10; j++) {
      if ((i >> j) & 1) {
        for (int mise = 0; mise < n; mise++) {
          if (f[mise][j] == 1)
            mise_cnt[mise]++;
        }
      }
    }
    for (int mise = 0; mise < n; mise++) {
      tans += p[mise][mise_cnt[mise]];
    }
    // cout << mise_cnt[0] << endl;
    // cout << i << " " << tans << endl;
    ans = max(tans, ans);
  }

  cout << ans << endl;
}