Problem p02683 (C++) — buggy submission, verdict: Runtime Error

#include "bits/stdc++.h"

const double pi = 3.141592653589793;
#define YESNO(x) x ? printf("YES") : printf("NO")
#define YesNo(x) x ? printf("Yes") : printf("No")
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define scani(x) scanf("%d", &x)
#define scanll(x) scanf("%lld", &x)
#define printi(x) printf("%d", x)
#define printll(x) printf("%lld", x)
typedef long long ll;
using namespace std;

long long GCD(long long x, long long y) { return y ? GCD(y, x % y) : x; }

long long LCM(long long x, long long y) { return x * y / GCD(x, y); }

// give up
// infを低く設定しすぎてたせいで失敗
int Main() {
  ll n, m, x;
  const ll inf = pow(10, 7);
  ll ans = inf;

  scanll(n);
  scanll(m);
  scanll(x);
  vector<ll> yen(n, 0), und(m, 0);
  vector<vector<ll>> hon;
  hon.resize(n);
  for (auto &itr : hon) {
    itr.resize(m);
  }

  for (ll j = 0; j < n; j++) {
    scanll(yen[j]);
    for (ll i = 0; i < m; i++) {
      scanll(hon[j][i]);
    }
  }

  ll flag = 1;
  while (1) {
    ll cost = 0;
    fill(und.begin(), und.end(), 0);

    // calc cost
    for (ll i = 0; i < n; i++) {
      if (flag & (ll)pow(2, i)) {
        cost += yen[i];
        for (ll j = 0; j < m; j++) {
          und[j] += hon[i][j];
        }
      }
    }

    // clear check
    ll ok = true;
    for (auto &itr : und) {
      if (itr < x) {
        ok = false;
      }
    }

    if (ok) {
      ans = min(ans, cost);
    }

    flag++;
    if (flag == pow(2, 14))
      break;
  }
  if (inf == ans) {
    printf("-1");
  } else {
    printll(ans);
  }

  return 0;
}

int main() {
  Main();
  return 0;
}

Error: -11

Fixed submission:

#include "bits/stdc++.h"

#define YESNO(x) x ? printf("YES") : printf("NO")
#define YesNo(x) x ? printf("Yes") : printf("No")
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define scani(x) scanf("%d", &x)
#define scanll(x) scanf("%lld", &x)
#define printi(x) printf("%d", x)
#define printll(x) printf("%lld", x)
typedef long long ll;
using namespace std;

long long GCD(long long x, long long y) { return y ? GCD(y, x % y) : x; }

long long LCM(long long x, long long y) { return x * y / GCD(x, y); }

int A() {
  string s, t;
  cin >> s >> t;

  t.pop_back();
  YesNo(s == t);
  return 0;
}

int B() {
  ll a, b, c, k;
  scanll(a);
  scanll(b);
  scanll(c);
  scanll(k);
  ll ans = 0;

  if (k <= a) {
    ans = k;
  } else if (k <= a + b) {
    ans = a;
  } else {
    ans = a - (k - a - b);
  }

  printll(ans);

  return 0;
}

int Main() {
  ll n, m, x;
  const ll inf = pow(10, 6);
  ll ans = inf;

  scanll(n);
  scanll(m);
  scanll(x);
  vector<ll> yen(n, 0), und(m, 0);
  vector<vector<ll>> hon;
  hon.resize(n);
  for (auto &itr : hon) {
    itr.resize(m);
  }

  for (ll j = 0; j < n; j++) {
    scanll(yen[j]);
    for (ll i = 0; i < m; i++) {
      scanll(hon[j][i]);
    }
  }

  ll flag = 1;
  while (1) {
    ll cost = 0;
    fill(und.begin(), und.end(), 0);

    // calc cost
    for (ll i = 0; i <= n; i++) {
      if (flag & (ll)pow(2, i)) {
        cost += yen[i];
        for (ll j = 0; j < m; j++) {
          und[j] += hon[i][j];
        }
      }
    }

    // clear check
    ll ok = true;
    for (auto &itr : und) {
      if (itr < x) {
        ok = false;
      }
    }

    if (ok) {
      ans = min(ans, cost);
    }

    flag++;
    if (flag == pow(2, 14))
      break;
  }
  if (inf == ans) {
    printf("-1");
  } else {
    printll(ans);
  }

  return 0;
}

int main() {
  Main();
  return 0;
}