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

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define rt return 0
#define endln "\\n"
#define all(v) v.begin(), v.end()
#define for1(i, a, b) for (long long int i = a; i < b; i++)
#define for2(i, a, b) for (long long int i = a; i > b; i--)
//  cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;typedef long long
//  int i;
typedef long long int lli;
typedef pair<lli, lli> pll;
vector<lli> price;
vector<vector<lli>> v;
lli n, m, x;
lli infi = 1000000000000000;
lli mincost = infi;
void recurse(vector<lli> arr, lli index) {
  // for1(i, 0, index)
  // {
  //     cout << arr[i] << " ";
  // }
  // cout << endl;
  if (index == m) {
    lli f = 0;
    lli cost = 0;
    for1(i, 0, n) {
      lli y = 0;
      for1(j, 0, m) {
        if (arr[j] == 1) {
          y += v[j][i];
        }
      }
      if (y < x) {
        f = 1;
        break;
      }
    }
    if (f == 0) {
      for1(j, 0, m) {
        if (arr[j] == 1) {
          cost += price[j];
        }
      }
      mincost = min(mincost, cost);
    }

    // mincost = min(mincost, cost);
  } else {
    vector<lli> p, q;
    for1(i, 0, index) {
      p.pb(arr[i]);
      q.pb(arr[i]);
    }
    p.pb(0);
    q.pb(1);
    // index += 1;
    recurse(p, index + 1);
    recurse(q, index + 1);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> m >> n >> x;

  v.resize(25);
  for1(i, 0, m) {
    lli a;
    cin >> a;
    price.pb(a);
    for1(j, 0, n) {
      lli k;
      cin >> k;
      v[i].pb(k);
    }
  }

  vector<lli> arr1;
  recurse(arr1, 0);
  if (mincost == infi) {
    cout << "-1" << endl;
    rt;
  }
  cout << mincost << endl;
  rt;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define rt return 0
#define endln "\\n"
#define all(v) v.begin(), v.end()
#define for1(i, a, b) for (long long int i = a; i < b; i++)
#define for2(i, a, b) for (long long int i = a; i > b; i--)
//  cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;typedef long long
//  int i;
typedef long long int lli;
typedef pair<lli, lli> pll;
vector<lli> price;
vector<vector<lli>> v;
lli n, m, x;
lli infi = 1000000000000000;
lli mincost = infi;
lli recurse(vector<lli> arr, lli index) {
  // for1(i, 0, index)
  // {
  //     cout << arr[i] << " ";
  // }
  // cout << endl;
  if (index == m) {
    lli f = 0;
    lli cost = 0;
    for1(i, 0, n) {
      lli y = 0;
      for1(j, 0, m) {
        if (arr[j] == 1) {
          y += v[j][i];
        }
      }
      if (y < x) {
        f = 1;
        break;
      }
    }
    if (f == 0) {
      for1(j, 0, m) {
        if (arr[j] == 1) {
          cost += price[j];
        }
      }
      mincost = min(mincost, cost);
    }
    // mincost = min(mincost, cost);
  } else {
    vector<lli> p, q;
    for1(i, 0, index) {
      p.pb(arr[i]);
      q.pb(arr[i]);
    }
    p.pb(0);
    q.pb(1);
    // index += 1;
    recurse(p, index + 1);
    recurse(q, index + 1);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> m >> n >> x;

  v.resize(25);
  for1(i, 0, m) {
    lli a;
    cin >> a;
    price.pb(a);
    for1(j, 0, n) {
      lli k;
      cin >> k;
      v[i].pb(k);
    }
  }

  vector<lli> arr1;
  recurse(arr1, 0);
  if (mincost == infi) {
    cout << "-1" << endl;
    rt;
  }
  cout << mincost << endl;
}