Problem p03503 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define PII pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name)                                                               \
  int(name);                                                                   \
  scanf("%d", &(name))
#define GI2(name1, name2)                                                      \
  int(name1), (name2);                                                         \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3)                                               \
  int(name1), (name2), (name3);                                                \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)                                                        \
  vector<int>(name)(size);                                                     \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name)                                                               \
  string(name);                                                                \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) { return s; }

template <class T> string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail> void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI(N);
  vector<vector<int>> F(N);
  FOR(i, N) {
    F[i] = vector<int>(10);
    FOR(j, 10) { cin >> F[i][j]; }
  }
  vector<vector<int>> P(N);
  FOR(i, N) {
    P[i] = vector<int>(11);
    FOR(j, 11) { cin >> P[i][j]; }
  }
  int ans = -1000000000;
  FORIN(i, 1, 1024) {
    vector<int> count(10);
    FOR(j, 10) {
      if ((i >> j) & 1) {
        FOR(k, N) {
          if (F[k][j])
            count[k]++;
        }
      }
    }
    int sum = 0;
    FOR(j, N) { sum += P[j][count[j]]; }
    if (ans < sum)
      ans = sum;
  }
  print(ans);
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define PII pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name)                                                               \
  int(name);                                                                   \
  scanf("%d", &(name))
#define GI2(name1, name2)                                                      \
  int(name1), (name2);                                                         \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3)                                               \
  int(name1), (name2), (name3);                                                \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)                                                        \
  vector<int>(name)(size);                                                     \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name)                                                               \
  string(name);                                                                \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) { return s; }

template <class T> string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail> void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI(N);
  vector<vector<int>> F(N);
  FOR(i, N) {
    F[i] = vector<int>(10);
    FOR(j, 10) { cin >> F[i][j]; }
  }
  vector<vector<int>> P(N);
  FOR(i, N) {
    P[i] = vector<int>(11);
    FOR(j, 11) { cin >> P[i][j]; }
  }
  int ans = -1000000000;
  FORIN(i, 1, 1024) {
    vector<int> count(N);
    FOR(j, 10) {
      if ((i >> j) & 1) {
        FOR(k, N) {
          if (F[k][j])
            count[k]++;
        }
      }
    }
    int sum = 0;
    FOR(j, N) { sum += P[j][count[j]]; }
    if (ans < sum)
      ans = sum;
  }
  print(ans);
  return 0;
}